Commit 5cc66198 by 丁伟峰

Merge remote-tracking branch 'origin/develop' into develop

2 parents 3bdae3dc f495281b
package com.dituhui.pea.pojo; package com.dituhui.pea.pojo;
import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.Date;
import lombok.Data;
/** /**
* 资源信息 * 资源信息
* @author zl
*/ */
@Data @Data
public class ResourceInfo { public class ResourceInfo {
...@@ -26,29 +24,12 @@ public class ResourceInfo { ...@@ -26,29 +24,12 @@ public class ResourceInfo {
*/ */
private String extra; private String extra;
/** /**
* 团队id
*/
@NotBlank(message = "团队ID不能为空!")
private String teamId;
/**
* 描述 * 描述
*/ */
private String description; private String description;
/** /**
* 创建人 * 资源类型1菜单2功能点3所属组织
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/ */
private Date updatedTime; private Integer type;
} }
package com.dituhui.pea.pojo; package com.dituhui.pea.pojo;
import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.Date;
import lombok.Data;
/** /**
* 角色信息 * 角色信息
* @author zl
*/ */
@Data @Data
public class RoleInfo { public class RoleInfo {
...@@ -22,11 +20,6 @@ public class RoleInfo { ...@@ -22,11 +20,6 @@ public class RoleInfo {
@NotBlank(message = "角色名称不能为空!") @NotBlank(message = "角色名称不能为空!")
private String name; private String name;
/** /**
* 团队id
*/
@NotBlank(message = "团队ID不能为空!")
private String teamId;
/**
* 角色组id * 角色组id
*/ */
private String groupId; private String groupId;
...@@ -35,22 +28,5 @@ public class RoleInfo { ...@@ -35,22 +28,5 @@ public class RoleInfo {
*/ */
@NotBlank(message = "角色条件不能为空!") @NotBlank(message = "角色条件不能为空!")
private String extra; private String extra;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
} }
package com.dituhui.pea.pojo; package com.dituhui.pea.pojo;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data; import lombok.Data;
...@@ -20,4 +22,7 @@ public class UserLoginDTO { ...@@ -20,4 +22,7 @@ public class UserLoginDTO {
private String wechat; private String wechat;
private String token; private String token;
private List<RoleInfo> roles;
private List<ResourceInfo> resources;
} }
...@@ -20,8 +20,8 @@ public class DispatchOrderListReq { ...@@ -20,8 +20,8 @@ public class DispatchOrderListReq {
private List<String> teamIds; private List<String> teamIds;
private List<String> engineerCodes; private List<String> engineerCodes;
private List<Integer> priorities; private List<Integer> priorities;
private List<String> productCategory; private List<String> typeCategory;
private List<String> serviceCategory; private List<String> skillCategory;
private String phone; private String phone;
private String orderId; private String orderId;
private List<String> appointmentStatus; private List<String> appointmentStatus;
......
...@@ -26,8 +26,8 @@ public class OrderServiceListReq { ...@@ -26,8 +26,8 @@ public class OrderServiceListReq {
private List<String> teamIds; private List<String> teamIds;
private List<String> engineerCodes; private List<String> engineerCodes;
private List<Integer> priorities; private List<Integer> priorities;
private List<String> productCategory; private List<String> typeCategory;
private List<String> serviceCategory; private List<String> skillCategory;
private String phone; private String phone;
private String orderId; private String orderId;
private List<String> appointmentStatus; private List<String> appointmentStatus;
......
...@@ -287,13 +287,23 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -287,13 +287,23 @@ public class DispatchServiceImpl implements DispatchService {
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderRequest::getPriority, reqDTO.getPriorities()); lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderRequest::getPriority, reqDTO.getPriorities());
lqw.in(ListUtils.isNotEmpty(reqDTO.getProductCategory()), OrderRequest::getType, reqDTO.getProductCategory());
lqw.in(ListUtils.isNotEmpty(reqDTO.getProductCategory()), OrderRequest::getSkill, reqDTO.getServiceCategory());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus());
if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) {
String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types);
lqw.exists(sql);
}
if (ListUtils.isNotEmpty(reqDTO.getSkillCategory())) {
String skills = "'" + String.join("','", reqDTO.getSkillCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and skill_category in (%s)", skills);
lqw.exists(sql);
}
if(ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) { if(ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
String engineerCodes = String.join(",", reqDTO.getEngineerCodes()); String engineerCodes = "'" + String.join("','", reqDTO.getEngineerCodes()) + "'";
String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes); String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes);
lqw.exists(sql); lqw.exists(sql);
} }
......
...@@ -57,13 +57,23 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -57,13 +57,23 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderRequest::getOrgGroupId, reqDTO.getGroupIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderRequest::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderRequest::getPriority, reqDTO.getPriorities()); lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderRequest::getPriority, reqDTO.getPriorities());
lqw.in(ListUtils.isNotEmpty(reqDTO.getProductCategory()), OrderRequest::getType, reqDTO.getProductCategory());
lqw.in(ListUtils.isNotEmpty(reqDTO.getProductCategory()), OrderRequest::getSkill, reqDTO.getServiceCategory());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderRequest::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderRequest::getAppointmentStatus, reqDTO.getAppointmentStatus());
if(ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) { if (ListUtils.isNotEmpty(reqDTO.getTypeCategory())) {
String engineerCodes = String.join(",", reqDTO.getEngineerCodes()); String types = "'" + String.join("','", reqDTO.getTypeCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and type_category in (%s)", types);
lqw.exists(sql);
}
if (ListUtils.isNotEmpty(reqDTO.getSkillCategory())) {
String skills = "'" + String.join("','", reqDTO.getSkillCategory()) + "'";
String sql = String.format("select 1 from skill_info sk where sk.brand = order_request.brand and sk.type = order_request.type and sk.skill = order_request.skill and skill_category in (%s)", skills);
lqw.exists(sql);
}
if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
String engineerCodes = "'" + String.join("','", reqDTO.getEngineerCodes()) + "'";
String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes); String sql = String.format("select 1 from order_appointment oa where oa.order_id = order_request.order_id and oa.dt = order_request.dt and oa.engineer_code in (%s)", engineerCodes);
lqw.exists(sql); lqw.exists(sql);
} }
......
...@@ -11,8 +11,6 @@ import java.util.List; ...@@ -11,8 +11,6 @@ import java.util.List;
/** /**
* 资源表 用户对某种具体权限或者功能的描述(Resource)表数据库访问层 * 资源表 用户对某种具体权限或者功能的描述(Resource)表数据库访问层
* *
* @author makejava
* @since 2020-12-09 15:33:27
*/ */
public interface ResourceDao extends JpaRepository<ResourceEntity, String>, public interface ResourceDao extends JpaRepository<ResourceEntity, String>,
JpaSpecificationExecutor<ResourceEntity>, CrudRepository<ResourceEntity, String> { JpaSpecificationExecutor<ResourceEntity>, CrudRepository<ResourceEntity, String> {
......
...@@ -9,8 +9,6 @@ import org.springframework.data.repository.CrudRepository; ...@@ -9,8 +9,6 @@ import org.springframework.data.repository.CrudRepository;
/** /**
* 角色表(Role)表数据库访问层 * 角色表(Role)表数据库访问层
* *
* @author zl
* @since 2020-12-09 15:33:38
*/ */
public interface RoleDao extends JpaRepository<RoleEntity, String>, public interface RoleDao extends JpaRepository<RoleEntity, String>,
JpaSpecificationExecutor<RoleEntity>, CrudRepository<RoleEntity, String> { JpaSpecificationExecutor<RoleEntity>, CrudRepository<RoleEntity, String> {
......
package com.dituhui.pea.user.dao; package com.dituhui.pea.user.dao;
import com.dituhui.pea.user.entity.RoleResourceEntity; import com.dituhui.pea.user.entity.RoleResourceEntity;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
...@@ -9,33 +11,40 @@ import org.springframework.data.repository.CrudRepository; ...@@ -9,33 +11,40 @@ import org.springframework.data.repository.CrudRepository;
/** /**
* 角色资源表(RoleResource)表数据库访问层 * 角色资源表(RoleResource)表数据库访问层
* *
* @author zl
* @since 2020-12-09 15:33:55
*/ */
public interface RoleResourceDao extends JpaRepository<RoleResourceEntity, String>, public interface RoleResourceDao extends JpaRepository<RoleResourceEntity, String>,
JpaSpecificationExecutor<RoleResourceEntity>, CrudRepository<RoleResourceEntity, String> { JpaSpecificationExecutor<RoleResourceEntity>, CrudRepository<RoleResourceEntity, String> {
/** /**
* 根据角色ID和资源ID查询 * 根据角色ID和资源ID查询
*
* @param roleId 角色ID * @param roleId 角色ID
* @param resourceId 资源ID * @param resourceId 资源ID
* @return * @return
*/ */
RoleResourceEntity findByRoleIdAndResourceId(String roleId, String resourceId); RoleResourceEntity findByRoleIdAndResourceId(String roleId, String resourceId);
/**
* 根据角色ID查询
*
* @param roleIds 角色ID
* @return
*/
List<RoleResourceEntity> findByRoleIdIn(List<String> roleIds);
/** /**
* 根据角色ID删除对应的资源关系 * 根据角色ID删除对应的资源关系
*
* @param roleId 角色ID * @param roleId 角色ID
*/ */
void deleteByRoleId(String roleId); void deleteByRoleId(String roleId);
/** /**
* 根据角色ID和资源ID删除 * 根据角色ID和资源ID删除
*
* @param roleId 角色ID * @param roleId 角色ID
* @param resourceId 资源ID * @param resourceId 资源ID
*/ */
void deleteByRoleIdAndResourceId(String roleId, String resourceId); void deleteByRoleIdAndResourceId(String roleId, String resourceId);
} }
...@@ -24,6 +24,12 @@ public interface UserRoleDao extends JpaRepository<UserRoleEntity, String>, ...@@ -24,6 +24,12 @@ public interface UserRoleDao extends JpaRepository<UserRoleEntity, String>,
*/ */
List<UserRoleEntity> findByRoleId(String roleId); List<UserRoleEntity> findByRoleId(String roleId);
/**
* 根据用户ID查询
* @param roleId 角色ID
* @return
*/
List<UserRoleEntity> findByUserId(String userId);
/** /**
* 根据角色ID和用户ID删除 * 根据角色ID和用户ID删除
......
...@@ -56,6 +56,11 @@ public class ResourceEntity implements Serializable { ...@@ -56,6 +56,11 @@ public class ResourceEntity implements Serializable {
@Column(name = "CREATED_BY") @Column(name = "CREATED_BY")
private String createdBy; private String createdBy;
/** /**
* 名称
*/
@Column(name = "parent_id")
private String parentId;
/**
* 创建时间 * 创建时间
*/ */
@Column(name = "CREATED_TIME") @Column(name = "CREATED_TIME")
......
...@@ -2,6 +2,7 @@ package com.dituhui.pea.user.service; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.user.service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
...@@ -12,18 +13,28 @@ import org.springframework.data.jpa.domain.Specification; ...@@ -12,18 +13,28 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.enums.RedisKeyGroup; import com.dituhui.pea.enums.RedisKeyGroup;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.enums.ThirdPartyEnum; import com.dituhui.pea.enums.ThirdPartyEnum;
import com.dituhui.pea.exception.BusinessException; import com.dituhui.pea.exception.BusinessException;
import com.dituhui.pea.pojo.ResourceInfo;
import com.dituhui.pea.pojo.RoleInfo;
import com.dituhui.pea.pojo.ThirdUserInfo; import com.dituhui.pea.pojo.ThirdUserInfo;
import com.dituhui.pea.pojo.UserInfo; import com.dituhui.pea.pojo.UserInfo;
import com.dituhui.pea.pojo.UserLoginDTO; import com.dituhui.pea.pojo.UserLoginDTO;
import com.dituhui.pea.user.commom.RedisService; import com.dituhui.pea.user.commom.RedisService;
import com.dituhui.pea.user.constant.TextConstant; import com.dituhui.pea.user.constant.TextConstant;
import com.dituhui.pea.user.dao.ResourceDao;
import com.dituhui.pea.user.dao.RoleDao;
import com.dituhui.pea.user.dao.RoleResourceDao;
import com.dituhui.pea.user.dao.UserDao; import com.dituhui.pea.user.dao.UserDao;
import com.dituhui.pea.user.dao.UserRoleDao;
import com.dituhui.pea.user.entity.RoleEntity;
import com.dituhui.pea.user.entity.RoleResourceEntity;
import com.dituhui.pea.user.entity.UserEntity; import com.dituhui.pea.user.entity.UserEntity;
import com.dituhui.pea.user.entity.UserRoleEntity;
import com.dituhui.pea.user.factory.ThirdStrategy; import com.dituhui.pea.user.factory.ThirdStrategy;
import com.dituhui.pea.user.factory.ThirdStrategyFactory; import com.dituhui.pea.user.factory.ThirdStrategyFactory;
import com.dituhui.pea.user.utils.TextHelper; import com.dituhui.pea.user.utils.TextHelper;
...@@ -47,7 +58,7 @@ public class UserService { ...@@ -47,7 +58,7 @@ public class UserService {
/** /**
* 失效时间ms * 失效时间ms
*/ */
private static final int aliveTime = 7200000; private static final int LIVE_TIME_MILLIS = 7200000;
@Autowired @Autowired
UserDao userDao; UserDao userDao;
...@@ -58,17 +69,48 @@ public class UserService { ...@@ -58,17 +69,48 @@ public class UserService {
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Autowired
UserRoleDao userRoleDao;
@Autowired
RoleDao roleDao;
@Autowired
RoleResourceDao roleResourceDao;
@Autowired
ResourceDao resourceDao;
public Result<?> userLogin(String account, String password) { public Result<?> userLogin(String account, String password) {
UserEntity user = userDao.findByAccountAndPassword(account, SecureUtil.md5(password)); UserEntity user = userDao.findByAccountAndPassword(account, SecureUtil.md5(password));
log.info("{}:{}:{}:{}", account, password, SecureUtil.md5(password), user); log.info("{}/{} login", account, password);
if (null != user) { if (null != user) {
// 生成token // 生成token
UserLoginDTO userDTO = BeanUtil.copyProperties(user, UserLoginDTO.class);
// 生成token
String uuid = IdUtil.simpleUUID(); String uuid = IdUtil.simpleUUID();
// 2小时 long timestamp = System.currentTimeMillis() + LIVE_TIME_MILLIS;
long timestamp = System.currentTimeMillis() + aliveTime;
redisService.set(RedisKeyGroup.authToken + ":" + uuid, user, timestamp); redisService.set(RedisKeyGroup.authToken + ":" + uuid, user, timestamp);
UserLoginDTO userDTO = BeanUtil.copyProperties(user, UserLoginDTO.class);
// 获取角色
List<UserRoleEntity> userRoles = userRoleDao.findByUserId(user.getId());
if (CollectionUtils.isNotEmpty(userRoles)) {
List<String> ids = userRoles.stream().map(r -> r.getRoleId()).collect(Collectors.toList());
List<RoleEntity> roles = roleDao.findAllById(ids);
if (CollectionUtils.isNotEmpty(roles)) {
userDTO.setRoles(roles.stream().map(r -> BeanUtil.copyProperties(r, RoleInfo.class))
.collect(Collectors.toList()));
// 获取资源
List<RoleResourceEntity> roleResources = roleResourceDao.findByRoleIdIn(ids);
if (CollectionUtils.isNotEmpty(roleResources)) {
List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId())
.collect(Collectors.toList());
userDTO.setResources(resourceDao.findAllById(resourceIds).stream()
.map(r -> BeanUtil.copyProperties(r, ResourceInfo.class)).collect(Collectors.toList()));
}
}
}
userDTO.setToken(uuid); userDTO.setToken(uuid);
return Result.success(userDTO); return Result.success(userDTO);
} else { } else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!