123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package com.qxgmat.service.inline;
- import com.github.pagehelper.Page;
- import com.nuliji.tools.AbstractService;
- import com.nuliji.tools.exception.ParameterException;
- import com.nuliji.tools.exception.SystemException;
- import com.nuliji.tools.mybatis.Example;
- import com.qxgmat.data.constants.enums.user.ExportType;
- import com.qxgmat.data.dao.UserExportMapper;
- import com.qxgmat.data.dao.UserSearchHistoryMapper;
- import com.qxgmat.data.dao.entity.UserExport;
- import com.qxgmat.data.dao.entity.UserSearchHistory;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.Collection;
- import java.util.List;
- @Service
- public class UserSearchHistoryService extends AbstractService {
- private static final Logger logger = LoggerFactory.getLogger(UserSearchHistoryService.class);
- @Resource
- private UserSearchHistoryMapper userSearchHistoryMapper;
- public List<UserSearchHistory> listByUser(Integer userId, String startTime, String endTime){
- Example example = new Example(UserExport.class);
- example.and(
- example.createCriteria()
- .andEqualTo("userId", userId)
- .andGreaterThanOrEqualTo("createTime", startTime)
- .andLessThan("createTime", endTime)
- );
- return select(userSearchHistoryMapper, example);
- }
- public UserSearchHistory add(UserSearchHistory entity){
- int result = insert(userSearchHistoryMapper, entity);
- entity = one(userSearchHistoryMapper, entity.getId());
- if(entity == null){
- throw new SystemException("记录添加失败");
- }
- return entity;
- }
- public UserSearchHistory edit(UserSearchHistory entity){
- UserSearchHistory in = one(userSearchHistoryMapper, entity.getId());
- if(in == null){
- throw new ParameterException("记录不存在");
- }
- int result = update(userSearchHistoryMapper, entity);
- return entity;
- }
- public boolean delete(Number id){
- UserSearchHistory in = one(userSearchHistoryMapper, id);
- if(in == null){
- throw new ParameterException("记录不存在");
- }
- int result = delete(userSearchHistoryMapper, id);
- return result > 0;
- }
- public UserSearchHistory get(Number id){
- UserSearchHistory in = one(userSearchHistoryMapper, id);
- if(in == null){
- throw new ParameterException("记录不存在");
- }
- return in;
- }
- public Page<UserSearchHistory> select(int page, int pageSize){
- return select(userSearchHistoryMapper, page, pageSize);
- }
- public Page<UserSearchHistory> select(Integer[] ids){
- return page(()->select(userSearchHistoryMapper, ids), 1, ids.length);
- }
- public List<UserSearchHistory> select(Collection ids){
- return select(userSearchHistoryMapper, ids);
- }
- }
|