package com.xhkjedu.sapi.service.assess;

import com.xhkjedu.sapi.mapper.assess.AssessMapper;
import com.xhkjedu.sapi.mapper.system.UserMapper;
import com.xhkjedu.sapi.model.assess.TAssess;
import com.xhkjedu.utils.N_Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author ywx
 * @classname AssessService
 * @description
 * @date 2021/11/10 13:40
 **/
@Service
public class AssessService {
    @Resource
    private AssessMapper assessMapper;
    @Resource
    private UserMapper userMapper;

    //添加
    public TAssess save(TAssess model) {
        model.setCreatetime(N_Utils.getSecondTimestamp());
        assessMapper.insertUseGeneratedKeys(model);
        model.setAssessid(model.getId());
        return model;
    }

    //删除
    public Integer deleteById(Integer id) {
        return assessMapper.deleteByPrimaryKey(id);
    }

    //修改
    public Integer update(TAssess model) {
        return assessMapper.updateByPrimaryKeySelective(model);
    }

    //获取详情
    public List<Map> listDetail(TAssess assess) {
        return assessMapper.listByAssess(assess);
    }

    //获取列表
    public List <Map> listAll(TAssess assess) {
        return assessMapper.listAll(assess);
    }

    //获取用户类型
    public Integer getUsertypeById(Integer createid) {
        return userMapper.getUsertypeById(createid);
    }

    //评价统计
    public List<Map> listAnalyze(TAssess assess) {
        List<Map> list = assessMapper.listAnalyze(assess);
        return list;
    }
}
