| | |
| | | package com.project.enforce.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.project.common.utils.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.project.enforce.domain.vo.EnforceEvaluateQuestionVo; |
| | | import com.project.enforce.domain.bo.editBo.EnforceEvaluateQuestionBo; |
| | | import com.project.enforce.domain.bo.queryBo.EnforceEvaluateQuestionQueryBo; |
| | | import com.project.enforce.domain.EnforceEvaluateQuestion; |
| | | import com.project.enforce.mapper.EnforceEvaluateQuestionMapper; |
| | | import com.project.enforce.service.IEnforceEvaluateQuestionService; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 执法评价题目Service业务层处理 |
| | |
| | | |
| | | |
| | | |
| | | @Override//列表查询 |
| | | public List<EnforceEvaluateQuestionVo> queryList(EnforceEvaluateQuestionQueryBo bo) |
| | | { |
| | | QueryWrapper<EnforceEvaluateQuestion> qw = getQw(bo); |
| | | List<EnforceEvaluateQuestion> list = this.list(qw); |
| | | return Convert.toList(EnforceEvaluateQuestionVo.class , list); |
| | | } |
| | | |
| | | @Override//id查询 |
| | | public EnforceEvaluateQuestionVo queryById(Long questionId) |
| | | { |
| | | EnforceEvaluateQuestion db = this.baseMapper.selectById(questionId); |
| | | return Convert.convert(EnforceEvaluateQuestionVo.class , db); |
| | | } |
| | | |
| | | |
| | | @Override//添加 |
| | | @Transactional |
| | | public Boolean insertByBo(EnforceEvaluateQuestionBo bo) |
| | | { |
| | | EnforceEvaluateQuestion add = Convert.convert(EnforceEvaluateQuestion.class, bo); |
| | | validEntityBeforeSave(add); |
| | | return this.save(add); |
| | | } |
| | | |
| | | @Override//修改 |
| | | @Transactional |
| | | public Boolean updateByBo(EnforceEvaluateQuestionBo bo) |
| | | { |
| | | EnforceEvaluateQuestion update = Convert.convert(EnforceEvaluateQuestion.class, bo); |
| | | validEntityBeforeSave(update); |
| | | return this.updateById(update); |
| | | } |
| | | |
| | | @Override//删除 |
| | | @Transactional |
| | | public Boolean deleteByIds(Collection<Long> ids) |
| | | { |
| | | |
| | | //做一些业务上的校验,判断是否需要校验 |
| | | |
| | | return this.removeByIds(ids); |
| | | } |
| | | |
| | | |
| | | //------------------------------------------------------------------------------------- |
| | | |
| | | //保存前校验 |
| | | private void validEntityBeforeSave(EnforceEvaluateQuestion entity) |
| | | { |
| | | //做一些数据校验,如唯一约束 |
| | | } |
| | | |
| | | //获取查询参数 |
| | | private QueryWrapper<EnforceEvaluateQuestion> getQw(EnforceEvaluateQuestionQueryBo bo) |
| | | { |
| | | QueryWrapper<EnforceEvaluateQuestion> qw = Wrappers.query(); |
| | | |
| | | qw.like(StringUtils.isNotEmpty(bo.getQuestionName()), "question_name", bo.getQuestionName()); |
| | | qw.eq(bo.getQuestionScore() != null, "question_score", bo.getQuestionScore()); |
| | | qw.eq(bo.getQuestionStatus() != null, "question_status", bo.getQuestionStatus()); |
| | | qw.eq(StringUtils.isNotEmpty(bo.getAnswerIds()), "answer_ids", bo.getAnswerIds()); |
| | | if (StringUtils.isNotEmpty(bo.getIsAsc()) && StringUtils.isNotEmpty(bo.getOrderByColumn())){ |
| | | if ("acs".equals(bo.getIsAsc())) { |
| | | qw.orderByAsc(bo.getOrderByColumn()); |
| | | } else if ("desc".equals(bo.getIsAsc())) { |
| | | qw.orderByDesc(bo.getOrderByColumn()); |
| | | } |
| | | } |
| | | return qw; |
| | | } |
| | | } |