1
13693261870
2024-09-10 4a24728338b869117a58c21dbd5544d1f1e782fd
1
已修改2个文件
84 ■■■■■ 文件已修改
se-modules/se-system/src/main/java/com/se/system/controller/SysConfigController.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-modules/se-system/src/main/java/com/se/system/controller/SysProfileController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
se-modules/se-system/src/main/java/com/se/system/controller/SysConfigController.java
@@ -3,8 +3,11 @@
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.se.common.core.utils.AesUtils;
import com.se.common.core.utils.StringUtils;
import com.se.system.domain.SysConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@@ -31,8 +34,13 @@
 */
@RestController
@RequestMapping("/config")
public class SysConfigController extends BaseController
{
@SuppressWarnings("ALL")
public class SysConfigController extends BaseController {
    @Value("${enableEncrypt}")
    boolean enableEncrypt;
    private final static String PWD_KEY = "sys.user.initPassword";
    @Autowired
    private ISysConfigService configService;
@@ -41,19 +49,33 @@
     */
    @RequiresPermissions("system:config:list")
    @GetMapping("/list")
    public TableDataInfo list(SysConfig config)
    {
    public TableDataInfo list(SysConfig config) throws Exception {
        startPage();
        List<SysConfig> list = configService.selectConfigList(config);
        /*if (enableEncrypt && null != list) {
            for (SysConfig cfg : list) {
                if (null != cfg && PWD_KEY.equals(cfg.getConfigKey()) && !StringUtils.isEmpty(cfg.getConfigValue())) {
                    cfg.setConfigValue(AesUtils.encrypt(cfg.getConfigValue()));
                }
            }
        }*/
        return getDataTable(list);
    }
    @Log(title = "参数管理", businessType = BusinessType.EXPORT)
    @RequiresPermissions("system:config:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysConfig config)
    {
    public void export(HttpServletResponse response, SysConfig config) {
        List<SysConfig> list = configService.selectConfigList(config);
        /*if (enableEncrypt && null != list) {
            for (SysConfig cfg : list) {
                if (null != cfg && PWD_KEY.equals(cfg.getConfigKey()) && !StringUtils.isEmpty(cfg.getConfigValue())) {
                    cfg.setConfigValue(AesUtils.encrypt(cfg.getConfigValue()));
                }
            }
        }*/
        ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
        util.exportExcel(response, list, "参数数据");
    }
@@ -62,18 +84,26 @@
     * 根据参数编号获取详细信息
     */
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable Long configId)
    {
        return success(configService.selectConfigById(configId));
    public AjaxResult getInfo(@PathVariable Long configId) throws Exception {
        SysConfig config = configService.selectConfigById(configId);
        /*if ((enableEncrypt && null != config && PWD_KEY.equals(config.getConfigKey()) && !StringUtils.isEmpty(config.getConfigValue())) {
            config.setConfigValue(AesUtils.encrypt(config.getConfigValue()));
        }*/
        return success(config);
    }
    /**
     * 根据参数键名查询参数值
     */
    @GetMapping(value = "/configKey/{configKey}")
    public AjaxResult getConfigKey(@PathVariable String configKey)
    {
        return success(configService.selectConfigByKey(configKey));
    public AjaxResult getConfigKey(@PathVariable String configKey) throws Exception {
        String val = configService.selectConfigByKey(configKey);
        /*if (enableEncrypt && PWD_KEY.equals(configKey) && !StringUtils.isEmpty(val)) {
            val = AesUtils.encrypt(val);
        }*/
        return success(val);
    }
    /**
@@ -82,10 +112,8 @@
    @RequiresPermissions("system:config:add")
    @Log(title = "参数管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysConfig config)
    {
        if (!configService.checkConfigKeyUnique(config))
        {
    public AjaxResult add(@Validated @RequestBody SysConfig config) {
        if (!configService.checkConfigKeyUnique(config)) {
            return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
        }
        config.setCreateBy(SecurityUtils.getUsername());
@@ -98,13 +126,15 @@
    @RequiresPermissions("system:config:edit")
    @Log(title = "参数管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysConfig config)
    {
        if (!configService.checkConfigKeyUnique(config))
        {
    public AjaxResult edit(@Validated @RequestBody SysConfig config) throws Exception {
        if (!configService.checkConfigKeyUnique(config)) {
            return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
        }
        config.setUpdateBy(SecurityUtils.getUsername());
        /*if ((enableEncrypt && PWD_KEY.equals(config.getConfigKey()) && !StringUtils.isEmpty(config.getConfigValue())){
            config.setConfigValue(AesUtils.decrypt(config.getConfigValue()));
        }*/
        return toAjax(configService.updateConfig(config));
    }
@@ -114,8 +144,7 @@
    @RequiresPermissions("system:config:remove")
    @Log(title = "参数管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable Long[] configIds)
    {
    public AjaxResult remove(@PathVariable Long[] configIds) {
        configService.deleteConfigByIds(configIds);
        return success();
    }
@@ -126,8 +155,7 @@
    @RequiresPermissions("system:config:remove")
    @Log(title = "参数管理", businessType = BusinessType.CLEAN)
    @DeleteMapping("/refreshCache")
    public AjaxResult refreshCache()
    {
    public AjaxResult refreshCache() {
        configService.resetConfigCache();
        return success();
    }
se-modules/se-system/src/main/java/com/se/system/controller/SysProfileController.java
@@ -98,11 +98,13 @@
    @Log(title = "个人信息", businessType = BusinessType.UPDATE)
    @PutMapping("/updatePwd")
    public AjaxResult updatePwd(String oldPassword, String newPassword) throws Exception {
        if (enableEncrypt) {
            oldPassword = AesUtils.decrypt(oldPassword);
            newPassword = AesUtils.decrypt(newPassword);
        }
        String username = SecurityUtils.getUsername();
        SysUser user = userService.selectUserByUserName(username);
        if (enableEncrypt && !StringUtils.isEmpty(user.getPassword())) {
            user.setPassword(AesUtils.decrypt(user.getPassword()));
        }
        String password = user.getPassword();
        if (!SecurityUtils.matchesPassword(oldPassword, password)) {
            return error("修改密码失败,旧密码错误");