package com.designhub.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.designhub.entity.ProgressDeductionLog; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.math.BigDecimal; /** * 进度未更新扣分记录Mapper */ @Mapper public interface ProgressDeductionLogMapper extends BaseMapper { /** * 查询用户指定月份的扣分总额(仅主任务) */ @Select("SELECT COALESCE(SUM(deduction_score), 0) FROM progress_deduction_log " + "WHERE user_id = #{userId} " + "AND YEAR(deduction_date) = #{year} " + "AND MONTH(deduction_date) = #{month} " + "AND task_item_id IS NULL") BigDecimal sumMonthlyDeduction(@Param("userId") Long userId, @Param("year") int year, @Param("month") int month); /** * 查询用户总扣分 */ @Select("SELECT COALESCE(SUM(deduction_score), 0) FROM progress_deduction_log WHERE user_id = #{userId}") BigDecimal sumTotalDeduction(@Param("userId") Long userId); }