longz
2026-07-02 c788ca1640f080f821cb1cbe07da741302d355ef
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.stylefeng.guns.modular.system.controller.general;
 
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.base.tips.ErrorTip;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.modular.system.model.EnterpriseConfig;
import com.stylefeng.guns.modular.system.service.IEnterpriseConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.Date;
import java.util.Map;
 
/**
 * 企业配置管理控制器
 */
@Controller
@RequestMapping("/enterpriseConfig")
public class EnterpriseConfigController extends BaseController {
 
    private String PREFIX = "/system/enterpriseConfig/";
 
    @Autowired
    private IEnterpriseConfigService enterpriseConfigService;
 
    /**
     * 跳转到企业配置管理首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "enterpriseConfig.html";
    }
 
    /**
     * 跳转到添加企业配置
     */
    @RequestMapping("/enterpriseConfig_add")
    public String enterpriseConfigAdd() {
        return PREFIX + "enterpriseConfig_add.html";
    }
 
    /**
     * 跳转到编辑企业配置
     */
    @RequestMapping("/enterpriseConfig_update/{enterpriseConfigId}")
    public String enterpriseConfigUpdate(@PathVariable Integer enterpriseConfigId, Model model) {
        EnterpriseConfig enterpriseConfig = enterpriseConfigService.selectById(enterpriseConfigId);
        model.addAttribute("item", enterpriseConfig);
        LogObjectHolder.me().set(enterpriseConfig);
        return PREFIX + "enterpriseConfig_edit.html";
    }
 
    /**
     * 获取企业配置管理列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String enterpriseName) {
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(enterpriseConfigService.getEnterpriseConfigList(page, enterpriseName));
        return super.packForBT(page);
    }
 
    /**
     * 新增企业配置
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(EnterpriseConfig enterpriseConfig) {
        if (SinataUtil.isEmpty(enterpriseConfig.getEnterpriseName())) {
            return new ErrorTip(500, "企业名称不能为空");
        }
        enterpriseConfig.setInsertTime(new Date());
        enterpriseConfig.setInsertUserId(ShiroKit.getUser().getId());
        enterpriseConfig.setInsertUserName(ShiroKit.getUser().getName());
        enterpriseConfig.setState(1);
        enterpriseConfigService.insert(enterpriseConfig);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改企业配置
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(EnterpriseConfig enterpriseConfig) {
        if (SinataUtil.isEmpty(enterpriseConfig.getEnterpriseName())) {
            return new ErrorTip(500, "企业名称不能为空");
        }
        EnterpriseConfig oldEnterpriseConfig = enterpriseConfigService.selectById(enterpriseConfig.getId());
        oldEnterpriseConfig.setEnterpriseName(enterpriseConfig.getEnterpriseName());
        enterpriseConfigService.updateById(oldEnterpriseConfig);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除企业配置
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer enterpriseConfigId) {
        EnterpriseConfig enterpriseConfig = enterpriseConfigService.selectById(enterpriseConfigId);
        enterpriseConfig.setState(3);
        enterpriseConfigService.updateById(enterpriseConfig);
        return SUCCESS_TIP;
    }
 
    /**
     * 启用企业配置
     */
    @RequestMapping(value = "/enable")
    @ResponseBody
    public Object enable(@RequestParam Integer enterpriseConfigId) {
        return updateState(enterpriseConfigId, 1);
    }
 
    /**
     * 停用企业配置
     */
    @RequestMapping(value = "/disable")
    @ResponseBody
    public Object disable(@RequestParam Integer enterpriseConfigId) {
        return updateState(enterpriseConfigId, 2);
    }
 
    private Object updateState(Integer enterpriseConfigId, Integer state) {
        EnterpriseConfig enterpriseConfig = enterpriseConfigService.selectById(enterpriseConfigId);
        enterpriseConfig.setState(state);
        enterpriseConfigService.updateById(enterpriseConfig);
        return SUCCESS_TIP;
    }
}