mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-07 17:55:59 +08:00
课程附件查询接口,返回值增加已有附件类型列表
This commit is contained in:
parent
295992e4d4
commit
3eb7864582
@ -40,6 +40,11 @@ public class BackendConstant {
|
||||
public static final String RESOURCE_TYPE_RAR = "RAR";
|
||||
public static final String RESOURCE_TYPE_TXT = "TXT";
|
||||
|
||||
public static final String RESOURCE_TYPE_ANNEX =
|
||||
RESOURCE_TYPE_PDF +","+ RESOURCE_TYPE_TXT +","+
|
||||
RESOURCE_TYPE_ZIP +","+ RESOURCE_TYPE_RAR +","+
|
||||
RESOURCE_TYPE_WORD +","+RESOURCE_TYPE_PPT +","+RESOURCE_TYPE_EXCEL;
|
||||
|
||||
public static final HashMap<String, String> RESOURCE_EXT_2_CONTENT_TYPE =
|
||||
new HashMap<>() {
|
||||
{
|
||||
|
@ -109,6 +109,11 @@ public class ResourceController {
|
||||
data.put("admin_users", adminUsers);
|
||||
}
|
||||
|
||||
if(!type.equals(BackendConstant.RESOURCE_TYPE_VIDEO) &&
|
||||
!type.equals(BackendConstant.RESOURCE_TYPE_IMAGE)){
|
||||
filter.setType(BackendConstant.RESOURCE_TYPE_ANNEX);
|
||||
data.put("existingType",resourceService.paginateType(filter));
|
||||
}
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
|
@ -35,4 +35,6 @@ public interface ResourceMapper extends BaseMapper<Resource> {
|
||||
List<Resource> paginate(ResourcePaginateFilter filter);
|
||||
|
||||
Long paginateCount(ResourcePaginateFilter filter);
|
||||
|
||||
List<String> paginateType(ResourcePaginateFilter filter);
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ public interface ResourceService extends IService<Resource> {
|
||||
|
||||
PaginationResult<Resource> paginate(int page, int size, ResourcePaginateFilter filter);
|
||||
|
||||
List<String> paginateType(ResourcePaginateFilter filter);
|
||||
|
||||
Resource create(
|
||||
Integer adminId,
|
||||
String categoryIds,
|
||||
|
@ -60,6 +60,11 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource>
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> paginateType(ResourcePaginateFilter filter) {
|
||||
return getBaseMapper().paginateType(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Resource create(
|
||||
|
@ -140,4 +140,46 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="paginateType" resultType="java.lang.String">
|
||||
SELECT DISTINCT ( `resources`.`type` )
|
||||
FROM `resources`
|
||||
<choose>
|
||||
<when test="categoryIds != null and categoryIds != ''">
|
||||
<choose>
|
||||
<when test="categoryIds.indexOf('0') == 0">
|
||||
LEFT JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
|
||||
WHERE `resources`.`is_hidden` = 0
|
||||
AND `resource_category`.`cid` IS NULL
|
||||
</when>
|
||||
<otherwise>
|
||||
INNER JOIN `resource_category` ON `resource_category`.`rid` = `resources`.`id`
|
||||
WHERE `resources`.`is_hidden` = 0
|
||||
AND `resource_category`.`cid` IN (#{categoryIds})
|
||||
</otherwise>
|
||||
</choose>
|
||||
</when>
|
||||
<otherwise>
|
||||
WHERE `resources`.`is_hidden` = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="name != null and name != ''">
|
||||
AND `resources`.`name` LIKE concat('%',#{name},'%')
|
||||
</if>
|
||||
<if test="disk != null and disk != ''">
|
||||
AND `resources`.`disk` = #{disk}
|
||||
</if>
|
||||
<if test="extension != null and extension != ''">
|
||||
AND `resources`.`extension` = #{extension}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
AND `resources`.`type` IN
|
||||
<foreach item="item" collection="type.split(',')" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="adminId != null and adminId != 0">
|
||||
AND `resources`.`admin_id` = #{adminId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user