Summary of problems encountered in learning documents and making office supplies

Summary of problems encountered in learning documents and making office supplies

Create Project Phase

In the project creation stage, the generated project is created according to the scaffolding of the backend. The client and service modules are generated by default, and the model module is added as needed.

  1. Link: Backend .
  2. Link: Frontend .

After the creation here, you need to pull the gateway gateway project from the remote warehouse, because you need to access the corresponding service later by accessing the gateway. Otherwise, 503 will appear, and the microservice accesses different abnormal conditions. Some configuration knowledge of the gateway needs to be paid attention to here:
link: gateway .

Change the first @RequestMapping on the back-end controller class to the service-id of the corresponding microservice module. such as office supplies

@RequestMapping("/goods")

Learn about what’s being developed

First, see if you need to make changes during the migration process according to your needs:

  1. Database environment For example, what kingbase8 encounters in microservices is mysql, and you should also understand redis, mongdb, etc.;
  2. Understand the design of database tables, which database tables are included, and what is the relationship between each table ;

Some problems encountered and solutions

The @CurrentUser annotation cannot be used in microservices

use in microservices

SecurityUser securityUser = SecurityUtils.getPrincipal();
UmsUser user = umsUserClient.getUmsUserByNo(securityUser.getUsername());

Instead of getting information about the user of course

The next step after creating the menu requires the assignment of permissions

Backend direct link: Backend menu configuration .

After configuring the menu, you may forget to assign permissions in the next step. You need to assign them to the corresponding roles before you can use the menu.

The front-end and back-end read and display time inconsistencies (to solve the problem that the date value returned to the front-end in the background is one day less)

  1. Reason: spring-boot uses Jackson by default to serialize values ​​returned to the frontend. The default time zone of the Jackson framework is UTC, which is 8 hours less than the East Eight District (east + west -)
  2. solution:

The first: use the following configuration in application.yml

spring: 
  jackson:
    date-format: yyyy-MM-dd hh:mm:ss
    time-zone: GMT+8

The second: You can add the following annotations directly to the entity class in the model

@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
private Date applyDate;

The page needs to configure the dictionary data

Direct link to documentation: Dictionary Configuration .

When the front-end and the back-end make requests, you need to use normal asynchronous requests instead

then this is changed to this, using the method of this.$utils.ajax . The specific code is as follows

this.$utils.ajax({
                    'url': '/doc/dispatch/workflow/getProcessPermission',
                    'method': 'get',
                    'data': {
                        docId: this.dispatchDocId,
                        workTodoId: this.dispatchAid
                    }
                }). then ( (res) => {
                     this .permission = res;
                     // TODO current file status judgment. It should be unified and written as a public method
                }).finally(() => {
                    this.loading = false;
                });
         )

The front-end page needs to be changed to a three-layer page format

After changing to a microservice module, some front-end development needs to be modified. For details, please refer to the documentation of the front-end project development process.

Direct link to the documentation: Three-tier interface modification .

The front-end modification of tree-button, after switching to microservices, has been modified

Previous code:

<tree-button v-model="form.userNo"
             :request="{
             'api': 'rmsSystem_getTrees',
              'param': { 'treeType': 'user' }
                       }"
              :tree="{
                      'multiplePattern': false
                      }"
               resType="id"
               :can-add-item="false"
               core="ztree"
               :lazy-load="true"
               @select-change="handleSelectEChangeToUser">
</tree-button>

The code after modification is as follows:

<tree-button v-model="form.userNo"
              :request="{
              'url': '/user/rjUser/getTrees',
               'param': {
                            'treeType': 'user'
                         },
                'method': 'get'
                       }"
                 :tree="{
                          'multiplePattern': false
                        }"
                 resType="id"
                 :can-add-item="false"
                 core="ztree"
                 :lazy-load="true"
                 @select-change="handleSelectEChangeToUser">
</tree-button>

Leave a Comment

Your email address will not be published. Required fields are marked *