package com.ruoyi.tc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.tc.entity.po.AssetAppCpPo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 资产移动应用程序表(asset_app_cp)表数据库访问层
 *
 * @author makejava
 * @since 2024-11-15 10:03:56
 */
public interface AssetAppCpMapper extends BaseMapper<AssetAppCpPo> {


    /**
     * 根据资产id和任务id删除数据
     *
     * @param assetId 资产id
     * @param taskId  任务id
     */
    @Delete("delete from asset_app_cp where asset_id=#{assetId} and task_id =#{taskId}  ")
    void deletByAssetIdandTaskId(@Param("assetId") Long assetId, @Param("taskId") Integer taskId);


    /**
     * 根据资产id和任务id删除数据
     *
     * @param assetId 资产id
     */
    @Delete("delete from asset_app_cp where asset_id=#{assetId}  ")
    void deletByAssetId(@Param("assetId") Long assetId);


    /**
     * 根据assetId查询查询数据
     *
     * @param assetId 资产id
     * @return
     * @Param taskId 任务id
     */
    @Select("select * from  asset_app_cp where asset_id=#{assetId} and task_id =#{taskId}")
    AssetAppCpPo findByTaskId(@Param("assetId") int assetId,@Param("taskId") int taskId);

    /**
     * 修改不通过原因
     *
     * @param assetId 资产id
     * @param taskId  任务id
     * @param btgyy   不通过原因
     */
    @Update("update asset_app_cp set btgyy=#{btgyy},count=#{newThcs} where asset_id=#{assetId} and task_id =#{taskId} ")
    void updateByAssetId(@Param("assetId") Integer assetId, @Param("taskId") Integer taskId, @Param("btgyy") String btgyy, @Param("newThcs") Integer newThcs);


    /**
     * 根据任务id,资产id获取退回次数
     *
     * @param assetId 资产id
     * @param taskId  任务id
     * @return
     */
    @Select("select * from asset_app_cp where asset_id=#{assetId} and task_id =#{taskId} ")
    AssetAppCpPo findByassetIdandTaskId(@Param("assetId") Integer assetId, @Param("taskId") Integer taskId);


    @Select(" select * from  asset_app_cp  where asset_id = #{id} ")
    AssetAppCpPo findDwmc(Long id);
}

