zhoulisky 10 months ago
parent
commit
1cb12beeb3

+ 20 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/SubjectQueryDto.java

@@ -0,0 +1,20 @@
+ package org.sky.scientific.pojo.dto;
+
+ import io.swagger.v3.oas.annotations.media.Schema;
+ import lombok.Data;
+
+ import java.io.Serializable;
+
+ /**
+  * 实体类
+  *
+   */
+ @Data
+ public class SubjectQueryDto implements Serializable {
+
+	 @Schema(description = "科目代码")
+	 private String code;
+
+	 @Schema(description = "科目名称")
+	 private String name;
+ }

+ 3 - 3
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/SubjectController.java

@@ -7,7 +7,7 @@ import lombok.AllArgsConstructor;
 import org.sky.core.boot.ctrl.KdController;
 import org.sky.core.tenant.annotation.NonDS;
 import org.sky.core.tool.api.R;
-import org.sky.scientific.pojo.entity.Subject;
+import org.sky.scientific.pojo.dto.SubjectQueryDto;
 import org.sky.scientific.pojo.vo.SubjectVO;
 import org.sky.scientific.service.ISubjectService;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -33,8 +33,8 @@ public class SubjectController extends KdController {
 	@GetMapping("/list")
 	@ApiOperationSupport(order = 1)
 	@Operation(summary = "列表")
-	public R<List<SubjectVO>> list(Subject subject) {
-		List<SubjectVO> list = service.allSubject(subject);
+	public R<List<SubjectVO>> list(SubjectQueryDto dto) {
+		List<SubjectVO> list = service.allSubject(dto);
 		return R.data(list);
 	}
 }

+ 5 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/SubjectMapper.java

@@ -1,8 +1,11 @@
 package org.sky.scientific.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.sky.scientific.pojo.dto.SubjectQueryDto;
 import org.sky.scientific.pojo.entity.Subject;
 
+import java.util.List;
+
 
 /**
  * SubjectMapper 接口
@@ -10,6 +13,8 @@ import org.sky.scientific.pojo.entity.Subject;
  */
 public interface SubjectMapper extends BaseMapper<Subject> {
 
+	List<Subject> selectSubjectList(SubjectQueryDto queryDto);
+
 //	/**
 //	 * 懒加载列表
 //	 *

+ 6 - 431
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/SubjectMapper.xml

@@ -21,435 +21,10 @@
         <result column="key" property="key"/>
     </resultMap>
 
-<!--    <select id="lazyList"  resultMap="menuVOResultMap">-->
-<!--        SELECT-->
-<!--            menu.*,-->
-<!--            (-->
-<!--                SELECT-->
-<!--                    CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END-->
-<!--            FROM-->
-<!--                kd_menu-->
-<!--            WHERE-->
-<!--                parent_id = menu.id AND is_deleted = 0-->
-<!--        ) AS "has_children"-->
-<!--        FROM-->
-<!--            kd_menu menu-->
-<!--        WHERE menu.is_deleted = 0-->
-<!--        <if test="param1!=null">-->
-<!--            and menu.parent_id = #{param1}-->
-<!--        </if>-->
-<!--        <if test="param2.name!=null and param2.name!=''">-->
-<!--            and menu.name like concat(concat('%', #{param2.name}),'%')-->
-<!--        </if>-->
-<!--        <if test="param2.code!=null and param2.code!=''">-->
-<!--            and menu.code like concat(concat('%', #{param2.code}),'%')-->
-<!--        </if>-->
-<!--        <if test="param2.alias!=null and param2.alias!=''">-->
-<!--            and menu.alias like concat(concat('%', #{param2.alias}),'%')-->
-<!--        </if>-->
-<!--        ORDER BY menu.sort-->
-<!--    </select>-->
-
-<!--    <select id="lazyMenuList" resultMap="menuVOResultMap">-->
-<!--        SELECT-->
-<!--            menu.*,-->
-<!--            (-->
-<!--                SELECT-->
-<!--                    CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END-->
-<!--        FROM-->
-<!--                kd_menu-->
-<!--        WHERE-->
-<!--        parent_id = menu.id AND is_deleted = 0  AND category = 1-->
-<!--        ) AS "has_children"-->
-<!--        FROM-->
-<!--            kd_menu menu-->
-<!--        WHERE menu.is_deleted = 0 AND menu.category = 1-->
-<!--        <if test="param1!=null">-->
-<!--            and menu.parent_id = #{param1}-->
-<!--        </if>-->
-<!--        <if test="param2.name!=null and param2.name!=''">-->
-<!--            and menu.name like concat(concat('%', #{param2.name}),'%')-->
-<!--        </if>-->
-<!--        <if test="param2.code!=null and param2.code!=''">-->
-<!--            and menu.code like concat(concat('%', #{param2.code}),'%')-->
-<!--        </if>-->
-<!--        <if test="param2.alias!=null and param2.alias!=''">-->
-<!--            and menu.alias like concat(concat('%', #{param2.alias}),'%')-->
-<!--        </if>-->
-<!--        ORDER BY menu.sort-->
-<!--    </select>-->
-
-<!--    <select id="tree" resultMap="treeNodeResultMap">-->
-<!--        select id, parent_id, name as title, id as "value", id as "key" from kd_menu where is_deleted = 0 and category = 1-->
-<!--    </select>-->
-
-<!--    <select id="allMenu" resultMap="menuResultMap">-->
-<!--        select * from kd_menu where is_deleted = 0 and category = 1-->
-<!--    </select>-->
-
-<!--    <select id="roleMenu" resultMap="menuResultMap">-->
-<!--        select * from kd_menu where is_deleted = 0 and id IN-->
-<!--        ( SELECT menu_id FROM kd_role_menu WHERE role_id IN-->
-<!--        <foreach collection="param1" index="index" item="item" open="(" separator="," close=")">-->
-<!--            #{item}-->
-<!--        </foreach>-->
-<!--        )-->
-<!--        <if test="param2!=null and param2>0">-->
-<!--            AND id IN-->
-<!--            (-->
-<!--            SELECT menu_id FROM kd_top_menu_setting WHERE top_menu_id = #{param2}-->
-<!--            )-->
-<!--        </if>-->
-<!--    </select>-->
-
-<!--    <select id="roleMenuByRoleId" resultMap="menuResultMap">-->
-<!--        select * from kd_menu where is_deleted = 0 and id IN-->
-<!--            ( SELECT menu_id FROM kd_role_menu WHERE role_id IN-->
-<!--                <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                    #{item}-->
-<!--                </foreach>-->
-<!--            )-->
-<!--    </select>-->
-
-<!--    <select id="roleMenuByTopMenuId" resultMap="menuResultMap">-->
-<!--        select * from kd_menu where is_deleted = 0 and id IN-->
-<!--              (-->
-<!--                  SELECT menu_id FROM kd_top_menu_setting WHERE top_menu_id = #{param1}-->
-<!--              )-->
-<!--    </select>-->
-
-<!--    <select id="routes" resultMap="menuResultMap">-->
-<!--        SELECT-->
-<!--            *-->
-<!--        FROM-->
-<!--            kd_menu-->
-<!--        WHERE-->
-<!--            is_deleted = 0 and category = 1-->
-<!--            and id IN ( SELECT menu_id FROM kd_role_menu WHERE role_id IN-->
-<!--                        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                            #{item}-->
-<!--                        </foreach> )-->
-<!--    </select>-->
-
-<!--    <select id="allButtons" resultMap="menuResultMap">-->
-<!--        SELECT-->
-<!--            id,-->
-<!--            parent_id,-->
-<!--            CODE,-->
-<!--            NAME,-->
-<!--            alias,-->
-<!--            path,-->
-<!--            source,-->
-<!--            action,-->
-<!--            sort-->
-<!--        FROM-->
-<!--            kd_menu-->
-<!--        WHERE-->
-<!--            (-->
-<!--                category = 2 OR id IN ( SELECT parent_id FROM kd_menu WHERE is_deleted = 0 AND category = 2 )-->
-<!--            )-->
-<!--          AND is_deleted = 0-->
-<!--        ORDER BY sort-->
-<!--    </select>-->
-
-<!--    <select id="buttons" resultMap="menuResultMap">-->
-<!--        SELECT * FROM (-->
-<!--            SELECT-->
-<!--                id,-->
-<!--                parent_id,-->
-<!--                code,-->
-<!--                name,-->
-<!--                alias,-->
-<!--                path,-->
-<!--                source,-->
-<!--                action,-->
-<!--                sort-->
-<!--            FROM-->
-<!--                kd_menu-->
-<!--            WHERE-->
-<!--                is_deleted = 0 and id IN (-->
-<!--                  SELECT parent_id FROM kd_menu-->
-<!--                  WHERE ( category = 2 AND id IN ( SELECT menu_id FROM kd_role_menu WHERE role_id IN-->
-<!--                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                  ) ) )-->
-
-<!--            UNION ALL-->
-
-<!--            SELECT-->
-<!--                id,-->
-<!--                parent_id,-->
-<!--                code,-->
-<!--                name,-->
-<!--                alias,-->
-<!--                path,-->
-<!--                source,-->
-<!--                action,-->
-<!--                sort-->
-<!--            FROM-->
-<!--                kd_menu-->
-<!--            WHERE-->
-<!--                is_deleted = 0 and  category = 2 AND id IN ( SELECT menu_id FROM kd_role_menu WHERE role_id IN-->
-<!--                <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                    #{item}-->
-<!--                </foreach>)-->
-<!--        ) menu ORDER BY sort-->
-<!--    </select>-->
-
-<!--    <select id="grantTree" resultMap="treeNodeResultMap">-->
-<!--        select id, parent_id, name as title, id as "value", id as "key" from kd_menu where is_deleted = 0 order by sort-->
-<!--    </select>-->
-
-<!--    <select id="grantTreeByRole" resultMap="treeNodeResultMap">-->
-<!--        select id, parent_id, name as title, id as "value", id as "key" from kd_menu where is_deleted = 0-->
-<!--        and id in ( select menu_id from kd_role_menu where role_id in-->
-<!--        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--            #{item}-->
-<!--        </foreach> )-->
-<!--        or id in (-->
-<!--            select parent_id from kd_menu where is_deleted = 0-->
-<!--            and id in ( select menu_id from kd_role_menu where role_id in-->
-<!--            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                #{item}-->
-<!--            </foreach> )-->
-<!--          )-->
-<!--        order by sort-->
-<!--    </select>-->
-
-<!--    <select id="grantTopTree" resultMap="treeNodeResultMap">-->
-<!--        select id, parent_id, name as title, id as "value", id as "key" from kd_menu where category = 1 and is_deleted = 0 order by sort-->
-<!--    </select>-->
-
-<!--    <select id="grantTopTreeByRole" resultMap="treeNodeResultMap">-->
-<!--        select id, parent_id, name as title, id as "value", id as "key" from kd_menu where category = 1 and is_deleted = 0-->
-<!--        and id in ( select menu_id from kd_role_menu where role_id in-->
-<!--        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--            #{item}-->
-<!--        </foreach> )-->
-<!--        or id in (-->
-<!--        select parent_id from kd_menu where is_deleted = 0-->
-<!--        and id in ( select menu_id from kd_role_menu where role_id in-->
-<!--        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--            #{item}-->
-<!--        </foreach> )-->
-<!--        )-->
-<!--        order by sort-->
-<!--    </select>-->
-
-<!--    <select id="grantDataScopeTree" resultMap="treeNodeResultMap">-->
-<!--        SELECT-->
-<!--            *-->
-<!--        FROM-->
-<!--            (-->
-<!--                SELECT-->
-<!--                    id,-->
-<!--                    parent_id,-->
-<!--                    NAME AS title,-->
-<!--                    id AS "value",-->
-<!--                    id AS "key"-->
-<!--                FROM-->
-<!--                    kd_menu-->
-<!--                WHERE-->
-<!--                    category = 1-->
-<!--                  AND is_deleted = 0-->
-<!--                  AND id IN ( SELECT menu_id FROM kd_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL )-->
-<!--            ) menu-->
-
-<!--        UNION ALL-->
-
-<!--        SELECT-->
-<!--            id,-->
-<!--            menu_id AS parent_id,-->
-<!--            scope_name AS title,-->
-<!--            id AS "value",-->
-<!--            id AS "key"-->
-<!--        FROM-->
-<!--            kd_scope_data-->
-<!--        WHERE-->
-<!--            is_deleted = 0-->
-<!--          AND menu_id IS NOT NULL-->
-<!--    </select>-->
-
-<!--    <select id="grantApiScopeTree" resultMap="treeNodeResultMap">-->
-<!--        SELECT-->
-<!--            *-->
-<!--        FROM-->
-<!--            (-->
-<!--                SELECT-->
-<!--                    id,-->
-<!--                    parent_id,-->
-<!--                    NAME AS title,-->
-<!--                    id AS "value",-->
-<!--                    id AS "key"-->
-<!--                FROM-->
-<!--                    kd_menu-->
-<!--                WHERE-->
-<!--                    category = 1-->
-<!--                  AND is_deleted = 0-->
-<!--                  AND id IN ( SELECT menu_id FROM kd_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL )-->
-<!--            ) menu-->
-
-<!--        UNION ALL-->
-
-<!--        SELECT-->
-<!--            id,-->
-<!--            menu_id AS parent_id,-->
-<!--            scope_name AS title,-->
-<!--            id AS "value",-->
-<!--            id AS "key"-->
-<!--        FROM-->
-<!--            kd_scope_api-->
-<!--        WHERE-->
-<!--            is_deleted = 0-->
-<!--          AND menu_id IS NOT NULL-->
-<!--    </select>-->
-
-<!--    <select id="grantDataScopeTreeByRole" resultMap="treeNodeResultMap">-->
-<!--        SELECT-->
-<!--        *-->
-<!--        FROM-->
-<!--        (-->
-<!--            SELECT-->
-<!--                id,-->
-<!--                parent_id,-->
-<!--                NAME AS title,-->
-<!--                id AS "value",-->
-<!--                id AS "key"-->
-<!--            FROM-->
-<!--                kd_menu-->
-<!--            WHERE-->
-<!--                category = 1-->
-<!--            AND is_deleted = 0-->
-<!--            AND id IN ( SELECT menu_id FROM kd_scope_data WHERE is_deleted = 0 AND menu_id IS NOT NULL )-->
-<!--            AND (-->
-<!--                id IN (-->
-<!--                    select menu_id from kd_role_menu where role_id in-->
-<!--                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                )-->
-<!--                OR id IN (-->
-<!--                    select parent_id from kd_menu where is_deleted = 0-->
-<!--                    and id in ( select menu_id from kd_role_menu where role_id in-->
-<!--                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                        #{item}-->
-<!--                    </foreach> )-->
-<!--                )-->
-<!--            )-->
-<!--        ) menu-->
-
-<!--        UNION ALL-->
-
-<!--        SELECT-->
-<!--            id,-->
-<!--            menu_id AS parent_id,-->
-<!--            scope_name AS title,-->
-<!--            id AS "value",-->
-<!--            id AS "key"-->
-<!--        FROM-->
-<!--            kd_scope_data-->
-<!--        WHERE-->
-<!--            is_deleted = 0-->
-<!--        AND (-->
-<!--            menu_id IN (-->
-<!--                select menu_id from kd_role_menu where role_id in-->
-<!--                <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                    #{item}-->
-<!--                </foreach>-->
-<!--            )-->
-<!--            OR menu_id IN (-->
-<!--                select parent_id from kd_menu where is_deleted = 0-->
-<!--                and id in ( select menu_id from kd_role_menu where role_id in-->
-<!--                <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                    #{item}-->
-<!--                </foreach> )-->
-<!--            )-->
-<!--        )-->
-<!--        AND menu_id IS NOT NULL-->
-<!--    </select>-->
-
-<!--    <select id="grantApiScopeTreeByRole" resultMap="treeNodeResultMap">-->
-<!--        SELECT-->
-<!--        *-->
-<!--        FROM-->
-<!--        (-->
-<!--            SELECT-->
-<!--                id,-->
-<!--                parent_id,-->
-<!--                NAME AS title,-->
-<!--                id AS "value",-->
-<!--                id AS "key"-->
-<!--            FROM-->
-<!--                kd_menu-->
-<!--            WHERE-->
-<!--                category = 1-->
-<!--            AND is_deleted = 0-->
-<!--            AND id IN ( SELECT menu_id FROM kd_scope_api WHERE is_deleted = 0 AND menu_id IS NOT NULL )-->
-<!--            AND (-->
-<!--                id IN (-->
-<!--                    select menu_id from kd_role_menu where role_id in-->
-<!--                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                )-->
-<!--                OR id IN (-->
-<!--                    select parent_id from kd_menu where is_deleted = 0-->
-<!--                    and id in (-->
-<!--                        select menu_id from kd_role_menu where role_id in-->
-<!--                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                        #{item}-->
-<!--                    </foreach> )-->
-<!--                )-->
-<!--            )-->
-<!--        ) menu-->
-
-<!--        UNION ALL-->
-
-<!--        SELECT-->
-<!--            id,-->
-<!--            menu_id AS parent_id,-->
-<!--            scope_name AS title,-->
-<!--            id AS "value",-->
-<!--            id AS "key"-->
-<!--        FROM-->
-<!--            kd_scope_api-->
-<!--        WHERE-->
-<!--            is_deleted = 0-->
-<!--        AND-->
-<!--            (-->
-<!--                menu_id IN (-->
-<!--                    select menu_id from kd_role_menu where role_id in-->
-<!--                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                        #{item}-->
-<!--                    </foreach>-->
-<!--                )-->
-<!--            OR menu_id IN (-->
-<!--                    select parent_id from kd_menu where is_deleted = 0-->
-<!--                    and id in ( select menu_id from kd_role_menu where role_id in-->
-<!--                    <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                        #{item}-->
-<!--                    </foreach> )-->
-<!--                )-->
-<!--        )-->
-<!--        AND menu_id IS NOT NULL-->
-<!--    </select>-->
-
-<!--    <select id="authRoutes" resultType="org.sky.system.pojo.dto.MenuDTO">-->
-<!--        SELECT-->
-<!--            GROUP_CONCAT(r.role_alias) as alias,-->
-<!--            m.path-->
-<!--        FROM-->
-<!--            kd_role_menu rm-->
-<!--            LEFT JOIN kd_menu m ON rm.menu_id = m.id-->
-<!--            LEFT JOIN kd_role r ON rm.role_id = r.id-->
-<!--        WHERE-->
-<!--            rm.role_id IN-->
-<!--            <foreach collection="list" index="index" item="item" open="(" separator="," close=")">-->
-<!--                #{item}-->
-<!--            </foreach>-->
-<!--            AND m.path IS NOT NULL and m.is_deleted = 0-->
-<!--        GROUP BY m.path-->
-<!--    </select>-->
-
+    <select id="selectSubjectList" resultMap="ResultMap">
+        select * from kd_subject
+        where 1=1
+        <if test="code != null and code != ''">and code = #{code} </if>
+        <if test="name != null and name != ''">and name like concat('%',#{name},'%')</if>
+    </select>
 </mapper>

+ 2 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/ISubjectService.java

@@ -1,6 +1,7 @@
  package org.sky.scientific.service;
 
  import com.baomidou.mybatisplus.extension.service.IService;
+ import org.sky.scientific.pojo.dto.SubjectQueryDto;
  import org.sky.scientific.pojo.entity.Subject;
  import org.sky.scientific.pojo.vo.SubjectVO;
 
@@ -12,5 +13,5 @@
   */
  public interface ISubjectService extends IService<Subject> {
 
-	 List<SubjectVO> allSubject(Subject subject);
+	 List<SubjectVO> allSubject(SubjectQueryDto queryDto);
  }

+ 3 - 3
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/SubjectServiceImpl.java

@@ -1,10 +1,10 @@
 package org.sky.scientific.service.impl;
 
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.AllArgsConstructor;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.scientific.mapper.SubjectMapper;
+import org.sky.scientific.pojo.dto.SubjectQueryDto;
 import org.sky.scientific.pojo.entity.Subject;
 import org.sky.scientific.pojo.vo.SubjectVO;
 import org.sky.scientific.service.ISubjectService;
@@ -25,8 +25,8 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
 	private final static String PARENT_ID = "parentId";
 
 	@Override
-	public List<SubjectVO> allSubject(Subject subject) {
-		List<Subject> allSubject = baseMapper.selectList(Wrappers.emptyWrapper());
+	public List<SubjectVO> allSubject(SubjectQueryDto queryDto) {
+		List<Subject> allSubject = baseMapper.selectSubjectList(queryDto);
 		List<SubjectVO> list = allSubject.stream().map(menu -> BeanUtil.copyProperties(menu, SubjectVO.class)).toList();
 
 		Map<Long, SubjectVO> subjectMap = new HashMap<>();