Your Name 4 年前
父节点
当前提交
5851692554

+ 23
- 0
src/main/java/com/yunzhi/demo/controller/LoginController.java 查看文件

@@ -5,6 +5,7 @@ import com.yunzhi.demo.entity.SysLogin;
5 5
 import com.yunzhi.demo.entity.SysUser;
6 6
 import com.yunzhi.demo.service.ISysLoginService;
7 7
 import com.yunzhi.demo.service.ISysUserService;
8
+import com.yunzhi.demo.vo.ChangePassword;
8 9
 import com.yunzhi.demo.vo.LoginParam;
9 10
 import com.yunzhi.demo.vo.TokenParam;
10 11
 import io.swagger.annotations.Api;
@@ -12,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
12 13
 import io.swagger.annotations.ApiParam;
13 14
 import org.springframework.beans.factory.annotation.Autowired;
14 15
 import org.springframework.web.bind.annotation.PostMapping;
16
+import org.springframework.web.bind.annotation.PutMapping;
15 17
 import org.springframework.web.bind.annotation.RequestBody;
16 18
 import org.springframework.web.bind.annotation.RestController;
17 19
 
@@ -76,6 +78,27 @@ public class LoginController extends BaseController {
76 78
         return ResponseBean.success(res);
77 79
     }
78 80
 
81
+
82
+    @PutMapping("/admin/change-password")
83
+    @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "PUT", response = ResponseBean.class)
84
+    public ResponseBean changePassword(@ApiParam("修改密码参数") @RequestBody ChangePassword param) throws Exception {
85
+        if (StringUtils.isEmpty(param.getOriginPassword()) || StringUtils.isEmpty(param.getNewPassword())) {
86
+            return ResponseBean.error("原始密码或新密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
87
+        }
88
+
89
+        SysUser currentUser = getCurrentUser();
90
+        SysLogin sysLogin = iSysLoginService.getByUser(currentUser.getUserId());
91
+
92
+        if (!checkPassword(param.getOriginPassword(), currentUser.getUserId(), sysLogin.getPassword())) {
93
+            return ResponseBean.error("原始密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
94
+        }
95
+
96
+        sysLogin.setPassword(EncryptUtils.md5(param.getNewPassword(), currentUser.getUserId()));
97
+        iSysLoginService.updateById(sysLogin);
98
+
99
+        return ResponseBean.success("密码修改成功");
100
+    }
101
+
79 102
     private boolean checkPassword(String src, String targ, String salt) {
80 103
         return EncryptUtils.md5(src, salt).equals(targ);
81 104
     }

+ 16
- 81
src/main/java/com/yunzhi/demo/controller/SysBannerController.java 查看文件

@@ -42,26 +42,6 @@ public class SysBannerController extends BaseController {
42 42
     @Autowired
43 43
     public ISysBannerService iSysBannerService;
44 44
 
45
-
46
-    /**
47
-     * 分页查询列表
48
-     * @param pageNum
49
-     * @param pageSize
50
-     * @return
51
-     */
52
-    @RequestMapping(value="/sysBanner",method= RequestMethod.GET)
53
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
54
-    public ResponseBean sysBannerList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
56
-
57
-		    IPage<SysBanner> pg = new Page<>(pageNum, pageSize);
58
-            QueryWrapper<SysBanner> queryWrapper = new QueryWrapper<>();
59
-            queryWrapper.orderByDesc("create_date");
60
-
61
-            IPage<SysBanner> result = iSysBannerService.page(pg, queryWrapper);
62
-            return ResponseBean.success(result);
63
-    }
64
-
65 45
     /**
66 46
      * 分页查询列表
67 47
      * @param pageNum
@@ -75,29 +55,16 @@ public class SysBannerController extends BaseController {
75 55
                                    @ApiParam("标题") @RequestParam(value = "title", required = false) String title) throws Exception{
76 56
 
77 57
         IPage<SysBanner> pg = new Page<>(pageNum, pageSize);
78
-        QueryWrapper<SysBanner> queryWrapper = new QueryWrapper<SysBanner>().like(!StringUtils.isEmpty(title), "title", title);
79
-        queryWrapper.orderByDesc("create_date");
58
+        QueryWrapper<SysBanner> queryWrapper = new QueryWrapper<SysBanner>()
59
+                .like(!StringUtils.isEmpty(title), "title", title)
60
+                .gt("status", Constants.STATUS_DELETED)
61
+                .orderByAsc("sort_no")
62
+                .orderByDesc("create_date");
80 63
 
81 64
         IPage<SysBanner> result = iSysBannerService.page(pg, queryWrapper);
82 65
         return ResponseBean.success(result);
83 66
     }
84 67
 
85
-    /**
86
-     * 保存对象
87
-     * @param sysBanner 实体对象
88
-     * @return
89
-     */
90
-    @RequestMapping(value="/sysBanner",method= RequestMethod.POST)
91
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
92
-    public ResponseBean sysBannerAdd(@ApiParam("保存内容") @RequestBody SysBanner sysBanner) throws Exception{
93
-
94
-        if (iSysBannerService.save(sysBanner)){
95
-            return ResponseBean.success(sysBanner);
96
-        }else {
97
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
98
-        }
99
-    }
100
-
101 68
     /**
102 69
      * 保存对象
103 70
      * @param sysBanner 实体对象
@@ -118,48 +85,21 @@ public class SysBannerController extends BaseController {
118 85
      * 根据id删除对象
119 86
      * @param id  实体ID
120 87
      */
121
-    @RequestMapping(value="/sysBanner/{id}", method= RequestMethod.DELETE)
88
+    @RequestMapping(value="/admin/banner/{id}", method= RequestMethod.DELETE)
122 89
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
123
-    public ResponseBean sysBannerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
124
-        if(iSysBannerService.removeById(id)){
90
+    public ResponseBean bannerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception {
91
+        SysBanner sysBanner = iSysBannerService.getById(id);
92
+        if (null == sysBanner || Constants.STATUS_DELETED.equals(sysBanner.getStatus())) {
125 93
             return ResponseBean.success("success");
126
-        }else {
127
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
128 94
         }
129
-    }
130 95
 
131
-    /**
132
-     * 根据id删除对象
133
-     * @param id  实体ID
134
-     */
135
-    @RequestMapping(value="/admin/banner/{id}", method= RequestMethod.DELETE)
136
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
137
-    public ResponseBean bannerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
138
-        if(iSysBannerService.removeById(id)){
96
+        if(iSysBannerService.updateById(sysBanner)){
139 97
             return ResponseBean.success("success");
140 98
         }else {
141 99
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
142 100
         }
143 101
     }
144 102
 
145
-    /**
146
-     * 修改对象
147
-     * @param id  实体ID
148
-     * @param sysBanner 实体对象
149
-     * @return
150
-     */
151
-    @RequestMapping(value="/sysBanner/{id}",method= RequestMethod.PUT)
152
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
153
-    public ResponseBean sysBannerUpdate(@ApiParam("对象ID") @PathVariable Integer id,
154
-                                        @ApiParam("更新内容") @RequestBody SysBanner sysBanner) throws Exception{
155
-
156
-        if (iSysBannerService.updateById(sysBanner)){
157
-            return ResponseBean.success(iSysBannerService.getById(id));
158
-        }else {
159
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
160
-        }
161
-    }
162
-
163 103
     /**
164 104
      * 修改对象
165 105
      * @param id  实体ID
@@ -178,16 +118,6 @@ public class SysBannerController extends BaseController {
178 118
         }
179 119
     }
180 120
 
181
-    /**
182
-     * 根据id查询对象
183
-     * @param id  实体ID
184
-     */
185
-    @RequestMapping(value="/sysBanner/{id}",method= RequestMethod.GET)
186
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
187
-    public ResponseBean sysBannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
188
-        return ResponseBean.success(iSysBannerService.getById(id));
189
-    }
190
-
191 121
     /**
192 122
      * 根据id查询对象
193 123
      * @param id  实体ID
@@ -195,6 +125,11 @@ public class SysBannerController extends BaseController {
195 125
     @RequestMapping(value="/admin/banner/{id}",method= RequestMethod.GET)
196 126
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
197 127
     public ResponseBean bannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
198
-        return ResponseBean.success(iSysBannerService.getById(id));
128
+        SysBanner sysBanner = iSysBannerService.getById(id);
129
+        if (null == sysBanner || Constants.STATUS_DELETED.equals(sysBanner.getStatus())) {
130
+            return ResponseBean.error("未找到当前ID对应信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
131
+        }
132
+
133
+        return ResponseBean.success(sysBanner);
199 134
     }
200 135
 }

+ 0
- 77
src/main/java/com/yunzhi/demo/controller/SysLoginController.java 查看文件

@@ -39,81 +39,4 @@ public class SysLoginController extends BaseController {
39 39
     @Autowired
40 40
     public ISysLoginService iSysLoginService;
41 41
 
42
-
43
-    /**
44
-     * 分页查询列表
45
-     * @param pageNum
46
-     * @param pageSize
47
-     * @return
48
-     */
49
-    @RequestMapping(value="/sysLogin",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean sysLoginList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
-
54
-		    IPage<SysLogin> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<SysLogin> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
57
-
58
-            IPage<SysLogin> result = iSysLoginService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
60
-    }
61
-
62
-    /**
63
-     * 保存对象
64
-     * @param sysLogin 实体对象
65
-     * @return
66
-     */
67
-    @RequestMapping(value="/sysLogin",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean sysLoginAdd(@ApiParam("保存内容") @RequestBody SysLogin sysLogin) throws Exception{
70
-
71
-        if (iSysLoginService.save(sysLogin)){
72
-            return ResponseBean.success(sysLogin);
73
-        }else {
74
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
-        }
76
-    }
77
-
78
-    /**
79
-     * 根据id删除对象
80
-     * @param id  实体ID
81
-     */
82
-    @RequestMapping(value="/sysLogin/{id}", method= RequestMethod.DELETE)
83
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean sysLoginDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iSysLoginService.removeById(id)){
86
-            return ResponseBean.success("success");
87
-        }else {
88
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89
-        }
90
-    }
91
-
92
-    /**
93
-     * 修改对象
94
-     * @param id  实体ID
95
-     * @param sysLogin 实体对象
96
-     * @return
97
-     */
98
-    @RequestMapping(value="/sysLogin/{id}",method= RequestMethod.PUT)
99
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean sysLoginUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
-                                        @ApiParam("更新内容") @RequestBody SysLogin sysLogin) throws Exception{
102
-
103
-        if (iSysLoginService.updateById(sysLogin)){
104
-            return ResponseBean.success(iSysLoginService.getById(id));
105
-        }else {
106
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107
-        }
108
-    }
109
-
110
-    /**
111
-     * 根据id查询对象
112
-     * @param id  实体ID
113
-     */
114
-    @RequestMapping(value="/sysLogin/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean sysLoginGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iSysLoginService.getById(id));
118
-    }
119 42
 }

+ 0
- 10
src/main/java/com/yunzhi/demo/controller/TaPersonController.java 查看文件

@@ -69,16 +69,6 @@ public class TaPersonController extends BaseController {
69 69
                                      @ApiParam("学号") @RequestParam(value ="studentId", required = false) String studentId) throws Exception{
70 70
 
71 71
 		    IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
72
-            QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<TaPerson>()
73
-                    .gt("student_id", "")
74
-                    .gt("status", Constants.STATUS_DELETED)
75
-                    .like(!StringUtils.isEmpty(name), "name", "%"+name+"%")
76
-                    .eq(!StringUtils.isEmpty(schoolId), "school_id", schoolId)
77
-                    .eq(!StringUtils.isEmpty(specialtyId), "specialty_id", specialtyId)
78
-                    .like(!StringUtils.isEmpty(phone), "phone", "%"+phone+"%")
79
-                    .like(!StringUtils.isEmpty(studentId), "student_id", "%"+studentId+"%")
80
-                    .orderByDesc("create_date");
81
-
82 72
             IPage<TaPerson> result = iTaPersonService.getStudentInfoPagedBy(pg, name, schoolId, specialtyId, phone, studentId);
83 73
             return ResponseBean.success(result);
84 74
     }

+ 16
- 0
src/main/java/com/yunzhi/demo/vo/ChangePassword.java 查看文件

@@ -0,0 +1,16 @@
1
+package com.yunzhi.demo.vo;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+
7
+@ApiModel(description = "修改密码参数")
8
+@Data
9
+public class ChangePassword {
10
+
11
+    @ApiModelProperty("原始密码, MD5 加密后数据")
12
+    String originPassword;
13
+
14
+    @ApiModelProperty("新密码, MD5 加密后数据")
15
+    String newPassword;
16
+}