| | |
| | | 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.EnforceEvaluateAnswerVo; |
| | | import com.project.enforce.domain.bo.editBo.EnforceEvaluateAnswerBo; |
| | | import com.project.enforce.domain.bo.queryBo.EnforceEvaluateAnswerQueryBo; |
| | | import com.project.enforce.domain.EnforceEvaluateAnswer; |
| | | import com.project.enforce.mapper.EnforceEvaluateAnswerMapper; |
| | | import com.project.enforce.service.IEnforceEvaluateAnswerService; |
| | | |
| | | 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<EnforceEvaluateAnswerVo> queryList(EnforceEvaluateAnswerQueryBo bo) |
| | | { |
| | | QueryWrapper<EnforceEvaluateAnswer> qw = getQw(bo); |
| | | List<EnforceEvaluateAnswer> list = this.list(qw); |
| | | return Convert.toList(EnforceEvaluateAnswerVo.class , list); |
| | | } |
| | | |
| | | @Override//id查询 |
| | | public EnforceEvaluateAnswerVo queryById(Long answerId) |
| | | { |
| | | EnforceEvaluateAnswer db = this.baseMapper.selectById(answerId); |
| | | return Convert.convert(EnforceEvaluateAnswerVo.class , db); |
| | | } |
| | | |
| | | |
| | | @Override//添加 |
| | | @Transactional |
| | | public Boolean insertByBo(EnforceEvaluateAnswerBo bo) |
| | | { |
| | | EnforceEvaluateAnswer add = Convert.convert(EnforceEvaluateAnswer.class, bo); |
| | | validEntityBeforeSave(add); |
| | | return this.save(add); |
| | | } |
| | | |
| | | @Override//修改 |
| | | @Transactional |
| | | public Boolean updateByBo(EnforceEvaluateAnswerBo bo) |
| | | { |
| | | EnforceEvaluateAnswer update = Convert.convert(EnforceEvaluateAnswer.class, bo); |
| | | validEntityBeforeSave(update); |
| | | return this.updateById(update); |
| | | } |
| | | |
| | | @Override//删除 |
| | | @Transactional |
| | | public Boolean deleteByIds(Collection<Long> ids) |
| | | { |
| | | |
| | | //做一些业务上的校验,判断是否需要校验 |
| | | |
| | | return this.removeByIds(ids); |
| | | } |
| | | |
| | | |
| | | //------------------------------------------------------------------------------------- |
| | | |
| | | //保存前校验 |
| | | private void validEntityBeforeSave(EnforceEvaluateAnswer entity) |
| | | { |
| | | //做一些数据校验,如唯一约束 |
| | | } |
| | | |
| | | //获取查询参数 |
| | | private QueryWrapper<EnforceEvaluateAnswer> getQw(EnforceEvaluateAnswerQueryBo bo) |
| | | { |
| | | QueryWrapper<EnforceEvaluateAnswer> qw = Wrappers.query(); |
| | | |
| | | qw.like(StringUtils.isNotEmpty(bo.getAnswerName()), "answer_name", bo.getAnswerName()); |
| | | qw.eq(bo.getQuestionId() != null, "question_id", bo.getQuestionId()); |
| | | qw.like(StringUtils.isNotEmpty(bo.getQuestionName()), "question_name", bo.getQuestionName()); |
| | | qw.eq(bo.getIsScore() != null, "is_score", bo.getIsScore()); |
| | | qw.eq(StringUtils.isNotEmpty(bo.getAnswerRemark()), "answer_remark", bo.getAnswerRemark()); |
| | | qw.eq(bo.getAnswerStatus() != null, "answer_status", bo.getAnswerStatus()); |
| | | 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; |
| | | } |
| | | } |