|
|
@@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.constant.WeChatTemplateConst;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Codec;
|
|
|
@@ -116,23 +117,27 @@ public class AdminController {
|
|
|
* 编辑管理员
|
|
|
*/
|
|
|
@PutMapping("/put")
|
|
|
- public Result<String> editAdmin(@RequestBody Admin admin) {
|
|
|
+ public Result<String> editAdmin(@RequestBody Admin admin) throws Exception {
|
|
|
Long adminId = StpUserUtil.getLoginIdAsLong();
|
|
|
Admin exist = adminService.getById(adminId);
|
|
|
- if (admin == null) {
|
|
|
+ if (exist == null) {
|
|
|
throw BusinessRuntimeException.getInstance("账号不存在,请重新登录");
|
|
|
}
|
|
|
if (exist.getCategory() != Admin.Category.superoot) {
|
|
|
throw BusinessRuntimeException.getInstance("无超级管理员权限");
|
|
|
}
|
|
|
+ if (admin.getId() == null || adminService.getById(admin.getId()) == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("账号不存在");
|
|
|
+ }
|
|
|
if (StrUtil.isNotEmpty(admin.getPhone())) {
|
|
|
boolean mobile = Validator.isMobile(admin.getPhone());
|
|
|
if (!mobile) {
|
|
|
throw BusinessRuntimeException.getInstance("请输入正确的手机号");
|
|
|
}
|
|
|
}
|
|
|
- if (admin.getId() == null || adminService.getById(admin.getId()) == null) {
|
|
|
- throw BusinessRuntimeException.getInstance("账号不存在");
|
|
|
+ if (StrUtil.isNotEmpty(admin.getPassWord())) {
|
|
|
+ String encodePasscode = Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.SHA256).setStringData(admin.getPassWord()).toBase64String();
|
|
|
+ admin.setPassWord(encodePasscode);
|
|
|
}
|
|
|
adminService.saveOrUpdate(admin);
|
|
|
StpUserUtil.logoutByLoginId(admin.getId());
|
|
|
@@ -183,9 +188,9 @@ public class AdminController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get/list")
|
|
|
- public Result<List<Admin>> list(){
|
|
|
- List<Admin> list = adminService.list(new LambdaQueryWrapper<Admin>().eq(Admin::getStatus,true));
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
+ public Result<Page<Admin>> list(@RequestParam(defaultValue = "1") Integer start, @RequestParam(defaultValue = "5") Integer limit) {
|
|
|
+ Page<Admin> page = adminService.page(new Page<>(start, limit), new LambdaQueryWrapper<Admin>().eq(Admin::getStatus, true));
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(page);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/send/template")
|
|
|
@@ -249,4 +254,4 @@ public class AdminController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|