package com.ruoyi.postCheck.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.postCheck.mapper.PostAssessmentRatingOtherInfoMapper;
import com.ruoyi.postCheck.domain.PostAssessmentRatingOtherInfo;
import com.ruoyi.postCheck.service.IPostAssessmentRatingOtherInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;

/**
 * 打分表明细(职能互评生产日常)Service业务层处理
 *
 * @author csg
 * @date 2024-01-01
 */
@Service
public class PostAssessmentRatingOtherInfoServiceImpl extends ServiceImpl<PostAssessmentRatingOtherInfoMapper, PostAssessmentRatingOtherInfo> implements IPostAssessmentRatingOtherInfoService {
    @Autowired
    private PostAssessmentRatingOtherInfoMapper postAssessmentRatingOtherInfoMapper;

    /**
     * 查询打分表明细(职能互评生产日常)
     *
     * @param id 打分表明细(职能互评生产日常)主键
     * @return 打分表明细(职能互评生产日常)
     */
    @Override
    public PostAssessmentRatingOtherInfo selectPostAssessmentRatingOtherInfoById(Long id) {
        return postAssessmentRatingOtherInfoMapper.selectPostAssessmentRatingOtherInfoById(id);
    }

    /**
     * 查询打分表明细(职能互评生产日常)列表
     *
     * @param postAssessmentRatingOtherInfo 打分表明细(职能互评生产日常)
     * @return 打分表明细(职能互评生产日常)
     */
    @Override
    public List<PostAssessmentRatingOtherInfo> selectPostAssessmentRatingOtherInfoList(PostAssessmentRatingOtherInfo postAssessmentRatingOtherInfo) {
        return postAssessmentRatingOtherInfoMapper.selectPostAssessmentRatingOtherInfoList(postAssessmentRatingOtherInfo);
    }

    /**
     * 新增打分表明细(职能互评生产日常)
     *
     * @param postAssessmentRatingOtherInfo 打分表明细(职能互评生产日常)
     * @return 结果
     */
    @Override
    public int insertPostAssessmentRatingOtherInfo(PostAssessmentRatingOtherInfo postAssessmentRatingOtherInfo) {
        //TODO 自增主键修改为-MyBatis-Plus雪花算法(截取5位解决VUE精度丢失BUG)-系统登录日志
//        if (postAssessmentRatingOtherInfo.getId() == null)
        postAssessmentRatingOtherInfo.setId(Long.parseLong(IdWorker.getIdStr().substring(4)));
        // postAssessmentRatingOtherInfo.setCreateTime(DateUtils.getNowDate());
        postAssessmentRatingOtherInfo.setCreateDefault();
//        postAssessmentRatingOtherInfo.setStatus(PostAssessmentRatingOtherInfoEnum.STATUS_WAIT.getValue()); // 去创建自己的枚举类
        postAssessmentRatingOtherInfo.setCreateUserId(SecurityUtils.getUserId());
        return postAssessmentRatingOtherInfoMapper.insertPostAssessmentRatingOtherInfo(postAssessmentRatingOtherInfo);
    }

    /**
     * 修改打分表明细(职能互评生产日常)
     *
     * @param postAssessmentRatingOtherInfo 打分表明细(职能互评生产日常)
     * @return 结果
     */
    @Override
    public int updatePostAssessmentRatingOtherInfo(PostAssessmentRatingOtherInfo postAssessmentRatingOtherInfo) {
        // postAssessmentRatingOtherInfo.setUpdateTime(DateUtils.getNowDate());
        postAssessmentRatingOtherInfo.setUpdateDefault();
        return postAssessmentRatingOtherInfoMapper.updatePostAssessmentRatingOtherInfo(postAssessmentRatingOtherInfo);
    }

    /**
     * 批量删除打分表明细(职能互评生产日常)
     *
     * @param ids 需要删除的打分表明细(职能互评生产日常)主键
     * @return 结果
     */
    @Override
    public int deletePostAssessmentRatingOtherInfoByIds(Long[] ids) {
        return postAssessmentRatingOtherInfoMapper.deletePostAssessmentRatingOtherInfoByIds(ids);
    }

    /**
     * 删除打分表明细(职能互评生产日常)信息
     *
     * @param id 打分表明细(职能互评生产日常)主键
     * @return 结果
     */
    @Override
    public int deletePostAssessmentRatingOtherInfoById(Long id) {
        return postAssessmentRatingOtherInfoMapper.deletePostAssessmentRatingOtherInfoById(id);
    }
}
