许鹏程
2023-05-24 34ff70bc904e68548b5996561d5da52a67a46d24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.product.admin.controller;
 
import javax.servlet.http.HttpServletRequest;
 
import com.product.common.lang.StringUtils;
import com.product.core.spring.context.SpringMVCContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import com.product.admin.config.SystemCode;
import com.product.admin.service.SystemCacheService;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.module.sys.version.ApiVersion;
 
@RequestMapping(value = "/api/system")
@RestController
public class SystemCacheController extends AbstractBaseController {
 
    @Autowired
    private SystemCacheService systemCacheService;
 
    @RequestMapping(value = "/refresh-cache/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String findEmailSmtp(HttpServletRequest request) {
        try {
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            String tableNames = null;
            if (fse != null && StringUtils.isEmpty(fse.getString("tableNames"))) {
                tableNames = fse.getString("tableNames");
            }
            systemCacheService.refreshCache(fse == null || tableNames == null ? null : tableNames.split(","));
            return OK();
        } catch (BaseException e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            return this.error(e);
        } catch (Exception e) {
            SpringMVCContextHolder.getSystemLogger().error(e);
            e.printStackTrace();
            return this.error(SystemCode.SYSTEM_REFRESH_CACHE_FIAL.getValue(), SystemCode.SYSTEM_REFRESH_CACHE_FIAL.getText() + e.getMessage());
        }
    }
 
 
}