Compare commits
3 Commits
de53fb7838
...
740a343863
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
740a343863 | ||
|
|
a76d954979 | ||
|
|
ecbb2e993c |
@@ -57,6 +57,8 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
|||||||
.excludePathPatterns("/api/app", "/api/app/getAppVersion")
|
.excludePathPatterns("/api/app", "/api/app/getAppVersion")
|
||||||
.excludePathPatterns("/api/website/**")
|
.excludePathPatterns("/api/website/**")
|
||||||
.excludePathPatterns("/api/app/access_statistics/accumulate")
|
.excludePathPatterns("/api/app/access_statistics/accumulate")
|
||||||
|
.excludePathPatterns("/api/app/resource_category/**")
|
||||||
|
.excludePathPatterns("/api/app/resource/**")
|
||||||
// 排除模型接口
|
// 排除模型接口
|
||||||
.excludePathPatterns("/model/page", "/model/list", "/model/detail/**", "/model/category/**")
|
.excludePathPatterns("/model/page", "/model/list", "/model/detail/**", "/model/category/**")
|
||||||
// 排除咨询接口
|
// 排除咨询接口
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.corewing.app.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ResourceCategoryTreeRequest {
|
||||||
|
}
|
||||||
14
src/main/java/com/corewing/app/dto/ResourcePageRequest.java
Normal file
14
src/main/java/com/corewing/app/dto/ResourcePageRequest.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.corewing.app.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ResourcePageRequest {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "搜索参数")
|
||||||
|
private String searchKey;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分类id")
|
||||||
|
private String categoryId;
|
||||||
|
}
|
||||||
44
src/main/java/com/corewing/app/entity/BizResource.java
Normal file
44
src/main/java/com/corewing/app/entity/BizResource.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package com.corewing.app.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.corewing.app.common.base.CommonEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class BizResource extends CommonEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String thumbnail;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
private String categoryId;
|
||||||
|
|
||||||
|
private String subtitle;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
private String downloadUrl;
|
||||||
|
|
||||||
|
private Integer sortCode;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private String extJson;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.corewing.app.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.corewing.app.common.base.CommonEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class BizResourceCategory extends CommonEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
private String parentId;
|
||||||
|
|
||||||
|
private Integer sortCode;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private String extJson;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.corewing.app.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.corewing.app.entity.BizResourceCategory;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BizResourceCategoryMapper extends BaseMapper<BizResourceCategory> {
|
||||||
|
|
||||||
|
}
|
||||||
13
src/main/java/com/corewing/app/mapper/BizResourceMapper.java
Normal file
13
src/main/java/com/corewing/app/mapper/BizResourceMapper.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package com.corewing.app.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.corewing.app.dto.ResourcePageRequest;
|
||||||
|
import com.corewing.app.entity.BizResource;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface BizResourceMapper extends BaseMapper<BizResource> {
|
||||||
|
Page<BizResource> page(Page<BizResource> page, @Param("resourcePageRequest") ResourcePageRequest resourcePageRequest);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.corewing.app.modules.downloadCenter;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
|
import com.corewing.app.common.Result;
|
||||||
|
import com.corewing.app.dto.ResourceCategoryTreeRequest;
|
||||||
|
import com.corewing.app.service.BizResourceCategoryService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源分类接口
|
||||||
|
*/
|
||||||
|
@Api(tags = "资源分类接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/app/resource_category")
|
||||||
|
public class BizResourceCategoryController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BizResourceCategoryService bizResourceCategoryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类树形集合
|
||||||
|
* @param resourceCategoryTreeRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation("分类树形集合")
|
||||||
|
@GetMapping("/tree")
|
||||||
|
public Result<List<Tree<String>>> categoryTree(ResourceCategoryTreeRequest resourceCategoryTreeRequest) {
|
||||||
|
return Result.success(bizResourceCategoryService.tree(resourceCategoryTreeRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.corewing.app.modules.downloadCenter;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.corewing.app.common.Result;
|
||||||
|
import com.corewing.app.dto.ResourcePageRequest;
|
||||||
|
import com.corewing.app.entity.BizResource;
|
||||||
|
import com.corewing.app.service.BizResourceService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资源接口
|
||||||
|
*/
|
||||||
|
@Api(tags = "资源接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/app/resource")
|
||||||
|
public class BizResourceController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BizResourceService bizResourceService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资源分页
|
||||||
|
* @param resourcePageRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取资源分页")
|
||||||
|
@GetMapping("/page")
|
||||||
|
public Result<Page<BizResource>> page(ResourcePageRequest resourcePageRequest) {
|
||||||
|
return Result.success(bizResourceService.page(resourcePageRequest));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.corewing.app.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.corewing.app.dto.ResourceCategoryTreeRequest;
|
||||||
|
import com.corewing.app.entity.BizResourceCategory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface BizResourceCategoryService extends IService<BizResourceCategory> {
|
||||||
|
|
||||||
|
List<Tree<String>> tree(ResourceCategoryTreeRequest resourceCategoryTreeRequest);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.corewing.app.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.corewing.app.dto.ResourcePageRequest;
|
||||||
|
import com.corewing.app.entity.BizResource;
|
||||||
|
|
||||||
|
public interface BizResourceService extends IService<BizResource> {
|
||||||
|
|
||||||
|
Page<BizResource> page(ResourcePageRequest resourcePageRequest);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.corewing.app.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
|
import cn.hutool.core.lang.tree.TreeNode;
|
||||||
|
import cn.hutool.core.lang.tree.TreeUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.corewing.app.dto.ResourceCategoryTreeRequest;
|
||||||
|
import com.corewing.app.entity.AppModelCategory;
|
||||||
|
import com.corewing.app.entity.BizResourceCategory;
|
||||||
|
import com.corewing.app.mapper.BizResourceCategoryMapper;
|
||||||
|
import com.corewing.app.service.BizResourceCategoryService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BizResourceCategoryServiceImpl extends ServiceImpl<BizResourceCategoryMapper, BizResourceCategory> implements BizResourceCategoryService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Tree<String>> tree(ResourceCategoryTreeRequest resourceCategoryTreeRequest) {
|
||||||
|
LambdaQueryWrapper<BizResourceCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
List<BizResourceCategory> resourceList = list(queryWrapper);
|
||||||
|
|
||||||
|
// 填充上层的父级菜单
|
||||||
|
this.fillParentCategoryInfo(resourceList);
|
||||||
|
|
||||||
|
List<TreeNode<String>> treeNodeList = resourceList.stream().map(category ->
|
||||||
|
new TreeNode<>(category.getId(), category.getParentId(),
|
||||||
|
category.getCategoryName(), category.getSortCode()).setExtra(JSONUtil.parseObj(category)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
return TreeUtil.build(treeNodeList, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillParentCategoryInfo(List<BizResourceCategory> categoryList) {
|
||||||
|
if(CollUtil.isNotEmpty(categoryList)){
|
||||||
|
List<BizResourceCategory> parentResourceCategoryList = categoryList.stream().filter(distinctByKey(BizResourceCategory::getParentId)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<String> parentIds = null;
|
||||||
|
if(CollUtil.isNotEmpty(parentResourceCategoryList)){
|
||||||
|
parentIds = CollUtil.newArrayList();
|
||||||
|
for(BizResourceCategory parentCategory : categoryList){
|
||||||
|
if(!StrUtil.equals(parentCategory.getParentId(),"0")){
|
||||||
|
parentIds.add(parentCategory.getParentId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollUtil.isNotEmpty(parentIds)){
|
||||||
|
LambdaQueryWrapper<BizResourceCategory> parentCategoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
parentCategoryLambdaQueryWrapper.in(BizResourceCategory::getId,parentIds);
|
||||||
|
List<BizResourceCategory> parentCategoryList = this.list(parentCategoryLambdaQueryWrapper);
|
||||||
|
if(CollUtil.isNotEmpty(parentCategoryList)){
|
||||||
|
this.fillParentCategoryInfo(parentCategoryList);
|
||||||
|
categoryList.addAll(parentCategoryList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
||||||
|
Set<Object> seen = ConcurrentHashMap.newKeySet();
|
||||||
|
return t -> seen.add(keyExtractor.apply(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.corewing.app.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.corewing.app.common.page.PageContext;
|
||||||
|
import com.corewing.app.dto.ResourcePageRequest;
|
||||||
|
import com.corewing.app.entity.AppModel;
|
||||||
|
import com.corewing.app.entity.BizResource;
|
||||||
|
import com.corewing.app.entity.BizResourceCategory;
|
||||||
|
import com.corewing.app.mapper.BizResourceCategoryMapper;
|
||||||
|
import com.corewing.app.mapper.BizResourceMapper;
|
||||||
|
import com.corewing.app.service.BizProductService;
|
||||||
|
import com.corewing.app.service.BizResourceCategoryService;
|
||||||
|
import com.corewing.app.service.BizResourceService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BizResourceServiceImpl extends ServiceImpl<BizResourceMapper, BizResource> implements BizResourceService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BizResourceMapper bizResourceMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<BizResource> page(ResourcePageRequest resourcePageRequest) {
|
||||||
|
Page<BizResource> page = PageContext.getPage(BizResource.class);
|
||||||
|
return bizResourceMapper.page(page, resourcePageRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
7
src/main/resources/mapper/BizResourceCategoryMapper.xml
Normal file
7
src/main/resources/mapper/BizResourceCategoryMapper.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.corewing.app.mapper.BizResourceCategoryMapper">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
22
src/main/resources/mapper/BizResourceMapper.xml
Normal file
22
src/main/resources/mapper/BizResourceMapper.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.corewing.app.mapper.BizResourceMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="page" resultType="com.corewing.app.entity.BizResource">
|
||||||
|
select r.*, rc.category_name
|
||||||
|
from biz_resource r
|
||||||
|
left join biz_resource_category rc on rc.id = r.category_id
|
||||||
|
<where>
|
||||||
|
and r.delete_flag = 'NOT_DELETE'
|
||||||
|
and r.status = 'ENABLE'
|
||||||
|
<if test="resourcePageRequest.categoryId != null and resourcePageRequest.categoryId != ''">
|
||||||
|
and r.category_id = #{resourcePageRequest.categoryId}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="resourcePageRequest.searchKey != null and resourcePageRequest.searchKey != ''">
|
||||||
|
and r.title like CONCAT('%', #{resourcePageRequest.searchKey}, '%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user