package thyyxxk.webserver.dao.his.targetmanagement;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import thyyxxk.webserver.entity.highreport.TableDisplayInfo;

import java.util.List;

/**
 * @ClassName TableDisplayInfoDao
 * @Author hsh
 * @Date 2024/4/3 15:03
 * @Version 1.0
 * @Description 报表详情页面配置
 **/
@Mapper
public interface TableDisplayInfoDao extends BaseMapper<TableDisplayInfo> {

    @Select(" select * from table_display_info where flag = 'Y' and report_id = #{reportId} and level_id = #{levelId} order by sort ")
    List<TableDisplayInfo> selectTableDisplayByReportId(@Param("reportId") String reportId, @Param("levelId") String levelId);

    @Select(" select * from table_display_info where flag = 'Y' and report_id = #{reportId} and level_id = #{levelId} and prop = #{prop} ")
    TableDisplayInfo selectTableDisplayByProp(@Param("reportId") String reportId, @Param("levelId") String levelId, @Param("prop") String prop);

    @Update("<script>" +
            "update table_display_info " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"reportId != null and reportId != '' \">" +
            "report_id = #{reportId}, " +
            "</if>" +
            "<if test=\"levelId != null and levelId != '' \">" +
            "level_id = #{levelId}, " +
            "</if>" +
            "<if test=\"levelName != null and levelName != '' \">" +
            "level_name = #{levelName}, " +
            "</if>" +
            "<if test=\"title != null and title != '' \">" +
            "title = #{title}, " +
            "</if>" +
            "<if test=\"prop != null and prop != '' \">" +
            "prop = #{prop}, " +
            "</if>" +
            "<if test=\"label != null and label != '' \">" +
            "label = #{label}, " +
            "</if>" +
            "<if test=\"align != null and align != '' \">" +
            "align = #{align}, " +
            "</if>" +
            "<if test=\"width != null and width != '' \">" +
            "width = #{width}, " +
            "</if>" +
            "<if test=\"sortable != null and sortable != '' \">" +
            "sortable = #{sortable}, " +
            "</if>" +
            "<if test=\"flag != null and flag != '' \">" +
            "flag = #{flag}, " +
            "</if>" +
            "<if test=\"isShow != null and isShow != '' \">" +
            "is_show = #{isShow}, " +
            "</if>" +
            "<if test=\"sort != null and sort != '' \">" +
            "sort = #{sort}, " +
            "</if>" +
            "<if test=\"id != null and id != '' \">" +
            "id = #{id}, " +
            "</if>" +
            "<if test=\"pid != null and pid != '' \">" +
            "pid = #{pid}, " +
            "</if>" +
            "</trim>" +
            "where report_id = #{reportId} and level_id = #{levelId} and prop = #{prop} " +
            "</script>")
    int updateTableDisplayByProp(TableDisplayInfo info);

    @Delete(" delete from table_display_info where report_id = #{reportId} and level_id = #{levelId} and prop = #{prop} ")
    int delTableDisplayByProp(@Param("reportId") String reportId, @Param("levelId") String levelId, @Param("prop") String prop);

}
