|
@@ -1,25 +1,20 @@
|
|
|
package cn.cslg.pas.service.upLoadPatent;
|
|
|
|
|
|
-import cn.cslg.pas.common.model.vo.AdminUserVO;
|
|
|
+import cn.cslg.pas.common.model.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.model.dto.RetrieveRecordDTO;
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.Response;
|
|
|
-import cn.cslg.pas.common.utils.StringUtils;
|
|
|
-import cn.cslg.pas.domain.AdminUser;
|
|
|
+import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.pas.domain.RetrieveRecord;
|
|
|
-import cn.cslg.pas.mapper.AdminUserMapper;
|
|
|
import cn.cslg.pas.mapper.RetrieveRecordMapper;
|
|
|
-import cn.hutool.crypto.SecureUtil;
|
|
|
-import com.baomidou.mybatisplus.annotation.IdType;
|
|
|
-import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
-import com.baomidou.mybatisplus.annotation.TableId;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -32,9 +27,81 @@ import java.util.Date;
|
|
|
@Service
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class RetrieveRecordService extends ServiceImpl<RetrieveRecordMapper, RetrieveRecord> {
|
|
|
+ private final CacheUtils cacheUtils;
|
|
|
+ private final LoginUtils loginUtils;
|
|
|
|
|
|
- public void addRetrieveRecord(){
|
|
|
+ /**
|
|
|
+ * 新增检索记录
|
|
|
+ * @param retrieveRecordDTO
|
|
|
+ */
|
|
|
+ public String addRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO){
|
|
|
+ //判空
|
|
|
+ if(retrieveRecordDTO != null){
|
|
|
+ //新建实体类
|
|
|
+ RetrieveRecord retrieveRecord = new RetrieveRecord();
|
|
|
+ //复制
|
|
|
+ BeanUtils.copyProperties(retrieveRecordDTO, retrieveRecord);
|
|
|
+ //获取创建人信息
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ retrieveRecord.setCreateId(personnelVO.getId());
|
|
|
+ retrieveRecord.setTenantId(personnelVO.getTenantId());
|
|
|
+ //数据入表
|
|
|
+ retrieveRecord.insert();
|
|
|
+ return Response.success("新增成功");
|
|
|
+ } else {
|
|
|
+ return Response.error("传入参数不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新检索记录表
|
|
|
+ * @param retrieveRecordDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String updateRetrieveRecord(RetrieveRecordDTO retrieveRecordDTO){
|
|
|
+ //判空
|
|
|
+ if(retrieveRecordDTO != null){
|
|
|
+ Integer id = retrieveRecordDTO.getId();
|
|
|
+ //根据传入对象的id查询出实体类
|
|
|
+ RetrieveRecord retrieveRecord = this.getById(id);
|
|
|
+ //更新数据
|
|
|
+ BeanUtils.copyProperties(retrieveRecordDTO, retrieveRecord);
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ retrieveRecord.setCreateId(personnelVO.getId());
|
|
|
+ retrieveRecord.setTenantId(personnelVO.getTenantId());
|
|
|
+ retrieveRecord.updateById();
|
|
|
+ return Response.success("更新成功");
|
|
|
+ } else {
|
|
|
+ return Response.error("更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除检索历史
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String deleteRetrieveRecord(List<Integer> ids){
|
|
|
+ //判空
|
|
|
+ if(ids != null && ids.size() > 0){
|
|
|
+ this.removeByIds(ids);
|
|
|
+ return Response.success("删除成功");
|
|
|
+ } else {
|
|
|
+ return Response.error("删除错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询检索历史
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<RetrieveRecord> queryRetrieveRecord(){
|
|
|
+ //获取当前登陆人信息
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ Integer createId = personnelVO.getId();
|
|
|
+ LambdaQueryWrapper<RetrieveRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(RetrieveRecord::getCreateId, createId);
|
|
|
+ List<RetrieveRecord> retrieveRecords = this.list(queryWrapper);
|
|
|
+ return retrieveRecords;
|
|
|
}
|
|
|
}
|