Commit 3705de59 by 林永健

feat(员工查询): 实现北森员工列表查询功能

- 在BeisenEmployeeInfoMapper中添加selectByConditions方法
- 修改BeiSenEmployeeListRequestDTO字段类型和注释
- 实现MerchantStaffService中的getBeisenUserWithConditions方法
- 添加XML映射文件中的查询条件和结果映射
- 更新测试用例处理异常情况
1 parent aeaee58f
...@@ -30,7 +30,7 @@ public class BeiSenEmployeeListRequestDTO implements Serializable { ...@@ -30,7 +30,7 @@ public class BeiSenEmployeeListRequestDTO implements Serializable {
private String employeeName; private String employeeName;
/** /**
* 手机号 * 手机号(模糊查询)
*/ */
private String mobilePhone; private String mobilePhone;
private List<String> mobilePhoneList; private List<String> mobilePhoneList;
...@@ -55,7 +55,7 @@ public class BeiSenEmployeeListRequestDTO implements Serializable { ...@@ -55,7 +55,7 @@ public class BeiSenEmployeeListRequestDTO implements Serializable {
/** /**
* 岗位 ID 列表 * 岗位 ID 列表
*/ */
private List<Integer> oIdJobPostIds; private List<String> oIdJobPostIds;
/** /**
* 部门 ID 列表 * 部门 ID 列表
......
package cn.com.glsx.merchants.mapper; package cn.com.glsx.merchants.mapper;
import cn.com.glsx.merchants.entity.BeisenEmployeeInfo; import cn.com.glsx.merchants.entity.BeisenEmployeeInfo;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListRequestDTO;
import cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListResonseDTO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper @Mapper
public interface BeisenEmployeeInfoMapper extends CommonBaseMapper<BeisenEmployeeInfo> { public interface BeisenEmployeeInfoMapper extends CommonBaseMapper<BeisenEmployeeInfo> {
BeisenEmployeeInfo findByUserId(@Param("userId") Integer userID); BeisenEmployeeInfo findByUserId(@Param("userId") Integer userID);
List<BeiSenEmployeeListResonseDTO> selectByConditions(@Param("req") BeiSenEmployeeListRequestDTO req);
} }
...@@ -16,6 +16,7 @@ import cn.com.glsx.merchants.kafka.producer.SynStaffComponent; ...@@ -16,6 +16,7 @@ import cn.com.glsx.merchants.kafka.producer.SynStaffComponent;
import cn.com.glsx.merchants.mapper.MerchantMapper; import cn.com.glsx.merchants.mapper.MerchantMapper;
import cn.com.glsx.merchants.mapper.MerchantRoleMapper; import cn.com.glsx.merchants.mapper.MerchantRoleMapper;
import cn.com.glsx.merchants.mapper.MerchantStaffMapper; import cn.com.glsx.merchants.mapper.MerchantStaffMapper;
import cn.com.glsx.merchants.mapper.BeisenEmployeeInfoMapper;
import cn.com.glsx.merchants.model.MerchantCompareModel; import cn.com.glsx.merchants.model.MerchantCompareModel;
import cn.com.glsx.merchants.model.request.*; import cn.com.glsx.merchants.model.request.*;
import cn.com.glsx.merchants.model.request.serviceCenter.SearchMerchantRpcRequest; import cn.com.glsx.merchants.model.request.serviceCenter.SearchMerchantRpcRequest;
...@@ -34,6 +35,7 @@ import cn.com.glsx.merchants.model.response.staff.StaffCountRpcResponse; ...@@ -34,6 +35,7 @@ import cn.com.glsx.merchants.model.response.staff.StaffCountRpcResponse;
import cn.com.glsx.merchants.model.response.staff.VisualMerchantListRpcResponse; import cn.com.glsx.merchants.model.response.staff.VisualMerchantListRpcResponse;
import cn.com.glsx.merchants.util.*; import cn.com.glsx.merchants.util.*;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.text.NamingCase;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
...@@ -126,6 +128,8 @@ public class MerchantStaffService { ...@@ -126,6 +128,8 @@ public class MerchantStaffService {
@Qualifier("merchantMapper") @Qualifier("merchantMapper")
@Autowired @Autowired
private MerchantMapper merchantMapper; private MerchantMapper merchantMapper;
@Autowired
private BeisenEmployeeInfoMapper beisenEmployeeInfoMapper;
@BeiSenNotice(type = AccountEventSyncBeiSenEnum.CREATE_ACCOUNT, description = "创建账户") @BeiSenNotice(type = AccountEventSyncBeiSenEnum.CREATE_ACCOUNT, description = "创建账户")
@Transactional(rollbackFor = RpcServiceException.class) @Transactional(rollbackFor = RpcServiceException.class)
...@@ -1496,9 +1500,38 @@ public class MerchantStaffService { ...@@ -1496,9 +1500,38 @@ public class MerchantStaffService {
// 推送修改员工消息 // 推送修改员工消息
ThreadUtil.execute(()->sendStaffMessage(merchantStaff1.getStaffUuid())); ThreadUtil.execute(()->sendStaffMessage(merchantStaff1.getStaffUuid()));
} }
/**
* 查询北森员工列表
*/
public RpcPagination<BeiSenEmployeeListResonseDTO> getBeisenUserWithConditions(RpcPagination<BeiSenEmployeeListRequestDTO> request) { public RpcPagination<BeiSenEmployeeListResonseDTO> getBeisenUserWithConditions(RpcPagination<BeiSenEmployeeListRequestDTO> request) {
// TODO Auto-generated method stub RpcAssert.assertNotNull(request, DefaultErrorEnum.DATA_NULL, "pagination must not be null");
throw new UnsupportedOperationException("Unimplemented method 'getBeisenUserWithConditions'"); BeiSenEmployeeListRequestDTO condition = Optional.ofNullable(request.getCondition()).orElse(new BeiSenEmployeeListRequestDTO());
if (StringUtils.isNotEmpty(condition.getSortField())) {
String sortOrder = StringUtils.isNotEmpty(condition.getSortOrder()) ? condition.getSortOrder().toLowerCase() : "desc";
sortOrder = ("asc".equals(sortOrder) || "desc".equals(sortOrder)) ? sortOrder : "desc";
condition.setSortOrder(sortOrder);
condition.setSortField(toSnake(condition.getSortField()));
}
condition.setStatus(null);
PageHelper.startPage(request.getPageNum(), request.getPageSize());
List<BeiSenEmployeeListResonseDTO> responseList = beisenEmployeeInfoMapper.selectByConditions(condition);
if (CollectionUtils.isEmpty(responseList)) {
return RpcPagination.copyPage(Collections.emptyList());
}
return RpcPagination.copyPage(responseList);
}
/**
* 排序字段驼峰转下划线
* 先走白名单避免缩略词误拆分,再使用 Hutool 转换。
*/
private String toSnake(String camel) {
if (StringUtils.isEmpty(camel)) return camel;
Map<String, String> whiteMap = new HashMap<>();
whiteMap.put("userID", "user_id");
whiteMap.put("oIdJobPostId", "oId_job_post_id");
whiteMap.put("oldDepartmentId", "old_department_id");
String mapped = whiteMap.get(camel);
if (mapped != null) return mapped;
return NamingCase.toUnderlineCase(camel);
} }
} }
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
<id column="user_id" jdbcType="INTEGER" property="userId" /> <id column="user_id" jdbcType="INTEGER" property="userID" />
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="name_pinyin" jdbcType="VARCHAR" property="namePinyin" /> <result column="name_pinyin" jdbcType="VARCHAR" property="_Name" />
<result column="phonetic_of_xing" jdbcType="VARCHAR" property="phoneticOfXing" /> <result column="phonetic_of_xing" jdbcType="VARCHAR" property="phoneticOfXing" />
<result column="phonetic_of_ming" jdbcType="VARCHAR" property="phoneticOfMing" /> <result column="phonetic_of_ming" jdbcType="VARCHAR" property="phoneticOfMing" />
<result column="gender" jdbcType="TINYINT" property="gender" /> <result column="gender" jdbcType="TINYINT" property="gender" />
<result column="email" jdbcType="VARCHAR" property="email" /> <result column="email" jdbcType="VARCHAR" property="email" />
<result column="id_type" jdbcType="VARCHAR" property="idType" /> <result column="id_type" jdbcType="VARCHAR" property="iDType" />
<result column="id_number" jdbcType="VARCHAR" property="idNumber" /> <result column="id_number" jdbcType="VARCHAR" property="iDNumber" />
<result column="time_zone" jdbcType="VARCHAR" property="timeZone" /> <result column="time_zone" jdbcType="VARCHAR" property="timeZone" />
<result column="is_long_term_certificate" jdbcType="BIT" property="isLongTermCertificate" /> <result column="is_long_term_certificate" jdbcType="BIT" property="isLongTermCertificate" />
<result column="certificate_start_date" jdbcType="DATE" property="certificateStartDate" /> <result column="certificate_start_date" jdbcType="DATE" property="certificateStartDate" />
...@@ -89,7 +89,9 @@ ...@@ -89,7 +89,9 @@
<result column="about_me" jdbcType="LONGVARCHAR" property="aboutMe" /> <result column="about_me" jdbcType="LONGVARCHAR" property="aboutMe" />
<result column="business_address" jdbcType="LONGVARCHAR" property="businessAddress" /> <result column="business_address" jdbcType="LONGVARCHAR" property="businessAddress" />
<result column="old_department_id" jdbcType="INTEGER" property="oldDepartmentId" /> <result column="old_department_id" jdbcType="INTEGER" property="oldDepartmentId" />
<result column="old_job_post_id" jdbcType="VARCHAR" property="oldJobPostId" /> <result column="old_job_post_id" jdbcType="VARCHAR" property="oIdJobPostId" />
</resultMap>
<resultMap id="DTOResultMap" extends="BaseResultMap" type="cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListResonseDTO">
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -118,4 +120,54 @@ ...@@ -118,4 +120,54 @@
from beisen_employee_info from beisen_employee_info
where user_id = #{userId} where user_id = #{userId}
</select> </select>
<select id="selectByConditions" parameterType="cn.com.glsx.merchants.dto.beisen.BeiSenEmployeeListRequestDTO" resultMap="DTOResultMap">
select
*
from beisen_employee_info
<where>
<if test="req.userIds != null and req.userIds.size > 0">
and user_id in
<foreach collection="req.userIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="req.employeeName != null and req.employeeName != ''">
and `name` like concat('%', #{req.employeeName}, '%')
</if>
<if test="req.mobilePhoneList != null and req.mobilePhoneList.size > 0">
and mobile_phone in
<foreach collection="req.mobilePhoneList" item="mp" open="(" separator="," close=")">
#{mp}
</foreach>
</if>
<if test="((req.mobilePhoneList == null or req.mobilePhoneList.size == 0)) and req.mobilePhone != null and req.mobilePhone != ''">
and mobile_phone like concat('%', #{req.mobilePhone}, '%')
</if>
<if test="req.status != null">
and zz_status = #{req.status}
</if>
<if test="req.entryStartDate != null">
and entry_date &gt;= #{req.entryStartDate}
</if>
<if test="req.entryEndDate != null">
and entry_date &lt;= #{req.entryEndDate}
</if>
<if test="req.oIdJobPostIds != null and req.oIdJobPostIds.size > 0">
and oId_job_post_id in
<foreach collection="req.oIdJobPostIds" item="jp" open="(" separator="," close=")">
#{jp}
</foreach>
</if>
<if test="req.oIdDepartmentIds != null and req.oIdDepartmentIds.size > 0">
and old_department_id in
<foreach collection="req.oIdDepartmentIds" item="dp" open="(" separator="," close=")">
#{dp}
</foreach>
</if>
</where>
<if test="req.sortField != null and req.sortField != '' and req.sortOrder != null and req.sortOrder != ''">
order by ${req.sortField} ${req.sortOrder}
</if>
</select>
</mapper> </mapper>
...@@ -301,11 +301,15 @@ public class StaffServiceTest { ...@@ -301,11 +301,15 @@ public class StaffServiceTest {
} }
@Test @Test
public void getBeisenUserWithConditionsTest(){ public void getBeisenUserWithConditionsTest() {
try {
RpcPagination<BeiSenEmployeeListRequestDTO> request = new RpcPagination<BeiSenEmployeeListRequestDTO>(); RpcPagination<BeiSenEmployeeListRequestDTO> request = new RpcPagination<BeiSenEmployeeListRequestDTO>();
request.setPageNum(1); request.setPageNum(1);
request.setPageSize(10); request.setPageSize(10);
RpcPagination<BeiSenEmployeeListResonseDTO> response = merchantStaffService.getBeisenUserWithConditions(request); RpcPagination<BeiSenEmployeeListResonseDTO> response = merchantStaffService.getBeisenUserWithConditions(request);
System.out.println(response); System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!