LearningContentBoardMapper.java 5.06 KB
Newer Older
liqin's avatar
liqin committed
1 2
package cn.wisenergy.chnmuseum.party.mapper;

liqin's avatar
liqin committed
3
import cn.wisenergy.chnmuseum.party.model.Asset;
liqin's avatar
liqin committed
4
import cn.wisenergy.chnmuseum.party.model.ExhibitionBoard;
liqin's avatar
liqin committed
5 6
import cn.wisenergy.chnmuseum.party.model.LearningContentBoard;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
liqin's avatar
liqin committed
7 8
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
liqin's avatar
liqin committed
9 10 11
import org.apache.ibatis.annotations.Select;

import java.util.List;
liqin's avatar
liqin committed
12 13 14 15 16 17 18 19 20 21 22

/**
 * <p>
 * 学习内容展板 Mapper 接口
 * </p>
 *
 * @author Danny Lee
 * @since 2021-03-16
 */
public interface LearningContentBoardMapper extends BaseMapper<LearningContentBoard> {

liqin's avatar
liqin committed
23
    @Select("SELECT lcb.*, eb.`name` as exhibition_board_name FROM learning_content_board lcb, exhibition_board eb WHERE lcb.exhibition_board_id = eb.id and lcb.learning_content_id = #{learningContentId} order by lcb.sortorder desc")
liqin's avatar
liqin committed
24 25
    List<LearningContentBoard> selectBoardListByLearningContentId(String learningContentId);

liqin's avatar
liqin committed
26 27 28 29
    @Select("<script>"
            + "SELECT eb.* FROM learning_content_board lcb, exhibition_board eb "
            + "WHERE lcb.exhibition_board_id = eb.id "
            + "<if test='learningContentId != null'>and lcb.learning_content_id = #{learningContentId} </if>"
liqin's avatar
liqin committed
30 31
            + "<if test='nameOrCode != null'>and eb.name like CONCAT('%', #{nameOrCode}, '%') </if>"
            + "order by lcb.sortorder desc"
liqin's avatar
liqin committed
32 33 34 35
            + "</script>"
    )
    IPage<ExhibitionBoard> selectBoardPageByLearningContentId(Page<?> page, String learningContentId, String nameOrCode);

liqin's avatar
liqin committed
36
    @Select("SELECT t.* FROM " +
liqin's avatar
liqin committed
37 38
            "(" +

liqin's avatar
liqin committed
39
            "SELECT a.*, eb.id exhibition_board_id, eb.name exhibition_board_name, eb.cover exhibition_board_cover FROM learning_content_board lcb, learning_content lc, exhibition_board eb, video_content vc, asset a "
liqin's avatar
liqin committed
40 41
            + "WHERE lcb.learning_content_id = lc.id "
            + "and lcb.exhibition_board_id = eb.id "
liqin's avatar
liqin committed
42 43
            + "and eb.video_content_id = vc.id "
            + "and vc.id = a.ref_item_id "
liqin's avatar
liqin committed
44
            + "and a.file_type = 'VIDEO' "
liqin's avatar
liqin committed
45 46
            + "and lc.applicable_scope = 'THIS_ORGAN' "
            + "and lc.organ_code = #{organCode} "
liqin's avatar
liqin committed
47
            + "UNION ALL "
liqin's avatar
liqin committed
48
            + "SELECT a.*, eb.id exhibition_board_id, eb.name exhibition_board_name, eb.cover exhibition_board_cover FROM learning_content_board lcb, learning_content lc, exhibition_board eb, asset a "
liqin's avatar
liqin committed
49 50 51 52 53 54 55 56
            + "WHERE lcb.learning_content_id = lc.id "
            + "and lcb.exhibition_board_id = eb.id "
            + "and eb.id = a.ref_item_id "
            + "and a.file_cat = 'EXHIBITION_BOARD_DATUM' "
            + "and a.file_type = 'VIDEO' "
            + "and lc.applicable_scope = 'THIS_ORGAN' "
            + "and lc.organ_code = #{organCode} "

liqin's avatar
liqin committed
57
            + "UNION "
liqin's avatar
liqin committed
58 59 60

            + "SELECT a.*, eb.id exhibition_board_id, eb.name exhibition_board_name, eb.cover exhibition_board_cover "
            + "FROM learning_content_board lcb, learning_content lc, exhibition_board eb, video_content vc, asset a "
liqin's avatar
liqin committed
61 62
            + "WHERE lcb.learning_content_id = lc.id "
            + "and lcb.exhibition_board_id = eb.id "
liqin's avatar
liqin committed
63 64
            + "and eb.video_content_id = vc.id "
            + "and vc.id = a.ref_item_id "
liqin's avatar
liqin committed
65
            + "and a.file_type = 'VIDEO' "
liqin's avatar
liqin committed
66 67
            + "and lc.applicable_scope = 'THIS_ORGAN_SUB'"
            + "and lc.organ_code like CONCAT(#{organCode},'%') "
liqin's avatar
liqin committed
68
            + "UNION ALL "
liqin's avatar
liqin committed
69
            + "SELECT a.*, eb.id exhibition_board_id, eb.name exhibition_board_name, eb.cover exhibition_board_cover FROM learning_content_board lcb, learning_content lc, exhibition_board eb, asset a "
liqin's avatar
liqin committed
70 71 72 73 74 75 76 77
            + "WHERE lcb.learning_content_id = lc.id "
            + "and lcb.exhibition_board_id = eb.id "
            + "and eb.id = a.ref_item_id "
            + "and a.file_cat = 'EXHIBITION_BOARD_DATUM' "
            + "and a.file_type = 'VIDEO' "
            + "and lc.applicable_scope = 'THIS_ORGAN_SUB' "
            + "and lc.organ_code = #{organCode} "

liqin's avatar
liqin committed
78
            + "UNION "
liqin's avatar
liqin committed
79 80

            + "SELECT a.*, eb.id exhibition_board_id, eb.name exhibition_board_name, eb.cover exhibition_board_cover FROM learning_content_board lcb, learning_content lc, exhibition_board eb, video_content vc, asset a "
liqin's avatar
liqin committed
81 82
            + "WHERE lcb.learning_content_id = lc.id "
            + "and lcb.exhibition_board_id = eb.id "
liqin's avatar
liqin committed
83 84
            + "and eb.video_content_id = vc.id "
            + "and vc.id = a.ref_item_id "
liqin's avatar
liqin committed
85
            + "and a.file_type = 'VIDEO' "
liqin's avatar
liqin committed
86 87
            + "and lc.applicable_scope = 'ALL_PLAT'"
            + "UNION ALL "
liqin's avatar
liqin committed
88 89
            + "SELECT a.*, eb.id exhibition_board_id, eb.name exhibition_board_name, eb.cover exhibition_board_cover "
            + "FROM learning_content_board lcb, learning_content lc, exhibition_board eb, asset a "
liqin's avatar
liqin committed
90 91 92 93 94 95 96
            + "WHERE lcb.learning_content_id = lc.id "
            + "and lcb.exhibition_board_id = eb.id "
            + "and eb.id = a.ref_item_id "
            + "and a.file_cat = 'EXHIBITION_BOARD_DATUM' "
            + "and a.file_type = 'VIDEO' "
            + "and lc.applicable_scope = 'ALL_PLAT'" +
            ") t"
liqin's avatar
liqin committed
97
    )
liqin's avatar
liqin committed
98
    IPage<Asset> selectAssetPageByOrganCode(Page<?> page, String organCode);
liqin's avatar
liqin committed
99

liqin's avatar
liqin committed
100
}