package com.yiboshi.science.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiboshi.science.base.BaseServiceImpl;
import com.yiboshi.science.dao.ComEvaluationValueDAO;
import com.yiboshi.science.entity.ComEvaluationValue;
import com.yiboshi.science.param.dto.ComEvaluationValueDTO;
import com.yiboshi.science.param.query.ComEvaluationValueQueryVO;
import com.yiboshi.science.service.ComEvaluationValueService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class ComEvaluationValueServiceImpl extends BaseServiceImpl<ComEvaluationValueDAO, ComEvaluationValueQueryVO, ComEvaluationValueDTO, ComEvaluationValue> implements ComEvaluationValueService {

    @Autowired
    private ComEvaluationValueDAO comEvaluationValueDAO;

    @Override
    protected void setCriteriaForQuery(ComEvaluationValueQueryVO vo, QueryWrapper<ComEvaluationValueQueryVO> criteria) {

    }

    public List<ComEvaluationValueDTO> getEvaluationValueByObjectId(String id) {
        QueryWrapper<ComEvaluationValue> criteria = new QueryWrapper();
        ComEvaluationValue comEvaluationValue = new ComEvaluationValue();
        comEvaluationValue.setObjectId(id);
        notNullField(comEvaluationValue, criteria);
        criteria.orderByAsc("show_index");
        return convertEntity2DtoList(this.list(criteria));
    }


    public String insertEvaluationValue(ComEvaluationValueDTO dto) {
        ComEvaluationValue entity = convert2Entity(dto);
        this.save(entity);
        return "值添加成功！";
    }

    public String updateEvaluationValue(ComEvaluationValueDTO dto) {
        ComEvaluationValue entity = convert2Entity(dto);
        this.update(entity);
        return "值修改成功！";
    }

    public String deleteEvaluationValue(String id) {
        this.deleteById(id);
        return "值删除成功！";
    }
}
