Commit bab2254465eb1a417b935dde998969cdb2a896a2

Authored by 房远帅
1 parent d8763cdc

框架合同:移动端搜索

... ... @@ -98,6 +98,14 @@ public class ContractFrameworkController extends DefaultBaseController {
98 98
99 99 vo.setCustomerIdList(customerList.stream().map(Customer::getId).collect(Collectors.toList()));
100 100 }
  101 + if (vo != null && StringUtils.isNotBlank(vo.getKeyword())) {
  102 + QueryCustomerVo queryCustomerVo = new QueryCustomerVo();
  103 + queryCustomerVo.setName(vo.getKeyword());
  104 + List<Customer> customerList = customerService.query(queryCustomerVo);
  105 + if (CollectionUtils.isNotEmpty(customerList)) {
  106 + vo.setCustomerIdList(customerList.stream().map(Customer::getId).collect(Collectors.toList()));
  107 + }
  108 + }
101 109
102 110 PageResult<ContractFramework> pageResult = contractFrameworkService.query(getPageIndex(vo), getPageSize(vo), vo);
103 111
... ...
... ... @@ -92,4 +92,10 @@ public class QueryContractFrameworkVo extends PageVo implements BaseVo, Serializ
92 92 */
93 93 @ApiModelProperty("客户Id集合")
94 94 private List<String> customerIdList;
  95 +
  96 + /**
  97 + * 移动端搜索
  98 + */
  99 + @ApiModelProperty("移动端搜索")
  100 + private String keyword;
95 101 }
... ...
... ... @@ -63,12 +63,31 @@
63 63 <if test="vo.validityTimeEnd != null">
64 64 AND tb.validity_time &lt;= #{vo.validityTimeEnd}
65 65 </if>
66   - <if test="vo.customerIdList != null and vo.customerIdList.size() > 0">
67   - AND tb.customer_id IN
68   - <foreach collection="vo.customerIdList" open="(" separator="," close=")" item="item">
69   - #{item}
70   - </foreach>
71   - </if>
  66 + <choose>
  67 + <!-- 情况1:customerIdList 和 keyword 都有值 -->
  68 + <when test="vo.customerIdList != null and vo.customerIdList.size() > 0 and vo.keyword != null and vo.keyword != ''">
  69 + AND (
  70 + tb.customer_id IN
  71 + <foreach collection="vo.customerIdList" open="(" separator="," close=")" item="item">
  72 + #{item}
  73 + </foreach>
  74 + OR tb.code LIKE CONCAT('%', #{vo.keyword}, '%')
  75 + )
  76 + </when>
  77 +
  78 + <!-- 情况2:只有 customerIdList 有值 -->
  79 + <when test="vo.customerIdList != null and vo.customerIdList.size() > 0">
  80 + AND tb.customer_id IN
  81 + <foreach collection="vo.customerIdList" open="(" separator="," close=")" item="item">
  82 + #{item}
  83 + </foreach>
  84 + </when>
  85 +
  86 + <!-- 情况3:只有 keyword 有值 -->
  87 + <when test="vo.keyword != null and vo.keyword != ''">
  88 + AND tb.code LIKE CONCAT('%', #{vo.keyword}, '%')
  89 + </when>
  90 + </choose>
72 91 </where>
73 92 order by tb.create_time desc
74 93 </select>
... ...