Bladeren bron

Merge branch 'develop' of http://192.168.11.14:51037/gitadmin/tuoheng_freeway into feature_v1.0

tags/v1.0.0^2
chengwang 1 jaar geleden
bovenliggende
commit
18f552d6be
14 gewijzigde bestanden met toevoegingen van 103 en 52 verwijderingen
  1. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java
  2. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/UserController.java
  3. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/ClientEnum.java
  4. +10
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/EditUserCodeEnum.java
  5. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/EditUserPasswordCodeEnum.java
  6. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListByWorkOrderIdService.java
  7. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/AddOidcUserService.java
  8. +4
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/EditOidcUserPasswordService.java
  9. +0
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/EditOidcUserService.java
  10. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/IUserService.java
  11. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/UserServiceImpl.java
  12. +11
    -12
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/add/AddUserService.java
  13. +6
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/update/UpdateUserPasswordService.java
  14. +61
    -20
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/update/UpdateUserService.java

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/constant/SystemConstant.java Bestand weergeven

@@ -7,6 +7,8 @@ public interface SystemConstant {
*/
String ROOT_DEPT_PID = "0";

String INIT_PASSWORD = "123456";

/**
* 高德url地址
*/

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/UserController.java Bestand weergeven

@@ -102,7 +102,7 @@ public class UserController {
*/
@PutMapping("/resetPwd/{id}")
public JsonResult resetPwd(@PathVariable("id") String id) {
return userService.resetPwd(id);
return userService.resetPassword(id);
}

/**

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/ClientEnum.java Bestand weergeven

@@ -14,7 +14,7 @@ import java.util.Map;
public enum ClientEnum {

ADMIN(1, "tuoheng-freeway-admin"),
API(0, "tuoheng-freeway-mp");
API(2, "tuoheng-freeway-mp");

ClientEnum(int code, String description) {
this.code = code;

+ 10
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/EditUserCodeEnum.java Bestand weergeven

@@ -12,10 +12,16 @@ package com.tuoheng.admin.enums.code.user;
public enum EditUserCodeEnum {

EDIT_IS_FAILED(1100300, "修改失败"),
USER_ID_IS_NULL(1100301, "用户ID为空"),
PHONE_NOT_IMATCH(1100302, "手机号不匹配"),
USER_IS_NOT_EXIST(1100303, "用户不存在"),
USERNAME_ALREADY_EXISTS(1100304, "系统中已经存在该用户名");
ID_IS_NULL(1100301, "用户ID为空"),
CODE_IS_NULL(1100302, "编号不能为空"),
REALNAME_IS_NULL(1100303, "姓名不能为空"),
ROLE_ID_IS_NULL(1100304, "角色不能为空"),
DEPT_ID_IS_NULL(1100305, "部门不能为空"),
CLIENT_ID_IS_NULL(1100306, "ClientID不能为空"),
PHONE_NOT_IMATCH(1100307, "手机号不匹配"),
USER_IS_NOT_EXIST(1100308, "用户不存在"),
USERNAME_ALREADY_EXISTS(1100309, "系统中已经存在该用户名"),
ROLE_IS_NOT_EXISTS(1100310, "该角色不存在");;

/**
* 错误码

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/EditUserPasswordCodeEnum.java Bestand weergeven

@@ -11,7 +11,7 @@ package com.tuoheng.admin.enums.code.user;
*/
public enum EditUserPasswordCodeEnum {

EDIT_IS_FAILED(1100400, "修改失败"),
EDIT_IS_FAILED(1100400, "重置密码失败"),
USER_ID_IS_NULL(1100401, "用户ID为空"),
USER_IS_NOT_EXIST(1100402, "用户不存在"),
NON_TENANT_USER(1100403, "当前用户非本租户用户");

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspectionfile/query/QueryInspectionFilePageListByWorkOrderIdService.java Bestand weergeven

@@ -225,7 +225,7 @@ public class QueryInspectionFilePageListByWorkOrderIdService {
if (CollectionUtil.isEmpty(inspectionFileHandleList)) {
return null;
}
Map<String, InspectionFileHandle> inspectionFileHandleMap = inspectionFileHandleList.stream().collect(Collectors.toMap(InspectionFileHandle::getId, Function.identity()));
Map<String, InspectionFileHandle> inspectionFileHandleMap = inspectionFileHandleList.stream().collect(Collectors.toMap(InspectionFileHandle::getInspectionFileId, Function.identity()));
return inspectionFileHandleMap;
}


+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/AddOidcUserService.java Bestand weergeven

@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.third.oidc;

import cn.hutool.core.util.ObjectUtil;
import com.tuoheng.admin.constant.OidcUrlConstant;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.dto.ClientRoleDto;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.entity.User;
@@ -69,7 +70,7 @@ public class AddOidcUserService {
if (StringUtils.isNotEmpty(user.getPassword())) {
oidcCreateUserRequest.setPassword(user.getPassword());
} else {
oidcCreateUserRequest.setPassword("123456");
oidcCreateUserRequest.setPassword(SystemConstant.INIT_PASSWORD);
}
if (ObjectUtil.isNull(tenant)) {
// 普通用户新增

+ 4
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/EditOidcUserPasswordService.java Bestand weergeven

@@ -1,6 +1,7 @@
package com.tuoheng.admin.service.third.oidc;

import com.tuoheng.admin.constant.OidcUrlConstant;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.request.oidc.OidcUpdateUserPasswordRequest;
import com.tuoheng.common.core.config.common.CommonConfig;
@@ -27,12 +28,13 @@ public class EditOidcUserPasswordService {
public JsonResult editUserPassword(User user) {
OidcUpdateUserPasswordRequest oidcUpdateUserPasswordRequest = new OidcUpdateUserPasswordRequest();
oidcUpdateUserPasswordRequest.setUsername(user.getUsername());
// 重置密码123456
oidcUpdateUserPasswordRequest.setPassword("123456");
// 重置密码
oidcUpdateUserPasswordRequest.setPassword(SystemConstant.INIT_PASSWORD);

//设置请求头
org.springframework.http.HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + SecurityUserUtils.token());
HttpEntity httpEntity = new HttpEntity(oidcUpdateUserPasswordRequest, resultRequestHeader);
//设置地址,飞手小程序 经过网关
String url = CommonConfig.oidcUrl + OidcUrlConstant.USER_UPDATEPASS;

+ 0
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/EditOidcUserService.java Bestand weergeven

@@ -36,7 +36,6 @@ public class EditOidcUserService {
//设置请求头
HttpHeaders resultRequestHeader = new HttpHeaders();
resultRequestHeader.add("Authorization", "Bearer " + SecurityUserUtils.token());
//resultRequestHeader.add("Authorization", "Bearer "+ "eyJraWQiOiJiZDhjZWUwNi0yY2E1LTQzZDYtYTA2OC1kOWM5ZDFhZmYxYzYiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImF1ZCI6InR1b2hlbmctZHNwLXdlYiIsIm5iZiI6MTY2NzIwOTU4NSwib1VzZXJJZCI6MTIsInNjb3BlIjpbImFkbWluIl0sImlzcyI6Imh0dHA6XC9cL29pZGMuZGV2LnQtYWFyb24uY29tIiwiY2xpZW50Um9sZUxpc3QiOltdLCJleHAiOjE2NjcyOTU5ODUsImlhdCI6MTY2NzIwOTU4NSwidXNlcm5hbWUiOiJhZG1pbiJ9.bfZceQpXwlR22Q1tODDGXgFQ718iXPL9aGKF_truMkSUj96h_a0DOqoCjtAELo0r703o9jEFb0pUzERvaOVK-IhL_z37rmf2kVRnM7yy_cOnpNa6yhD7c0UpqRN-2L8QPpQcWzmEUtvEp4icS_zFOp-lN_A0J6jpoGhpYbqiZCUn_1_ojRX9iGc6JzzaVPRgsHgrwt1g2mMrQWhoG7_4sIyWEM4y1RimUaEDCDjuFko3HWh8qLfTLMMSML0Zt1ovSRSVLCFmAOROeerNpte6UuzWrcsIpckBLmr-uNFVu8SZOZ1UE4W5_LHTztAel8JtZx84Q1Aaoy9TM9h_pv2jCg");
HttpEntity httpEntity = new HttpEntity(oidcUpdateUserRequest, resultRequestHeader);
//设置地址(飞手平台)
String url = CommonConfig.oidcUrl + OidcUrlConstant.USER_UPDATEROLE;

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/IUserService.java Bestand weergeven

@@ -75,7 +75,7 @@ public interface IUserService {
* @param id 参数
* @return
*/
JsonResult resetPwd(String id);
JsonResult resetPassword(String id);

/**
* 根据部门id查询用户列表

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/UserServiceImpl.java Bestand weergeven

@@ -132,8 +132,8 @@ public class UserServiceImpl implements IUserService {
* @return
*/
@Override
public JsonResult resetPwd(String id) {
return updateUserPasswordService.resetPwd(id);
public JsonResult resetPassword(String id) {
return updateUserPasswordService.resetPassword(id);
}



+ 11
- 12
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/add/AddUserService.java Bestand weergeven

@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.user.add;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.entity.User;
@@ -98,16 +99,14 @@ public class AddUserService {
if (StringUtils.isEmpty(user.getDeptId())) {
return JsonResult.error(AddUserCodeEnum.DEPT_ID_IS_NULL.getCode(), AddUserCodeEnum.DEPT_ID_IS_NULL.getMsg());
}

if (ObjectUtil.isNull(user.getType()) || 0 == user.getType()) {
return JsonResult.error(AddUserCodeEnum.TYPE_ID_IS_NULL.getCode(), AddUserCodeEnum.TYPE_ID_IS_NULL.getMsg());
} else {
UserTypeEnum userTypeEnum = UserTypeEnum.parse(user.getType());
if (null == userTypeEnum) {
return JsonResult.error(AddUserCodeEnum.TYPE_ID_IS_NOT_EXISTS.getCode(), AddUserCodeEnum.TYPE_ID_IS_NOT_EXISTS.getMsg());
}
}

// if (ObjectUtil.isNull(user.getType()) || 0 == user.getType()) {
// return JsonResult.error(AddUserCodeEnum.TYPE_ID_IS_NULL.getCode(), AddUserCodeEnum.TYPE_ID_IS_NULL.getMsg());
// } else {
// UserTypeEnum userTypeEnum = UserTypeEnum.parse(user.getType());
// if (null == userTypeEnum) {
// return JsonResult.error(AddUserCodeEnum.TYPE_ID_IS_NOT_EXISTS.getCode(), AddUserCodeEnum.TYPE_ID_IS_NOT_EXISTS.getMsg());
// }
// }
if (StringUtils.isEmpty(user.getClientId())) {
return JsonResult.error(AddUserCodeEnum.CLIENT_ID_IS_NULL.getCode(), AddUserCodeEnum.CLIENT_ID_IS_NULL.getMsg());
}
@@ -147,8 +146,8 @@ public class AddUserService {
if (StringUtils.isNotEmpty(user.getPassword())) {
user.setPassword(CommonUtils.password(user.getPassword()));
} else {
//默认为123456密码
user.setPassword(CommonUtils.password("123456"));
// 默认密码
user.setPassword(CommonUtils.password(SystemConstant.INIT_PASSWORD));
}

if (StringUtils.isNotNull(user.getAvatar()) && user.getAvatar().contains(CommonConfig.imageURL)) {

+ 6
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/update/UpdateUserPasswordService.java Bestand weergeven

@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.user.update;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.code.user.EditUserPasswordCodeEnum;
import com.tuoheng.admin.mapper.UserMapper;
@@ -36,11 +37,11 @@ public class UpdateUserPasswordService {
*
* @return
*/
public JsonResult resetPwd(String id) {
log.info("进入修改用户密码业务接口: id={}, status={}", id);
public JsonResult resetPassword(String id) {
log.info("进入重置密码业务接口: id={}, status={}", id);
JsonResult result = this.check(id);
if (0 != result.getCode()) {
log.info("修改用户密码业务接口:校验失败:{}", result.getMsg());
log.info("重置密码业务接口:校验失败:{}", result.getMsg());
return result;
}
User user = (User) result.getData();
@@ -48,11 +49,11 @@ public class UpdateUserPasswordService {
// 修改oidc用户密码
result = oidcService.editUserPassword(user);
if (0 != result.getCode()) {
log.info("修改用户密码业务接口:修改oidc用户密码失败:{}", result.getMsg());
log.info("重置密码业务接口:修改oidc用户密码失败:{}", result.getMsg());
return result;
}

user.setPassword(CommonUtils.password("123456"));
user.setPassword(CommonUtils.password(SystemConstant.INIT_PASSWORD));
Integer rowCount = userMapper.updateById(user);
if (rowCount <= 0) {
return JsonResult.error(EditUserPasswordCodeEnum.EDIT_IS_FAILED.getCode(), EditUserPasswordCodeEnum.EDIT_IS_FAILED.getMsg());

+ 61
- 20
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/update/UpdateUserService.java Bestand weergeven

@@ -2,9 +2,10 @@ package com.tuoheng.admin.service.user.update;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Role;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.code.user.AddUserCodeEnum;
import com.tuoheng.admin.enums.code.user.EditUserCodeEnum;
import com.tuoheng.admin.mapper.RoleMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.service.third.oidc.OidcService;
import com.tuoheng.admin.utils.CurrentUserUtil;
@@ -31,6 +32,9 @@ public class UpdateUserService {
@Autowired
private UserMapper userMapper;

@Autowired
private RoleMapper roleMapper;

@Autowired
private OidcService oidcService;

@@ -47,11 +51,11 @@ public class UpdateUserService {
log.info("修改用户业务接口:校验失败:{}", result.getMsg());
return result;
}
User userOld = (User) result.getData();

// 修改oidc
result = oidcService.editUser(user);
result = this.notifyOicd(userOld, user);
if (0 != result.getCode()) {
log.info("修改用户业务接口:修改oidc数据失败:{}", result.getMsg());
log.info("修改用户业务接口:校验失败:{}", result.getMsg());
return result;
}

@@ -63,13 +67,30 @@ public class UpdateUserService {
}
return JsonResult.success();
}

/**
* 检查参数
*
* @param tenantId
* @param user
* @return
*/
private JsonResult check(String tenantId, User user) {
if (StringUtils.isEmpty(user.getId())) {
return JsonResult.error(EditUserCodeEnum.ID_IS_NULL.getCode(), EditUserCodeEnum.ID_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(user.getCode())) {
return JsonResult.error(EditUserCodeEnum.CODE_IS_NULL.getCode(), EditUserCodeEnum.CODE_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(user.getRealname())) {
return JsonResult.error(EditUserCodeEnum.REALNAME_IS_NULL.getCode(), EditUserCodeEnum.REALNAME_IS_NULL.getMsg());
}
if (ObjectUtil.isNull(user.getRoleId()) || 0 == user.getRoleId()) {
return JsonResult.error(EditUserCodeEnum.ROLE_ID_IS_NULL.getCode(), EditUserCodeEnum.ROLE_ID_IS_NULL.getMsg());
}
if (StringUtils.isEmpty(user.getClientId())) {
return JsonResult.error(EditUserCodeEnum.CLIENT_ID_IS_NULL.getCode(), EditUserCodeEnum.CLIENT_ID_IS_NULL.getMsg());
}
if (StringUtils.isNotEmpty(user.getMobile())) {
//校验手机号
boolean flag = CommonUtils.isMobile(user.getMobile());
@@ -77,28 +98,49 @@ public class UpdateUserService {
return JsonResult.error(EditUserCodeEnum.PHONE_NOT_IMATCH.getCode(), EditUserCodeEnum.PHONE_NOT_IMATCH.getMsg());
}
}

User userTmp = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getId, user.getId())
.eq(User::getMark, 1));

if (ObjectUtil.isNull(userTmp)) {
return JsonResult.error("该用户不存在");
}

Integer count = userMapper.selectCount(new LambdaQueryWrapper<User>()
.eq(User::getTenantId, tenantId)
.eq(User::getUsername, user.getUsername())
.eq(User::getId, user.getId())
.eq(User::getMark, 1));
if (count > 0) {
return JsonResult.error(EditUserCodeEnum.USERNAME_ALREADY_EXISTS.getCode(), EditUserCodeEnum.USERNAME_ALREADY_EXISTS.getMsg());
if (ObjectUtil.isNull(userTmp)) {
return JsonResult.error(EditUserCodeEnum.USER_IS_NOT_EXIST.getCode(), EditUserCodeEnum.USER_IS_NOT_EXIST.getMsg());
}

return JsonResult.success();
Integer count = roleMapper.selectCount(new LambdaQueryWrapper<Role>()
.eq(Role::getTenantId, tenantId)
.eq(Role::getId, user.getRoleId())
.eq(Role::getMark, 1));
if (count <= 0) {
// return JsonResult.error(EditUserCodeEnum.ROLE_IS_NOT_EXISTS.getCode(), EditUserCodeEnum.ROLE_IS_NOT_EXISTS.getMsg());
}
return JsonResult.success(userTmp);
}

/**
* 同步修改oicd数据
* 1)、如果roleId和clientId没有变动,则不需要通知oicd
*
* @param userOld
* @param userNew
*
*/
private JsonResult notifyOicd(User userOld, User userNew) {
if (userOld.getRoleId().equals(userNew.getRoleId())
&& userOld.getClientId().equals(userNew.getClientId())) {
log.info("修改用户业务接口:角色和clientId,没有变动,不需要同步通知oicd。");
return JsonResult.success("角色和clientId,没有变动,不需要同步通知oicd");
}
log.info("修改用户业务接口:角色和clientId,变动,同步通知oicd。");
// 修改oidc
userNew.setUsername(userOld.getUsername());
JsonResult result = oidcService.editUser(userNew);
if (0 != result.getCode()) {
log.info("修改用户业务接口:修改oidc数据失败:{}", result.getMsg());
return result;
}
return JsonResult.success("角色和clientId,通知oicd成功");
}

/**
* 构建实体字段数据
*
* @param user
@@ -115,5 +157,4 @@ public class UpdateUserService {
user.setUpdateTime(DateUtils.now());
}


}

Laden…
Annuleren
Opslaan