package com.willalp.flow.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.willalp.flow.domain.HsFlowTask;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * 流程任务Mapper接口
 *
 * @author willalp
 * @date 2022-10-09
 */
public interface HsFlowTaskMapper extends BaseMapper<HsFlowTask> {
    /**
     * 查询流程任务列表
     *
     * @param hsFlowTask 流程任务
     * @return 流程任务集合
     */
    List<HsFlowTask> selectHsFlowTaskList(HsFlowTask hsFlowTask);

    List<HsFlowTask> selectAllByOperator(@Param("userCode") String userCode);

    List<HsFlowTask> selectAllByInitiator(@Param("userCode") String userCode);

    /**
     * 获取已办
     *
     * @param userCode
     * @return
     */
    List<HsFlowTask> getDone(String userCode);

    @Select("SELECT * FROM ${tableName} WHERE id = #{id}")
    Map<String, Object> selectBusinessCase(@Param("tableName") String tableName, @Param("id") String id);


    /**
     * 已读任务
     *
     * @param taskId
     */
    @Update("UPDATE hs_flow_task set msg_is_read = '1', remark = null WHERE id = #{taskId};")
    void readTask(@Param("taskId") String taskId);
}
