当前位置:网站首页>Function development of user information management

Function development of user information management

2022-06-11 18:37:00 C_ x_ three hundred and thirty

Background login function development

  • Demand analysis

  • Code development

     Insert picture description here

  • A functional test

Background exit function development

  • Demand analysis

  • Code development

  • A functional test

Improve the background login function

  • Log in first when the user is not logged in

  • Use filter / Interceptor

  • filter

    •  Insert picture description here
  • How to create a filter
    • First create a class
    • Add annotations @WebFilter(filtername=" This is the same as the class name ",urlPatterns=“/*”)
    • Implementation interface Filter
    • Rewriting methods General writing doFilter The method will do
    • Add an annotation to the startup class @ServletComponentScan

Implementation logic

 Insert picture description here


New employees

 Insert picture description here

 Insert picture description here

Paging query of employee information

  • How to configure MybatisPlus Pagination plug-in for ?
@Configuration
public class MybatisPlusConfig {
     

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
     
        MybatisPlusInterceptor mpi = new MybatisPlusInterceptor();
        mpi.addInnerInterceptor(new PaginationInnerInterceptor());
        return mpi;
    }
}
    @GetMapping("/page")
    public R<Page> page(int page,int pageSize,String name){
     
        log.info("page= {}, pageSize= {}, name= {}",page,pageSize,name);

        // Construct a paging constructor 
        Page pageinfo= new Page(page,pageSize);
        // Construct condition constructors 
        LambdaQueryWrapper<Employee> lqw=new LambdaQueryWrapper();
        lqw.like(StringUtils.isNotEmpty(name),Employee::getName,name);
        // Add sorting criteria   By update time 
        lqw.orderByAsc(Employee::getUpdateTime);
        // Execute the query 
        employeeService.page(pageinfo,lqw);
        return R.success(pageinfo);
    }

Enable / disable employee account

 Insert picture description here

  • Js Yes Long Loss of precision in data processing , That leads to the submission of id And in the database id atypism
  • resolvent
  • We will respond to the server Json Data time , United will Long Type data is converted to string data for processing

Edit employee information

 Insert picture description here

  • Echo employee information
   @GetMapping("/{id}")
   public R<Employee> edit(@PathVariable Long id){
     
       log.info(" according to id Query employee information ");
       Employee emp = employeeService.getById(id);
       if(emp!=null){
     
           return R.success(emp);
       }
       return R.error(" Edit failed ");
   }
  • There's a little detail : @GetMapping(“/{id}”)
  • This "/{id}" Don't add it in front by mistake "/${id}" Don't confuse
原网站

版权声明
本文为[C_ x_ three hundred and thirty]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111819132195.html