Blame view

SubjectDimensionDictServiceImpl.java 3.83 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
package com.meishu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.meishu.mapper.SubjectDimensionStarDictMapper;
import com.meishu.mapper.SubjectTestGradeStarMappingMapper;
import com.meishu.model.*;
import com.meishu.mapper.SubjectDimensionDictMapper;
import com.meishu.service.SubjectDimensionDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meishu.util.ConstantUtils;
import com.meishu.vo.dimension.GetAllDimensionStarVO;
import com.meishu.vo.dimension.GetAllDimensionStarsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 测评表 服务实现类
 * </p>
 *
 * @author Tuyp
 * @since 2021-05-06
 */
@Service
public class SubjectDimensionDictServiceImpl extends ServiceImpl<SubjectDimensionDictMapper, SubjectDimensionDictDO> implements SubjectDimensionDictService {

    @Autowired
    private SubjectDimensionStarDictMapper subjectDimensionStarDictMapper;

    @Autowired
    private SubjectDimensionDictMapper subjectDimensionDictMapper;

    @Autowired
    private SubjectTestGradeStarMappingMapper subjectTestGradeStarMappingMapper;

    public List<SubjectDimensionDictDO> getAllDimensions(SubjectDimensionDictDO subjectDimensionDictDO){
        return this.baseMapper.selectList(new QueryWrapper<SubjectDimensionDictDO>()
        .lambda()
        .eq(SubjectDimensionDictDO::getRuleId,subjectDimensionDictDO.getRuleId()));
    }

    public String deleteDimensionById(SubjectDimensionDictDO subjectDimensionDictDO){
        this.baseMapper.deleteById(subjectDimensionDictDO.getId());

        //删除下面的星级
        subjectDimensionStarDictMapper.delete(new QueryWrapper<SubjectDimensionStarDictDO>()
        .lambda()
        .eq(SubjectDimensionStarDictDO::getDimensionId,subjectDimensionDictDO.getId()));

        return ConstantUtils.DELETE_SUCCESS;
    }

    public String updateDimension(SubjectDimensionDictDO subjectDimensionDictDO){
        this.baseMapper.updateById(subjectDimensionDictDO);
        return ConstantUtils.SUCCESS_UPDATE;
    }

    public String addDimension(SubjectDimensionDictDO subjectDimensionDictDO){
        this.baseMapper.insert(subjectDimensionDictDO);
        return ConstantUtils.ADD_SUCCESS;
    }

    public List<GetAllDimensionStarVO> getAllDimensionStar(SubjectTestPublishGradeDO subjectTestPublishGradeDO){

        //通过发布id查询规则
        SubjectRuleDO subjectRuleDO = subjectTestGradeStarMappingMapper.getRuleIdByPublishId(subjectTestPublishGradeDO.getPublishId());

        List<GetAllDimensionStarVO> getAllDimensionStarVOS = new ArrayList<>();

        //获取所有的维度
        List<SubjectDimensionDictDO> subjectDimensionDictDOS = subjectDimensionDictMapper.selectList(new QueryWrapper<SubjectDimensionDictDO>()
        .lambda()
        .eq(SubjectDimensionDictDO::getRuleId,subjectRuleDO.getId()));

        for (SubjectDimensionDictDO subjectDimensionDictDO: subjectDimensionDictDOS){

            GetAllDimensionStarVO getAllDimensionStarsVO = new GetAllDimensionStarVO();
            //维度获取星级
            List<SubjectDimensionStarDictDO> subjectDimensionStarDictDOS = subjectDimensionStarDictMapper.selectList(new QueryWrapper<SubjectDimensionStarDictDO>()
            .lambda()
            .eq(SubjectDimensionStarDictDO::getDimensionId,subjectDimensionDictDO.getId()));

            getAllDimensionStarsVO.setDimensionId(subjectDimensionDictDO.getId());
            getAllDimensionStarsVO.setDimension(subjectDimensionDictDO.getDimension());
            getAllDimensionStarsVO.setSubjectDimensionStarDictDOS(subjectDimensionStarDictDOS);

            getAllDimensionStarVOS.add(getAllDimensionStarsVO);
        }
        return getAllDimensionStarVOS;
    }

}