张延森 4 years ago
parent
commit
3971b7fa1f

+ 7
- 0
src/main/java/com/yunzhi/demo/common/Constants.java View File

@@ -13,6 +13,13 @@ public class Constants {
13 13
     // 资源类型
14 14
     public final static String RESOURCE_TYPE_POST = "post"; // 科普文章
15 15
 
16
+    // 超级管理员
16 17
     public final static String SUPER_ADMIN_ID = "1";
17 18
     public final static Integer SUPER_ADMIN_ROLE = 1;
19
+
20
+    // 系统参数
21
+    // 阅读文章可获取的积分
22
+    public final static String SYS_PARAM_POST_POINTS = "POINTS_OF_PER_POST";
23
+    // 学分积分转换比例
24
+    public final static String SYS_PARAM_POINT_CREDIT_RATIO = "POINT_CREDIT_RATIO";
18 25
 }

+ 25
- 49
src/main/java/com/yunzhi/demo/controller/SysConfigController.java View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7 8
 import com.yunzhi.demo.common.ResponseBean;
8 9
 import io.swagger.annotations.Api;
9 10
 import io.swagger.annotations.ApiOperation;
@@ -46,47 +47,19 @@ public class SysConfigController extends BaseController {
46 47
      * @param pageSize
47 48
      * @return
48 49
      */
49
-    @RequestMapping(value="/sysConfig",method= RequestMethod.GET)
50
+    @RequestMapping(value="/admin/sys-config",method= RequestMethod.GET)
50 51
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51 52
     public ResponseBean sysConfigList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+                                      @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53 54
 
54
-		    IPage<SysConfig> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<SysConfig> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
55
+        IPage<SysConfig> pg = new Page<>(pageNum, pageSize);
56
+        QueryWrapper<SysConfig> queryWrapper = new QueryWrapper<>();
57
+        queryWrapper.gt("status", Constants.STATUS_DELETED);
58
+        queryWrapper.orderByAsc("sort_no");
59
+        queryWrapper.orderByDesc("create_date");
57 60
 
58
-            IPage<SysConfig> result = iSysConfigService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
60
-    }
61
-
62
-    /**
63
-     * 保存对象
64
-     * @param sysConfig 实体对象
65
-     * @return
66
-     */
67
-    @RequestMapping(value="/sysConfig",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean sysConfigAdd(@ApiParam("保存内容") @RequestBody SysConfig sysConfig) throws Exception{
70
-
71
-        if (iSysConfigService.save(sysConfig)){
72
-            return ResponseBean.success(sysConfig);
73
-        }else {
74
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
-        }
76
-    }
77
-
78
-    /**
79
-     * 根据id删除对象
80
-     * @param id  实体ID
81
-     */
82
-    @RequestMapping(value="/sysConfig/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean sysConfigDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iSysConfigService.removeById(id)){
86
-            return ResponseBean.success("success");
87
-        }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89
-        }
61
+        IPage<SysConfig> result = iSysConfigService.page(pg, queryWrapper);
62
+        return ResponseBean.success(result);
90 63
     }
91 64
 
92 65
     /**
@@ -95,25 +68,28 @@ public class SysConfigController extends BaseController {
95 68
      * @param sysConfig 实体对象
96 69
      * @return
97 70
      */
98
-    @RequestMapping(value="/sysConfig/{id}",method= RequestMethod.PUT)
71
+    @RequestMapping(value="/admin/sys-config/{id}",method= RequestMethod.PUT)
99 72
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100 73
     public ResponseBean sysConfigUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101 74
                                         @ApiParam("更新内容") @RequestBody SysConfig sysConfig) throws Exception{
75
+        if (!id.equals(sysConfig.getSerialNo())) {
76
+            throw new Exception("校验修改参数ID不正确");
77
+        }
102 78
 
103
-        if (iSysConfigService.updateById(sysConfig)){
79
+        SysConfig origin = iSysConfigService.getById(id);
80
+        if (!origin.getCode().equals(sysConfig.getCode())) {
81
+            throw new Exception("校验修改参数内容不正确");
82
+        }
83
+
84
+        origin.setValue(sysConfig.getValue());
85
+        if (Constants.STATUS_NORMAL.equals(sysConfig.getStatus()) || Constants.STATUS_READY.equals(sysConfig.getStatus())) {
86
+            origin.setStatus(sysConfig.getStatus());
87
+        }
88
+
89
+        if (iSysConfigService.updateById(origin)){
104 90
             return ResponseBean.success(iSysConfigService.getById(id));
105 91
         }else {
106 92
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107 93
         }
108 94
     }
109
-
110
-    /**
111
-     * 根据id查询对象
112
-     * @param id  实体ID
113
-     */
114
-    @RequestMapping(value="/sysConfig/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean sysConfigGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iSysConfigService.getById(id));
118
-    }
119 95
 }

+ 45
- 20
src/main/java/com/yunzhi/demo/controller/SysRoleMenuController.java View File

@@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7 8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.entity.SysRole;
10
+import com.yunzhi.demo.service.ISysRoleService;
8 11
 import io.swagger.annotations.Api;
9 12
 import io.swagger.annotations.ApiOperation;
10 13
 import io.swagger.annotations.ApiParam;
@@ -20,6 +23,8 @@ import com.yunzhi.demo.service.ISysRoleMenuService;
20 23
 import com.yunzhi.demo.entity.SysRoleMenu;
21 24
 import org.springframework.web.bind.annotation.RestController;
22 25
 
26
+import java.util.List;
27
+
23 28
 /**
24 29
  * <p>
25 30
     * 角色菜单 前端控制器
@@ -37,39 +42,59 @@ public class SysRoleMenuController extends BaseController {
37 42
     private final Logger logger = LoggerFactory.getLogger(SysRoleMenuController.class);
38 43
 
39 44
     @Autowired
40
-    public ISysRoleMenuService iSysRoleMenuService;
45
+    ISysRoleMenuService iSysRoleMenuService;
41 46
 
47
+    @Autowired
48
+    ISysRoleService iSysRoleService;
42 49
 
43 50
     /**
44
-     * 分页查询列表
45
-     * @param pageNum
46
-     * @param pageSize
51
+     * 查询角色授权菜单
52
+     * @param roleId
47 53
      * @return
54
+     * @throws Exception
48 55
      */
49
-    @RequestMapping(value="/sysRoleMenu",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean sysRoleMenuList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
-
54
-		    IPage<SysRoleMenu> pg = new Page<>(pageNum, pageSize);
56
+    @RequestMapping(value="/admin/role-menu",method= RequestMethod.GET)
57
+    @ApiOperation(value="查询角色授权菜单", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
58
+    public ResponseBean sysRoleMenuList(@ApiParam("角色ID") @RequestParam Integer roleId) throws Exception{
55 59
             QueryWrapper<SysRoleMenu> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
60
+            queryWrapper.eq("role_id", roleId);
57 61
 
58
-            IPage<SysRoleMenu> result = iSysRoleMenuService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
62
+            List<SysRoleMenu> roleMenuList = iSysRoleMenuService.list(queryWrapper);
63
+            return ResponseBean.success(roleMenuList);
60 64
     }
61 65
 
62 66
     /**
63
-     * 保存对象
64
-     * @param sysRoleMenu 实体对象
67
+     * 授权菜单
68
+     * @param roleId
69
+     * @param roleMenuList
65 70
      * @return
71
+     * @throws Exception
66 72
      */
67
-    @RequestMapping(value="/sysRoleMenu",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean sysRoleMenuAdd(@ApiParam("保存内容") @RequestBody SysRoleMenu sysRoleMenu) throws Exception{
73
+    @RequestMapping(value="/admin/role-menu/{roleId}",method= RequestMethod.POST)
74
+    @ApiOperation(value="授权菜单", notes = "授权菜单", httpMethod = "POST", response = ResponseBean.class)
75
+    public ResponseBean sysRoleMenuAdd(@ApiParam("角色ID") @PathVariable Integer roleId,
76
+                                       @ApiParam("保存内容") @RequestBody List<SysRoleMenu> roleMenuList) throws Exception{
77
+        if (Constants.SUPER_ADMIN_ROLE.equals(roleId)) {
78
+            throw new Exception("您无权进行此操作");
79
+        }
80
+
81
+        SysRole sysRole = iSysRoleService.getById(roleId);
82
+        if (null == sysRole || Constants.STATUS_DELETED.equals(sysRole.getStatus())) {
83
+            throw new Exception("验证角色信息失败: 当前角色不存在");
84
+        }
85
+
86
+        // 先删除所有授权信息
87
+        iSysRoleMenuService.deleteByRole(roleId);
88
+        if (null == roleMenuList || roleMenuList.size() == 0) {
89
+            return ResponseBean.success("success");
90
+        }
91
+
92
+        for (SysRoleMenu roleMenu : roleMenuList) {
93
+            roleMenu.setRoleId(roleId);
94
+        }
70 95
 
71
-        if (iSysRoleMenuService.save(sysRoleMenu)){
72
-            return ResponseBean.success(sysRoleMenu);
96
+        if (iSysRoleMenuService.saveBatch(roleMenuList)){
97
+            return ResponseBean.success(roleMenuList);
73 98
         }else {
74 99
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75 100
         }

+ 3
- 0
src/main/java/com/yunzhi/demo/controller/SysUserController.java View File

@@ -220,6 +220,9 @@ public class SysUserController extends BaseController {
220 220
         List<SysMenu> sysMenuList = iSysMenuService.getListWithRoles();
221 221
         List<SysUserRole> sysUserRoleList = iSysUserRoleService.getListByUser(sysUser.getUserId());
222 222
 
223
+        SysLogin sysLogin = iSysLoginService.getByUser(sysUser.getUserId());
224
+        sysUser.setLoginName(sysLogin.getLoginName());
225
+
223 226
         Map<String, Object> result = new HashMap<String, Object>() {{
224 227
             put("user", sysUser);
225 228
             put("menus", sysMenuList);

+ 79
- 34
src/main/java/com/yunzhi/demo/controller/TdHospitalController.java View File

@@ -4,7 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
7 8
 import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.common.StringUtils;
10
+import com.yunzhi.demo.entity.TdSchool;
11
+import com.yunzhi.demo.service.ITdSchoolService;
8 12
 import io.swagger.annotations.Api;
9 13
 import io.swagger.annotations.ApiOperation;
10 14
 import io.swagger.annotations.ApiParam;
@@ -20,6 +24,8 @@ import com.yunzhi.demo.service.ITdHospitalService;
20 24
 import com.yunzhi.demo.entity.TdHospital;
21 25
 import org.springframework.web.bind.annotation.RestController;
22 26
 
27
+import java.time.LocalDateTime;
28
+
23 29
 /**
24 30
  * <p>
25 31
     * 医务室 前端控制器
@@ -37,36 +43,61 @@ public class TdHospitalController extends BaseController {
37 43
     private final Logger logger = LoggerFactory.getLogger(TdHospitalController.class);
38 44
 
39 45
     @Autowired
40
-    public ITdHospitalService iTdHospitalService;
46
+    ITdHospitalService iTdHospitalService;
47
+
48
+    @Autowired
49
+    ITdSchoolService iTdSchoolService;
41 50
 
42 51
 
43 52
     /**
44
-     * 分页查询列表
53
+     * 学校诊室管理
45 54
      * @param pageNum
46 55
      * @param pageSize
47 56
      * @return
48 57
      */
49
-    @RequestMapping(value="/tdHospital",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
58
+    @RequestMapping(value="/admin/hospital",method= RequestMethod.GET)
59
+    @ApiOperation(value="学校诊室管理", notes = "学校诊室管理", httpMethod = "GET", response = ResponseBean.class)
51 60
     public ResponseBean tdHospitalList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
61
+                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
62
+                                       @ApiParam("所属学校") @RequestParam(value ="schoolId") String schoolId,
63
+                                       @ApiParam("诊室名称") @RequestParam(value ="name", required = false) String name) throws Exception{
53 64
 
54
-		    IPage<TdHospital> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TdHospital> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
65
+        TdSchool tdSchool = iTdSchoolService.getById(schoolId);
66
+        if (null == tdSchool || Constants.STATUS_DELETED.equals(tdSchool.getStatus())) {
67
+            throw new Exception("没有找到所属学校信息");
68
+        }
57 69
 
58
-            IPage<TdHospital> result = iTdHospitalService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
70
+        IPage<TdHospital> pg = new Page<>(pageNum, pageSize);
71
+        QueryWrapper<TdHospital> queryWrapper = new QueryWrapper<>();
72
+        queryWrapper.eq("school_id", schoolId);
73
+        queryWrapper.gt("status", Constants.STATUS_DELETED);
74
+        queryWrapper.like(!StringUtils.isEmpty(name),"name", "%"+name+"%");
75
+        queryWrapper.orderByDesc("create_date");
76
+
77
+        IPage<TdHospital> result = iTdHospitalService.page(pg, queryWrapper);
78
+        return ResponseBean.success(result);
60 79
     }
61 80
 
62 81
     /**
63
-     * 保存对象
82
+     * 保存诊室信息
64 83
      * @param tdHospital 实体对象
65 84
      * @return
66 85
      */
67
-    @RequestMapping(value="/tdHospital",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean tdHospitalAdd(@ApiParam("保存内容") @RequestBody TdHospital tdHospital) throws Exception{
86
+    @RequestMapping(value="/admin/hospital",method= RequestMethod.POST)
87
+    @ApiOperation(value="保存诊室信息", notes = "保存诊室信息", httpMethod = "POST", response = ResponseBean.class)
88
+    public ResponseBean tdHospitalAdd(@ApiParam("诊室信息") @RequestBody TdHospital tdHospital) throws Exception{
89
+        if (StringUtils.isEmpty(tdHospital.getSchoolId())) {
90
+            throw new Exception("没有找到所属学校信息");
91
+        }
92
+
93
+        TdSchool tdSchool = iTdSchoolService.getById(tdHospital.getSchoolId());
94
+        if (null == tdSchool || Constants.STATUS_DELETED.equals(tdSchool.getStatus())) {
95
+            throw new Exception("没有找到所属学校信息");
96
+        }
97
+
98
+        if (StringUtils.isEmpty(tdHospital.getName())) {
99
+            throw new Exception("没有填写诊室信息");
100
+        }
70 101
 
71 102
         if (iTdHospitalService.save(tdHospital)){
72 103
             return ResponseBean.success(tdHospital);
@@ -76,13 +107,20 @@ public class TdHospitalController extends BaseController {
76 107
     }
77 108
 
78 109
     /**
79
-     * 根据id删除对象
110
+     * 删除诊室
80 111
      * @param id  实体ID
81 112
      */
82
-    @RequestMapping(value="/tdHospital/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean tdHospitalDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTdHospitalService.removeById(id)){
113
+    @RequestMapping(value="/admin/hospital/{id}", method= RequestMethod.DELETE)
114
+    @ApiOperation(value="删除诊室", notes = "删除诊室", httpMethod = "DELETE", response = ResponseBean.class)
115
+    public ResponseBean tdHospitalDelete(@ApiParam("诊室ID") @PathVariable String id) throws Exception{
116
+        TdHospital tdHospital = iTdHospitalService.getById(id);
117
+        if (null == tdHospital || Constants.STATUS_DELETED.equals(tdHospital.getStatus())) {
118
+            return ResponseBean.success("success");
119
+        }
120
+
121
+        tdHospital.setStatus(Constants.STATUS_DELETED);
122
+
123
+        if(iTdHospitalService.updateById(tdHospital)){
86 124
             return ResponseBean.success("success");
87 125
         }else {
88 126
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -90,30 +128,37 @@ public class TdHospitalController extends BaseController {
90 128
     }
91 129
 
92 130
     /**
93
-     * 修改对象
131
+     * 修改诊室信息
94 132
      * @param id  实体ID
95 133
      * @param tdHospital 实体对象
96 134
      * @return
97 135
      */
98
-    @RequestMapping(value="/tdHospital/{id}",method= RequestMethod.PUT)
136
+    @RequestMapping(value="/admin/hospital/{id}",method= RequestMethod.PUT)
99 137
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean tdHospitalUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody TdHospital tdHospital) throws Exception{
138
+    public ResponseBean tdHospitalUpdate(@ApiParam("对象ID") @PathVariable String id,
139
+                                         @ApiParam("更新内容") @RequestBody TdHospital tdHospital) throws Exception{
140
+        TdHospital origin = iTdHospitalService.getById(id);
141
+        if (null == origin || Constants.STATUS_DELETED.equals(origin)) {
142
+            throw new Exception("未找到更新记录");
143
+        }
144
+
145
+        if (StringUtils.isEmpty(tdHospital.getName())) {
146
+            throw new Exception("没有填写诊室信息");
147
+        }
148
+
149
+        if (!id.equals(tdHospital.getHospitalId())) {
150
+            throw new Exception("校验诊室信息出错");
151
+        }
102 152
 
103
-        if (iTdHospitalService.updateById(tdHospital)){
153
+        // 允许修改的字段
154
+        origin.setName(tdHospital.getName());
155
+        origin.setStatus(tdHospital.getStatus());
156
+        origin.setUpdateDate(LocalDateTime.now());
157
+
158
+        if (iTdHospitalService.updateById(origin)){
104 159
             return ResponseBean.success(iTdHospitalService.getById(id));
105 160
         }else {
106 161
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107 162
         }
108 163
     }
109
-
110
-    /**
111
-     * 根据id查询对象
112
-     * @param id  实体ID
113
-     */
114
-    @RequestMapping(value="/tdHospital/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean tdHospitalGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTdHospitalService.getById(id));
118
-    }
119 164
 }

+ 40
- 78
src/main/java/com/yunzhi/demo/controller/TdSchoolController.java View File

@@ -49,25 +49,6 @@ public class TdSchoolController extends BaseController {
49 49
         return ResponseBean.success(iTdSchoolService.list(queryWrapper));
50 50
     }
51 51
 
52
-    /**
53
-     * 分页查询列表
54
-     * @param pageNum
55
-     * @param pageSize
56
-     * @return
57
-     */
58
-    @RequestMapping(value="/tdSchool",method= RequestMethod.GET)
59
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
60
-    public ResponseBean tdSchoolList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
61
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
62
-
63
-		    IPage<TdSchool> pg = new Page<>(pageNum, pageSize);
64
-            QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<>();
65
-            queryWrapper.orderByDesc("create_date");
66
-
67
-            IPage<TdSchool> result = iTdSchoolService.page(pg, queryWrapper);
68
-            return ResponseBean.success(result);
69
-    }
70
-
71 52
     /**
72 53
      * 分页查询列表
73 54
      * @param pageNum
@@ -77,7 +58,7 @@ public class TdSchoolController extends BaseController {
77 58
     @RequestMapping(value="/admin/school",method= RequestMethod.GET)
78 59
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
79 60
     public ResponseBean schoolList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
80
-                                     @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
61
+                                   @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
81 62
                                    @ApiParam("名称") @RequestParam(value = "name", required = false) String name,
82 63
                                    @ApiParam("状态") @RequestParam(value = "status", required = false) String status) throws Exception{
83 64
 
@@ -85,6 +66,7 @@ public class TdSchoolController extends BaseController {
85 66
         QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<TdSchool>()
86 67
                 .like(!StringUtils.isEmpty(name), "name", name)
87 68
                 .eq(null != status, "status", status)
69
+                .gt("status", Constants.STATUS_DELETED)
88 70
                 .orderByDesc("create_date");
89 71
 
90 72
         IPage<TdSchool> result = iTdSchoolService.page(pg, queryWrapper);
@@ -96,25 +78,18 @@ public class TdSchoolController extends BaseController {
96 78
      * @param tdSchool 实体对象
97 79
      * @return
98 80
      */
99
-    @RequestMapping(value="/tdSchool",method= RequestMethod.POST)
81
+    @RequestMapping(value="/admin/school",method= RequestMethod.POST)
100 82
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
101
-    public ResponseBean tdSchoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
83
+    public ResponseBean schoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
102 84
 
103
-        if (iTdSchoolService.save(tdSchool)){
104
-            return ResponseBean.success(tdSchool);
105
-        }else {
106
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
85
+        if (StringUtils.isEmpty(tdSchool.getName())) {
86
+            throw new Exception("学校名称不能为空");
107 87
         }
108
-    }
109 88
 
110
-    /**
111
-     * 保存对象
112
-     * @param tdSchool 实体对象
113
-     * @return
114
-     */
115
-    @RequestMapping(value="/admin/school",method= RequestMethod.POST)
116
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
117
-    public ResponseBean schoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
89
+        TdSchool exitSchool = iTdSchoolService.getByName(tdSchool.getName());
90
+        if (null != exitSchool) {
91
+            throw new Exception("学校名称已经存在");
92
+        }
118 93
 
119 94
         if (iTdSchoolService.save(tdSchool)){
120 95
             return ResponseBean.success(tdSchool);
@@ -123,20 +98,6 @@ public class TdSchoolController extends BaseController {
123 98
         }
124 99
     }
125 100
 
126
-    /**
127
-     * 根据id删除对象
128
-     * @param id  实体ID
129
-     */
130
-    @RequestMapping(value="/tdSchool/{id}", method= RequestMethod.DELETE)
131
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
132
-    public ResponseBean tdSchoolDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
133
-        if(iTdSchoolService.removeById(id)){
134
-            return ResponseBean.success("success");
135
-        }else {
136
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
137
-        }
138
-    }
139
-
140 101
     /**
141 102
      * 根据id删除对象
142 103
      * @param id  实体ID
@@ -144,28 +105,17 @@ public class TdSchoolController extends BaseController {
144 105
     @RequestMapping(value="/admin/school/{id}", method= RequestMethod.DELETE)
145 106
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
146 107
     public ResponseBean schoolDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
147
-        if(iTdSchoolService.removeById(id)){
108
+        TdSchool origin = iTdSchoolService.getById(id);
109
+        if (null == origin || Constants.STATUS_DELETED.equals(origin.getStatus())) {
148 110
             return ResponseBean.success("success");
149
-        }else {
150
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
151 111
         }
152
-    }
153 112
 
154
-    /**
155
-     * 修改对象
156
-     * @param id  实体ID
157
-     * @param tdSchool 实体对象
158
-     * @return
159
-     */
160
-    @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.PUT)
161
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
162
-    public ResponseBean tdSchoolUpdate(@ApiParam("对象ID") @PathVariable String id,
163
-                                        @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
113
+        origin.setStatus(Constants.STATUS_DELETED);
164 114
 
165
-        if (iTdSchoolService.updateById(tdSchool)){
166
-            return ResponseBean.success(iTdSchoolService.getById(id));
115
+        if(iTdSchoolService.updateById(origin)){
116
+            return ResponseBean.success("success");
167 117
         }else {
168
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
118
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
169 119
         }
170 120
     }
171 121
 
@@ -178,7 +128,24 @@ public class TdSchoolController extends BaseController {
178 128
     @RequestMapping(value="/admin/school/{id}",method= RequestMethod.PUT)
179 129
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
180 130
     public ResponseBean schoolUpdate(@ApiParam("对象ID") @PathVariable String id,
181
-                                       @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
131
+                                     @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
132
+        TdSchool origin = iTdSchoolService.getById(id);
133
+        if (null == origin || Constants.STATUS_DELETED.equals(origin.getStatus())) {
134
+            throw new Exception("没有找到对应的学校信息");
135
+        }
136
+
137
+        if (!id.equals(tdSchool.getSchoolId())) {
138
+            throw new Exception("校验学校信息失败");
139
+        }
140
+
141
+        if (StringUtils.isEmpty(tdSchool.getName())) {
142
+            throw new Exception("学校名称不能为空");
143
+        }
144
+
145
+        TdSchool exitSchool = iTdSchoolService.getByName(tdSchool.getName());
146
+        if (null != exitSchool && !id.equals(exitSchool.getSchoolId())) {
147
+            throw new Exception("学校名称已经存在");
148
+        }
182 149
 
183 150
         if (iTdSchoolService.updateById(tdSchool)){
184 151
             return ResponseBean.success(iTdSchoolService.getById(id));
@@ -191,19 +158,14 @@ public class TdSchoolController extends BaseController {
191 158
      * 根据id查询对象
192 159
      * @param id  实体ID
193 160
      */
194
-    @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.GET)
161
+    @RequestMapping(value="/admin/school/{id}",method= RequestMethod.GET)
195 162
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
196 163
     public ResponseBean tdSchoolGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
197
-        return ResponseBean.success(iTdSchoolService.getById(id));
198
-    }
164
+        TdSchool tdSchool = iTdSchoolService.getById(id);
165
+        if (null == tdSchool || Constants.STATUS_DELETED.equals(tdSchool.getStatus())) {
166
+            throw new Exception("学校信息不存在");
167
+        }
199 168
 
200
-    /**
201
-     * 根据id查询对象
202
-     * @param id  实体ID
203
-     */
204
-    @RequestMapping(value="/admin/school/{id}",method= RequestMethod.GET)
205
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
206
-    public ResponseBean schoolGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
207
-        return ResponseBean.success(iTdSchoolService.getById(id));
169
+        return ResponseBean.success(tdSchool);
208 170
     }
209 171
 }

+ 3
- 0
src/main/java/com/yunzhi/demo/entity/TaTopic.java View File

@@ -36,6 +36,9 @@ public class TaTopic implements Serializable {
36 36
     @ApiModelProperty(value = "对象ID")
37 37
     private String targetId;
38 38
 
39
+    @ApiModelProperty(value = "对象名称")
40
+    private String targetTitle;
41
+
39 42
     @ApiModelProperty(value = "封面")
40 43
     private String poster;
41 44
 

+ 1
- 1
src/main/java/com/yunzhi/demo/entity/TdHospital.java View File

@@ -27,7 +27,7 @@ public class TdHospital implements Serializable {
27 27
     private static final long serialVersionUID = 1L;
28 28
 
29 29
     @ApiModelProperty(value = "医务室ID")
30
-    @TableId(value = "hospital_id", type = IdType.INPUT)
30
+    @TableId(value = "hospital_id", type = IdType.UUID)
31 31
     private String hospitalId;
32 32
 
33 33
     @ApiModelProperty(value = "名称")

+ 1
- 0
src/main/java/com/yunzhi/demo/service/ISysRoleMenuService.java View File

@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 13
  */
14 14
 public interface ISysRoleMenuService extends IService<SysRoleMenu> {
15 15
 
16
+    boolean deleteByRole(Integer roleId);
16 17
 }

+ 1
- 0
src/main/java/com/yunzhi/demo/service/ITdSchoolService.java View File

@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 13
  */
14 14
 public interface ITdSchoolService extends IService<TdSchool> {
15 15
 
16
+    TdSchool getByName(String name);
16 17
 }

+ 7
- 0
src/main/java/com/yunzhi/demo/service/impl/SysRoleMenuServiceImpl.java View File

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.demo.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.yunzhi.demo.entity.SysRoleMenu;
4 5
 import com.yunzhi.demo.mapper.SysRoleMenuMapper;
5 6
 import com.yunzhi.demo.service.ISysRoleMenuService;
@@ -17,4 +18,10 @@ import org.springframework.stereotype.Service;
17 18
 @Service
18 19
 public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService {
19 20
 
21
+    @Override
22
+    public boolean deleteByRole(Integer roleId) {
23
+        QueryWrapper<SysRoleMenu> queryWrapper = new QueryWrapper<SysRoleMenu>()
24
+                .eq("role_id", roleId);
25
+        return remove(queryWrapper);
26
+    }
20 27
 }

+ 10
- 0
src/main/java/com/yunzhi/demo/service/impl/TdSchoolServiceImpl.java View File

@@ -1,5 +1,7 @@
1 1
 package com.yunzhi.demo.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.demo.common.Constants;
3 5
 import com.yunzhi.demo.entity.TdSchool;
4 6
 import com.yunzhi.demo.mapper.TdSchoolMapper;
5 7
 import com.yunzhi.demo.service.ITdSchoolService;
@@ -17,4 +19,12 @@ import org.springframework.stereotype.Service;
17 19
 @Service
18 20
 public class TdSchoolServiceImpl extends ServiceImpl<TdSchoolMapper, TdSchool> implements ITdSchoolService {
19 21
 
22
+    @Override
23
+    public TdSchool getByName(String name) {
24
+        QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<TdSchool>()
25
+                .eq("name", name)
26
+                .gt("status", Constants.STATUS_DELETED)
27
+                .last("limit 1");
28
+        return getOne(queryWrapper);
29
+    }
20 30
 }