From c1cfa1781e76cfa2640e9338f25a0f40fa13ed9f Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Wed, 20 Apr 2022 17:31:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B3=E8=B4=AD=E8=BD=A6=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E9=97=A8=E6=88=B7=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/FileUploadController.java | 1 - .../interceptor/YaweiSSOProperties.java | 2 - .../controller/CategoryController.java | 14 ++- .../service/impl/CategoryServiceImpl.java | 1 + .../controller/FileManagerController.java | 17 +++ .../service/impl/FileManagerServiceImpl.java | 14 +++ .../controller/ResourceController.java | 37 ++++-- .../modules/resource/dao/ResourceDao.java | 5 +- .../modules/resource/dto/ResourceDTO.java | 4 + .../resource/entity/ResourceEntity.java | 8 ++ .../resource/service/ResourceService.java | 9 +- .../service/impl/ResourceServiceImpl.java | 104 ++++++++++++++++- .../controller/ResourceCarController.java | 83 ++++++++++++++ .../resourceCar/dao/ResourceCarDao.java | 26 +++++ .../resourceCar/dto/ResourceCarDTO.java | 51 +++++++++ .../resourceCar/entity/ResourceCarEntity.java | 74 ++++++++++++ .../resourceCar/excel/ResourceCarExcel.java | 47 ++++++++ .../service/ResourceCarService.java | 26 +++++ .../service/impl/ResourceCarServiceImpl.java | 106 ++++++++++++++++++ .../modules/security/oauth2/Oauth2Filter.java | 2 +- .../sys/controller/SysRegionController.java | 9 +- .../service/impl/SysRegionServiceImpl.java | 1 + .../src/main/resources/application-prod.yml | 6 +- .../resources/mapper/resource/ResourceDao.xml | 68 ++++++----- .../mapper/resourceCar/ResourceCarDao.xml | 52 +++++++++ 25 files changed, 717 insertions(+), 50 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/fileManager/controller/FileManagerController.java create mode 100644 renren-admin/src/main/java/io/renren/modules/fileManager/service/impl/FileManagerServiceImpl.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resourceCar/dto/ResourceCarDTO.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resourceCar/entity/ResourceCarEntity.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resourceCar/excel/ResourceCarExcel.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java create mode 100644 renren-admin/src/main/java/io/renren/modules/resourceCar/service/impl/ResourceCarServiceImpl.java create mode 100644 renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml diff --git a/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java b/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java index 44c98968..4259a658 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java @@ -1,6 +1,5 @@ package io.renren.common.controller; - import io.renren.common.utils.Result; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; diff --git a/renren-admin/src/main/java/io/renren/common/interceptor/YaweiSSOProperties.java b/renren-admin/src/main/java/io/renren/common/interceptor/YaweiSSOProperties.java index b189b099..5a7b4f17 100644 --- a/renren-admin/src/main/java/io/renren/common/interceptor/YaweiSSOProperties.java +++ b/renren-admin/src/main/java/io/renren/common/interceptor/YaweiSSOProperties.java @@ -1,12 +1,10 @@ package io.renren.common.interceptor; - import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; - @Data @Component @PropertySource("classpath:/yaweisso.properties") diff --git a/renren-admin/src/main/java/io/renren/modules/category/controller/CategoryController.java b/renren-admin/src/main/java/io/renren/modules/category/controller/CategoryController.java index cd129fc3..a4b6f832 100644 --- a/renren-admin/src/main/java/io/renren/modules/category/controller/CategoryController.java +++ b/renren-admin/src/main/java/io/renren/modules/category/controller/CategoryController.java @@ -1,5 +1,6 @@ package io.renren.modules.category.controller; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import io.renren.common.exception.ErrorCode; import io.renren.common.utils.MessageUtils; @@ -14,8 +15,10 @@ import io.renren.modules.category.service.CategoryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import java.io.File; import java.util.List; @RestController @@ -55,12 +58,20 @@ public class CategoryController { @PostMapping("/insert") @ApiOperation("保存") + @Transactional(rollbackFor = RuntimeException.class) public Object insert(@RequestBody CategoryDTO categoryDTO) { //效验数据 ValidatorUtils.validateEntity(categoryDTO, AddGroup.class, DefaultGroup.class); categoryDTO.setDelFlag(0); categoryService.save(categoryDTO); - + //若为一级分类,增加文件夹 + if (ObjectUtil.isNull(categoryDTO.getPid())) { + File file = new File("D:\\新建文件夹\\resource\\" + categoryDTO.getName()); + file.mkdirs(); + if (file.mkdirs()) { + throw new RuntimeException("创建文件夹失败!"); + } + } return new Result(); } @@ -87,4 +98,5 @@ public class CategoryController { return new Result<>().error(ErrorCode.INTERNAL_SERVER_ERROR, MessageUtils.getMessage(ErrorCode.INTERNAL_SERVER_ERROR)); } } + } diff --git a/renren-admin/src/main/java/io/renren/modules/category/service/impl/CategoryServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/category/service/impl/CategoryServiceImpl.java index 1183980c..2d92acad 100644 --- a/renren-admin/src/main/java/io/renren/modules/category/service/impl/CategoryServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/category/service/impl/CategoryServiceImpl.java @@ -62,6 +62,7 @@ public class CategoryServiceImpl extends CrudServiceImpl idList = jsonArray.toJavaList(Long.class); categoryDao.deleteByIds(idList); } diff --git a/renren-admin/src/main/java/io/renren/modules/fileManager/controller/FileManagerController.java b/renren-admin/src/main/java/io/renren/modules/fileManager/controller/FileManagerController.java new file mode 100644 index 00000000..3f1a45aa --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fileManager/controller/FileManagerController.java @@ -0,0 +1,17 @@ +package io.renren.modules.fileManager.controller; + +import io.renren.modules.fileManager.service.FileManagerService; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/fileManager") +@Api(tags = "文件管理") +public class FileManagerController { + + //@Autowired + //private FileManagerService fileManagerService; + +} diff --git a/renren-admin/src/main/java/io/renren/modules/fileManager/service/impl/FileManagerServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/fileManager/service/impl/FileManagerServiceImpl.java new file mode 100644 index 00000000..a40ec751 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/fileManager/service/impl/FileManagerServiceImpl.java @@ -0,0 +1,14 @@ +package io.renren.modules.fileManager.service.impl; + +import io.renren.modules.fileManager.service.FileManagerService; +import org.springframework.stereotype.Service; + +/** + * @author + * @date 2022/04/20 + * @version 1.0 + */ +@Service +public class FileManagerServiceImpl implements FileManagerService { + +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index c6efe74a..51634a5e 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -18,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.Map; /** @@ -56,25 +58,29 @@ public class ResourceController { @PostMapping("/pageWithAttrs") @ApiOperation("分页查询资源信息2") - //@ApiImplicitParams({ - // @ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType="String") , - // @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query",required = true, dataType="String") , - // @ApiImplicitParam(name = "infoList", value = "类型", paramType = "query", dataType="List") - //}) - //@RequiresPermissions("resource:resource:page") + @LogOperation("分页查询资源信息2") public Result pageWithAttrs(@RequestBody JSONObject jsonObject){ return new Result<>().ok(resourceService.pageWithAttrs(jsonObject)); } @GetMapping("/select/{id}") @ApiOperation("查询资源详细信息") + @LogOperation("查询资源详细信息") //@RequiresPermissions("resource:resource:info") public Result get(@PathVariable("id") Long id){ ResourceDTO data = resourceService.selectWithAttrs(id); - return new Result().ok(data); } + + @GetMapping("/selectTotal") + @ApiOperation("查询系统及本部门已汇聚能力") + @LogOperation("查询系统及本部门已汇聚能力") + public Result selectTotal(){ + return new Result<>().ok(resourceService.selectTotal()); + } + + @PostMapping("/insert") @ApiOperation("保存") @LogOperation("保存") @@ -112,6 +118,23 @@ public class ResourceController { return new Result(); } + @GetMapping("/getDevelopmentFile") + @ApiOperation("获取开发指南") + @LogOperation("获取开发指南") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "类型", paramType = "query",required = true, dataType="String") , + @ApiImplicitParam(name = "resourceId", value = "能力ID", paramType = "query",required = false, dataType="Long") , + }) + public void getDevelopmentFile(@ApiIgnore HttpServletRequest request, @ApiIgnore HttpServletResponse response){ + try { + resourceService.getDevelopmentFile(request, response); + } catch (Exception e) { + System.err.println(e.getMessage()); + e.printStackTrace(); + new Result<>().error(500,"文件获取失败!"); + } + } + /*@GetMapping("export") @ApiOperation("导出") @LogOperation("导出") diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java index e3b1ab2f..15fc6082 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/ResourceDao.java @@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 资源表 @@ -19,5 +20,7 @@ public interface ResourceDao extends BaseDao { Integer deleteByIds(@Param("ids") List idList); - List selectWithAttrs(@Param("dto") ResourceDTO resourceDTO, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize); + List selectWithAttrs(@Param("dto") ResourceDTO resourceDTO); + + List selectTypeCount(Long deptId); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java b/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java index 3857a789..5092fdaa 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dto/ResourceDTO.java @@ -30,6 +30,10 @@ public class ResourceDTO implements Serializable { private String description; @ApiModelProperty(value = "链接URL") private String link; + @ApiModelProperty(value = "所属部门") + private Long deptId; + @ApiModelProperty(value = "地区编码") + private Long districtId; @ApiModelProperty(value = "图片保存地址") private String image; @ApiModelProperty(value = "数据量") diff --git a/renren-admin/src/main/java/io/renren/modules/resource/entity/ResourceEntity.java b/renren-admin/src/main/java/io/renren/modules/resource/entity/ResourceEntity.java index 7dcf9fc0..87ce50f2 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/entity/ResourceEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/entity/ResourceEntity.java @@ -39,6 +39,14 @@ public class ResourceEntity { */ private String link; /** + * 所属部门 + */ + private Long deptId; + /** + * 地区编码 + */ + private Long districtId; + /** * 图片保存地址 */ private String image; diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index 163f1660..8aa19d76 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java @@ -6,6 +6,8 @@ import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.AttrEntity; import io.renren.modules.resource.entity.ResourceEntity; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -24,7 +26,12 @@ public interface ResourceService extends CrudService pageWithAttrs(JSONObject jsonObject); + Object pageWithAttrs(JSONObject jsonObject); List selectAttrsByResourceId(Long id); + + Object selectTotal(); + + void getDevelopmentFile(HttpServletRequest request, HttpServletResponse response) throws Exception; + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index 6d2ab17b..36670d39 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -1,10 +1,13 @@ package io.renren.modules.resource.service.impl; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.renren.common.service.impl.CrudServiceImpl; import io.renren.modules.resource.dao.AttrDao; import io.renren.modules.resource.dao.ResourceDao; @@ -12,12 +15,22 @@ import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.AttrEntity; import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.service.ResourceService; +import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.security.user.UserDetail; +import org.apache.commons.io.IOUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -103,12 +116,46 @@ public class ResourceServiceImpl extends CrudServiceImpl pageWithAttrs(JSONObject jsonObject) { + public Object pageWithAttrs(JSONObject jsonObject) { ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class); - Integer pageNum = jsonObject.getInteger("pageNum"); Integer pageSize = jsonObject.getInteger("pageSize"); - return resourceDao.selectWithAttrs(resourceDTO, (pageNum - 1) * pageSize, pageSize); + Page resultPage = new Page<>(pageNum, pageSize); + if (resourceDTO.getInfoList().isEmpty()) { + Page page = new Page(pageNum, pageSize); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("del_flag", 0) + .like(StringUtils.isNotBlank(resourceDTO.getName()), "name", resourceDTO.getName()) + .eq(ObjectUtil.isNotNull(resourceDTO.getDistrictId()),"district_id", resourceDTO.getDistrictId()) + .eq(ObjectUtil.isNotNull(resourceDTO.getDeptId()),"dept_id", resourceDTO.getDeptId()) + .eq("type", resourceDTO.getType()); + Page entityPage = resourceDao.selectPage(page, queryWrapper); + ArrayList list = new ArrayList<>(); + entityPage.getRecords().forEach(item -> { + ResourceDTO dto = new ResourceDTO(); + BeanUtils.copyProperties(item, dto); + dto.setInfoList(this.selectAttrsByResourceId(dto.getId())); + list.add(dto); + }); + resultPage.setRecords(list); + resultPage.setTotal(page.getTotal()); + + } else { + List resourceDTOS = resourceDao.selectWithAttrs(resourceDTO); + int j = pageNum * pageSize > resourceDTOS.size() ? resourceDTOS.size() : pageNum * pageSize; + if (resourceDTOS.isEmpty()) { + resultPage.setRecords(null); + resultPage.setTotal(0); + } else { + ArrayList recordLists = new ArrayList<>(); + for (int i = (pageNum - 1 ) * pageSize; i < j; i++) { + recordLists.add(resourceDTOS.get(i)); + } + resultPage.setRecords(recordLists); + resultPage.setTotal(resourceDTOS.size()); + } + } + return resultPage; } @Override @@ -119,4 +166,55 @@ public class ResourceServiceImpl extends CrudServiceImpl resultMap = new HashMap<>(); + List totalMap = resourceDao.selectTypeCount(null); + resultMap.put("total", totalMap); + List deptMap = resourceDao.selectTypeCount(user.getDeptId()); + resultMap.put("dept", deptMap); + return resultMap; + } + + @Override + public void getDevelopmentFile(HttpServletRequest request, HttpServletResponse response) throws Exception { + //String type = request.getParameter("type").toString(); + //Long resourceId = Long.parseLong(request.getParameter("resourceId")); + //String url = type + "/devModelFile.txt"; + String url = "renren-admin/src/main/resources/temp/devModelFile.md"; + File file = new File(url); + if (!file.exists()) { + Exception e = new Exception("文件不存在"); + e.printStackTrace(); + throw e;//抛出文件不存在的 + } + response.setContentType("text/html"); + FileInputStream fis = null; + OutputStream outputStream = response.getOutputStream(); + try { + fis = new FileInputStream(file); + //将读取流拷贝到输出流中 + IOUtils.copy(fis, outputStream); + //清空缓存的读取流,保证数据完整性 + response.flushBuffer(); + } catch (IOException e) { + System.err.println("解析失败!!!"); + e.printStackTrace(); + throw new Exception("解析失败"); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (outputStream != null) { + outputStream.close();//输出流关闭 + } + } + System.err.println("获取开发指南成功!!!"); + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java new file mode 100644 index 00000000..13c73656 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/controller/ResourceCarController.java @@ -0,0 +1,83 @@ +package io.renren.modules.resourceCar.controller; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.renren.common.annotation.LogOperation; +import io.renren.common.utils.Result; +import io.renren.common.validator.ValidatorUtils; +import io.renren.common.validator.group.AddGroup; +import io.renren.common.validator.group.DefaultGroup; +import io.renren.modules.resourceCar.dto.ResourceCarDTO; +import io.renren.modules.resourceCar.service.ResourceCarService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.Map; + +/** +* 申购记录表 +* +* @author dg +* @since 1.0 2022-04-16 +*/ +@RestController +@RequestMapping("/resourcecar") +@Api(tags="申购记录表") +public class ResourceCarController { + @Autowired + private ResourceCarService resourceCarService; + + @GetMapping("/page") + @ApiOperation("分页") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "当前页码,从1开始", paramType = "body", required = true, dataType="int") , + @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "body",required = true, dataType="int") , + @ApiImplicitParam(name = "type", value = "资源类型", paramType = "body", dataType="String"), + @ApiImplicitParam(name = "name", value = "资源名称", paramType = "body", dataType="String") + }) + //@RequiresPermissions("resourceCar:resourcecar:page") + public Result> page(@ApiIgnore @RequestParam Map params){ + return new Result>().ok(resourceCarService.selectPage(params)); + } + + @GetMapping("/total") + @ApiOperation("申购车总数") + public Result total(){ + return new Result<>().ok(resourceCarService.total()); + } + + + @GetMapping("/select/{id}") + @ApiOperation("信息") + //@RequiresPermissions("resourceCar:resourcecar:info") + public Result get(@PathVariable("id") Long id){ + ResourceCarDTO data = resourceCarService.get(id); + return new Result().ok(data); + } + + @PostMapping("/insert") + @ApiOperation("保存") + @LogOperation("保存") + //@RequiresPermissions("resourceCar:resourcecar:save") + public Result save(@RequestBody ResourceCarDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + resourceCarService.insertOrUpdate(dto); + return new Result(); + } + + @DeleteMapping("/delete") + @ApiOperation("删除") + @LogOperation("删除") + //@RequiresPermissions("resourceCar:resourcecar:delete") + public Result delete(@RequestBody JSONObject jsonObject){ + resourceCarService.deleteByIds(jsonObject); + return new Result(); + } + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java new file mode 100644 index 00000000..a9a8a997 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/dao/ResourceCarDao.java @@ -0,0 +1,26 @@ +package io.renren.modules.resourceCar.dao; + +import io.renren.common.dao.BaseDao; +import io.renren.modules.resourceCar.dto.ResourceCarDTO; +import io.renren.modules.resourceCar.entity.ResourceCarEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** +* 申购记录表 +* +* @author dg +* @since 1.0 2022-04-16 +*/ +@Mapper +public interface ResourceCarDao extends BaseDao { + + Integer deleteByIds(@Param("ids") List ids); + + List selectPageWithResource(@Param("params") Map params, + @Param("pageNum") Integer pageNum, + @Param("pageSize") Integer pageSize); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/dto/ResourceCarDTO.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/dto/ResourceCarDTO.java new file mode 100644 index 00000000..f290a09b --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/dto/ResourceCarDTO.java @@ -0,0 +1,51 @@ +package io.renren.modules.resourceCar.dto; + +import io.renren.modules.resource.dto.ResourceDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** +* 申购记录表 +* +* @author dg +* @since 1.0 2022-04-16 +*/ +@Data +@ApiModel(value = "申购记录表") +public class ResourceCarDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + @ApiModelProperty(value = "用户ID,sys_user主键") + private Long userId; + @ApiModelProperty(value = "资源ID,tb_data_resource主键") + private Long resourceId; + @ApiModelProperty(value = "删除标志:0:正常;1:已删除;9:其他") + private Integer delFlag; + @ApiModelProperty(value = "创建时间") + private Date createDate; + @ApiModelProperty(value = "创建人") + private Long creator; + @ApiModelProperty(value = "修改时间") + private Date updateDate; + @ApiModelProperty(value = "修改人") + private Long updater; + @ApiModelProperty(value = "备用字段") + private String note1; + @ApiModelProperty(value = "备用字段") + private String note2; + @ApiModelProperty(value = "备用字段") + private String note3; + @ApiModelProperty(value = "备用字段") + private String note4; + @ApiModelProperty(value = "备用字段") + private String note5; + + @ApiModelProperty(value = "资源信息") + private ResourceDTO resourceDTO; + +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/entity/ResourceCarEntity.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/entity/ResourceCarEntity.java new file mode 100644 index 00000000..cee82e30 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/entity/ResourceCarEntity.java @@ -0,0 +1,74 @@ +package io.renren.modules.resourceCar.entity; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.baomidou.mybatisplus.annotation.*; +import java.util.Date; + +/** + * 申购记录表 + * + * @author dg + * @since 1.0 2022-04-16 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tb_resource_car") +public class ResourceCarEntity { + private static final long serialVersionUID = 1L; + + @TableId + private Long id; + /** + * 用户ID,sys_user主键 + */ + private Long userId; + /** + * 资源ID,tb_data_resource主键 + */ + private Long resourceId; + /** + * 删除标志:0:正常;1:已删除;9:其他 + */ + private Integer delFlag; + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + private Date createDate; + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + private Long creator; + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateDate; + /** + * 修改人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Long updater; + /** + * 备用字段 + */ + private String note1; + /** + * 备用字段 + */ + private String note2; + /** + * 备用字段 + */ + private String note3; + /** + * 备用字段 + */ + private String note4; + /** + * 备用字段 + */ + private String note5; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/excel/ResourceCarExcel.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/excel/ResourceCarExcel.java new file mode 100644 index 00000000..02e6c267 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/excel/ResourceCarExcel.java @@ -0,0 +1,47 @@ +package io.renren.modules.resourceCar.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; +import java.util.Date; + +/** + * 申购记录表 + * + * @author dg + * @since 1.0 2022-04-16 + */ +@Data +@ContentRowHeight(20) +@HeadRowHeight(20) +@ColumnWidth(25) +public class ResourceCarExcel { + @ExcelProperty(value = "Long", index = 0) + private Long id; + @ExcelProperty(value = "用户ID,sys_user主键", index = 1) + private Long userId; + @ExcelProperty(value = "资源ID,tb_data_resource主键", index = 2) + private Long resourceId; + @ExcelProperty(value = "删除标志:0:正常;1:已删除;9:其他", index = 3) + private Integer delFlag; + @ExcelProperty(value = "创建时间", index = 4) + private Date createDate; + @ExcelProperty(value = "创建人", index = 5) + private Long creator; + @ExcelProperty(value = "修改时间", index = 6) + private Date updateDate; + @ExcelProperty(value = "修改人", index = 7) + private Long updater; + @ExcelProperty(value = "备用字段", index = 8) + private String note1; + @ExcelProperty(value = "备用字段", index = 9) + private String note2; + @ExcelProperty(value = "备用字段", index = 10) + private String note3; + @ExcelProperty(value = "备用字段", index = 11) + private String note4; + @ExcelProperty(value = "备用字段", index = 12) + private String note5; +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java new file mode 100644 index 00000000..f17bc06e --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/service/ResourceCarService.java @@ -0,0 +1,26 @@ +package io.renren.modules.resourceCar.service; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.renren.common.service.CrudService; +import io.renren.modules.resourceCar.dto.ResourceCarDTO; +import io.renren.modules.resourceCar.entity.ResourceCarEntity; + +import java.util.Map; + +/** + * 申购记录表 + * + * @author dg + * @since 1.0 2022-04-16 + */ +public interface ResourceCarService extends CrudService { + + void deleteByIds(JSONObject jsonObject); + + void insertOrUpdate(ResourceCarDTO dto); + + IPage selectPage(Map params); + + Object total(); +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceCar/service/impl/ResourceCarServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceCar/service/impl/ResourceCarServiceImpl.java new file mode 100644 index 00000000..ea58dbde --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resourceCar/service/impl/ResourceCarServiceImpl.java @@ -0,0 +1,106 @@ +package io.renren.modules.resourceCar.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.renren.common.service.impl.CrudServiceImpl; +import io.renren.modules.resource.dao.ResourceDao; +import io.renren.modules.resource.entity.ResourceEntity; +import io.renren.modules.resource.service.ResourceService; +import io.renren.modules.resourceCar.dao.ResourceCarDao; +import io.renren.modules.resourceCar.dto.ResourceCarDTO; +import io.renren.modules.resourceCar.entity.ResourceCarEntity; +import io.renren.modules.resourceCar.service.ResourceCarService; +import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.security.user.UserDetail; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 申购记录表 + * + * @author dg + * @since 1.0 2022-04-16 + */ +@Service +public class ResourceCarServiceImpl extends CrudServiceImpl implements ResourceCarService { + + @Autowired + private ResourceService resourceService; + + @Autowired + private ResourceCarDao resourceCarDao; + + @Autowired + private ResourceDao resourceDao; + + @Override + public QueryWrapper getWrapper(Map params){ + QueryWrapper wrapper = new QueryWrapper<>(); + return wrapper; + } + + + @Override + public void deleteByIds(JSONObject jsonObject) { + List ids = jsonObject.getJSONArray("ids").toJavaList(Long.class); + resourceCarDao.deleteByIds(ids); + } + + @Override + public void insertOrUpdate(ResourceCarDTO dto) { + Map selectMap = new HashMap<>(); + UserDetail user = SecurityUser.getUser(); + Long userId = user.getId(); + selectMap.put("resource_id", dto.getResourceId()); + selectMap.put("user_id", userId); + selectMap.put("del_flag", 0); + List carEntities = resourceCarDao.selectByMap(selectMap); + if (carEntities.isEmpty()) { + ResourceCarEntity carEntity = new ResourceCarEntity(); + dto.setUserId(userId); + BeanUtils.copyProperties(dto, carEntity); + resourceCarDao.insert(carEntity); + }else { + ResourceCarEntity entity = carEntities.get(0); + ResourceCarEntity carEntity = new ResourceCarEntity(); + BeanUtils.copyProperties(entity, carEntity, "updateDate"); + resourceCarDao.updateById(carEntity); + } + } + + @Override + public IPage selectPage(Map params) { + UserDetail user = SecurityUser.getUser(); + int pageNum = Integer.parseInt(params.get("pageNum").toString()); + int pageSize = Integer.parseInt(params.get("pageSize").toString()); + Page page = new Page(pageNum, pageSize); + params.put("userId", user.getId()); + List resourceCarDTOS = resourceCarDao.selectPageWithResource(params, (pageNum - 1) * pageSize, pageSize); + resourceCarDTOS.forEach(item -> { + item.setResourceDTO(resourceService.selectWithAttrs(item.getResourceId())); + }); + List resourceCarDTOSs = resourceCarDao.selectPageWithResource(params, 0, 100000); + page.setRecords(resourceCarDTOS); + page.setTotal(resourceCarDTOSs.size()); + return page; + } + + @Override + public Object total() { + UserDetail user = SecurityUser.getUser(); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("del_flag", 0) + .eq("user_id", user.getId()); + Integer count = resourceCarDao.selectCount(wrapper); + HashMap resultMap = new HashMap<>(); + resultMap.put("count", count); + return resultMap; + } +} \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java index a565d8f3..1e07ae14 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java +++ b/renren-admin/src/main/java/io/renren/modules/security/oauth2/Oauth2Filter.java @@ -22,7 +22,7 @@ import java.io.IOException; * oauth2过滤器 * */ -public class Oauth2Filter extends AuthenticatingFilter { +public class Oauth2Filter extends AuthenticatingFilter { @Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception { diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysRegionController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysRegionController.java index 6cf9264d..0a59952f 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysRegionController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysRegionController.java @@ -19,6 +19,7 @@ import io.swagger.annotations.ApiOperation; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; import java.util.List; import java.util.Map; @@ -40,7 +41,7 @@ public class SysRegionController { @ApiImplicitParam(name = "pid", value = "上级ID", paramType = "query", dataType="String") }) // @RequiresPermissions("sys:region:list") - public Result> list(@RequestParam Map params){ + public Result> list(@ApiIgnore @RequestParam Map params){ List list = sysRegionService.list(params); return new Result>().ok(list); @@ -89,13 +90,13 @@ public class SysRegionController { return new Result(); } - @DeleteMapping("{id}") + @PostMapping("{id}") @ApiOperation("删除") @LogOperation("删除") // @RequiresPermissions("sys:region:delete") public Result delete(@PathVariable("id") Long id){ - //效验数据 - AssertUtils.isNull(id, "id"); + ////效验数据 + //AssertUtils.isNull(id, "id"); int count = sysRegionService.getCountByPid(id); if(count > 0){ diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRegionServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRegionServiceImpl.java index a6917a24..6980f775 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRegionServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysRegionServiceImpl.java @@ -51,6 +51,7 @@ public class SysRegionServiceImpl extends BaseServiceImpl> getTreeList() { + return baseDao.getTreeList(); } diff --git a/renren-admin/src/main/resources/application-prod.yml b/renren-admin/src/main/resources/application-prod.yml index 21683997..385d3856 100644 --- a/renren-admin/src/main/resources/application-prod.yml +++ b/renren-admin/src/main/resources/application-prod.yml @@ -3,9 +3,9 @@ spring: druid: #MySQL driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true - username: renren - password: 123456 + url: jdbc:mysql://15.72.183.91:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: root + password: w@CmM1mBVQkPhdrc initial-size: 10 max-active: 100 min-idle: 10 diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index f0247431..861320cf 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -9,6 +9,8 @@ + + @@ -32,6 +34,8 @@ + + @@ -84,36 +88,48 @@ tb_data_resource r, tb_data_attr a WHERE 1 = 1 - and r.id = a.data_resource_id - and r.type = #{dto.type} - and r.del_flag = 0 - - and r.name like CONCAT('%',#{dto.name},'%') - + AND r.id = a.data_resource_id + AND r.type = #{dto.type} + AND r.del_flag = 0 + + AND r.name like CONCAT('%',#{dto.name},'%') + + + AND r.district_id = #{dto.districtId} + + + AND r.dept_id = #{deptId} + AND a.data_resource_id IN ( - SELECT - data_resource_id - FROM - ( - SELECT - tb.data_resource_id - FROM - ( - - SELECT data_resource_id FROM tb_data_attr - WHERE attr_type = #{item.attrType} AND attr_value = #{item.attrValue} and del_flag = 0 - - ) tb - GROUP BY - tb.data_resource_id - HAVING - COUNT( tb.data_resource_id ) = ${dto.infoList.size} - ORDER BY - tb.data_resource_id ASC - ) tmp) limit ${pageNum}, ${pageSize} + SELECT data_resource_id + FROM ( + SELECT tb.data_resource_id + FROM ( + + SELECT data_resource_id FROM tb_data_attr + WHERE attr_type = #{item.attrType} + AND attr_value = #{item.attrValue} + AND del_flag = 0 + ) tb + GROUP BY tb.data_resource_id + HAVING COUNT( tb.data_resource_id ) = ${dto.infoList.size} + ORDER BY tb.data_resource_id ASC + ) tmp + ) + + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml new file mode 100644 index 00000000..b434fa18 --- /dev/null +++ b/renren-admin/src/main/resources/mapper/resourceCar/ResourceCarDao.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + update tb_resource_car + set del_flag = 1 , + update_date = now() + where 1 = 1 + and id in + + #{item} + + + + + + \ No newline at end of file