futian.liu
2023-12-22 fd95223d9703b9c038ed3c782474c885052dda08
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
package com.consum.base.controller;
 
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import com.consum.base.BaseController;
import com.consum.base.core.utils.CommonUtil;
import com.consum.base.pojo.FinSysServerSearchParam;
import com.consum.base.pojo.FinSysServerVo;
import com.consum.base.service.FinSysServerService;
import com.consum.model.po.FinSysServer;
import com.iplatform.model.po.S_role;
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.utils.DateUtils;
import com.walker.infrastructure.utils.NumberGenerator;
import com.walker.web.ResponseValue;
 
import io.swagger.annotations.Api;
 
@Api(value = "系统服务信息", tags = "系统服务信息")
@RestController
@RequestMapping("/pc/fin/sys/server")
public class FinSysServerController extends BaseController {
 
    private FinSysServerService finSysServerServiceImpl;
 
    @Autowired
    public void setfinSysCategory(FinSysServerService finSysServerServiceImpl) {
        this.finSysServerServiceImpl = finSysServerServiceImpl;
    }
 
    /**
     * @Description 根据DataScop查询数据信息
     * @Author wh
     * @Date 2023/9/13 9:27
     */
    @GetMapping("/selectByDataScope")
    public ResponseValue selectByDataScope(Integer dataScope) {
        List<S_role> roleList = finSysServerServiceImpl.getByDataScope(dataScope);
        // 过滤仓库管理员的显示
        roleList.removeIf(role -> "仓库管理员".equals(role.getRole_name()));
        return ResponseValue.success(roleList);
    }
 
    /**
     * 查询左侧树
     *
     * @return
     */
    @GetMapping("/select/tree")
    public ResponseValue selectFinSysCategoryTree() {
 
        List<FinSysServerVo> finSysCategoryVos = finSysServerServiceImpl.queryAllCategory();
        if (finSysCategoryVos != null) {
            return ResponseValue.success(finSysCategoryVos);
        }
        return ResponseValue.error("未查询到数据!");
 
    }
 
    @GetMapping("/select/detail")
    public ResponseValue selectById(@RequestParam(name = "id") Long Id) {
        FinSysServer finSysServer = this.finSysServerServiceImpl.get(new FinSysServer(Id));
        if (finSysServer == null) {
            return ResponseValue.error("查询失败!");
        }
        return ResponseValue.success("查询成功!", finSysServer);
    }
 
    /**
     * 分页查询
     *
     * @return
     */
    @RequestMapping("/select/list")
    public ResponseValue finSysServerList() {
        FinSysServerSearchParam param = CommonUtil.getObjFromReq(FinSysServerSearchParam.class);
        FinSysServerSearchParam param2 = new FinSysServerSearchParam();
        CommonUtil.copyProperties(param, param2);
        param = param2;
 
        GenericPager<FinSysServer> pager = this.finSysServerServiceImpl.selectServerListByPage(param);
        return ResponseValue.success(pager);
    }
 
    /**
     * 添加
     *
     * @return
     */
    @PostMapping("/insert")
    public ResponseValue addFinSysServer() {
        FinSysServer param = CommonUtil.getObjFromReqBody(FinSysServer.class);
        FinSysServer finSysServer = new FinSysServer();
        CommonUtil.copyProperties(param, finSysServer);
        param = finSysServer;
 
        if (param == null) {
            return ResponseValue.error("参数为空");
        }
        param.setId(NumberGenerator.getLongSequenceNumber());
        param.setCreatedTime(DateUtils.getDateTimeNumber(System.currentTimeMillis()));
        param.setCreatedBy(this.getCurrentUser().getUser_name());
        param.setLv(param.getParentId() + 1);
        int num = this.finSysServerServiceImpl.insert(param);
        if (num > 0) {
            return ResponseValue.success(1);
        }
        return ResponseValue.error("插入失败!");
    }
 
    /**
     * 编辑
     */
    @PostMapping("/edit")
    public ResponseValue editFinSysServer() {
        FinSysServer param = CommonUtil.getObjFromReqBody(FinSysServer.class);
        FinSysServer finSysServer = new FinSysServer();
        CommonUtil.copyProperties(param, finSysServer);
        param = finSysServer;
 
        if (param == null) {
            return ResponseValue.error("参数为空");
        }
        int num = this.finSysServerServiceImpl.save(param);
        return num > 0 ? ResponseValue.success(1) : ResponseValue.error("编辑失败!");
    }
}