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());
|
}
|
}
|
|
|
}
|