123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- package com.qxgmat.service.inline;
- import com.github.pagehelper.Page;
- import com.nuliji.tools.AbstractService;
- import com.nuliji.tools.Tools;
- import com.nuliji.tools.Transform;
- import com.nuliji.tools.exception.ParameterException;
- import com.nuliji.tools.exception.SystemException;
- import com.nuliji.tools.mybatis.Example;
- import com.qxgmat.data.constants.enums.module.FeedbackModule;
- import com.qxgmat.data.constants.enums.status.DirectionStatus;
- import com.qxgmat.data.constants.enums.status.FeedbackStatus;
- import com.qxgmat.data.constants.enums.user.MoneyRange;
- import com.qxgmat.data.dao.UserFeedbackErrorMapper;
- import com.qxgmat.data.dao.entity.UserFeedbackError;
- import com.qxgmat.data.relation.UserFeedbackErrorRelationMapper;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.Collection;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- @Service
- public class UserFeedbackErrorService extends AbstractService {
- private static final Logger logger = LoggerFactory.getLogger(UserFeedbackErrorService.class);
- @Resource
- private UserFeedbackErrorMapper userFeedbackErrorMapper;
- @Resource
- private UserFeedbackErrorRelationMapper userFeedbackErrorRelationMapper;
- private Map<String, String> adminMap = new HashMap<String, String>(){{
- put("", "ufe");
- }};
- public Page<UserFeedbackError> listAdmin(int page, int size, FeedbackModule module, FeedbackStatus status, String questionType, String target, Integer moduleId, String keyword, Integer userId, MoneyRange moneyRange, String order, DirectionStatus direction){
- String moduleKey = module == null ? null : module.key;
- Integer statusIndex = status == null ? null : status.index;
- Integer max = moneyRange != null ? moneyRange.max == Integer.MAX_VALUE ? null : moneyRange.max : null;
- Integer min = moneyRange != null ? moneyRange.min : null;
- if(order == null || order.isEmpty()){
- order = "id";
- }
- if(adminMap.containsKey(order)){
- order = adminMap.get(order)+".`"+Tools.underscoreName(order)+"`";
- }else{
- order = adminMap.get("")+".`"+Tools.underscoreName(order)+"`";
- }
- if (direction == null){
- direction = DirectionStatus.DESC;
- }
- String finalOrder = order;
- DirectionStatus finalDirection = direction;
- Page<UserFeedbackError> p = page(
- ()-> userFeedbackErrorRelationMapper.listAdmin(moduleKey, statusIndex, questionType, target, moduleId, userId, keyword, min, max, finalOrder, finalDirection.key)
- , page, size);
- Collection ids = Transform.getIds(p, UserFeedbackError.class, "id");
- Transform.replace(p, select(ids), UserFeedbackError.class, "id");
- return p;
- }
- public UserFeedbackError add(UserFeedbackError feedbackError){
- int result = insert(userFeedbackErrorMapper, feedbackError);
- feedbackError = one(userFeedbackErrorMapper, feedbackError.getId());
- if(feedbackError == null){
- throw new SystemException("勘误添加失败");
- }
- return feedbackError;
- }
- public UserFeedbackError edit(UserFeedbackError feedbackError){
- UserFeedbackError in = one(userFeedbackErrorMapper, feedbackError.getId());
- if(in == null){
- throw new ParameterException("勘误不存在");
- }
- int result = update(userFeedbackErrorMapper, feedbackError);
- return feedbackError;
- }
- public boolean delete(Number id){
- UserFeedbackError in = one(userFeedbackErrorMapper, id);
- if(in == null){
- throw new ParameterException("勘误不存在");
- }
- int result = delete(userFeedbackErrorMapper, id);
- return result > 0;
- }
- public UserFeedbackError get(Number id){
- UserFeedbackError in = one(userFeedbackErrorMapper, id);
- if(in == null){
- throw new ParameterException("勘误不存在");
- }
- return in;
- }
- public Page<UserFeedbackError> select(int page, int pageSize){
- return select(userFeedbackErrorMapper, page, pageSize);
- }
- public Page<UserFeedbackError> select(Integer[] ids){
- return page(()->select(userFeedbackErrorMapper, ids), 1, ids.length);
- }
- public List<UserFeedbackError> select(Collection ids){
- return select(userFeedbackErrorMapper, ids);
- }
- }
|