This commit is contained in:
ran.shang
2025-06-11 09:42:13 +08:00
commit 7e38b8d971
1935 changed files with 132836 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package com.newyetai.usercenter.searchHistory.controller;
import com.newyetai.common.AlitaResult;
import com.newyetai.tkmybatis.pojo.Page;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryCreateDTO;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryInfoDTO;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryPageQueryDTO;
import com.newyetai.usercenter.searchHistory.service.SearchHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author czy on 2021-03-25
*/
@RestController
@RequestMapping("search_history")
@Api(tags = "搜索记录")
public class SearchHistoryController {
@Autowired
private SearchHistoryService searchHistoryService;
@PostMapping("/create")
@ApiOperation("创建")
public AlitaResult<Void> create(@RequestBody SearchHistoryCreateDTO createDTO) {
searchHistoryService.create(createDTO);
return AlitaResult.success();
}
@GetMapping("/page")
@ApiOperation("列表")
public AlitaResult<Page<SearchHistoryInfoDTO>> page(SearchHistoryPageQueryDTO pageQueryDTO) {
searchHistoryService.page(pageQueryDTO);
return AlitaResult.success(pageQueryDTO.getPageResult());
}
@PostMapping("/clean_all")
@ApiOperation("删除")
public AlitaResult<Void> cleanAll() {
searchHistoryService.cleanAll();
return AlitaResult.success();
}
}

View File

@@ -0,0 +1,22 @@
package com.newyetai.usercenter.searchHistory.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryInfoDTO;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryPageQueryDTO;
import com.newyetai.usercenter.searchHistory.entity.SearchHistory;
import java.util.List;
/**
* 搜索历史映射器
*
* @author Carlye
* @date 2021/10/22
*/
public interface SearchHistoryMapper extends BaseMapper<SearchHistory> {
List<SearchHistoryInfoDTO> page(SearchHistoryPageQueryDTO queryDTO);
}

View File

@@ -0,0 +1,40 @@
package com.newyetai.usercenter.searchHistory.dto;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import com.newyetai.common.dto.BaseDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 搜索历史记录
*
* @author Carlye
* @date 2021/10/22
*/
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
public class SearchHistoryCreateDTO extends BaseDTO{
private static final long serialVersionUID = -4903984190748073753L;
/**
* 搜索内容
*/
@NotEmpty(message = "搜索内容不能为空")
private String context;
/**
* 搜索类目 1:招聘系统搜索记录
*/
@NotNull(message = "搜索类目不能为空")
private Integer type;
}

View File

@@ -0,0 +1,37 @@
package com.newyetai.usercenter.searchHistory.dto;
import com.newyetai.common.dto.BaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 搜索历史记录
*
* @author Carlye
* @date 2021/10/22
*/
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("搜索历史记录")
public class SearchHistoryInfoDTO extends BaseDTO{
private static final long serialVersionUID = 4107885503029801211L;
/**
* 搜索内容
*/
@ApiModelProperty("搜索内容")
private String context;
@ApiModelProperty("搜索次数")
private Integer count;
}

View File

@@ -0,0 +1,42 @@
package com.newyetai.usercenter.searchHistory.dto;
import com.newyetai.common.dto.PageQueryDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 搜索历史记录
*
* @author Carlye
* @date 2021/10/22
*/
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel("搜索历史记录 - 查询DTO")
public class SearchHistoryPageQueryDTO extends PageQueryDTO<SearchHistoryInfoDTO> {
private static final long serialVersionUID = 6186970573776391657L;
/**
* 搜索内容
*/
@ApiModelProperty("搜索内容")
private String context;
/**
* 搜索类目 1:招聘系统搜索记录
*/
@ApiModelProperty("搜索类目")
private Integer type;
private Long userId;
}

View File

@@ -0,0 +1,46 @@
package com.newyetai.usercenter.searchHistory.entity;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.newyetai.common.entity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 搜索历史记录
*
* @author Carlye
* @date 2021/10/22
*/
@TableName("xs_search_history")
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Data
public class SearchHistory extends BaseEntity implements Serializable {
private static final long serialVersionUID = 3512068172003223792L;
/**
* 搜索内容
*/
private String context;
/**
* 搜索类目 1:招聘系统搜索记录
*/
private Integer type;
/**
* 用户ID
*/
private Long userId;
}

View File

@@ -0,0 +1,38 @@
package com.newyetai.usercenter.searchHistory.enums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.newyetai.mybatis.handle.BaseEnum;
/**
* 关联类型枚举
*
* @author Carlye
* @date 2021/01/21
*/
public enum SearchHistoryTypeEnum implements BaseEnum<Integer> {
POST(1, "招聘系统搜索记录");
@EnumValue
private final Integer type;
private final String desc;
SearchHistoryTypeEnum(Integer type, String desc) {
this.type = type;
this.desc = desc;
}
public Integer getType() {
return type;
}
public String getDesc() {
return desc;
}
@Override
public Integer getValue() {
return type;
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.newyetai.usercenter.searchHistory.dao.SearchHistoryMapper">
<select id="page" resultType="com.newyetai.usercenter.searchHistory.dto.SearchHistoryInfoDTO">
SELECT
sh.context,
count(*) count
FROM
xs_search_history sh
WHERE
sh.deleted = 0 AND sh.user_id = #{userId}
GROUP BY
sh.context
ORDER BY
MAX( sh.id ) DESC
</select>
</mapper>

View File

@@ -0,0 +1,42 @@
package com.newyetai.usercenter.searchHistory.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryCreateDTO;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryInfoDTO;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryPageQueryDTO;
import com.newyetai.usercenter.searchHistory.entity.SearchHistory;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.groups.Default;
import java.util.List;
/**
* 搜索历史记录服务
*
* @author Carlye
* @date 2021/10/22
*/
@Validated(Default.class)
public interface SearchHistoryService extends IService<SearchHistory> {
/**
* 新建搜索记录
*
* @param createDTO 创建dto
*/
void create(@Valid SearchHistoryCreateDTO createDTO);
/**
* 分页查询搜索记录
*
* @param queryDTO 查询dto
* @return {@link List}<{@link SearchHistoryInfoDTO}>
*/
List<SearchHistoryInfoDTO> page(SearchHistoryPageQueryDTO queryDTO);
/**
* 清楚所有的搜搜记录
*/
void cleanAll();
}

View File

@@ -0,0 +1,47 @@
package com.newyetai.usercenter.searchHistory.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.newyetai.common.util.UserContextHolder;
import com.newyetai.usercenter.searchHistory.dao.SearchHistoryMapper;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryCreateDTO;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryInfoDTO;
import com.newyetai.usercenter.searchHistory.dto.SearchHistoryPageQueryDTO;
import com.newyetai.usercenter.searchHistory.entity.SearchHistory;
import com.newyetai.usercenter.searchHistory.service.SearchHistoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SearchHistoryServiceImpl extends ServiceImpl<SearchHistoryMapper, SearchHistory> implements SearchHistoryService {
@Override
public void create(SearchHistoryCreateDTO createDTO) {
save(SearchHistory.builder().context(createDTO.getContext()).type(createDTO.getType()).userId(UserContextHolder.getExistLoginUserId()).build());
}
@Override
public List<SearchHistoryInfoDTO> page(SearchHistoryPageQueryDTO queryDTO) {
queryDTO.setUserId(UserContextHolder.getExistLoginUserId());
return getBaseMapper().page(queryDTO);
}
@Override
public void cleanAll() {
update(Wrappers.<SearchHistory>lambdaUpdate()
.set(SearchHistory::getDeleted,true)
.set(SearchHistory::getUpdateBy,UserContextHolder.getExistLoginUserId())
.set(SearchHistory::getUpdateTime, DateUtil.date())
.eq(SearchHistory::getUserId,UserContextHolder.getExistLoginUserId())
.eq(SearchHistory::getDeleted,false)
);
}
}