update:修改系统管理的返回提示语

This commit is contained in:
sunzheng
2024-08-09 10:13:19 +08:00
parent f5ffceceb6
commit 6bfccd84e5
5 changed files with 113 additions and 105 deletions
@@ -554,12 +554,12 @@ public class SysDictController {
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage);
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
return Result.error(ResultCommon.ERROR);
} finally {
fileClose(file);
}
}
return Result.error("文件导入失败!");
return Result.error(ResultCommon.ERROR);
}
private SuccessAndErrorLines getSuccessAndErrorLines(List<SysDictPage> list, List<String> errorMessage, int successLines, int errorLines, int i, SysDict po) {
@@ -615,7 +615,7 @@ public class SysDictController {
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
} catch (Exception e) {
e.printStackTrace();
return Result.error("删除失败!");
return Result.error(ResultCommon.ERROR);
}
}
@@ -632,7 +632,7 @@ public class SysDictController {
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
e.printStackTrace();
return Result.error("操作失败!");
return Result.error(ResultCommon.ERROR);
}
}
/**
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.api.vo.Result;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.constant.CommonConstant;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.MD5Util;
@@ -29,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.awt.image.RescaleOp;
import java.util.*;
import java.util.stream.Collectors;
@@ -177,7 +179,7 @@ public class SysPermissionController {
return Result.OK(listMap);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("批量查询子菜单失败:" + e.getMessage());
return Result.error(ResultCommon.ERROR);
}
}
@@ -193,7 +195,7 @@ public class SysPermissionController {
//直接获取当前用户不适用前端token
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (oConvertUtils.isEmpty(loginUser)) {
return Result.error("请登录系统!");
return Result.error(ResultCommon.ERROR);
}
List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getUsername());
@@ -219,7 +221,7 @@ public class SysPermissionController {
result.setMessage("查询成功");
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("查询失败:" + e.getMessage());
return Result.error(ResultCommon.ERROR);
}
return result;
}
@@ -235,10 +237,10 @@ public class SysPermissionController {
permission = PermissionDataUtil.intelligentProcessData(permission);
permission.setId(UUIDGenerator.generate());
sysPermissionService.addPermission(permission);
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -252,10 +254,10 @@ public class SysPermissionController {
try {
permission = PermissionDataUtil.intelligentProcessData(permission);
sysPermissionService.editPermission(permission);
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.EDIT_OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -268,14 +270,14 @@ public class SysPermissionController {
public Result<T> delete(@RequestBody Map<String, String> map) {
String id = map.get("id");
if(StringUtils.isBlank(id)){
return Result.error(PARAM_NULL);
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}
try {
sysPermissionService.deletePermission(id);
return Result.OK(DEL_SUCCESS);
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error(e.getMessage());
return Result.error(ResultCommon.ERROR);
}
}
@@ -288,7 +290,7 @@ public class SysPermissionController {
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
String ids = map.get("ids");
if(StringUtils.isBlank(ids)){
return Result.error(PARAM_NULL);
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}
try {
String[] arr = ids.split(",");
@@ -297,10 +299,10 @@ public class SysPermissionController {
sysPermissionService.deletePermission(id);
}
}
return Result.OK(DEL_SUCCESS);
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED_IN_BULK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error(DEL_SUCCESS);
return Result.error(ResultCommon.ERROR);
}
}
@@ -347,7 +349,7 @@ public class SysPermissionController {
try {
List<TreeModel> list = sysPermissionService.queryListByParentId(parentId);
if (list == null || list.isEmpty()) {
return Result.error("未找到角色信息");
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
} else {
result.setResult(list);
result.setSuccess(true);
@@ -391,10 +393,10 @@ public class SysPermissionController {
String lastPermissionIds = json.getString("lastpermissionIds");
this.sysRolePermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds);
log.info("======角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("授权失败!");
return Result.error(ResultCommon.ERROR);
}
}
@@ -672,10 +674,10 @@ public class SysPermissionController {
try {
sysPermissionDataRule.setCreateTime(new Date());
sysPermissionDataRuleService.savePermissionDataRule(sysPermissionDataRule);
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -683,10 +685,10 @@ public class SysPermissionController {
public Result<Object> editPermissionRule(@RequestBody SysPermissionDataRule sysPermissionDataRule) {
try {
sysPermissionDataRuleService.saveOrUpdate(sysPermissionDataRule);
return Result.OK("更新成功!");
return Result.OK(ResultCommon.EDIT_OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -701,13 +703,13 @@ public class SysPermissionController {
try {
String id = map.get("id");
if(StringUtils.isBlank(id)){
return Result.error(PARAM_NULL);
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}
sysPermissionDataRuleService.deletePermissionDataRule(id);
return Result.OK("删除成功!");
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -721,10 +723,10 @@ public class SysPermissionController {
public Result<List<SysPermissionDataRule>> queryPermissionRule(SysPermissionDataRule sysPermissionDataRule) {
try {
List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.queryPermissionRule(sysPermissionDataRule);
return Result.OK("查询成功", permRuleList);
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -760,10 +762,10 @@ public class SysPermissionController {
String lastPermissionIds = json.getString("lastpermissionIds");
this.sysDepartPermissionService.saveDepartPermission(departId, permissionIds, lastPermissionIds);
log.info("======部门授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("授权失败!");
return Result.error(ResultCommon.ERROR);
}
}
}
@@ -14,7 +14,9 @@ import javax.servlet.http.HttpServletResponse;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.jero.common.api.vo.Result;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.system.base.controller.JeroController;
import com.jero.common.util.MessageUtils;
import com.jero.common.util.UUIDGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -116,10 +118,10 @@ public class SysRoleController {
role.setCreateTime(new Date());
role.setId(UUIDGenerator.generate());
sysRoleService.save(role);
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.NO_CORRESPONDING_RECORD_FOUND);
}
}
@@ -133,16 +135,16 @@ public class SysRoleController {
public Result<Object> edit(@RequestBody SysRole role) {
SysRole sysrole = sysRoleService.getById(role.getId());
if(sysrole==null) {
return Result.error("未找到对应实体");
return Result.error(ResultCommon.NO_CORRESPONDING_RECORD_FOUND);
}else {
role.setUpdateTime(new Date());
boolean ok = sysRoleService.updateById(role);
if(ok) {
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.EDIT_OK);
}
}
return Result.OK();
return Result.OK(ResultCommon.EDIT_OK);
}
/**
@@ -155,10 +157,10 @@ public class SysRoleController {
public Result<T> delete(@RequestBody Map<String, String> map) {
String id = map.get("id");
if(StringUtils.isBlank(id)){
return Result.error("参数不识别!");
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}
sysRoleService.deleteRole(id);
return Result.OK("删除角色成功");
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
}
/**
@@ -171,13 +173,13 @@ public class SysRoleController {
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
String ids = map.get("ids");
if(StringUtils.isBlank(ids)){
return Result.error("参数不识别!");
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}
if(oConvertUtils.isEmpty(ids)) {
return Result.error("未选中角色!");
return Result.error(ResultCommon.PLEASE_SELECT_DATA);
}else {
sysRoleService.deleteBatchRole(ids.split(","));
return Result.OK("删除角色成功!");
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED_IN_BULK);
}
}
@@ -190,7 +192,7 @@ public class SysRoleController {
public Result<SysRole> queryById(@RequestParam(name="id",required=true) String id) {
SysRole sysRole = sysRoleService.getById(id);
if(sysRole==null) {
return Result.error("未找到对应实体");
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}else {
return Result.OK(sysRole);
}
@@ -200,7 +202,7 @@ public class SysRoleController {
public Result<List<SysRole>> queryall() {
List<SysRole> list = sysRoleService.list();
if(list==null||list.isEmpty()) {
return Result.error("未找到角色信息");
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}else {
return Result.OK(list);
}
@@ -225,13 +227,13 @@ public class SysRoleController {
//role为空=>新增模式=>只要roleCode存在则返回false
//否则=>编辑模式=>判断两者ID是否一致-
result.setSuccess(false);
result.setMessage("角色编码已存在");
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
return result;
}
} catch (Exception e) {
result.setSuccess(false);
result.setResult(false);
result.setMessage(e.getMessage());
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
return result;
}
result.setSuccess(true);
@@ -280,7 +282,7 @@ public class SysRoleController {
return sysRoleService.importExcelCheckRoleCode(file, params);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败:" + e.getMessage());
return Result.error(ResultCommon.ERROR);
} finally {
try {
file.getInputStream().close();
@@ -289,7 +291,7 @@ public class SysRoleController {
}
}
}
return Result.error("文件导入失败!");
return Result.error(ResultCommon.ERROR);
}
/**
@@ -299,7 +301,7 @@ public class SysRoleController {
public Result<Map<String, Object>> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("roleId") String roleId) {
List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
if(list==null || list.isEmpty()) {
return Result.error("未找到权限配置信息");
return Result.error(ResultCommon.NO_CORRESPONDING_RECORD_FOUND);
}else {
Map<String,Object> map = new HashMap<>();
map.put("datarule", list);
@@ -334,16 +336,16 @@ public class SysRoleController {
.eq(SysRolePermission::getRoleId,roleId);
SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
if(sysRolePermission==null) {
return Result.error("请先保存角色菜单权限!");
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}else {
sysRolePermission.setDataRuleIds(dataRuleIds);
this.sysRolePermissionService.updateById(sysRolePermission);
}
} catch (Exception e) {
log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
return Result.error("保存失败");
return Result.error(ResultCommon.ERROR);
}
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
}
@@ -194,10 +194,10 @@ public class SysUserController {
// 保存用户走一个service 保证事务
sysUserService.saveUser(user, selectedRoles, selectedDeparts);
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
} catch (Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -243,16 +243,16 @@ public class SysUserController {
SysUser sysUser = sysUserService.getById(jsonObject.getString("id"));
baseCommonService.addLog("编辑用户,id " +jsonObject.getString("id") ,CommonConstant.LOG_TYPE_2, 2);
if(sysUser==null) {
return Result.error(INEXISTENCE);
return Result.error(ResultCommon.ERROR);
}else {
SysUser user = getSysUser(jsonObject, rsaPrivateKey, sysUser);
// 修改用户走一个service 保证事务
sysUserService.editUser(user, roles, departs);
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.EDIT_OK);
}
} catch (Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
}
@@ -286,19 +286,20 @@ public class SysUserController {
public Result<T> delete(@RequestBody Map<String,String> map) {
String id = map.get("id");
if(StringUtils.isBlank(id)){
return Result.error("参数不识别!");
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}
baseCommonService.addLog("删除用户,id " +id ,CommonConstant.LOG_TYPE_2, 3);
// 验证是否为系统新增
SysUser sysUser = sysUserService.getById(id);
if(Objects.isNull(sysUser)){
return Result.error("数据不存在!");
return Result.error(ResultCommon.DATA_DOES_NOT_EXIST);
}
if(!Objects.equals(sysUser.getSource(),"1")){
return Result.error("数据不允许删除!");
// 数据不允许删除
return Result.error(ResultCommon.ERROR);
}
this.sysUserService.deleteUser(id);
return Result.OK("删除用户成功");
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
}
@PostMapping("/deleteBatch")
@@ -306,11 +307,11 @@ public class SysUserController {
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
String ids = map.get("ids");
if(StringUtils.isBlank(ids)){
return Result.error("参数不识别!");
return Result.error(ResultCommon.PARAMETER_NOT_RECOGNIZED);
}
baseCommonService.addLog("批量删除用户, ids " +ids ,CommonConstant.LOG_TYPE_2, 3);
this.sysUserService.deleteBatchUsers(ids);
return Result.OK("批量删除用户成功");
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED_IN_BULK);
}
@@ -329,9 +330,9 @@ public class SysUserController {
}
} catch (Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error("操作失败"+e.getMessage());
return Result.error(ResultCommon.ERROR);
}
return Result.OK(OPTION_SUCCESS);
return Result.OK(ResultCommon.OK);
}
@@ -341,7 +342,7 @@ public class SysUserController {
sysUserService.update(new LambdaUpdateWrapper<SysUser>()
.eq(SysUser::getId, sysUser.getId())
.set(SysUser::getAvatar, sysUser.getAvatar()));
return Result.OK(MessageUtils.getMessage(ResultCommon.OK));
return Result.OK(ResultCommon.OK);
}
@PostMapping("/importHandStamp")
@@ -353,7 +354,7 @@ public class SysUserController {
public Result<SysUser> queryById(@RequestParam(name = "id", required = true) String id) {
SysUser sysUser = sysUserService.queryById(id);
if (sysUser == null) {
return Result.error(INEXISTENCE);
return Result.error(ResultCommon.ERROR);
} else {
return Result.OK(sysUser);
}
@@ -364,7 +365,7 @@ public class SysUserController {
List<String> list = new ArrayList<>();
List<SysUserRole> userRole = sysUserRoleService.list(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, userid));
if (userRole == null || userRole.isEmpty()) {
return Result.error("未找到用户相关角色信息");
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
} else {
for (SysUserRole sysUserRole : userRole) {
list.add(sysUserRole.getRoleId());
@@ -395,16 +396,17 @@ public class SysUserController {
SysUser user = sysUserService.getOne(new QueryWrapper<>(sysUser));
if (user != null) {
result.setSuccess(false);
result.setMessage("用户账号已存在");
result.setMessage(MessageUtils.getMessage(ResultCommon.NUMBER_WORK_NO_ALREADY_EXISTS));
return result;
}
} catch (Exception e) {
result.setSuccess(false);
result.setMessage(e.getMessage());
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
return result;
}
result.setSuccess(true);
result.setMessage(MessageUtils.getMessage(ResultCommon.OK));
return result;
}
@@ -416,7 +418,7 @@ public class SysUserController {
public Result<T> changePassword(@RequestBody SysUser sysUser) {
SysUser u = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, sysUser.getUsername()));
if (u == null) {
return Result.error(USER_ERROR_MSG);
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}
sysUser.setId(u.getId());
return sysUserService.changePassword(sysUser);
@@ -435,17 +437,17 @@ public class SysUserController {
List<DepartIdModel> depIdModelList = this.sysUserDepartService.queryDepartIdsOfUser(userId);
if (depIdModelList != null && !depIdModelList.isEmpty()) {
result.setSuccess(true);
result.setMessage("查找成功");
result.setMessage(MessageUtils.getMessage(ResultCommon.OK));
result.setResult(depIdModelList);
} else {
result.setSuccess(false);
result.setMessage("查找失败");
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
}
return result;
} catch (Exception e) {
SysUserController.log.error(e.getMessage(), e);
result.setSuccess(false);
result.setMessage("查找过程中出现了异常: " + e.getMessage());
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
return result;
}
@@ -749,7 +751,7 @@ public class SysUserController {
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getUsername().equals(username)){
return Result.error("只允许修改自己的密码!");
return Result.error(ResultCommon.HORIZONTAL_TRANSGRESSION);
}
String RSAPrivateKey = String.valueOf(redisUtil.get(RSAPublicKey));
@@ -764,7 +766,7 @@ public class SysUserController {
SysUser user = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
if(user==null) {
return Result.error(USER_ERROR_MSG);
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}
return sysUserService.resetPassword(username,oldpassword,password,confirmpassword);
}
@@ -809,13 +811,13 @@ public class SysUserController {
}
}
result.setMessage(OPTION_SUCCESS);
result.setMessage(MessageUtils.getMessage(ResultCommon.OK));
result.setSuccess(true);
return result;
}catch(Exception e) {
SysUserController.log.error(e.getMessage(), e);
result.setSuccess(false);
result.setMessage("出错了: " + e.getMessage());
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
return result;
}
}
@@ -833,10 +835,10 @@ public class SysUserController {
QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(ROLE_ID, roleId).eq(USER_ID,userId);
sysUserRoleService.remove(queryWrapper);
return Result.OK(DEL_SUCCESS);
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
}catch(Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error(DEL_FAILE);
SysUserController.log.error(e.getMessage(), e);
return Result.error(ResultCommon.ERROR);
}
}
@@ -855,10 +857,10 @@ public class SysUserController {
QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(ROLE_ID, roleId).in(USER_ID,Arrays.asList(userIds.split(",")));
sysUserRoleService.remove(queryWrapper);
return Result.OK(DEL_SUCCESS);
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
}catch(Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error(DEL_FAILE);
return Result.error(ResultCommon.ERROR);
}
}
@@ -944,13 +946,13 @@ public class SysUserController {
sysUserDepartService.save(sysUserDepart);
}
}
result.setMessage(OPTION_SUCCESS);
result.setMessage(MessageUtils.getMessage(ResultCommon.OK));
result.setSuccess(true);
return result;
}catch(Exception e) {
SysUserController.log.error(e.getMessage(), e);
result.setSuccess(false);
result.setMessage("出错了: " + e.getMessage());
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
return result;
}
}
@@ -967,10 +969,10 @@ public class SysUserController {
queryWrapper.eq(DEP_ID, depId).eq(USER_ID,userId);
sysUserDepartService.remove(queryWrapper);
sysDepartService.deleteHeadDeptAndUserRelatedByUser(depId, userId);
return Result.OK(DEL_SUCCESS);
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
}catch(Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error(DEL_FAILE);
return Result.error(ResultCommon.ERROR);
}
}
@@ -992,10 +994,10 @@ public class SysUserController {
for (String userId : userIdList){
sysDepartService.deleteHeadDeptAndUserRelatedByUser(depId, userId);
}
return Result.OK(DEL_SUCCESS);
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
}catch(Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error(DEL_FAILE);
return Result.error(ResultCommon.ERROR);
}
}
@@ -1014,7 +1016,7 @@ public class SysUserController {
return Result.OK(map);
}catch(Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error("查询失败!");
return Result.error(ResultCommon.ERROR);
}
}
@@ -1045,7 +1047,7 @@ public class SysUserController {
String email = jsonObject.getString("email");
SysUser sysUser1 = sysUserService.getUserByName(username);
if (sysUser1 != null) {
result.setMessage("用户名已注册");
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
result.setSuccess(false);
return result;
}
@@ -1134,7 +1136,7 @@ public class SysUserController {
@RequestParam(name="phone") String phone) {
Result<SysUser> result = new Result<>();
if(oConvertUtils.isEmpty(username) || oConvertUtils.isEmpty(password) || oConvertUtils.isEmpty(smscode) || oConvertUtils.isEmpty(phone) ) {
result.setMessage("重置密码失败!");
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
result.setSuccess(false);
return result;
}
@@ -1142,18 +1144,19 @@ public class SysUserController {
SysUser sysUser;
Object object= redisUtil.get(phone);
if(null==object) {
result.setMessage("短信验证码失效!");
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
result.setSuccess(false);
return result;
}
if(!smscode.equals(object.toString())) {
result.setMessage("短信验证码不匹配!");
result.setMessage(MessageUtils.getMessage(ResultCommon.ERROR));
result.setMessage(MessageUtils.getMessage(ResultCommon.NO_CORRESPONDING_RECORD_FOUND));
result.setSuccess(false);
return result;
}
sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username).eq(SysUser::getPhone,phone));
if (sysUser == null) {
result.setMessage("未找到用户!");
result.setMessage(MessageUtils.getMessage(ResultCommon.NO_CORRESPONDING_RECORD_FOUND));
result.setSuccess(false);
return result;
} else {
@@ -1163,7 +1166,7 @@ public class SysUserController {
sysUser.setPassword(passwordEncode);
this.sysUserService.updateById(sysUser);
result.setSuccess(true);
result.setMessage("密码重置完成!");
result.setMessage(MessageUtils.getMessage(ResultCommon.OK));
return result;
}
}
@@ -1200,7 +1203,7 @@ public class SysUserController {
return Result.OK(map);
} catch (Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error(500, "查询失败:" + e.getMessage());
return Result.error(ResultCommon.ERROR);
}
}
@@ -1237,7 +1240,7 @@ public class SysUserController {
return Result.OK(res);
} catch (Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error(500, "查询失败:" + e.getMessage());
return Result.error(ResultCommon.ERROR);
}
}
@@ -1277,7 +1280,7 @@ public class SysUserController {
updateUser.setUpdateTime(new Date());
sysUserService.revertLogicDeleted(Arrays.asList(userIds.split(",")), updateUser);
}
return Result.OK("还原成功");
return Result.OK(ResultCommon.OK);
}
/**
@@ -1292,7 +1295,7 @@ public class SysUserController {
if (StringUtils.isNotBlank(userIds)) {
sysUserService.removeLogicDeleted(Arrays.asList(userIds.split(",")));
}
return Result.OK("删除成功");
return Result.OK(ResultCommon.SUCCESSFULLY_DELETED);
}
@@ -1477,11 +1480,11 @@ public class SysUserController {
}
SysUser user = sysUserService.getUserByName(username);
if(user==null) {
return Result.error(USER_ERROR_MSG);
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}
user.setPhone(phone);
sysUserService.updateById(user);
return Result.OK("手机号设置成功!");
return Result.OK(ResultCommon.OK);
}
/**
@@ -1512,7 +1515,7 @@ public class SysUserController {
SysUser sysUser = sysUserService.getById(id);
baseCommonService.addLog("编辑用户角色,id " + id, CommonConstant.LOG_TYPE_2, 2);
if (sysUser == null) {
return Result.error(INEXISTENCE);
return Result.error(ResultCommon.NO_CORRESPONDING_RECORD_FOUND);
} else {
SysUser user = new SysUser();
user.setId(id);
@@ -1522,9 +1525,9 @@ public class SysUserController {
}
} catch (Exception e) {
SysUserController.log.error(e.getMessage(), e);
return Result.error("操作失败");
return Result.error(ResultCommon.ERROR);
}
return Result.OK("修改成功!");
return Result.OK(ResultCommon.OK);
}
}
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.api.vo.Result;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.constant.CacheConstant;
import com.jero.common.constant.CommonConstant;
import com.jero.common.exception.JeroBootException;
@@ -117,7 +118,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt);
sysUser.setPassword(passwordEncode);
this.userMapper.updateById(sysUser);
return Result.OK("密码操作成功!");
return Result.OK(ResultCommon.OK);
}
@Override