医院废弃物信息化管理平台
“mitao”
2025-12-24 3763145f34d7706923d55edc32f5cfbc8bc08b92
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package cn.besteam.modules.system.controller;
 
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.besteam.common.api.vo.Result;
import cn.besteam.common.aspect.annotation.AutoLog;
import cn.besteam.common.util.oConvertUtils;
import cn.besteam.modules.system.entity.SysUserDepartment;
import cn.besteam.modules.system.service.ISysUserDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
 
 /**
 * @Title: Controller
 * @Description: 用户-组织架构表
 * @author: besteam
 * @date:   2020-04-17
 * @version: V1.0
 */
@RestController
@RequestMapping("/system/sysUserDepartment")
@Slf4j
@Api(description = "用户-组织架构表")
public class SysUserDepartmentController {
 
    @Autowired
    private ISysUserDepartmentService sysUserDepartmentService;
    
    /**
      * 分页列表查询
     * @param sysUserDepartment
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @GetMapping(value = "/list")
    @ApiOperation(value = "获取用户-组织架构表数据列表", notes = "获取所有用户-组织架构表数据列表", produces = "application/json")
    public Result<IPage<SysUserDepartment>> queryPageList(SysUserDepartment sysUserDepartment, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
 
        Result<IPage<SysUserDepartment>> result = new Result<IPage<SysUserDepartment>>();
        QueryWrapper<SysUserDepartment> queryWrapper = new QueryWrapper<SysUserDepartment>(sysUserDepartment);
        Page<SysUserDepartment> page = new Page<SysUserDepartment>(pageNo, pageSize);
        //排序逻辑 处理
        String column = req.getParameter("column");
        String order = req.getParameter("order");
        if(oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) {
            if("asc".equals(order)) {
                queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column));
            }else {
                queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column));
            }
        }
        IPage<SysUserDepartment> pageList = sysUserDepartmentService.page(page, queryWrapper);
        //log.debug("查询当前页:"+pageList.getCurrent());
        //log.debug("查询当前页数量:"+pageList.getSize());
        //log.debug("查询结果数量:"+pageList.getRecords().size());
        //log.debug("数据总数:"+pageList.getTotal());
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }
    
    /**
      *   添加
     * @param sysUserDepartment
     * @return
     */
    @PostMapping(value = "/add")
    @AutoLog(value = "添加用户-组织架构表")
    @ApiOperation(value = "添加用户-组织架构表", notes = "添加用户-组织架构表", produces = "application/json")
    public Result<SysUserDepartment> add(@RequestBody SysUserDepartment sysUserDepartment) {
 
        Result<SysUserDepartment> result = new Result<SysUserDepartment>();
        try {
            sysUserDepartmentService.save(sysUserDepartment);
            result.success("添加成功!");
        } catch (Exception e) {
            log.error("", e);
            result.error500("操作失败");
        }
        return result;
    }
    
    /**
      *  编辑
     * @param sysUserDepartment
     * @return
     */
    @PostMapping(value = "/edit")
    @AutoLog(value = "编辑用户-组织架构表")
    @ApiOperation(value = "编辑用户-组织架构表", notes = "编辑用户-组织架构表", produces = "application/json")
    public Result<SysUserDepartment> edit(@RequestBody SysUserDepartment sysUserDepartment) {
 
        Result<SysUserDepartment> result = new Result<SysUserDepartment>();
        SysUserDepartment sysUserDepartmentEntity = sysUserDepartmentService.getById(sysUserDepartment.getId());
        if(sysUserDepartmentEntity==null) {
            result.error500("未找到对应实体");
        }else {
            boolean ok = sysUserDepartmentService.updateById(sysUserDepartment);
            //TODO 返回false说明什么?
            if(ok) {
                result.success("修改成功!");
            }
        }
        
        return result;
    }
    
    /**
      *   通过id删除
     * @param id
     * @return
     */
    @PostMapping(value = "/delete")
    @AutoLog(value = "删除用户-组织架构表")
    @ApiOperation(value = "删除用户-组织架构表", notes = "删除用户-组织架构表", produces = "application/json")
    public Result<SysUserDepartment> delete(@RequestParam(name="id",required=true) String id) {
 
        Result<SysUserDepartment> result = new Result<SysUserDepartment>();
        SysUserDepartment sysUserDepartment = sysUserDepartmentService.getById(id);
        if(sysUserDepartment==null) {
            result.error500("未找到对应实体");
        }else {
            boolean ok = sysUserDepartmentService.removeById(id);
            if(ok) {
                result.success("删除成功!");
            }
        }
        
        return result;
    }
    
    /**
      *  批量删除
     * @param ids
     * @return
     */
    @PostMapping(value = "/deleteBatch")
    @AutoLog(value = "批量删除用户-组织架构表")
    @ApiOperation(value = "批量删除用户-组织架构表", notes = "批量删除用户-组织架构表", produces = "application/json")
    public Result<SysUserDepartment> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
 
        Result<SysUserDepartment> result = new Result<SysUserDepartment>();
        if(ids==null || "".equals(ids.trim())) {
            result.error500("参数不识别!");
        }else {
            this.sysUserDepartmentService.removeByIds(Arrays.asList(ids.split(",")));
            result.success("删除成功!");
        }
        return result;
    }
    
    /**
      * 通过id查询
     * @param id
     * @return
     */
    @GetMapping(value = "/queryById")
    @ApiOperation(value = "通过id查询用户-组织架构表", notes = "通过id查询用户-组织架构表", produces = "application/json")
    public Result<SysUserDepartment> queryById(@RequestParam(name="id",required=true) String id) {
 
        Result<SysUserDepartment> result = new Result<SysUserDepartment>();
        SysUserDepartment sysUserDepartment = sysUserDepartmentService.getById(id);
        if(sysUserDepartment==null) {
            result.error500("未找到对应实体");
        }else {
            result.setResult(sysUserDepartment);
            result.setSuccess(true);
        }
        return result;
    }
 
}