package cn.com.ty.lift.ud.schoolVideo.mapper;

import java.math.BigDecimal;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import cn.com.ty.lift.ud.schoolVideo.controller.query.SchoolVideoQuery;
import cn.com.ty.lift.ud.schoolVideo.mapper.entity.SchoolVideoEntity;

/**
 * 电梯学堂 -Repository
 * 
 * @author Xson
 * @date 2020-04-23
 */
public interface SchoolVideoMapper extends BaseMapper<SchoolVideoEntity> {

    /**
     * 审批，修改审批状态为1
     *
     * @param id
     */
    @Update(value = "update school_video set check_flag= 1,statuz=1 where id = #{id}")
    void examineById(@Param("id") Long id);

    /**
     * 审批驳回，修改审批状态为0
     *
     * @param id
     */
    @Update(value = "update school_video set check_flag= 0,statuz=0,check_comment =#{reason} where id = #{id}")
    void updateInfoById(@Param("id") Long id, @Param("reason") String reason);

    /**
     * 更新浏览量
     *
     * @param id
     */
    @Update(value = "update school_video set browse_num= browse_num+1 where id = #{id}")
    void updateBrowseNum(Long id);

    List<SchoolVideoEntity> selectByQuery(@Param("ew") Wrapper wrapper, @Param("page") SchoolVideoQuery page);

    int countByQuery(@Param("ew") Wrapper wrapper);

    /**
     * 打赏数量加 1
     * 
     * @param id
     * @param reward
     */
    @Update(value = "update school_video set pay_num = pay_num + 1  where id = #{id}")
    void updateReward(@Param("id") Long id);
}
