@@ -94,7 +94,7 @@ public class CommonUtils { | |||
public static boolean isMobile(String mobile) { | |||
boolean flag = false; | |||
try { | |||
Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$"); | |||
Pattern p = Pattern.compile("^((13[0-9])|(14[5|7])|(15[0-9])|(17[013678])|(18[0-9]))\\d{8}$"); | |||
Matcher m = p.matcher(mobile); | |||
flag = m.matches(); | |||
} catch (Exception e) { |
@@ -2,6 +2,7 @@ package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.request.user.QueryUserPageListRequest; | |||
import com.tuoheng.admin.request.user.UserInitRequest; | |||
import com.tuoheng.admin.request.user.UserResetPwdRequest; | |||
import com.tuoheng.admin.service.user.IUserService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
@@ -40,12 +41,11 @@ public class UserController { | |||
/** | |||
* 获取用户详情 | |||
* | |||
* @param username | |||
* @return | |||
*/ | |||
@GetMapping("/info/{username}") | |||
public JsonResult getUserInfo(@PathVariable("username") String username) { | |||
return userService.getUserInfo(username); | |||
@GetMapping("/info") | |||
public JsonResult getUserInfo() { | |||
return userService.getUserInfo(); | |||
} | |||
/** | |||
@@ -115,14 +115,14 @@ public class UserController { | |||
} | |||
/** | |||
* 初始化系统超级管理员用户 | |||
* 初始化系统用户 | |||
* | |||
* @param username | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/init/{username}/{password}") | |||
public JsonResult init(@PathVariable("username") String username, @PathVariable("password") String password) { | |||
return userService.init(username, password); | |||
@PostMapping("/init") | |||
public JsonResult init(@RequestBody UserInitRequest request) { | |||
return userService.init(request); | |||
} | |||
} |
@@ -9,6 +9,7 @@ import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListReque | |||
import com.tuoheng.admin.request.user.QueryUserPageListRequest; | |||
import org.apache.ibatis.annotations.Param; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
@@ -22,6 +23,8 @@ public interface UserMapper extends BaseMapper<User> { | |||
Integer updateByIdList(Map<String, Object> map); | |||
Integer updateDeptIdByIdList(Map<String, Object> map); | |||
/** | |||
* 查询任务问题分页列表 | |||
* |
@@ -60,4 +60,9 @@ public class QueryInspectionPageListRequest extends BaseQuery { | |||
*/ | |||
private List<String> deptIdList; | |||
/** | |||
* 租户Id | |||
*/ | |||
private String tenantId; | |||
} |
@@ -34,4 +34,8 @@ public class QueryInspectionFileDistributionListRequest { | |||
*/ | |||
private List<String> deptIdList; | |||
/** | |||
* 租户Id | |||
*/ | |||
private String tenantId; | |||
} |
@@ -57,4 +57,9 @@ public class QueryInspectionFilePageListRequest extends BaseQuery { | |||
*/ | |||
private List<String> deptIdList; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
} |
@@ -19,5 +19,4 @@ public class QueryInspectionFileWorkOrderPageListRequest extends BaseQuery { | |||
* 工单ID | |||
*/ | |||
private String workOrderId; | |||
} |
@@ -33,4 +33,10 @@ public class QueryReportPageListRequest extends BaseQuery { | |||
*/ | |||
private String createUser; | |||
/** | |||
* 租户Id | |||
*/ | |||
private String tenantId; | |||
} |
@@ -0,0 +1,36 @@ | |||
package com.tuoheng.admin.request.user; | |||
import lombok.Data; | |||
/** | |||
* 重置密码 | |||
*/ | |||
@Data | |||
public class UserInitRequest { | |||
/** | |||
* 名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 密码 | |||
*/ | |||
private String password; | |||
/** | |||
* 租户编号 | |||
*/ | |||
private String tenantCode; | |||
/** | |||
* 是否租户:0(否);1(是) | |||
*/ | |||
private Integer tenantFlag; | |||
/** | |||
* 机场平台url | |||
*/ | |||
private String airportUrl; | |||
} |
@@ -57,4 +57,9 @@ public class QueryWorkOrderPageListRequest extends BaseQuery { | |||
*/ | |||
private List<String> deptIdList; | |||
/** | |||
* 租户Id | |||
*/ | |||
private String tenantId; | |||
} |
@@ -1,7 +1,8 @@ | |||
package com.tuoheng.admin.service.dept.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.dto.RoadSectionDto; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.code.dept.AddDeptCodeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
@@ -9,7 +10,6 @@ import com.tuoheng.admin.mapper.RoadDeptMapper; | |||
import com.tuoheng.admin.mapper.SectionDeptMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.request.dept.AddDeptRequest; | |||
import com.tuoheng.admin.dto.RoadSectionDto; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
@@ -55,6 +55,7 @@ public class AddDeptService { | |||
*/ | |||
public JsonResult add(AddDeptRequest addDeptRequest) { | |||
log.info("进入添加部门业务接口"); | |||
String userId = CurrentUserUtil.getUserId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
JsonResult result = this.check(tenantId, addDeptRequest); | |||
if (0 != result.getCode()) { | |||
@@ -76,7 +77,7 @@ public class AddDeptService { | |||
return JsonResult.error(AddDeptCodeEnum.ADD_DEPT_IS_FAILED.getCode(), AddDeptCodeEnum.ADD_DEPT_IS_FAILED.getMsg()); | |||
} | |||
this.updateSuperAdminUser(dept); | |||
this.updateSuperAdminUser(userId, tenantId, dept); | |||
// 新增公路/路段与部门数据 | |||
addRoadAndSectionToDept(tenantId, dept.getId(), addDeptRequest.getRoadSectionDtoList()); | |||
@@ -87,6 +88,7 @@ public class AddDeptService { | |||
/** | |||
* 检查参数 | |||
* | |||
* @param tenantId | |||
* @param addDeptRequest | |||
* @return | |||
@@ -152,8 +154,8 @@ public class AddDeptService { | |||
/** | |||
* 新增公路/路段与部门数据 | |||
* | |||
* @param tenantId 租户Id | |||
* @param deptId 部门Id | |||
* @param tenantId 租户Id | |||
* @param deptId 部门Id | |||
* @param roadSectionDtoList 公路/路段集合 | |||
* @return 结果 | |||
*/ | |||
@@ -233,7 +235,6 @@ public class AddDeptService { | |||
map.put("deptId", deptId); | |||
map.put("sectionIdList", sectionIdList); | |||
sectionDeptMapper.deleteBatchByMap(map); | |||
List<SectionDept> list = new ArrayList<>(); | |||
SectionDept sectionDept; | |||
for (Section section : sectionList) { | |||
@@ -252,27 +253,33 @@ public class AddDeptService { | |||
sectionDept.setSectionId(section.getId()); | |||
list.add(sectionDept); | |||
} | |||
if (!CollectionUtils.isEmpty(list)) { | |||
sectionDeptMapper.insertBatch(list); | |||
} | |||
} | |||
/** | |||
* 如果创建的是顶级部门,将该部门与超级管理员关联 | |||
* 如果创建的是顶级部门,将该部门与超级管理员关联 | |||
*/ | |||
private void updateSuperAdminUser(Dept dept) { | |||
if (!"0".equals(dept.getPid())) { | |||
private void updateSuperAdminUser(String userId, String tenantId, Dept dept) { | |||
if (!SystemConstant.ROOT_DEPT_PID.equals(dept.getPid())) { | |||
return; | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getRoleId, 1) | |||
.eq(User::getMark, 1)); | |||
if (ObjectUtil.isNull(user)) { | |||
if (CollectionUtils.isEmpty(userList)) { | |||
log.info("用户为空"); | |||
return; | |||
} | |||
user.setDeptId(dept.getId()); | |||
userMapper.updateById(user); | |||
List<String> userIdList = userList.stream().map(o -> o.getId()).collect(Collectors.toList()); | |||
Map<String, Object> map = new HashMap<>(); | |||
map.put("deptId", dept.getId()); | |||
map.put("idList", userIdList); | |||
map.put("updateUser", userId); | |||
map.put("updateTime", DateUtils.now()); | |||
userMapper.updateDeptIdByIdList(map); | |||
} | |||
} |
@@ -6,6 +6,7 @@ import com.tuoheng.admin.conver.DeptConverMapper; | |||
import com.tuoheng.admin.entity.Dept; | |||
import com.tuoheng.admin.enums.code.dept.QueryDeptTreeListCodeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.dept.DeptTreeVo; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -39,8 +40,11 @@ public class QueryListTreeService { | |||
public JsonResult getListTree() { | |||
List<DeptTreeVo> deptTreeVoList = new ArrayList<>(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
// 查询所有有效的部门数据 | |||
List<Dept> deptList = deptMapper.selectList(new LambdaQueryWrapper<Dept>() | |||
.eq(Dept::getTenantId, tenantId) | |||
.eq(Dept::getMark, 1)); | |||
if (CollectionUtil.isEmpty(deptList)) { |
@@ -5,6 +5,7 @@ import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionInfoByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.InspectionHistoryMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -25,12 +26,10 @@ public class QueryInspectionByIdService { | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
@Autowired | |||
private InspectionHistoryMapper inspectionHistoryMapper; | |||
public JsonResult getInspectionInfo(String id) { | |||
log.info("进入查询巡检任务信息业务"); | |||
JsonResult result = this.check(id); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
JsonResult result = this.check(tenantId, id); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询巡检任务信息业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
@@ -43,20 +42,20 @@ public class QueryInspectionByIdService { | |||
/** | |||
* 检查参数 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
private JsonResult check(String tenantId, String id) { | |||
// 判断任务id是否为空 | |||
if (StringUtils.isEmpty(id)) { | |||
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); | |||
} | |||
// 判断任务是否存在 | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getTenantId, tenantId) | |||
.eq(Inspection::getId, id) | |||
.eq(Inspection::getMark, 1)); | |||
if (null == inspection) { | |||
return JsonResult.error(QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryInspectionInfoByIdCodeEnum.INSPECTION_IS_NOT_EXIST.getMsg()); | |||
} |
@@ -9,6 +9,7 @@ import com.tuoheng.admin.enums.InspectionStatusEnum; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionDetailsByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.InspectionHistoryMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.inspection.InspectionDetailsVo; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
@@ -37,7 +38,8 @@ public class QueryInspectionDetailsByIdService { | |||
public JsonResult getInspectionDetails(String id) { | |||
log.info("进入查询巡检任务详情业务"); | |||
JsonResult result = this.check(id); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
JsonResult result = this.check(tenantId, id); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询巡检任务详情业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
@@ -65,7 +67,7 @@ public class QueryInspectionDetailsByIdService { | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
private JsonResult check(String tenantId, String id) { | |||
// 判断任务id是否为空 | |||
if (StringUtils.isEmpty(id)) { | |||
return JsonResult.error(QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getCode(), QueryInspectionDetailsByIdCodeEnum.INSPECTION_ID_IS_NULL.getMsg()); | |||
@@ -73,6 +75,7 @@ public class QueryInspectionDetailsByIdService { | |||
// 判断任务是否存在 | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getTenantId, tenantId) | |||
.eq(Inspection::getId, id) | |||
.eq(Inspection::getMark, 1)); | |||
@@ -97,6 +97,7 @@ public class QueryInspectionPageListService { | |||
String userId = CurrentUserUtil.getUserId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(tenantId, request); | |||
if (0 != result.getCode()) { |
@@ -103,19 +103,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
@Override | |||
public JsonResult getQuestionList() { | |||
//获取当前登录人租户id | |||
String username = SecurityUserUtils.username(); | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getMark, 1) | |||
.eq(User::getStatus,1) | |||
.eq(User::getUsername, username)); | |||
if(ObjectUtil.isNull(user)){ | |||
return null; | |||
} | |||
if(StringUtils.isEmpty(user.getTenantId())){ | |||
return JsonResult.error(ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getCode(),ListByDeptUserTypeEnum.TENANT_ID_IS_NULL.getMsg()); | |||
} | |||
//租户id | |||
String tenantId = user.getTenantId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
//查询区域范范围问题 | |||
List<InspectionFile> inspectionFileLists = new ArrayList<>(); | |||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | |||
@@ -165,22 +153,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
@Override | |||
public JsonResult getListByDeptUserType(InspectionFileQuery query) { | |||
// if(query.getUserId()==null){ | |||
// JsonResult.error(ListByDeptUserTypeEnum.QUERY_IS_FAILED.getCode(),ListByDeptUserTypeEnum.QUERY_IS_FAILED.getMsg()); | |||
// } | |||
//获取当前登录人信息 | |||
String username = SecurityUserUtils.username(); | |||
if(StringUtils.isEmpty(username)){ | |||
JsonResult.error(ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_NAME_IS_NULL.getMsg()); | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getMark, 1) | |||
.eq(User::getStatus,1) | |||
.eq(User::getUsername, username)); | |||
if(ObjectUtil.isNull(user)){ | |||
JsonResult.error(ListByDeptUserTypeEnum.USER_IS_NULL.getCode(),ListByDeptUserTypeEnum.USER_IS_NULL.getMsg()); | |||
} | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
//用户角色判断 1超级管理员 2部门管理员 3普通用户 | |||
if(null == user.getRoleId()){ | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
@@ -210,7 +183,7 @@ public class InspectionFileServiceImpl implements IInspectionFileService { | |||
//直接查问题列表 | |||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(Wrappers.<InspectionFile>lambdaQuery() | |||
.eq(InspectionFile::getMark, 1) | |||
.eq(InspectionFile::getTenantId, tenantId) | |||
.eq(InspectionFile::getTenantId, user.getTenantId()) | |||
.in(InspectionFile::getStatus,20,25)); | |||
//根据状态类型分类 | |||
if(null == inspectionFileList){ |
@@ -52,6 +52,8 @@ public class QueryInspectionFileDistributionListService { | |||
log.info("进入查询任务问题分布列表业务, request:{}", request.toString()); | |||
String userId = CurrentUserUtil.getUserId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { |
@@ -65,11 +65,14 @@ public class QueryInspectionFilePageListByWorkOrderIdService { | |||
return result; | |||
} | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
// 设置分页参数 | |||
IPage<WorkOrderFile> page = new Page<>(request.getPage(), request.getLimit()); | |||
// 查询结果 | |||
IPage<WorkOrderFile> pageData = workOrderFileMapper.selectPage(page, new LambdaQueryWrapper<WorkOrderFile>() | |||
.eq(WorkOrderFile::getWorkOrderId, request.getWorkOrderId())); | |||
.eq(WorkOrderFile::getTenantId, tenantId) | |||
.eq(WorkOrderFile::getWorkOrderId, request.getWorkOrderId())); | |||
if (null == pageData || pageData.getTotal() == 0) { | |||
log.info("根据工单ID查询工单问题列表业务:获取任务分页列表为空"); | |||
@@ -82,6 +85,7 @@ public class QueryInspectionFilePageListByWorkOrderIdService { | |||
List<InspectionFile> inspectionFileList = inspectionFileMapper.selectList(new LambdaQueryWrapper<InspectionFile>() | |||
.in(InspectionFile::getId, inspectionFileIdList) | |||
.eq(InspectionFile::getTenantId, tenantId) | |||
.eq(InspectionFile::getMark, 1)); | |||
// 构造返回结果对象 |
@@ -57,6 +57,8 @@ public class QueryInspectionFilePageListService { | |||
log.info("进入查询任务问题分页列表业务, request:{}", request.toString()); | |||
String userId = CurrentUserUtil.getUserId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { | |||
@@ -65,7 +67,7 @@ public class QueryInspectionFilePageListService { | |||
} | |||
// 获取部门Id的查询范围 | |||
List<String> deptIdList = this.getDeptIdList(userId, request.getDeptId()); | |||
List<String> deptIdList = this.getDeptIdList(userId, tenantId, request.getDeptId()); | |||
request.setDeptIdList(deptIdList); | |||
// 设置分页参数 | |||
@@ -112,7 +114,7 @@ public class QueryInspectionFilePageListService { | |||
* @param deptId | |||
* @return | |||
*/ | |||
private List<String> getDeptIdList(String userId, String deptId) { | |||
private List<String> getDeptIdList(String userId, String tenantId, String deptId) { | |||
List<String> deptIdList = new ArrayList<>(); | |||
if (!StringUtils.isEmpty(deptId)) { | |||
deptIdList.add(deptId); | |||
@@ -120,6 +122,7 @@ public class QueryInspectionFilePageListService { | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getId, userId) | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getMark, 1)); | |||
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) { | |||
return null; |
@@ -53,6 +53,7 @@ public class QueryReportPageListService { | |||
String userId = CurrentUserUtil.getUserId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(tenantId, request); | |||
if (0 != result.getCode()) { | |||
@@ -60,16 +61,6 @@ public class QueryReportPageListService { | |||
return result; | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getId, userId) | |||
.eq(User::getMark, 1)); | |||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | |||
.eq(Dept::getTenantId, tenantId) | |||
.eq(Dept::getId, user.getDeptId()) | |||
.eq(Dept::getMark, 1)); | |||
// 设置分页参数 | |||
IPage<Report> page = new Page<>(request.getPage(), request.getLimit()); | |||
// 用户只能查看自己生成的报告 |
@@ -145,10 +145,7 @@ public class RoadInformationServiceImpl extends BaseServiceImpl<RoadInformationM | |||
if(StringUtils.isEmpty(userId)){ | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||
.eq(User::getMark, 1) | |||
.eq(User::getStatus,1) | |||
.eq(User::getId, userId)); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if(null == user){ | |||
return JsonResult.error("用户不存在"); | |||
} |
@@ -63,15 +63,20 @@ public class RoleServiceImpl implements IRoleService { | |||
private OpRolePermissionService opRolePermissionService; | |||
/** | |||
* | |||
* 2023-01-11 此处角色先不区分租户的概念,整个系统就3个角色,后期调整 | |||
* | |||
* @param roleQuery | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getRoleList(RoleQuery roleQuery) { | |||
IPage<Role> page = new Page<>(roleQuery.getPage(), roleQuery.getLimit()); | |||
// 查询条件 | |||
QueryWrapper<Role> queryWrapper = new QueryWrapper<>(); | |||
// 租户ID | |||
queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||
// queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||
// 角色名称 | |||
if (!StringUtils.isEmpty(roleQuery.getRoleName())) { | |||
queryWrapper.like("role_name", roleQuery.getRoleName()); | |||
@@ -191,7 +196,7 @@ public class RoleServiceImpl implements IRoleService { | |||
// 租户ID | |||
//不展示超管 | |||
queryWrapper.ne("code", "001"); | |||
queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||
// queryWrapper.eq("tenant_id", CurrentUserUtil.getTenantId()); | |||
queryWrapper.eq("status", 1); | |||
queryWrapper.eq("mark", 1); | |||
queryWrapper.orderByAsc("create_time"); |
@@ -11,14 +11,16 @@ import com.tuoheng.admin.enums.SectionEnum; | |||
import com.tuoheng.admin.enums.StructureEnum; | |||
import com.tuoheng.admin.mapper.*; | |||
import com.tuoheng.admin.query.StructureQuery; | |||
import com.tuoheng.admin.service.structure.IStructureService; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.StructureInfoVo; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.*; | |||
import com.tuoheng.common.core.utils.CommonUtils; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -53,43 +55,42 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
@Autowired | |||
private SectionDeptMapper sectionDeptMapper; | |||
@Override | |||
public JsonResult queryPage(StructureQuery query) { | |||
if(null==(query.getPage()) && null == query.getLimit()){ | |||
if (null == (query.getPage()) && null == query.getLimit()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//获取登录信息 | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if(ObjectUtil.isNull(user)){ | |||
if (ObjectUtil.isNull(user)) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//租户id | |||
String tenantId = user.getTenantId(); | |||
query.setTenantId(tenantId); | |||
//获取用户角色 | |||
Integer roleId = user.getRoleId(); | |||
IPage<Structure> page = new Page<>(query.getPage(),query.getLimit()); | |||
IPage<Structure> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<StructureInfoVo> pageData = null; | |||
//如果是超级管理员,查看所有构造物 | |||
if(RoleEnum.SUPER_ADMIN.getCode() == roleId){ | |||
//query.setTenantId(tenantId); | |||
if (RoleEnum.SUPER_ADMIN.getCode() == roleId) { | |||
//数据分页 | |||
pageData = structureMapper.queryPage(page,query); | |||
pageData = structureMapper.queryPage(page, query); | |||
List<StructureInfoVo> list = pageData.getRecords().stream().map((item) -> { | |||
StructureInfoVo structureInfoVo = new StructureInfoVo(); | |||
BeanUtils.copyProperties(item, structureInfoVo); | |||
//获取构造物图片,对图片进行处理 | |||
if(StringUtils.isNotEmpty(item.getImageUrl())){ | |||
if (StringUtils.isNotEmpty(item.getImageUrl())) { | |||
String[] imageUrls = item.getImageUrl().split(","); | |||
if(StringUtils.isNotEmpty(imageUrls)){ | |||
if (StringUtils.isNotEmpty(imageUrls)) { | |||
for (int i = 0; i < imageUrls.length; i++) { | |||
if(StringUtils.isNotEmpty(imageUrls[i])){ | |||
imageUrls[i]= CommonConfig.imageURL+imageUrls[i]; | |||
if (StringUtils.isNotEmpty(imageUrls[i])) { | |||
imageUrls[i] = CommonConfig.imageURL + imageUrls[i]; | |||
} | |||
} | |||
} | |||
structureInfoVo.setImageUrl(StringUtils.join(imageUrls,",")); | |||
structureInfoVo.setImageUrl(StringUtils.join(imageUrls, ",")); | |||
} | |||
// if (StringUtils.isNotEmpty(item.getImageUrl())) { | |||
// String imageUrl = getMultipleUrl(item.getImageUrl()); | |||
@@ -101,22 +102,22 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
} | |||
//如果是部门管理员或普通用户,查询本部门及子部门包含的路段及路段对应的构造物 | |||
if(RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId){ | |||
if (RoleEnum.ADMIN.getCode() == roleId || RoleEnum.ORDINARY_USER.getCode() == roleId) { | |||
String deptId = user.getDeptId(); | |||
if (StringUtils.isEmpty(deptId)){ | |||
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(),StructureEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
if (StringUtils.isEmpty(deptId)) { | |||
return JsonResult.error(StructureEnum.DEPT_IS_NOT_EXIST.getCode(), StructureEnum.DEPT_IS_NOT_EXIST.getMsg()); | |||
} | |||
//获取当前登录用户对应的部门及子部门 | |||
List<String> deptList = deptMapper.selectAllChildListById(deptId); | |||
if(StringUtils.isEmpty(deptList) && deptList.size()<=0){ | |||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(),SectionEnum.DEPT_ID_IS_NULL.getMsg()); | |||
if (StringUtils.isEmpty(deptList) && deptList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_ID_IS_NULL.getCode(), SectionEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
//根据部门列表查对应的部门路段数据列表 | |||
List<SectionDept> sectionDeptList = sectionDeptMapper.selectList(Wrappers.<SectionDept>lambdaQuery() | |||
.eq(SectionDept::getTenantId, tenantId) | |||
.in(SectionDept::getDeptId, deptList)); | |||
if(StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size()<=0){ | |||
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(),SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg()); | |||
if (StringUtils.isEmpty(sectionDeptList) && sectionDeptList.size() <= 0) { | |||
return JsonResult.error(SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getCode(), SectionEnum.DEPT_SECTION_IS_NOT_EXIST.getMsg()); | |||
} | |||
//查询对应的路段列表 | |||
List<String> sectionIdList = sectionDeptList.stream().map(t -> t.getSectionId()).distinct().collect(Collectors.toList()); | |||
@@ -127,20 +128,20 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
//根据路段id查询对应的构造物列表 | |||
for (String sectionId : sectionIdList) { | |||
query.setSectionId(sectionId); | |||
pageData = structureMapper.queryPageBySectionId(page,query); | |||
pageData = structureMapper.queryPageBySectionId(page, query); | |||
List<StructureInfoVo> records = pageData.getRecords(); | |||
for (StructureInfoVo record : records) { | |||
//获取构造物图片,对图片进行处理 | |||
if(StringUtils.isNotEmpty(record.getImageUrl())){ | |||
if (StringUtils.isNotEmpty(record.getImageUrl())) { | |||
String[] imageUrls = record.getImageUrl().split(","); | |||
if(StringUtils.isNotEmpty(imageUrls)){ | |||
if (StringUtils.isNotEmpty(imageUrls)) { | |||
for (int i = 0; i < imageUrls.length; i++) { | |||
if(StringUtils.isNotEmpty(imageUrls[i])){ | |||
imageUrls[i]= CommonConfig.imageURL+imageUrls[i]; | |||
if (StringUtils.isNotEmpty(imageUrls[i])) { | |||
imageUrls[i] = CommonConfig.imageURL + imageUrls[i]; | |||
} | |||
} | |||
} | |||
record.setImageUrl(StringUtils.join(imageUrls,",")); | |||
record.setImageUrl(StringUtils.join(imageUrls, ",")); | |||
} | |||
list.add(record); | |||
} | |||
@@ -165,23 +166,23 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
public JsonResult editInfo(Structure entity) { | |||
//获取登录信息 | |||
String userId = CurrentUserUtil.getUserId(); | |||
if(StringUtils.isEmpty(userId)){ | |||
JsonResult.error(StructureEnum.USER_ID_IS_NULL.getCode(),StructureEnum.USER_ID_IS_NULL.getMsg()); | |||
if (StringUtils.isEmpty(userId)) { | |||
JsonResult.error(StructureEnum.USER_ID_IS_NULL.getCode(), StructureEnum.USER_ID_IS_NULL.getMsg()); | |||
} | |||
//校验 | |||
if(StringUtils.isEmpty(entity.getRoadId()) && StringUtils.isEmpty(entity.getSectionId())){ | |||
if (StringUtils.isEmpty(entity.getRoadId()) && StringUtils.isEmpty(entity.getSectionId())) { | |||
return JsonResult.error("公路和路段为空"); | |||
} | |||
//获取租户id | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
//查询用户信息 | |||
if(StringUtils.isEmpty(entity.getId())){ | |||
if (StringUtils.isEmpty(entity.getId())) { | |||
//新增 | |||
entity.setCreateTime(DateUtils.now()); | |||
entity.setCreateUser(userId); | |||
entity.setTenantId(tenantId); | |||
}else { | |||
} else { | |||
//更新 | |||
entity.setUpdateTime(DateUtils.now()); | |||
entity.setUpdateUser(userId); | |||
@@ -194,50 +195,51 @@ public class StructureServiceImpl extends BaseServiceImpl<StructureMapper, Struc | |||
/** | |||
* 当前登录人对应的公路所属的构造物 | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getSectionInfo() { | |||
//获取登录信息 | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
if(StringUtils.isEmpty(tenantId)){ | |||
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(),StructureEnum.TENANT_ID_IS_NULL.getMsg()); | |||
if (StringUtils.isEmpty(tenantId)) { | |||
JsonResult.error(StructureEnum.TENANT_ID_IS_NULL.getCode(), StructureEnum.TENANT_ID_IS_NULL.getMsg()); | |||
} | |||
List<Structure> structures = structureMapper.selectList(Wrappers.<Structure>lambdaQuery().eq(Structure::getMark, 1) | |||
.eq(Structure::getTenantId, tenantId)); | |||
if(null == structures){ | |||
if (null == structures) { | |||
return JsonResult.error(); | |||
} | |||
List<StructureInfoVo> list = new ArrayList<>(); | |||
for (Structure structure : structures) { | |||
StructureInfoVo structureInfoVo = new StructureInfoVo(); | |||
BeanUtils.copyProperties(structure,structureInfoVo); | |||
BeanUtils.copyProperties(structure, structureInfoVo); | |||
//设置图片 | |||
if(StringUtils.isNotEmpty(structure.getImageUrl())){ | |||
if (StringUtils.isNotEmpty(structure.getImageUrl())) { | |||
String[] imageUrls = structure.getImageUrl().split(","); | |||
if(StringUtils.isNotEmpty(imageUrls)){ | |||
if (StringUtils.isNotEmpty(imageUrls)) { | |||
for (int i = 0; i < imageUrls.length; i++) { | |||
if(StringUtils.isNotEmpty(imageUrls[i])){ | |||
imageUrls[i]=CommonConfig.imageURL+imageUrls[i]; | |||
if (StringUtils.isNotEmpty(imageUrls[i])) { | |||
imageUrls[i] = CommonConfig.imageURL + imageUrls[i]; | |||
} | |||
} | |||
} | |||
structureInfoVo.setImageUrl(StringUtils.join(imageUrls,",")); | |||
structureInfoVo.setImageUrl(StringUtils.join(imageUrls, ",")); | |||
} | |||
//根据公路id获取公路code | |||
if(StringUtils.isEmpty(structure.getRoadId())){ | |||
if (StringUtils.isEmpty(structure.getRoadId())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
RoadInformation roadInformation = roadInformationMapper.selectById(structure.getRoadId()); | |||
if(ObjectUtil.isNotNull(roadInformation)){ | |||
if (ObjectUtil.isNotNull(roadInformation)) { | |||
structureInfoVo.setCode(roadInformation.getCode()); | |||
} | |||
//根据路段id获取路段范围 | |||
if(StringUtils.isEmpty(structure.getSectionId())){ | |||
if (StringUtils.isEmpty(structure.getSectionId())) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
Section section = sectionMapper.selectById(structure.getSectionId()); | |||
if(ObjectUtil.isNotNull(section)){ | |||
if (ObjectUtil.isNotNull(section)) { | |||
structureInfoVo.setSectionRange(section.getSectionRange()); | |||
} | |||
list.add(structureInfoVo); |
@@ -3,6 +3,7 @@ package com.tuoheng.admin.service.user; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.request.user.QueryUserPageListRequest; | |||
import com.tuoheng.admin.request.user.UserInitRequest; | |||
import com.tuoheng.admin.request.user.UserResetPwdRequest; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.web.bind.annotation.*; | |||
@@ -33,7 +34,7 @@ public interface IUserService { | |||
* @param username | |||
* @return | |||
*/ | |||
JsonResult getUserInfo(String username); | |||
JsonResult getUserInfo(); | |||
/** | |||
* 添加用户 | |||
@@ -85,6 +86,6 @@ public interface IUserService { | |||
/** | |||
* 初始化系统超级管理员用户 | |||
*/ | |||
JsonResult init(String username, String password); | |||
JsonResult init(UserInitRequest request); | |||
} |
@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.user; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.request.user.QueryUserPageListRequest; | |||
import com.tuoheng.admin.request.user.UserInitRequest; | |||
import com.tuoheng.admin.request.user.UserResetPwdRequest; | |||
import com.tuoheng.admin.service.user.add.AddUserService; | |||
import com.tuoheng.admin.service.user.delete.DeleteUserService; | |||
@@ -75,12 +76,11 @@ public class UserServiceImpl implements IUserService { | |||
/** | |||
* 获取用户详情 | |||
* | |||
* @param username | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getUserInfo(String username) { | |||
return queryUserInfoByIdService.getUserInfo(username); | |||
public JsonResult getUserInfo() { | |||
return queryUserInfoByIdService.getUserInfo(); | |||
} | |||
/** | |||
@@ -153,8 +153,8 @@ public class UserServiceImpl implements IUserService { | |||
* 初始化系统超级管理员用户 | |||
*/ | |||
@Override | |||
public JsonResult init(String username, String password) { | |||
return systemUserInitService.init(username, password); | |||
public JsonResult init(UserInitRequest request) { | |||
return systemUserInitService.init(request); | |||
} | |||
} |
@@ -4,7 +4,6 @@ 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; | |||
import com.tuoheng.admin.enums.code.user.AddUserCodeEnum; | |||
import com.tuoheng.admin.mapper.RoleMapper; | |||
@@ -57,18 +56,13 @@ public class AddUserService { | |||
log.info("添加用户业务接口:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
Tenant tenant = tenantMapper.selectById(tenantId); | |||
// 添加oidc | |||
result = oidcService.addUser(user, SystemConstant.INIT_PASSWORD, tenant); | |||
result = oidcService.addUser(user, SystemConstant.INIT_PASSWORD, null); | |||
if (0 != result.getCode()) { | |||
log.info("添加用户业务接口:添加oidc数据失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
this.buildUser(user, tenantId); | |||
Integer rowCount = userMapper.insert(user); | |||
if (rowCount <= 0) { | |||
return JsonResult.error(AddUserCodeEnum.ADD_IS_FAILED.getCode(), AddUserCodeEnum.ADD_IS_FAILED.getMsg()); | |||
@@ -78,6 +72,7 @@ public class AddUserService { | |||
/** | |||
* 检查参数 | |||
* | |||
* @param tenantId | |||
* @param user | |||
* @return | |||
@@ -104,24 +99,22 @@ public class AddUserService { | |||
return JsonResult.error(AddUserCodeEnum.PHONE_NOT_IMATCH.getCode(), AddUserCodeEnum.PHONE_NOT_IMATCH.getMsg()); | |||
} | |||
Integer count = userMapper.selectCount(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getUsername, user.getUsername()) | |||
.eq(User::getMark, 1)); | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getUsername, user.getUsername()) | |||
.eq(User::getMark, 1)); | |||
if (count > 0) { | |||
return JsonResult.error(AddUserCodeEnum.USERNAME_ALREADY_EXISTS.getCode(), AddUserCodeEnum.USERNAME_ALREADY_EXISTS.getMsg()); | |||
} | |||
count = roleMapper.selectCount(new LambdaQueryWrapper<Role>() | |||
.eq(Role::getTenantId, tenantId) | |||
.eq(Role::getId, user.getRoleId()) | |||
.eq(Role::getMark, 1)); | |||
if (count <= 0) { | |||
if (count < 0) { | |||
return JsonResult.error(AddUserCodeEnum.ROLE_IS_NOT_EXISTS.getCode(), AddUserCodeEnum.ROLE_IS_NOT_EXISTS.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* | |||
* 构建实体字段数据 | |||
* | |||
* @param user | |||
@@ -135,15 +128,12 @@ public class AddUserService { | |||
// 默认密码 | |||
user.setPassword(CommonUtils.password(SystemConstant.INIT_PASSWORD)); | |||
} | |||
if (StringUtils.isNotNull(user.getAvatar()) && user.getAvatar().contains(CommonConfig.imageURL)) { | |||
user.setAvatar(user.getAvatar().replaceAll(CommonConfig.imageURL, "")); | |||
} else { | |||
//添加默认头像 | |||
user.setAvatar("imagedir/n1o1j9ndau_1670488066287.png"); | |||
} | |||
//id | |||
user.setCityName(""); | |||
user.setTenantId(tenantId); | |||
user.setCreateUser(CurrentUserUtil.getUserId()); |
@@ -2,12 +2,17 @@ package com.tuoheng.admin.service.user.init; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.Dept; | |||
import com.tuoheng.admin.entity.Role; | |||
import com.tuoheng.admin.entity.Tenant; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.RoleMapper; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.request.user.UserInitRequest; | |||
import com.tuoheng.admin.service.third.oidc.OidcService; | |||
import com.tuoheng.common.core.utils.CommonUtils; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
@@ -18,7 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 初始化系统用户业务层处理 | |||
* 初始化系统租户用户业务层处理 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
@@ -34,6 +39,9 @@ public class SystemUserInitService { | |||
@Autowired | |||
private RoleMapper roleMapper; | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@@ -41,57 +49,62 @@ public class SystemUserInitService { | |||
private OidcService oidcService; | |||
/** | |||
* 添加用户数据 | |||
* 添加租户用户数据 | |||
* | |||
* @return | |||
*/ | |||
public JsonResult init(String username, String password) { | |||
log.info("进入初始化系统用户业务接口"); | |||
Tenant tenant = tenantMapper.selectOne(new LambdaQueryWrapper<Tenant>() | |||
.eq(Tenant::getMark, 1)); | |||
String tenantId = ""; | |||
if (ObjectUtil.isNotNull(tenant)) { | |||
tenantId = tenant.getId(); | |||
} | |||
User user = this.buildUser(username, password, tenantId); | |||
JsonResult result = this.check(username, password, tenantId); | |||
public JsonResult init(UserInitRequest request) { | |||
log.info("进入初始化系统租户用户业务接口"); | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { | |||
log.info("初始化系统用户业务接口:校验失败:{}", result.getMsg()); | |||
log.info("初始化系统租户用户业务接口:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
Tenant tenant = null; | |||
if (1 == request.getTenantFlag()) { | |||
tenant = this.addTenant(request); | |||
} | |||
User user = this.buildUser(request); | |||
// 添加oidc | |||
result = oidcService.addUser(user, password, tenant); | |||
result = oidcService.addUser(user, request.getPassword(), tenant); | |||
if (0 != result.getCode()) { | |||
log.info("初始化系统用户业务接口:添加oidc数据失败:{}", result.getMsg()); | |||
log.info("初始化系统租户用户业务接口:添加oidc数据失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
Integer rowCount = userMapper.insert(user); | |||
if (rowCount <= 0) { | |||
return JsonResult.error(400, "初始化系统用户失败"); | |||
// 此次不能放在上面,要等oicd添加完之后,防止tenant不为空的话,创建都是租户 | |||
if (0 == request.getTenantFlag()) { | |||
tenant = tenantMapper.selectOne(Wrappers.<Tenant>lambdaQuery() | |||
.eq(Tenant::getMark, 1) | |||
.eq(Tenant::getCode, request.getTenantCode())); | |||
if (ObjectUtil.isNotNull(tenant)) { | |||
user.setTenantId(tenant.getId()); | |||
} else { | |||
log.info("租户不存在,tenantCode:{}", request.getTenantCode()); | |||
} | |||
} | |||
user.setTenantId(tenant.getId()); | |||
this.addUser(user); | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 构建实体字段数据 | |||
*/ | |||
private User buildUser(String username, String password, String tenantId) { | |||
if (StringUtils.isEmpty(username)) { | |||
username = "THJS"; | |||
} | |||
private User buildUser(UserInitRequest request) { | |||
User user = new User(); | |||
user.setCode("gs"); | |||
user.setUsername(username); | |||
user.setUsername(request.getName()); | |||
user.setRealname("超级管理员"); | |||
user.setNickname("超级管理员"); | |||
user.setCityName(""); | |||
user.setPassword(CommonUtils.password(password)); | |||
user.setPassword(CommonUtils.password(request.getPassword())); | |||
user.setAvatar("imagedir/n1o1j9ndau_1670488066287.png"); | |||
user.setClientId("1,2"); | |||
user.setRoleId(1); | |||
user.setDeptId(""); | |||
user.setStatus(1); | |||
user.setTenantId(tenantId); | |||
user.setCreateTime(DateUtils.now()); | |||
return user; | |||
} | |||
@@ -99,33 +112,28 @@ public class SystemUserInitService { | |||
/** | |||
* 检查参数 | |||
* | |||
* @param username | |||
* @param password | |||
* @param request | |||
* @param | |||
* | |||
* @return | |||
*/ | |||
private JsonResult check(String username, String password, String tenantId) { | |||
if (StringUtils.isEmpty(username)) { | |||
private JsonResult check(UserInitRequest request) { | |||
if (StringUtils.isEmpty(request.getName())) { | |||
return JsonResult.error(400, "用户名为空"); | |||
} | |||
if (StringUtils.isEmpty(password)) { | |||
if (StringUtils.isEmpty(request.getPassword())) { | |||
return JsonResult.error(400, "密码为空"); | |||
} | |||
Integer count = userMapper.selectCount(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getRoleId, 1) | |||
.eq(User::getMark, 1)); | |||
if (count > 0) { | |||
return JsonResult.error(400, "系统中已经存在超级管理员"); | |||
if (StringUtils.isEmpty(request.getTenantCode())) { | |||
return JsonResult.error(400, "租户编号"); | |||
} | |||
count = userMapper.selectCount(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getUsername, username) | |||
Integer count = userMapper.selectCount(new LambdaQueryWrapper<User>() | |||
.eq(User::getUsername, request.getName()) | |||
.eq(User::getMark, 1)); | |||
if (count > 0) { | |||
return JsonResult.error(400, "系统中已经存在该用户名"); | |||
} | |||
count = roleMapper.selectCount(new LambdaQueryWrapper<Role>() | |||
.eq(Role::getTenantId, tenantId) | |||
.eq(Role::getId, 1) | |||
.eq(Role::getMark, 1)); | |||
if (count <= 0) { | |||
@@ -133,5 +141,53 @@ public class SystemUserInitService { | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 添加租户 | |||
*/ | |||
private Tenant addTenant(UserInitRequest request) { | |||
// 如果是租户先去创建 | |||
Tenant tenant = new Tenant(); | |||
tenant.setName(request.getName()); | |||
tenant.setUsername(request.getName()); | |||
tenant.setCode(request.getTenantCode()); | |||
tenant.setAirportUrl(request.getAirportUrl()); | |||
Tenant tenantTmp = tenantMapper.selectOne(Wrappers.<Tenant>lambdaQuery() | |||
.eq(Tenant::getMark, 1) | |||
.eq(Tenant::getStatus, 1) | |||
.eq(Tenant::getName, request.getName()) | |||
.eq(Tenant::getCode, request.getTenantCode())); | |||
if (ObjectUtil.isNull(tenantTmp)) { | |||
tenantMapper.insert(tenant); | |||
return tenant; | |||
} else { | |||
return tenantTmp; | |||
} | |||
} | |||
/** | |||
* 添加用户 | |||
*/ | |||
private void addUser(User user) { | |||
User userTmp = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||
.eq(User::getMark, 1) | |||
.eq(User::getStatus, 1) | |||
.eq(User::getUsername, user.getUsername())); | |||
if (ObjectUtil.isNull(userTmp)) { | |||
log.info("初始化系统租户用户,用户已存在,username:{}", user.getUsername()); | |||
} | |||
// 如果顶级部门存在,将该超级管理员与顶级部门关联 | |||
Dept dept = deptMapper.selectOne(Wrappers.<Dept>lambdaQuery() | |||
.eq(Dept::getMark, 1) | |||
.eq(Dept::getPid, SystemConstant.ROOT_DEPT_PID)); | |||
if (ObjectUtil.isNotNull(dept)) { | |||
user.setDeptId(dept.getId()); | |||
} | |||
Integer rowCount = userMapper.insert(user); | |||
if (rowCount <= 0) { | |||
log.info("初始化系统租户用户失败,username:{}", user.getUsername()); | |||
} | |||
} | |||
} |
@@ -6,14 +6,11 @@ import com.tuoheng.admin.conver.UserConverMapper; | |||
import com.tuoheng.admin.entity.Dept; | |||
import com.tuoheng.admin.entity.Role; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.code.user.QueryUserInfoByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.RoleMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.vo.user.UserInfoVo; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -29,9 +26,6 @@ import org.springframework.stereotype.Service; | |||
@Service | |||
public class QueryUserInfoByIdService { | |||
@Autowired | |||
private UserMapper userMapper; | |||
@Autowired | |||
private DeptMapper deptMapper; | |||
@@ -43,16 +37,9 @@ public class QueryUserInfoByIdService { | |||
* | |||
* @return | |||
*/ | |||
public JsonResult getUserInfo(String username) { | |||
public JsonResult getUserInfo() { | |||
log.info("进入根据用户名查询用户信息业务"); | |||
JsonResult result = this.check(username); | |||
if (0 != result.getCode()) { | |||
log.info("根据用户名查询用户信息业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
User user = (User) result.getData(); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
UserInfoVo userInfoVo = UserConverMapper.INSTANCE.fromUserToUserInfoVo(user); | |||
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() | |||
.eq(Dept::getId, userInfoVo.getDeptId()) | |||
@@ -60,7 +47,6 @@ public class QueryUserInfoByIdService { | |||
if (ObjectUtil.isNotNull(dept)) { | |||
userInfoVo.setDeptName(dept.getName()); | |||
} | |||
Role role = roleMapper.selectOne(new LambdaQueryWrapper<Role>() | |||
.eq(Role::getId, userInfoVo.getRoleId()) | |||
.eq(Role::getMark, 1)); | |||
@@ -69,29 +55,4 @@ public class QueryUserInfoByIdService { | |||
} | |||
return JsonResult.success(userInfoVo); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param username | |||
* @return | |||
*/ | |||
private JsonResult check(String username) { | |||
if (StringUtils.isEmpty(username)) { | |||
return JsonResult.error(QueryUserInfoByIdCodeEnum.USERNAME_ID_IS_NULL.getCode(), QueryUserInfoByIdCodeEnum.USERNAME_ID_IS_NULL.getMsg()); | |||
} | |||
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() | |||
.eq(User::getUsername, username) | |||
.eq(User::getMark, 1)); | |||
if (ObjectUtil.isNull(user)) { | |||
return JsonResult.error(QueryUserInfoByIdCodeEnum.USER_IS_NOT_EXIST.getCode(), QueryUserInfoByIdCodeEnum.USER_IS_NOT_EXIST.getMsg()); | |||
} | |||
if (!user.getTenantId().equals(CurrentUserUtil.getTenantId())) { | |||
return JsonResult.error(QueryUserInfoByIdCodeEnum.NON_TENANT_USER.getCode(), QueryUserInfoByIdCodeEnum.NON_TENANT_USER.getMsg()); | |||
} | |||
return JsonResult.success(user); | |||
} | |||
} |
@@ -9,6 +9,7 @@ import com.tuoheng.admin.enums.code.dept.QueryDeptChildListCodeEnum; | |||
import com.tuoheng.admin.enums.code.user.QueryUserListByDeptIdCodeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -46,8 +47,9 @@ public class QueryUserListByDeptIdService { | |||
log.info("根据根据部门id查询用户列表业业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() | |||
.eq(User::getTenantId, tenantId) | |||
.eq(User::getDeptId, deptId) | |||
.ne(User::getRoleId, RoleEnum.SUPER_ADMIN.getCode()) | |||
.eq(User::getMark, 1)); |
@@ -56,6 +56,8 @@ public class QueryWorkOrderPageListService { | |||
log.info("进入查询工单分页列表业务, request:{}", request.toString()); | |||
String userId = CurrentUserUtil.getUserId(); | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(request); | |||
if (0 != result.getCode()) { |
@@ -196,6 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<where> | |||
<if test="1 == 1"> and tif.mark = 1 </if> | |||
<if test="request.key != null and request.key != ''"> and (ti.code like concat('%', #{request.key}, '%') or ti.name like concat('%', #{request.key}, '%')) </if> | |||
<if test="request.tenantId != null and request.tenantId != ''"> and tif.tenant_id = #{request.tenantId} </if> | |||
<if test="request.questionCode != null and request.questionCode != ''"> and tif.question_Code = #{request.questionCode} </if> | |||
<choose> | |||
<when test="request.status != null and request.status != 0"> | |||
@@ -228,6 +229,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<where> | |||
<if test="1 == 1"> and tif.mark = 1 </if> | |||
<if test="request.inspectionName != null and request.inspectionName != ''"> and ti.name like concat('%', #{request.inspectionName}, '%') </if> | |||
<if test="request.tenantId != null and request.tenantId != ''"> and tif.tenant_id = #{request.tenantId} </if> | |||
<if test="request.questionCode != null and request.questionCode != ''"> and tif.question_code = #{request.questionCode} </if> | |||
<if test="request.status != null"> | |||
<choose> |
@@ -93,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<where> | |||
<if test="1 == 1"> and mark = 1 </if> | |||
<if test="request.code != null and request.code != ''"> and code like concat('%', #{request.code}, '%') </if> | |||
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if> | |||
<if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if> | |||
<if test="request.inspectionLine != null and request.inspectionLine != 0"> and inspection_line = #{request.inspectionLine} </if> | |||
<if test="request.type != null and request.type != 0"> and type = #{request.type} </if> |
@@ -73,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<include refid="selectReportVo"/> | |||
<where> | |||
<if test="1 == 1"> and mark = 1 </if> | |||
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if> | |||
<if test="request.inspectionCode!= null and request.inspectionCode != ''"> and inspection_code like concat('%', #{request.inspectionCode}, '%') </if> | |||
<if test="request.airportId != null and request.airportId != 0"> and airport_id = #{request.airportId} </if> | |||
<if test="request.type != null and request.type != 0"> and type = #{request.type} </if> |
@@ -41,15 +41,10 @@ | |||
left JOIN th_section se ON sr.section_id=se.id | |||
left JOIN th_road rd ON sr.road_id=rd.id | |||
where sr.mark=1 and se.mark=1 and rd.mark=1 | |||
<if test="request.structureName !=null and request.structureName !=''"> | |||
AND sr.`structure_name` like concat('%',#{request.structureName},'%') | |||
</if> | |||
<if test="request.structureType !=null"> | |||
AND sr.structure_type = #{request.structureType} | |||
</if> | |||
<if test="request.roadId !=null"> | |||
AND sr.road_id = #{request.roadId} | |||
</if> | |||
<if test="request.structureName !=null and request.structureName !=''"> and sr.`structure_name` like concat('%',#{request.structureName},'%') </if> | |||
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if> | |||
<if test="request.structureType !=null"> and sr.structure_type = #{request.structureType} </if> | |||
<if test="request.roadId !=null"> and sr.road_id = #{request.roadId} </if> | |||
ORDER BY | |||
sr.create_time DESC | |||
</select> |
@@ -64,6 +64,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
</where> | |||
</update> | |||
<update id="updateDeptIdByIdList" parameterType="hashmap"> | |||
update th_oauth_user | |||
<trim prefix="SET" suffixOverrides=","> | |||
<if test="deptId != null"> dept_id = #{deptId}, </if> | |||
<if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if> | |||
<if test="updateTime != null"> update_time = #{updateTime}, </if> | |||
</trim> | |||
<where> | |||
<if test="idList != null and idList.size() > 0"> | |||
and id in | |||
<foreach collection="idList" item="id" separator="," open="(" close=")"> | |||
#{id} | |||
</foreach> | |||
</if> | |||
</where> | |||
</update> | |||
<select id="selectPageList" parameterType="com.tuoheng.admin.request.user.QueryUserPageListRequest" resultMap="UserResult"> | |||
select <include refid="selectUserVo"/> | |||
from th_oauth_user |
@@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<include refid="selectThWorkOrderVo"/> | |||
<where> | |||
<if test="1 == 1"> and mark = 1 </if> | |||
<if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if> | |||
<if test="request.code != null and request.code != 0"> and code = #{request.code} </if> | |||
<if test="request.status != null and request.status != ''"> and status = #{request.status} </if> | |||
<if test="(request.userDeptId != null and request.userDeptId != '') or (request.deptIdList != null and request.deptIdList.size() > 0)"> |
@@ -289,9 +289,6 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO | |||
if (null == query.getPage() && null == query.getLimit()) { | |||
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL); | |||
} | |||
//获取分页数据 | |||
IPage<InspectionFile> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<WorkOrderHandleVo> pageData = new Page<>(query.getPage(), query.getLimit()); | |||
//根据工单id获取对应的问题集合 | |||
List<WorkOrderFile> workOrderFiles = workOrderFileMapper.selectList(Wrappers.<WorkOrderFile>lambdaQuery() | |||
.eq(WorkOrderFile::getWorkOrderId, query.getId())); | |||
@@ -300,9 +297,13 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO | |||
} | |||
//工单子表获取对应的问题集合id | |||
List<String> inspectionFiledIds = workOrderFiles.stream().map(o -> o.getInspectionFileId()).collect(Collectors.toList()); | |||
List<InspectionFile> inspectionFilesList = inspectionFileMapper.selectBatchIds(inspectionFiledIds); | |||
//设置分页 | |||
IPage<InspectionFile> inspectionFilePageData = page.setRecords(inspectionFilesList); | |||
//获取分页数据 | |||
IPage<InspectionFile> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<WorkOrderHandleVo> pageData = new Page<>(query.getPage(), query.getLimit()); | |||
//获取当前分配人对应的工单分页数据 | |||
IPage<InspectionFile> inspectionFilePageData = inspectionFileMapper.selectPage(page, Wrappers.<InspectionFile>lambdaQuery() | |||
.in(InspectionFile::getId, inspectionFiledIds)); | |||
List<WorkOrderHandleVo> list = inspectionFilePageData.getRecords().stream().map(t -> { | |||
WorkOrderHandleVo vo = new WorkOrderHandleVo(); | |||
BeanUtils.copyProperties(t, vo); |