parent
c6a549a046
commit
8202e5526e
@ -0,0 +1,94 @@
|
||||
package cn.jyjz.xiaoyao.ocr.controller;
|
||||
|
||||
import cn.jyjz.xiaoyao.common.base.service.UserTokenService;
|
||||
import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil;
|
||||
import cn.jyjz.xiaoyao.common.base.vo.UserToken;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrMsgRead;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import cn.jyjz.xiaoyao.ocr.service.IOcrSearchHistoryService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ocr控制器
|
||||
*
|
||||
* @author 你的肉
|
||||
* @Date 2024-03-15 19:53:30
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/ocr/history")
|
||||
public class OcrSearchHistoryController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IOcrSearchHistoryService ocrSearchHistoryService;
|
||||
|
||||
@Autowired
|
||||
private UserTokenService userTokenService;
|
||||
|
||||
/**
|
||||
* 搜索查询
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/searchList", method = RequestMethod.GET)
|
||||
public ResponseEntity<?> searchList(HttpServletRequest request,
|
||||
@RequestParam(value = "search", required = false) String search) {
|
||||
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request));
|
||||
//执行查询方法
|
||||
List<String> selectsearch = ocrSearchHistoryService.selectsearch(search, userToken.getUsername());
|
||||
|
||||
OcrSearchHistory ocrsearchhistory =new OcrSearchHistory();
|
||||
ocrsearchhistory.setHistoryname(search);
|
||||
ocrsearchhistory.setUserid(Long.valueOf(userToken.getUserid()));
|
||||
ocrsearchhistory.setCreatedate(System.currentTimeMillis());
|
||||
ocrSearchHistoryService.save(ocrsearchhistory);
|
||||
|
||||
return new ResponseEntity<Object>(selectsearch, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过 删除历史记录
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/searchdelete", method = RequestMethod.DELETE)
|
||||
public ResponseEntity<?> searchdelete(HttpServletRequest request) {
|
||||
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request));
|
||||
QueryWrapper<OcrSearchHistory> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("userid",userToken.getUserid());
|
||||
//根据具体情况 判断 是否需要 进行数据返回, 默认不返回数据
|
||||
ocrSearchHistoryService.remove(wrapper);
|
||||
return new ResponseEntity<Object>("true",HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史搜索
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/historySearch", method = RequestMethod.GET)
|
||||
public ResponseEntity<?> historySearch(HttpServletRequest request) {
|
||||
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request));
|
||||
|
||||
QueryWrapper<OcrSearchHistory> wrapper = new QueryWrapper<>();
|
||||
wrapper.select("historyname","createdate").eq("userid",userToken.getUserid()).orderByDesc("createdate").last("limit 8");
|
||||
List<OcrSearchHistory> list = ocrSearchHistoryService.list(wrapper);
|
||||
|
||||
return new ResponseEntity<List<OcrSearchHistory>>(list, HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataDao;
|
||||
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import liquibase.pro.packaged.S;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface OcrSearchHistoryMapper extends BaseMapper<OcrSearchHistory> {
|
||||
List<String> selectsearch(@Param("search")String search,@Param("assignee") String assignee);
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
@TableName("ocr_search_history")
|
||||
public class OcrSearchHistory extends Model<OcrSearchHistory> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 历史主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
/**
|
||||
* 搜索历史名称
|
||||
*/
|
||||
private String historyname;
|
||||
|
||||
public Long getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(Long userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long userid;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long createdate;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getHistoryname() {
|
||||
return historyname;
|
||||
}
|
||||
|
||||
public void setHistoryname(String historyname) {
|
||||
this.historyname = historyname;
|
||||
}
|
||||
|
||||
public Long getCreatedate() {
|
||||
return createdate;
|
||||
}
|
||||
|
||||
public void setCreatedate(Long createdate) {
|
||||
this.createdate = createdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OcrSearchHistory{" +
|
||||
"id=" + id +
|
||||
", historyname=" + historyname +
|
||||
", userid=" + userid +
|
||||
", createdate=" + createdate +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.jyjz.xiaoyao.ocr.service;
|
||||
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
public interface IOcrSearchHistoryService extends IService<OcrSearchHistory> {
|
||||
List<String> selectsearch(String search,String assignee);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.jyjz.xiaoyao.ocr.service.impl;
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import cn.jyjz.xiaoyao.ocr.service.IOcrSearchHistoryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.jyjz.xiaoyao.ocr.dataDao.OcrSearchHistoryMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
@Service
|
||||
public class OcrSearchHistoryServiceImpl extends ServiceImpl<OcrSearchHistoryMapper, OcrSearchHistory> implements IOcrSearchHistoryService {
|
||||
|
||||
@Resource
|
||||
OcrSearchHistoryMapper ocrsearchhistorymapper;
|
||||
|
||||
@Override
|
||||
public List<String> selectsearch(String search, String assignee) {
|
||||
return ocrsearchhistorymapper.selectsearch(search,assignee);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.jyjz.xiaoyao.ocr.util;
|
||||
/**
|
||||
* 分页请求
|
||||
*/
|
||||
public class PageRequest {
|
||||
/**
|
||||
* 当前页码
|
||||
*/
|
||||
private int pageNum;
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
private int pageSize;
|
||||
|
||||
public int getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
public void setPageNum(int pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?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="cn.jyjz.xiaoyao.ocr.dataDao.OcrSearchHistoryMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory">
|
||||
<id column="id" property="id" />
|
||||
<result column="historyname" property="historyname" />
|
||||
<result column="userid" property="userid" />
|
||||
<result column="createdate" property="createdate" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, historyname, userid, createdate
|
||||
</sql>
|
||||
|
||||
<select id="selectsearch" resultType="map">
|
||||
|
||||
SELECT
|
||||
|
||||
CONCAT_WS("-",r.FROMTASKNAME,t.planName) as name
|
||||
FROM
|
||||
ocr_taskchild_picture r
|
||||
LEFT JOIN ocr_picture t ON r.PICTUREID = t.ID
|
||||
WHERE
|
||||
r.STATES='1'
|
||||
and
|
||||
r.ASSIGNEE=#{assignee}
|
||||
AND
|
||||
r.FROMTASKID like "%"#{search}"%"
|
||||
OR r.FROMTASKNAME like "%"#{search}"%"
|
||||
OR t.field1 like "%"#{search}"%"
|
||||
ORDER BY r.CREATEDATE DESC
|
||||
LIMIT 3
|
||||
|
||||
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in new issue