Difficulties in Realizing CRM Customer Relationship Management System

1. Solve the problem of slow loading of active code through redis caching technology

Space for time : By implementing CommandLineRunner on the startup class, rewriting the run method, loading all active codes to the cache, and querying directly from the redis cache next time, the query efficiency is improved

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class})
@EnableScheduling
public class HuiKeApplication implements CommandLineRunner{// implements CommandLineRunner
    //注入活动的service
    @Autowired
    private ITbActivityService activityService;

    public static void main(String[] args){
        SpringApplication.run(HuiKeApplication.class, args);
    }

    @Override
    public void run(String... args)  {
        try{
            //加载所有活动code到缓存
            activityService.loadAllActivityCode();
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}

2. Realize the interface resource authentication function through the @PreAuthorize annotation of spring security

In this system, all interfaces have an ss permission identifier, corresponding to the system directory table. When logging in, the user permission identifier is encapsulated into the user object and cached in Redis, and the key is UUID. The UUID will be encapsulated into the JWT payload and returned to the front end. The front end sends the request by storing the JWT in the Header. The backend parses the JWT to obtain the UUID, queries the user object in Redis, and verifies whether the authority identifier set contains the authority identifier hard-coded in the interface. If the authority verification passes, the access interface is run, otherwise the request is rejected.

	/**
	 * 查询线索管理列表
	 */
	@PreAuthorize("@ss.hasPermi('clues:clue:list')")
	@GetMapping("/list")
	public TableDataInfo list(TbClue tbClue) {
		List<TbClue> list = tbClueService.selectTbClueList(tbClue);
		return getDataTablePage(list);
	}

3. Realize AOP+ custom annotation @Log to record the operation log


        By adding the @Log annotation to the method of the Controller interface, combined with AOP technology, the state information before and after the execution of the method can be recorded. Parameters such as operation type and module name are set in the @Log annotation, and these parameters will be used to construct the operation log entity class. Interceptors can obtain request parameters, return values, and exception information, and encapsulate them into operation log entity classes. Finally, the system operation log is recorded.

Custom operation log annotation

/**
 * 自定义操作日志记录注解
 * 
 * 
 *
 */
@Target({ ElementType.PARAMETER, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Log
{
    /**
     * 模块 
     */
    public String title() default "";

    /**
     * 功能
     */
    public BusinessType businessType() default BusinessType.OTHER;

    /**
     * 操作人类别
     */
    public OperatorType operatorType() default OperatorType.MANAGE;

    /**
     * 是否保存请求的参数
     */
    public boolean isSaveRequestData() default true;
}

 

	/**
	 * 新增线索管理
	 */
	@PreAuthorize("@ss.hasPermi('clues:clue:add')")
	@Log(title = "线索管理", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody TbClue tbClue) {
		if(!tbClueService.checkCluePhoneExis(tbClue.getPhone())) return error("手机号已存在");
		return toAjax(tbClueService.insertTbClue(tbClue));
	}

Guess you like

Origin blog.csdn.net/weixin_71921932/article/details/129747297