Commit d9b31eb76102a03d722f1a908ff5aa141d86b381
1 parent
b2572cd4
feat: 公司历史搜索
Showing
8 changed files
with
139 additions
and
0 deletions
trash-garbage/src/main/java/com/trash/garbage/controller/GarbageOrderController.java
| ... | ... | @@ -149,6 +149,12 @@ public class GarbageOrderController { |
| 149 | 149 | return Result.OK(garOrderService.queryEnterpriseList(enterprise)); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | + @GetMapping("/search/history") | |
| 153 | + public Result<?> querySearchHistory(){ | |
| 154 | + return Result.OK(garOrderService.querySearchHistory()); | |
| 155 | + } | |
| 156 | + | |
| 157 | + | |
| 152 | 158 | protected void startPage() { |
| 153 | 159 | PageDomain pageDomain = TableSupport.buildPageRequest(); |
| 154 | 160 | Integer pageNum = pageDomain.getPageNum(); | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarSearchHistoryMapper.java
0 → 100644
| 1 | +package com.trash.garbage.mapper; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
| 4 | +import com.trash.garbage.pojo.domain.GarSearchHistory; | |
| 5 | +import com.trash.garbage.pojo.domain.GarUser; | |
| 6 | + | |
| 7 | +public interface GarSearchHistoryMapper extends BaseMapper<GarSearchHistory> { | |
| 8 | +} | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarSearchHistory.java
0 → 100644
| 1 | +package com.trash.garbage.pojo.domain; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 4 | +import org.apache.commons.lang3.builder.EqualsBuilder; | |
| 5 | +import org.apache.commons.lang3.builder.HashCodeBuilder; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 搜索历史 | |
| 9 | + * @author 20412 | |
| 10 | + */ | |
| 11 | +@TableName(value ="gar_search_history") | |
| 12 | +public class GarSearchHistory { | |
| 13 | + private String garSearchId; | |
| 14 | + private String garSearchValue; | |
| 15 | + private Long garSearchTimestamp; | |
| 16 | + private String garCreateBy; | |
| 17 | + | |
| 18 | + public String getGarSearchId() { | |
| 19 | + return garSearchId; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setGarSearchId(String garSearchId) { | |
| 23 | + this.garSearchId = garSearchId; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public String getGarSearchValue() { | |
| 27 | + return garSearchValue; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void setGarSearchValue(String garSearchValue) { | |
| 31 | + this.garSearchValue = garSearchValue; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public Long getGarSearchTimestamp() { | |
| 35 | + return garSearchTimestamp; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setGarSearchTimestamp(Long garSearchTimestamp) { | |
| 39 | + this.garSearchTimestamp = garSearchTimestamp; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public String getGarCreateBy() { | |
| 43 | + return garCreateBy; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public void setGarCreateBy(String garCreateBy) { | |
| 47 | + this.garCreateBy = garCreateBy; | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public String toString() { | |
| 52 | + return "GarSearchHistory{" + | |
| 53 | + "garSearchId='" + garSearchId + '\'' + | |
| 54 | + ", garSearchValue='" + garSearchValue + '\'' + | |
| 55 | + ", garSearchTimestamp=" + garSearchTimestamp + | |
| 56 | + ", createBy='" + garCreateBy + '\'' + | |
| 57 | + '}'; | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public boolean equals(Object o) { | |
| 62 | + if (this == o) return true; | |
| 63 | + | |
| 64 | + if (o == null || getClass() != o.getClass()) return false; | |
| 65 | + | |
| 66 | + GarSearchHistory that = (GarSearchHistory) o; | |
| 67 | + | |
| 68 | + return new EqualsBuilder().append(garSearchId, that.garSearchId).append(garSearchValue, that.garSearchValue).append(garSearchTimestamp, that.garSearchTimestamp).append(garCreateBy, that.garCreateBy).isEquals(); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public int hashCode() { | |
| 73 | + return new HashCodeBuilder(17, 37).append(garSearchId).append(garSearchValue).append(garSearchTimestamp).append(garCreateBy).toHashCode(); | |
| 74 | + } | |
| 75 | +} | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/service/GarOrderService.java
trash-garbage/src/main/java/com/trash/garbage/service/GarSearchHistoryService.java
0 → 100644
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderServiceImpl.java
| ... | ... | @@ -51,6 +51,9 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> |
| 51 | 51 | private GarOrderEvaluateService garOrderEvaluateService; |
| 52 | 52 | |
| 53 | 53 | @Autowired |
| 54 | + private GarSearchHistoryService garSearchHistoryService; | |
| 55 | + | |
| 56 | + @Autowired | |
| 54 | 57 | private GarUserService garUserService; |
| 55 | 58 | |
| 56 | 59 | @Autowired |
| ... | ... | @@ -379,6 +382,7 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> |
| 379 | 382 | public static void main(String[] args) { |
| 380 | 383 | System.out.println(convert("PAYPALISHIRING", 3)); |
| 381 | 384 | } |
| 385 | + | |
| 382 | 386 | public static String convert(String s, int numRows) { |
| 383 | 387 | if (numRows == 1) { |
| 384 | 388 | return s; |
| ... | ... | @@ -578,6 +582,18 @@ public class GarOrderServiceImpl extends ServiceImpl<GarOrderMapper, GarOrder> |
| 578 | 582 | return list; |
| 579 | 583 | } |
| 580 | 584 | |
| 585 | + @Override | |
| 586 | + public PageInfo querySearchHistory() { | |
| 587 | + // 查询历史搜索记录 最多返回8个历史搜索 | |
| 588 | + PageHelper.startPage(1, 8); | |
| 589 | + String userId = SecurityUtils.getLoginUser().getUser().getUserId(); | |
| 590 | + LambdaQueryWrapper<GarSearchHistory> qw = new LambdaQueryWrapper<>(); | |
| 591 | + qw.eq(GarSearchHistory::getGarCreateBy, userId); | |
| 592 | + List<GarSearchHistory> list = garSearchHistoryService.list(qw); | |
| 593 | + PageInfo<GarSearchHistory> page = new PageInfo<>(list); | |
| 594 | + return page; | |
| 595 | + } | |
| 596 | + | |
| 581 | 597 | private void handleCleanNumber(TransportationEnterpriseVo vo, List<GarOrder> orderList) { |
| 582 | 598 | Long cleanNumber = 0L; |
| 583 | 599 | for (GarOrder order : orderList) { | ... | ... |
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarSearchHistoryServiceImpl.java
0 → 100644
| 1 | +package com.trash.garbage.service.impl; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
| 4 | +import com.trash.garbage.mapper.GarSearchHistoryMapper; | |
| 5 | +import com.trash.garbage.pojo.domain.GarSearchHistory; | |
| 6 | +import com.trash.garbage.service.GarSearchHistoryService; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | + | |
| 9 | +@Service | |
| 10 | +public class GarSearchHistoryServiceImpl extends ServiceImpl<GarSearchHistoryMapper, GarSearchHistory> | |
| 11 | + implements GarSearchHistoryService { | |
| 12 | +} | ... | ... |
trash-garbage/src/main/resources/mapper/GarSearchHistoryMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper | |
| 3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |
| 4 | + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 5 | +<mapper namespace="com.trash.garbage.mapper.GarSearchHistoryMapper"> | |
| 6 | + <resultMap id="BaseResultMap" type="com.trash.garbage.pojo.domain.GarSearchHistory"> | |
| 7 | + <id property="garSearchId" column="gar_search_id" jdbcType="VARCHAR"/> | |
| 8 | + <result property="garSearchTimestamp" column="gar_search_timestamp" jdbcType="VARCHAR"/> | |
| 9 | + <result property="garSearchValue" column="gar_search_value" jdbcType="VARCHAR"/> | |
| 10 | + <result property="garCreateBy" column="gar_create_by" jdbcType="VARCHAR"/> | |
| 11 | + </resultMap> | |
| 12 | + | |
| 13 | +</mapper> | |
| 0 | 14 | \ No newline at end of file | ... | ... |