From c7e119ab1f3c8ab8a7b334f73024f456450c01b0 Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Thu, 14 Apr 2022 23:51:01 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BC=96=E7=9B=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=B5=84=E6=BA=90=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/category/dao/CategoryDao.java | 2 +- .../service/impl/CategoryServiceImpl.java | 16 ++- .../controller/ResourceController.java | 43 +++--- .../renren/modules/resource/dao/AttrDao.java | 1 + .../modules/resource/dao/ResourceDao.java | 4 + .../modules/resource/entity/AttrEntity.java | 136 +++++++++++++++++- .../resource/service/ResourceService.java | 8 ++ .../service/impl/ResourceServiceImpl.java | 27 +++- .../src/main/resources/application.yml | 1 + .../resources/mapper/category/CategoryDao.xml | 8 +- .../resources/mapper/resource/AttrDao.xml | 2 +- .../resources/mapper/resource/ResourceDao.xml | 81 +++++++++++ .../xss/XssHttpServletRequestWrapper.java | 1 - 13 files changed, 298 insertions(+), 32 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/category/dao/CategoryDao.java b/renren-admin/src/main/java/io/renren/modules/category/dao/CategoryDao.java index 832cea01..1a456652 100644 --- a/renren-admin/src/main/java/io/renren/modules/category/dao/CategoryDao.java +++ b/renren-admin/src/main/java/io/renren/modules/category/dao/CategoryDao.java @@ -16,5 +16,5 @@ public interface CategoryDao extends BaseDao { Integer deleteByIds(@Param("ids") List idList); - List selectFilterCriterByTopCategory(String topCategoryName); + List selectDictData(String linkValue); } 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 0cdb3304..1183980c 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 @@ -78,8 +78,20 @@ public class CategoryServiceImpl extends CrudServiceImpl getAllFilterCriteriaByTopCategory(String topCategoryName) { - //return categoryDao.selectFilterCriterByTopCategory(topCategoryName); - return null; + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("root_category", topCategoryName) + .eq("del_flag",0) + .eq("is_link_to_dic", "true") + .orderByAsc("xh"); + List categories = categoryDao.selectList(wrapper); + ArrayList resultList = new ArrayList<>(); + categories.forEach(item -> { + HashMap hashMap = new HashMap<>(); + hashMap.put("name", item.getName()); + hashMap.put("typeList", categoryDao.selectDictData(item.getLinkValue())); + resultList.add(hashMap); + }); + return resultList; } @Override 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 04350379..805332aa 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 @@ -1,19 +1,15 @@ package io.renren.modules.resource.controller; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import io.renren.common.annotation.LogOperation; import io.renren.common.constant.Constant; import io.renren.common.page.PageData; -import io.renren.common.utils.ExcelUtils; import io.renren.common.utils.Result; -import io.renren.common.validator.AssertUtils; import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; import io.renren.modules.resource.dto.ResourceDTO; -import io.renren.modules.resource.excel.ResourceExcel; import io.renren.modules.resource.service.ResourceService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -23,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; -import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -40,23 +35,33 @@ public class ResourceController { @Autowired private ResourceService resourceService; - @PostMapping("/page") + @GetMapping("/page") @ApiOperation("分页查询资源信息") @ApiImplicitParams({ - @ApiImplicitParam(name = "pageNum", value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = "", value = "排序字段", paramType = "query", dataType="String") , + @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , + @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , + @ApiImplicitParam(name = "type", value = "类型", paramType = "query",required = true, dataType="String") , + //@ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType="String") , + @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") }) //@RequiresPermissions("resource:resource:page") - public Result> page(@RequestBody JSONObject jsonObject){ - String pageNum = jsonObject.getString("pageNum"); - String pageSize = jsonObject.getString("pageSize"); - ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class); - //PageData page = resourceService.pageWithAttrs(params); + public Result> page(@ApiIgnore @RequestParam Map params){ + //ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class); + //resourceService.pageWithAttrs(resourceDTO); + PageData page = resourceService.page(params); + page.getList().forEach(item -> { + item.setInfoList(resourceService.selectAttrsByResourceId(item.getId())); + }); + return new Result>().ok(page); + } - //return new Result>().ok(page); - return null; + @PostMapping("/pageWithAttrs") + @ApiOperation("分页查询资源信息2") + //@RequiresPermissions("resource:resource:page") + public Result pageWithAttrs(@RequestBody ResourceDTO resourceDTO){ + + return new Result<>().ok(resourceService.pageWithAttrs(resourceDTO)); } @GetMapping("/select/{id}") @@ -81,13 +86,13 @@ public class ResourceController { return new Result(); } - @PutMapping + @PutMapping("/update") @ApiOperation("修改") @LogOperation("修改") //@RequiresPermissions("resource:resource:update") public Result update(@RequestBody ResourceDTO dto){ - //效验数据 - ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + ////效验数据 + //ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); resourceService.updateWithAttrs(dto); diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dao/AttrDao.java b/renren-admin/src/main/java/io/renren/modules/resource/dao/AttrDao.java index d6a394ef..58bebc47 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dao/AttrDao.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dao/AttrDao.java @@ -17,4 +17,5 @@ import java.util.List; public interface AttrDao extends BaseDao { Integer delete4Resource(@Param("resourceIds") List idList); + } \ No newline at end of file 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 3f3e74f3..5c2bee64 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 @@ -1,11 +1,13 @@ package io.renren.modules.resource.dao; import io.renren.common.dao.BaseDao; +import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.ResourceEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 资源表 @@ -17,4 +19,6 @@ import java.util.List; public interface ResourceDao extends BaseDao { Integer deleteByIds(@Param("ids") List idList); + + List selectWithAttrs(ResourceDTO resourceDTO); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/entity/AttrEntity.java b/renren-admin/src/main/java/io/renren/modules/resource/entity/AttrEntity.java index 3041a700..1dbb119b 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/entity/AttrEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/entity/AttrEntity.java @@ -11,8 +11,8 @@ import java.util.Date; * @author dg * @since 1.0 2022-04-13 */ -@Data -@EqualsAndHashCode(callSuper=false) +//@Data +//@EqualsAndHashCode(callSuper=false) @TableName("tb_data_attr") public class AttrEntity { private static final long serialVersionUID = 1L; @@ -60,4 +60,136 @@ public class AttrEntity { private String note3; private String note4; private String note5; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getDataResourceId() { + return dataResourceId; + } + + public void setDataResourceId(Long dataResourceId) { + this.dataResourceId = dataResourceId; + } + + public String getAttrType() { + return attrType; + } + + public void setAttrType(String attrType) { + this.attrType = attrType; + } + + public String getAttrValue() { + return attrValue; + } + + public void setAttrValue(String attrValue) { + this.attrValue = attrValue; + } + + public Integer getDelFlag() { + return delFlag; + } + + public void setDelFlag(Integer delFlag) { + this.delFlag = delFlag; + } + + public Long getCreator() { + return creator; + } + + public void setCreator(Long creator) { + this.creator = creator; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public Long getUpdater() { + return updater; + } + + public void setUpdater(Long updater) { + this.updater = updater; + } + + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + public String getNote1() { + return note1; + } + + public void setNote1(String note1) { + this.note1 = note1; + } + + public String getNote2() { + return note2; + } + + public void setNote2(String note2) { + this.note2 = note2; + } + + public String getNote3() { + return note3; + } + + public void setNote3(String note3) { + this.note3 = note3; + } + + public String getNote4() { + return note4; + } + + public void setNote4(String note4) { + this.note4 = note4; + } + + public String getNote5() { + return note5; + } + + public void setNote5(String note5) { + this.note5 = note5; + } + + @Override + public String toString() { + return "AttrEntity{" + + "id=" + id + + ", dataResourceId=" + dataResourceId + + ", attrType='" + attrType + '\'' + + ", attrValue='" + attrValue + '\'' + + ", delFlag=" + delFlag + + ", creator=" + creator + + ", createDate=" + createDate + + ", updater=" + updater + + ", updateDate=" + updateDate + + ", note1='" + note1 + '\'' + + ", note2='" + note2 + '\'' + + ", note3='" + note3 + '\'' + + ", note4='" + note4 + '\'' + + ", note5='" + note5 + '\'' + + '}'; + } } \ No newline at end of file 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 d1953ded..fe1f2691 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 @@ -1,10 +1,14 @@ package io.renren.modules.resource.service; import com.alibaba.fastjson.JSONObject; +import io.renren.common.page.PageData; import io.renren.common.service.CrudService; import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.entity.AttrEntity; import io.renren.modules.resource.entity.ResourceEntity; +import java.util.List; + /** * 资源表 * @@ -20,4 +24,8 @@ public interface ResourceService extends CrudService pageWithAttrs(ResourceDTO resourceDTO); + + List selectAttrsByResourceId(Long id); } \ 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 9c0cbe61..41357bc5 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 @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,8 +42,10 @@ public class ResourceServiceImpl extends CrudServiceImpl getWrapper(Map params){ QueryWrapper wrapper = new QueryWrapper<>(); - - + wrapper.eq("type", params.get("type").toString()) + .eq("del_flag", 0) + //.like(StringUtils.isNotBlank(params.get("name").toString()),"name", params.get("name").toString()) + .orderByDesc("create_date"); return wrapper; } @@ -51,9 +54,11 @@ public class ResourceServiceImpl extends CrudServiceImpl attrEntities= dto.getInfoList(); attrEntities.forEach(item -> { item.setDelFlag(0); @@ -97,6 +102,20 @@ public class ResourceServiceImpl extends CrudServiceImpl attrEntities = attrDao.selectList(wrapper); resourceDTO.setInfoList(attrEntities); - return null; + return resourceDTO; + } + + @Override + public List pageWithAttrs(ResourceDTO resourceDTO) { + return resourceDao.selectWithAttrs(resourceDTO); + } + + @Override + public List selectAttrsByResourceId(Long resourceId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("data_resource_id", resourceId) + .eq("del_flag", 0) + .orderByDesc("attr_type"); + return attrDao.selectList(wrapper); } } \ No newline at end of file diff --git a/renren-admin/src/main/resources/application.yml b/renren-admin/src/main/resources/application.yml index d86c92b7..038ccbb6 100644 --- a/renren-admin/src/main/resources/application.yml +++ b/renren-admin/src/main/resources/application.yml @@ -66,3 +66,4 @@ mybatis-plus: cache-enabled: false call-setters-on-nulls: true jdbc-type-for-null: 'null' +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl diff --git a/renren-admin/src/main/resources/mapper/category/CategoryDao.xml b/renren-admin/src/main/resources/mapper/category/CategoryDao.xml index c6d3d09e..0d6a77b5 100644 --- a/renren-admin/src/main/resources/mapper/category/CategoryDao.xml +++ b/renren-admin/src/main/resources/mapper/category/CategoryDao.xml @@ -37,8 +37,12 @@ order by xh - + select * + from sys_dict_data + where 1 = 1 + and dict_type_id = #{linkValue} + order by sort diff --git a/renren-admin/src/main/resources/mapper/resource/AttrDao.xml b/renren-admin/src/main/resources/mapper/resource/AttrDao.xml index 3eb3daee..1521b982 100644 --- a/renren-admin/src/main/resources/mapper/resource/AttrDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/AttrDao.xml @@ -25,7 +25,7 @@ set del_flag = 1, update_date = now() where 1 = 1 - and data_resourceId in + and data_resource_id in #{item} diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index 239f979a..fd620f64 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -26,6 +26,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update tb_data_resource set del_flag = 1, @@ -37,4 +76,46 @@ + \ No newline at end of file diff --git a/renren-common/src/main/java/io/renren/common/xss/XssHttpServletRequestWrapper.java b/renren-common/src/main/java/io/renren/common/xss/XssHttpServletRequestWrapper.java index c7f4781d..d04ac3fa 100644 --- a/renren-common/src/main/java/io/renren/common/xss/XssHttpServletRequestWrapper.java +++ b/renren-common/src/main/java/io/renren/common/xss/XssHttpServletRequestWrapper.java @@ -15,7 +15,6 @@ import java.nio.charset.StandardCharsets; import java.util.LinkedHashMap; import java.util.Map; - /** * XSS过滤处理 * From 5f2bd3aeab15d3dd762668453ce4993944c9f52f Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Fri, 15 Apr 2022 11:49:50 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E7=BC=96=E7=9B=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=B5=84=E6=BA=90=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/controller/ResourceController.java | 12 +++++++----- .../renren/modules/resource/dao/ResourceDao.java | 3 +-- .../resource/service/ResourceService.java | 3 +-- .../service/impl/ResourceServiceImpl.java | 13 +++++++------ .../resources/mapper/resource/ResourceDao.xml | 16 +++++++--------- 5 files changed, 23 insertions(+), 24 deletions(-) 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 805332aa..c6efe74a 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 @@ -8,7 +8,6 @@ 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.common.validator.group.UpdateGroup; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.service.ResourceService; import io.swagger.annotations.Api; @@ -19,7 +18,6 @@ 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; /** @@ -58,10 +56,14 @@ 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") - public Result pageWithAttrs(@RequestBody ResourceDTO resourceDTO){ - - return new Result<>().ok(resourceService.pageWithAttrs(resourceDTO)); + public Result pageWithAttrs(@RequestBody JSONObject jsonObject){ + return new Result<>().ok(resourceService.pageWithAttrs(jsonObject)); } @GetMapping("/select/{id}") 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 5c2bee64..e3b1ab2f 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,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; -import java.util.Map; /** * 资源表 @@ -20,5 +19,5 @@ public interface ResourceDao extends BaseDao { Integer deleteByIds(@Param("ids") List idList); - List selectWithAttrs(ResourceDTO resourceDTO); + List selectWithAttrs(@Param("dto") ResourceDTO resourceDTO, @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/resource/service/ResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/service/ResourceService.java index fe1f2691..163f1660 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 @@ -1,7 +1,6 @@ package io.renren.modules.resource.service; import com.alibaba.fastjson.JSONObject; -import io.renren.common.page.PageData; import io.renren.common.service.CrudService; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.AttrEntity; @@ -25,7 +24,7 @@ public interface ResourceService extends CrudService pageWithAttrs(ResourceDTO resourceDTO); + List pageWithAttrs(JSONObject jsonObject); List selectAttrsByResourceId(Long id); } \ 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 41357bc5..6d2ab17b 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,26 +1,23 @@ package io.renren.modules.resource.service.impl; +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 io.renren.common.service.impl.CrudServiceImpl; -import io.renren.common.constant.Constant; import io.renren.modules.resource.dao.AttrDao; import io.renren.modules.resource.dao.ResourceDao; 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 org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -106,8 +103,12 @@ public class ResourceServiceImpl extends CrudServiceImpl pageWithAttrs(ResourceDTO resourceDTO) { - return resourceDao.selectWithAttrs(resourceDTO); + public List 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); } @Override diff --git a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml index fd620f64..f0247431 100644 --- a/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml +++ b/renren-admin/src/main/resources/mapper/resource/ResourceDao.xml @@ -85,12 +85,12 @@ tb_data_attr a WHERE 1 = 1 and r.id = a.data_resource_id - and r.type = #{type} + and r.type = #{dto.type} and r.del_flag = 0 - - and r.name like CONCAT('%',#{name},'%') + + and r.name like CONCAT('%',#{dto.name},'%') - + AND a.data_resource_id IN ( SELECT @@ -101,20 +101,18 @@ 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 ) = ${infoList.size} + COUNT( tb.data_resource_id ) = ${dto.infoList.size} ORDER BY tb.data_resource_id ASC - limit #{pageNum} , #{pageSize} - ) tmp) + ) tmp) limit ${pageNum}, ${pageSize} From e1c935a25422b282b16473fff1c29d722d9e53dd Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 18 Apr 2022 13:59:25 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8A=E4=BC=A0=E4=B8=8E=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- renren-admin/pom.xml | 7 ++ .../controller/FileUploadController.java | 60 ++++++++++ .../interceptor/IdentityInterceptor.java | 111 ++++++++++++++++++ .../renren/common/interceptor/Validator.java | 83 +++++++++++++ .../interceptor/YaweiSSOProperties.java | 18 +++ .../modules/security/config/ShiroConfig.java | 10 +- .../modules/security/config/WebMvcConfig.java | 1 + .../src/main/resources/application.yml | 8 +- .../src/main/resources/yaweisso.properties | 3 + 9 files changed, 298 insertions(+), 3 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java create mode 100644 renren-admin/src/main/java/io/renren/common/interceptor/IdentityInterceptor.java create mode 100644 renren-admin/src/main/java/io/renren/common/interceptor/Validator.java create mode 100644 renren-admin/src/main/java/io/renren/common/interceptor/YaweiSSOProperties.java create mode 100644 renren-admin/src/main/resources/yaweisso.properties diff --git a/renren-admin/pom.xml b/renren-admin/pom.xml index 238aad94..879574ca 100644 --- a/renren-admin/pom.xml +++ b/renren-admin/pom.xml @@ -27,6 +27,7 @@ 5.22.0 2.2.9 2.7.1 + 2.0.2 @@ -200,6 +201,12 @@ IJPay-AliPay ${IJPay.version} + + + com.yawei.oav2 + yawei-pso + ${yawei-pso.version} + 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 new file mode 100644 index 00000000..902ff819 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/controller/FileUploadController.java @@ -0,0 +1,60 @@ +package io.renren.common.controller; + + +import io.renren.common.utils.Result; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.UUID; + +@RestController +public class FileUploadController { + @Value("${resource.path}") + private String uploadPath; + @Value("${resource.root_url}") + private String root_url; + @Value("${server.servlet.context-path}") + private String context_path; + + private static Logger logger = LoggerFactory.getLogger(FileUploadController.class); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/"); + + @PostMapping("/upload") + public Result upload(@RequestParam("file") MultipartFile uploadFile, + HttpServletRequest request) { + logger.info("上传文件:" + uploadFile.getOriginalFilename()); + String format = sdf.format(new Date()); + File folder = new File(uploadPath + "upload" + File.separator + format); + logger.info(uploadPath + format); + if (!folder.isDirectory()) { + folder.mkdirs(); + } + // 对上传的文件重命名,避免文件重名 + String oldName = uploadFile.getOriginalFilename(); + String newName = UUID.randomUUID().toString() + + oldName.substring(oldName.lastIndexOf("."), oldName.length()); + try { + // 文件保存 + uploadFile.transferTo(new File(folder, newName)); + + // 返回上传文件的访问路径 + String filePath = request.getScheme() + "://" + root_url + + ":" + request.getServerPort() + context_path + "/upload/" + format + newName; + return new Result().ok(filePath); + } catch (IOException e) { + return new Result().error(e.getMessage()); + } + } + +} diff --git a/renren-admin/src/main/java/io/renren/common/interceptor/IdentityInterceptor.java b/renren-admin/src/main/java/io/renren/common/interceptor/IdentityInterceptor.java new file mode 100644 index 00000000..5e4920f2 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/interceptor/IdentityInterceptor.java @@ -0,0 +1,111 @@ +package io.renren.common.interceptor; + +import com.yawei.pso.PSORequest; +import com.yawei.pso.SSOResponse; +import com.yawei.pso.TicketManager; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.net.URLEncoder; +import java.util.Iterator; +import java.util.Map.Entry; + +/** + * 亚微 sso拦截 + */ +@Component +public class IdentityInterceptor implements HandlerInterceptor { + private static Logger logger = LoggerFactory.getLogger(IdentityInterceptor.class); + + public final static String SEESION_USER = "seesion_user"; + + @Autowired + private YaweiSSOProperties yaweiSSOProperties; + + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + logger.info("==============执行顺序: 1、preHandle================"); + // 获取当前请求的url + String requestUri = request.getRequestURI(); + + Validator validator = Validator.getInstance(); + + String strResponse = request.getParameter(yaweiSSOProperties.getSsoKey()); + if (StringUtils.isEmpty(strResponse)) { + TicketManager tm = new TicketManager(); + if (!tm.LoadTicket(request)) { + PSORequest psoRequest = new PSORequest(request); + String requeststr = psoRequest.CreateHash(); + + String keeperUrl = yaweiSSOProperties.getKeeperUrl(); + keeperUrl = keeperUrl + "?" + yaweiSSOProperties.getSsoKey() + "=" + + URLEncoder.encode(requeststr, "UTF-8"); + response.sendRedirect(keeperUrl); + return false; + } + } else { + // 如果服务器端通过认证后,会返回后执行改操作,然后写入cookie + SSOResponse ssoResp = new SSOResponse(strResponse); + TicketManager tm = ssoResp.CreatePSOTicket(); + if (tm == null) { + PSORequest psoRequest = new PSORequest(request); + String requeststr = psoRequest.CreateHash(); + + String keeperUrl = yaweiSSOProperties.getKeeperUrl(); + keeperUrl = keeperUrl + "?" + yaweiSSOProperties.getSsoKey() + "=" + + URLEncoder.encode(requeststr, "UTF-8"); + response.sendRedirect(keeperUrl); + } else { + String domainName = yaweiSSOProperties.getDomain(); + tm.SaveTicket(response, domainName); + Iterator> iterator = request + .getParameterMap().entrySet().iterator(); + StringBuffer param = new StringBuffer(); + int i = 0; + while (iterator.hasNext()) { + Entry entry = (Entry) iterator + .next(); + if (entry.getKey().equals(yaweiSSOProperties.getSsoKey())) + continue; + else { + i++; + if (i == 1) + param.append("?").append(entry.getKey()) + .append("="); + else + param.append("&").append(entry.getKey()) + .append("="); + + if (entry.getValue() instanceof String[]) { + param.append(((String[]) entry.getValue())[0]); + } else { + param.append(entry.getValue()); + } + } + } + response.sendRedirect(requestUri + param.toString()); + return false; + } + } + validator.SetUserTicket(request); + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + logger.info("==============执行顺序: 2、postHandle================"); + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + logger.info("==============执行顺序: 3、afterCompletion================"); + } +} diff --git a/renren-admin/src/main/java/io/renren/common/interceptor/Validator.java b/renren-admin/src/main/java/io/renren/common/interceptor/Validator.java new file mode 100644 index 00000000..b02bc2f7 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/interceptor/Validator.java @@ -0,0 +1,83 @@ +package io.renren.common.interceptor; + +import com.yawei.pso.TicketManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +/** + * 验证器 + */ +public class Validator { + private static Logger logger = LoggerFactory.getLogger(Validator.class); + private static ThreadLocal validatorHolder = new ThreadLocal() { + + protected Validator initialValue() { + return new Validator(); + } + + }; + + // 当前请求的session + private HttpSession session = null; + + // 当前的请求 + private HttpServletRequest request = null; + + private Validator() { + + } + + public static Validator getInstance() { + return validatorHolder.get(); + } + + /** + * 执行初始化 + * + * @param httpRequest + */ + public void init(HttpServletRequest httpRequest) { + this.request = httpRequest; + this.session = request.getSession(); + } + + /** + * 将凭证身份加入到session + * + * @param httpRequest + */ + public void SetUserTicket(HttpServletRequest httpRequest) { + try { + if (httpRequest.getSession() + .getAttribute(IdentityInterceptor.SEESION_USER) == null) { + TicketManager ticket = new TicketManager(); + if (ticket.LoadTicket(httpRequest)) { + // 登录用户姓名 + String userName = ticket.getUserName(); + // 登录用户账号 + String userAccount = ticket.getUserID(); + // 登录用户标识 + String userGuid = ticket.getADGUID(); + logger.info("===userName===" + userName); + logger.info("===userAccount===" + userAccount); + logger.info("===userGuid===" + userGuid); + } + } else { + + } + } catch (Exception ex) { + logger.error("", ex); + } + } + + /** + * 清除session + */ + public void cancel() { + this.session = null; + } + +} 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 new file mode 100644 index 00000000..b189b099 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/interceptor/YaweiSSOProperties.java @@ -0,0 +1,18 @@ +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") +@ConfigurationProperties(prefix = "sso") +public class YaweiSSOProperties { + private String domain; + private String ssoKey; + private String keeperUrl; +} diff --git a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java index 37c2edb5..c07aa65d 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java +++ b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java @@ -19,13 +19,12 @@ import java.util.Map; /** * Shiro的配置文件 - * */ @Configuration public class ShiroConfig { @Bean - public DefaultWebSessionManager sessionManager(){ + public DefaultWebSessionManager sessionManager() { DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); sessionManager.setSessionValidationSchedulerEnabled(false); sessionManager.setSessionIdUrlRewritingEnabled(false); @@ -72,6 +71,13 @@ public class ShiroConfig { filterMap.put("/front/**", "anon"); filterMap.put("/applyRecord/**", "anon"); filterMap.put("/bsabilityrecord/**", "anon"); + + /** + * 资源上传 + */ + filterMap.put("/upload", "anon"); + filterMap.put("/upload/**", "anon"); + filterMap.put("/**", "oauth2"); shiroFilter.setFilterChainDefinitionMap(filterMap); diff --git a/renren-admin/src/main/java/io/renren/modules/security/config/WebMvcConfig.java b/renren-admin/src/main/java/io/renren/modules/security/config/WebMvcConfig.java index 641e67f5..df41a497 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/config/WebMvcConfig.java +++ b/renren-admin/src/main/java/io/renren/modules/security/config/WebMvcConfig.java @@ -37,6 +37,7 @@ public class WebMvcConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new AliPayInterceptor()).addPathPatterns("/pay/alipay/**"); +// registry.addInterceptor(new IdentityInterceptor()); } @Override diff --git a/renren-admin/src/main/resources/application.yml b/renren-admin/src/main/resources/application.yml index 038ccbb6..5ce8003a 100644 --- a/renren-admin/src/main/resources/application.yml +++ b/renren-admin/src/main/resources/application.yml @@ -1,3 +1,7 @@ +#上传的静态资源配置 +resource: + root_url: 127.0.0.1 + path: E:\liwen\ # Tomcat server: tomcat: @@ -38,12 +42,14 @@ spring: min-idle: 5 # 连接池中的最小空闲连接 activiti: check-process-definitions: false + resources: + static-locations: classpath:/static,classpath:/public,file:${resource.path} fdfs: so-timeout: 600000 connect-timeout: 6000 - tracker-list: #TrackerList参数,支持多个 + tracker-list: #TrackerList参数,支持多个 - 192.168.10.10:22122 # 是否开启redis缓存 true开启 false关闭 diff --git a/renren-admin/src/main/resources/yaweisso.properties b/renren-admin/src/main/resources/yaweisso.properties new file mode 100644 index 00000000..bb802a06 --- /dev/null +++ b/renren-admin/src/main/resources/yaweisso.properties @@ -0,0 +1,3 @@ +sso.domain=yw.com.cn +sso.ssoKey=SSOToken +sso.keeperUrl=http://127.0.0.1:9090/renren-admin/sys/user/123 \ No newline at end of file From e0e3450a866886741a497d210b42da7b8bb14fec Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 18 Apr 2022 17:12:06 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=89=B9=E9=87=8F=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=83=BD=E5=8A=9B=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3=EF=BC=88?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=8E=A5=E5=8F=A3=E6=90=9E=E5=AE=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AbilityCenterController.java | 100 ++++++++++++++++++ .../dto/TAbilityBatchApplicationDTO.java | 35 ++++++ 2 files changed, 135 insertions(+) create mode 100644 renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java create mode 100644 renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java diff --git a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java new file mode 100644 index 00000000..d41473b8 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java @@ -0,0 +1,100 @@ +package io.renren.common.controller; + + +import cn.hutool.core.util.ObjectUtil; +import io.renren.common.page.PageData; +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.activiti.dto.ProcessInstanceDTO; +import io.renren.modules.activiti.dto.ProcessStartDTO; +import io.renren.modules.activiti.service.ActProcessService; +import io.renren.modules.activiti.service.ActRunningService; +import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.processForm.dto.TAbilityBatchApplicationDTO; +import io.renren.modules.processForm.service.TAbilityApplicationService; +import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * 能力集中中心 接口 + */ +@RestController +@RequestMapping("/ability/center") +public class AbilityCenterController { + @Autowired + private ActProcessService actProcessService; + @Autowired + private TAbilityApplicationService tAbilityApplicationService; + @Autowired + private ActRunningService actRunningService; + + private static Map params = new HashMap() { + { + put("isLatestVersion", true); // 取最新版本 + put("key", "abilityprocess"); // 限定 + } + }; + + + /** + * 批量进行批量能力申请 + * + * @param abilityBatchApplicationDTO + * @return + */ + @PostMapping(value = "/apply") + public Result> apply(@RequestBody TAbilityBatchApplicationDTO abilityBatchApplicationDTO) { + // 仿照请求接口 /act/process/lastestPage + PageData> page = actProcessService.page(params); + if (page.getTotal() <= 0) { // + return new Result().error("联系管理员添加流程"); + } + return new Result().ok(abilityBatchApplicationDTO.getSystem().stream().map(index -> { + TAbilityApplicationDTO tAbilityApplicationDTO = new TAbilityApplicationDTO(); + tAbilityApplicationDTO.setArea(abilityBatchApplicationDTO.getArea()); + tAbilityApplicationDTO.setAttachment(abilityBatchApplicationDTO.getAttachment()); + tAbilityApplicationDTO.setBasis(abilityBatchApplicationDTO.getBasis()); + tAbilityApplicationDTO.setPhone(abilityBatchApplicationDTO.getPhone()); + tAbilityApplicationDTO.setScene(abilityBatchApplicationDTO.getScene()); + tAbilityApplicationDTO.setInstanceId(abilityBatchApplicationDTO.getInstanceId()); + tAbilityApplicationDTO.setUnit(abilityBatchApplicationDTO.getUnit()); + tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser()); + tAbilityApplicationDTO.setSystem(index); + // 仿照请求接口 /processForm/tabilityapplication + ValidatorUtils.validateEntity(tAbilityApplicationDTO, AddGroup.class, DefaultGroup.class); + tAbilityApplicationService.save(tAbilityApplicationDTO); // 写能力申请数据 + if (tAbilityApplicationDTO.getId() == null) { + return null; + } + + // 仿照请求接口 /act/running/startOfBusinessKey + ProcessStartDTO processStartDTO = new ProcessStartDTO(); + processStartDTO.setBusinessKey(tAbilityApplicationDTO.getId().toString()); + processStartDTO.setProcessDefinitionKey("abilityprocess"); //限定 + ObjectMapper oMapper = new ObjectMapper(); + Map variables = oMapper.convertValue(tAbilityApplicationDTO, Map.class); + processStartDTO.setVariables(variables); + ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO); + + if (Long.valueOf(dto.getBusinessKey()) != null) { + // 仿照请求接口 /processForm/tabilityapplication/updateInstanceId + tAbilityApplicationService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey())); + } + return dto; + }).filter(index -> ObjectUtil.isNotNull(index)).collect(Collectors.toList())); + } + + +} diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java new file mode 100644 index 00000000..7647ddf2 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java @@ -0,0 +1,35 @@ +package io.renren.modules.processForm.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +@Data +@ApiModel(value = "批量能力申请表单") +public class TAbilityBatchApplicationDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + @ApiModelProperty(value = "申请人") + private String user; + @ApiModelProperty(value = "申请人电话") + private String phone; + @ApiModelProperty(value = "申请人单位") + private String unit; + @ApiModelProperty(value = "申请人所在地区") + private String area; + @ApiModelProperty(value = "申请应用系统") + private List system; + @ApiModelProperty(value = "申请场景") + private String scene; + @ApiModelProperty(value = "申请依据") + private String basis; + @ApiModelProperty(value = "申请附件") + private String attachment; + @ApiModelProperty(value = "实例ID") + private String instanceId; +} From 1e2a8a64cb521b456f64d3f2e48834b5eaa5c41f Mon Sep 17 00:00:00 2001 From: wangliwen Date: Mon, 18 Apr 2022 17:12:14 +0800 Subject: [PATCH 5/6] ... --- .../java/io/renren/common/controller/FileUploadController.java | 2 +- .../processForm/controller/TAbilityApplicationController.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) 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 902ff819..da5266e6 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 @@ -28,7 +28,7 @@ public class FileUploadController { private static Logger logger = LoggerFactory.getLogger(FileUploadController.class); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/"); + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/"); @PostMapping("/upload") public Result upload(@RequestParam("file") MultipartFile uploadFile, diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java b/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java index 86301db6..82a641b9 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/controller/TAbilityApplicationController.java @@ -17,7 +17,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; 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; From 8ce7a18999b58adad8d2139711c719072c450144 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 19 Apr 2022 10:04:47 +0800 Subject: [PATCH 6/6] ... --- .../common/controller/AbilityCenterController.java | 5 +++++ .../renren/common/controller/FileUploadController.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java index d41473b8..1e30a7ea 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java @@ -14,6 +14,8 @@ import io.renren.modules.activiti.service.ActRunningService; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityBatchApplicationDTO; import io.renren.modules.processForm.service.TAbilityApplicationService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.codehaus.jackson.map.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -30,6 +32,8 @@ import java.util.stream.Collectors; /** * 能力集中中心 接口 */ + +@Api(tags = "能力集中") @RestController @RequestMapping("/ability/center") public class AbilityCenterController { @@ -55,6 +59,7 @@ public class AbilityCenterController { * @return */ @PostMapping(value = "/apply") + @ApiOperation("批量进行能力申请") public Result> apply(@RequestBody TAbilityBatchApplicationDTO abilityBatchApplicationDTO) { // 仿照请求接口 /act/process/lastestPage PageData> page = actProcessService.page(params); 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 da5266e6..44c98968 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 @@ -2,6 +2,10 @@ package io.renren.common.controller; import io.renren.common.utils.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -18,6 +22,7 @@ import java.util.Date; import java.util.UUID; @RestController +@Api(tags = "静态资源上传") public class FileUploadController { @Value("${resource.path}") private String uploadPath; @@ -31,6 +36,10 @@ public class FileUploadController { private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/"); @PostMapping("/upload") + @ApiOperation("上传") + @ApiImplicitParams({ + @ApiImplicitParam(name = "file", value = "文件", paramType = "file", dataType = "file", required = true) + }) public Result upload(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) { logger.info("上传文件:" + uploadFile.getOriginalFilename());