56 changed files with 5093 additions and 0 deletions
-
185mdp-arc-mate/README.md
-
62mdp-arc-mate/pom.xml
-
57mdp-arc-mate/src/main/java/com/mdp/arc/ArcTools.java
-
261mdp-arc-mate/src/main/java/com/mdp/arc/att/ctrl/AttachmentController.java
-
15mdp-arc-mate/src/main/java/com/mdp/arc/att/ctrl/AttachmentSubController.java
-
161mdp-arc-mate/src/main/java/com/mdp/arc/att/entity/Attachment.java
-
46mdp-arc-mate/src/main/java/com/mdp/arc/att/entity/Base64AttachmentVo.java
-
27mdp-arc-mate/src/main/java/com/mdp/arc/att/mapper/AttachmentMapper.java
-
70mdp-arc-mate/src/main/java/com/mdp/arc/att/mapper/AttachmentMapper.xml
-
160mdp-arc-mate/src/main/java/com/mdp/arc/att/service/AttachmentService.java
-
49mdp-arc-mate/src/main/java/com/mdp/arc/att/service/RichTextFileService.java
-
195mdp-arc-mate/src/main/java/com/mdp/arc/img/ctrl/ImageCategoryController.java
-
618mdp-arc-mate/src/main/java/com/mdp/arc/img/ctrl/ImageController.java
-
16mdp-arc-mate/src/main/java/com/mdp/arc/img/ctrl/ImageSubCategoryController.java
-
16mdp-arc-mate/src/main/java/com/mdp/arc/img/ctrl/ImageSubController.java
-
111mdp-arc-mate/src/main/java/com/mdp/arc/img/entity/Base64ImageVo.java
-
137mdp-arc-mate/src/main/java/com/mdp/arc/img/entity/Image.java
-
74mdp-arc-mate/src/main/java/com/mdp/arc/img/entity/ImageCategory.java
-
24mdp-arc-mate/src/main/java/com/mdp/arc/img/mapper/ImageCategoryMapper.java
-
27mdp-arc-mate/src/main/java/com/mdp/arc/img/mapper/ImageCategoryMapper.xml
-
26mdp-arc-mate/src/main/java/com/mdp/arc/img/mapper/ImageMapper.java
-
24mdp-arc-mate/src/main/java/com/mdp/arc/img/mapper/ImageMapper.xml
-
36mdp-arc-mate/src/main/java/com/mdp/arc/img/service/ImageCategoryService.java
-
73mdp-arc-mate/src/main/java/com/mdp/arc/img/service/ImageCompressService.java
-
176mdp-arc-mate/src/main/java/com/mdp/arc/img/service/ImageService.java
-
38mdp-arc-mate/src/test/java/com/mdp/ArcApplication.java
-
149mdp-arc-mate/src/test/java/com/mdp/ImgCompressTest.java
-
50mdp-arc-mate/src/test/java/com/mdp/WebSecurityConfig.java
-
35mdp-arc-mate/src/test/java/com/mdp/arc/att/service/TestAttachmentService.java
-
47mdp-arc-mate/src/test/java/com/mdp/arc/img/service/TestImageCategoryService.java
-
48mdp-arc-mate/src/test/java/com/mdp/arc/img/service/TestImageService.java
-
0mdp-arc-pub/README.md
-
21mdp-arc-pub/pom.xml
-
52mdp-arc-pub/src/main/java/com/mdp/arc/cache/TagCacheService.java
-
295mdp-arc-pub/src/main/java/com/mdp/arc/pub/ctrl/CategoryController.java
-
168mdp-arc-pub/src/main/java/com/mdp/arc/pub/ctrl/CategoryQxController.java
-
14mdp-arc-pub/src/main/java/com/mdp/arc/pub/ctrl/CategorySubController.java
-
197mdp-arc-pub/src/main/java/com/mdp/arc/pub/ctrl/TagCategoryController.java
-
246mdp-arc-pub/src/main/java/com/mdp/arc/pub/ctrl/TagController.java
-
120mdp-arc-pub/src/main/java/com/mdp/arc/pub/entity/Category.java
-
138mdp-arc-pub/src/main/java/com/mdp/arc/pub/entity/CategoryQx.java
-
58mdp-arc-pub/src/main/java/com/mdp/arc/pub/entity/Tag.java
-
58mdp-arc-pub/src/main/java/com/mdp/arc/pub/entity/TagCategory.java
-
25mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/CategoryMapper.java
-
75mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/CategoryMapper.xml
-
27mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/CategoryQxMapper.java
-
17mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/CategoryQxMapper.xml
-
24mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/TagCategoryMapper.java
-
17mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/TagCategoryMapper.xml
-
31mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/TagMapper.java
-
31mdp-arc-pub/src/main/java/com/mdp/arc/pub/mapper/TagMapper.xml
-
41mdp-arc-pub/src/main/java/com/mdp/arc/pub/service/CategoryQxService.java
-
235mdp-arc-pub/src/main/java/com/mdp/arc/pub/service/CategoryService.java
-
47mdp-arc-pub/src/main/java/com/mdp/arc/pub/service/TagCategoryService.java
-
126mdp-arc-pub/src/main/java/com/mdp/arc/pub/service/TagService.java
-
17pom.xml
@ -0,0 +1,185 @@ |
|||
# To start |
|||
|
|||
这是一个开发工具项目,主要帮助程序员自动生成增删改查代码,由广州擎勤网络科技有限公司研发。 |
|||
|
|||
|
|||
|
|||
` 前端` |
|||
|
|||
# 前端开发工具 |
|||
node.js、webpacck、npm、eclipse、svn、安卓、ios等 |
|||
|
|||
# 前端ui-pc端 |
|||
vue.js、element-ui、axios |
|||
|
|||
# 前端ui-手机端 |
|||
vue.js、vux、weui、weex |
|||
|
|||
# 前端ui-微信公众号端 |
|||
vue.js、vux |
|||
|
|||
# 前端ui-微信小程序 |
|||
微信开发工具 |
|||
|
|||
|
|||
# 前端文件结构 |
|||
* build - webpack config files |
|||
* config - webpack config files |
|||
* dist - build |
|||
* src -your app |
|||
* api |
|||
* assets |
|||
* common |
|||
* components - your vue components |
|||
* mock |
|||
* styles |
|||
* views - your pages |
|||
* vuex |
|||
* App.vue |
|||
* main.js - main file |
|||
* routes.js |
|||
* static - static assets |
|||
|
|||
# 前端web开发工具安装步骤 首次安装执行 1-6,添加工程执行 7-12 |
|||
## 1 安装node.js 从网络下载最新稳定版本 |
|||
node-v8.9.1-x64 |
|||
|
|||
## 2 安装 npm |
|||
npm install npm@latest -g |
|||
|
|||
## 3 设置淘宝镜像及安装淘宝镜像命令cnpm (如有必要) |
|||
npm config set registry https://registry.npm.taobao.org |
|||
|
|||
npm install -g cnpm --registry=https://registry.npm.taobao.org |
|||
|
|||
## 4 通过镜像下载 node-sass(如有必要) |
|||
npm install -g node-sass --registry=https://registry.npm.taobao.org |
|||
|
|||
## 5 安装vue 命令行工具 (如有必要) |
|||
npm install -g vue-cli |
|||
|
|||
## 6 设置eclipse 关联 .vue文件 |
|||
Window -> Preferences -> General -> Editors -> File Associations -> Add -> *.vue -> Add -> HTML Editor / JS Editor / CSS Editor |
|||
|
|||
## 7 用eclipse 从svn下载工程项目 |
|||
svn地址 http://203.195.131.73:8085/svn/ |
|||
如工程 mdp-arc-web |
|||
|
|||
## 8 进入工程 目录 (假设工程在 D:\workspace\mdp-arc-web) |
|||
cd /D D:\workspace\mdp-arc-web |
|||
|
|||
## 9 安装工程依赖包 |
|||
D:\workspace\mdp-arc-web > npm install |
|||
|
|||
## 10 开发调试工程 |
|||
npm dev |
|||
|
|||
## 11 编译 |
|||
npm build |
|||
|
|||
## 12 拷贝编译后文件到后台工程(用于与后台工程一起打成jar包发布)(如有必要) |
|||
npm copyToStatic |
|||
|
|||
|
|||
|
|||
`服务端` |
|||
# 服务端开发工具 |
|||
jdk8、eclipse oxygen、svn、maven、oracle |
|||
|
|||
# 服务端编程框架 |
|||
spring boot 1.5、spring mvc 4、spring cloud 1.5、spring security 4、logback 1、mybatis 3、thymeleaf 3 |
|||
|
|||
# 服务端安装开发工具步骤 首次安装执行 1-3,开发打包部署执行4-5 |
|||
## 1 安装开发工具 |
|||
### 1.0 安装jdk8, elcipse oxygen, svn 官网下载64位版本 |
|||
jdk-8u121-windows-x64 |
|||
eclipse-jee-oxygen-3-win32-x86_64 |
|||
TortoiseSVN-1.9.7.27907-x64 |
|||
|
|||
### 1.1 配置eclipse运行内存 |
|||
在eclipse.ini中添加下面几个参数 |
|||
-Xms512m |
|||
-Xmx1024m |
|||
|
|||
### 1.2 从eclipse marketplace 下载版本控制插件工具svn |
|||
eclipse -> help -> Eclipse marketplace,搜索svn,安装subclipse4.2.3 |
|||
|
|||
#### 1.2.1 设置eclipse svn 忽略的文件规则 */logs/* */target/* */node_modules/* |
|||
Window -> Preferences -> Team -> Ignored Resource -> Add pattern -> */logs/* |
|||
Window -> Preferences -> Team -> Ignored Resource -> Add pattern -> */target/* |
|||
Window -> Preferences -> Team -> Ignored Resource -> Add pattern -> */node_modules/* |
|||
|
|||
### 1.3 设置eclipse工程编码为utf-8 |
|||
Window -> Preferences -> General -> Content Types -> java Archive / java class path / Text -> utf-8 |
|||
Window -> Preferences -> General -> Workspace -> Text file encoding / UTF-8 |
|||
|
|||
### 1.4 设置eclipse jdk |
|||
Window -> Preferences -> Java -> Installed JREs -> 选择一条 -> Edit -> C:\Program Files\Java\jdk1.8.0_121(假设jdk安装目录,注意不是jre目录) |
|||
|
|||
### 1.5 设置eclipse 检查项,提升编译速度 |
|||
Window -> Preferences -> Validation -> 找到build列 -> 只保留 Classpath Dependance Validator 选中状态 |
|||
|
|||
## 2 下载代码生成器mdp-dev |
|||
### 2.0 从svn下载mdp-dev工程,mdp自研发的开发工具 |
|||
svn 地址为 http://203.195.131.73:8085/svn/mdp/trunk/mdp-dev |
|||
|
|||
### 2.1 使用mdp-dev生成crud代码(开发业务功能时使用,先设计表结构,再生成代码) |
|||
使用/mdp-dev/src/test/java/com/qqkj/mdp/dev/TestCodegenService.java 进行代码生成 |
|||
|
|||
## 3 maven 设置 |
|||
### 3.0 设置maven私服 用户密码 |
|||
将/mdp-dev/settings.xml拷贝到 C:\Users\Administrator\.m2目录下 |
|||
|
|||
### 3.1 安装本地jar包到私服(如果有本地jar包,目前有orcale的驱动包已经安装) |
|||
私服登录地址 http://203.195.131.73:8081/nexus 用户名、密码 admin/admin123 |
|||
|
|||
## 4 应用项目开发 |
|||
### 4.0 从svn下载应用工程项目 |
|||
svn 地址为 http://203.195.131.73:8085/svn/应用产品对应目录 |
|||
|
|||
### 4.1 从mven私服下载依赖jar包 |
|||
在 Eclipse 工程目录鼠标右键 -> Maven -> Update Project |
|||
|
|||
### 4.2 运行工程项目 |
|||
在src/main/java 中找到 ***Application。java -> 鼠标右键 -> Run as -> Java Application |
|||
或者 |
|||
在src/test/java 中找到 ***Application。java -> 鼠标右键 -> Run as -> Java Application |
|||
|
|||
## 5 打包部署 |
|||
### 5.0 工程打jar包 |
|||
在 Eclipse 工程目录鼠标右键 -> Run as -> Maven Install |
|||
|
|||
### 5.1 将打包好的jar包上传maven私服 |
|||
在 Eclipse 工程目录鼠标右键 -> Run as -> Maven Buil -> deploy |
|||
|
|||
|
|||
|
|||
|
|||
``` bash |
|||
# install dependencies |
|||
cnpm install |
|||
|
|||
# serve with hot reload at localhost:8081 |
|||
cnpm run dev |
|||
|
|||
# build for production with minification |
|||
cnpm run build |
|||
|
|||
``` |
|||
|
|||
|
|||
` 其它一些常用命令 ` |
|||
# 清除缓存 |
|||
npm cache clean --force |
|||
|
|||
# npm国内代理镜像服务器 镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在): |
|||
npm config set registry https://registry.npm.taobao.org |
|||
npm info underscore (如果上面配置正确这个命令会有字符串response) |
|||
|
|||
|
|||
# Browser support |
|||
|
|||
Modern browsers and IE 10+. |
|||
|
|||
# License |
|||
[MIT](http://opensource.org/licenses/MIT) |
|||
@ -0,0 +1,62 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<artifactId>mdp-arc-mate</artifactId> |
|||
<packaging>jar</packaging> |
|||
<name>mdp-arc-mate 内容管理系统</name> |
|||
<description>内容管理系统</description> |
|||
<parent> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-lcode-backend</artifactId> |
|||
<version>2.0.0-RELEASE</version> |
|||
</parent> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>druid</artifactId> |
|||
<version>1.2.4</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba</groupId> |
|||
<artifactId>druid-spring-boot-starter</artifactId> |
|||
<version>1.2.4</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-boot-starter</artifactId> |
|||
<version>${mdp.version}</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>net.coobird</groupId> |
|||
<artifactId>thumbnailator</artifactId> |
|||
<version>0.4.8</version> |
|||
</dependency> |
|||
<!--视频时长--> |
|||
<dependency> |
|||
<groupId>ws.schild</groupId> |
|||
<artifactId>jave-all-deps</artifactId> |
|||
<version>2.6.0</version> |
|||
</dependency> |
|||
<!--文章查看需要模板引擎--> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-thymeleaf</artifactId> |
|||
</dependency> |
|||
|
|||
<dependency> |
|||
<groupId>org.slf4j</groupId> |
|||
<artifactId>slf4j-api</artifactId> |
|||
</dependency> |
|||
<!-- logback --> |
|||
<dependency> |
|||
<groupId>ch.qos.logback</groupId> |
|||
<artifactId>logback-classic</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.twelvemonkeys.imageio</groupId> |
|||
<artifactId>imageio-jpeg</artifactId> |
|||
<version>3.8.2</version> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,57 @@ |
|||
package com.mdp.arc; |
|||
|
|||
public class ArcTools { |
|||
|
|||
public static String filterPath(String path){ |
|||
if(path==null){ |
|||
return null; |
|||
}else { |
|||
return path.replaceAll("//", "/"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 讲路径加入第一个中 |
|||
* @param filter 是否进行替换 //--> / |
|||
* @return |
|||
*/ |
|||
public static String pathJoin(boolean filter,String ...paths){ |
|||
if(paths==null||paths.length==0){ |
|||
return ""; |
|||
} |
|||
String src0=paths[0]; |
|||
for (int i = 1; i < paths.length; i++) { |
|||
String src2=paths[i]; |
|||
if(src0.endsWith("/")){ |
|||
if(src2.startsWith("/")){ |
|||
src0=src0+src2.substring(1); |
|||
}else { |
|||
src0=src0+src2; |
|||
} |
|||
}else{ |
|||
if(src2.startsWith("/")){ |
|||
src0= src0+src2; |
|||
}else { |
|||
src0= src0+"/"+src2; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
if(filter){ |
|||
return filterPath(src0); |
|||
}else { |
|||
return src0; |
|||
} |
|||
} |
|||
|
|||
|
|||
public static void main(String[] args) { |
|||
System.out.println(pathJoin(false)); |
|||
System.out.println(pathJoin(true,"https://xxx.com","/xxxxxxxx/ffffffffff")); |
|||
System.out.println(pathJoin(true,"https://xxx.com//","xxxxxxxx/ffffffffff")); |
|||
System.out.println(pathJoin(true,"https://xxx.com//","xxxxxxxx/ffffffffff")); |
|||
System.out.println(pathJoin(true,"https://xxx.com//","xxxxxxxx/ffffffffff")); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,261 @@ |
|||
package com.mdp.arc.att.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.ArcTools; |
|||
import com.mdp.arc.att.entity.Attachment; |
|||
import com.mdp.arc.att.service.AttachmentService; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.utils.ObjectTools; |
|||
import com.mdp.core.utils.RequestUtils; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.io.Resource; |
|||
import org.springframework.core.io.ResourceLoader; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
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 javax.servlet.http.HttpServletResponse; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.net.URLDecoder; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.util.Date; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* url编制采用rest风格,如对ARC.arc_attachment的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: arc/archiveAttachment/add <br> |
|||
* 查询: arc/archiveAttachment/list<br> |
|||
* 模糊查询: arc/archiveAttachment/listKey<br> |
|||
* 修改: arc/archiveAttachment/edit <br> |
|||
* 删除: arc/archiveAttachment/del<br> |
|||
* 批量删除: arc/archiveAttachment/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 arc 小模块 <br> |
|||
* 实体 ArchiveAttachment 表 ARC.arc_attachment 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.arc.archiveAttachmentController") |
|||
@RequestMapping(value="/**/arc/att/attachment") |
|||
public class AttachmentController { |
|||
|
|||
static Log logger=LogFactory.getLog(AttachmentController.class); |
|||
|
|||
@Autowired |
|||
private AttachmentService attachmentService; |
|||
|
|||
@Autowired |
|||
private HttpServletRequest request; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
@Autowired |
|||
ResourceLoader resourceLoader; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 请求,如list |
|||
* 分页参数 {pageNum:1,pageSize:10,total:0} |
|||
* 根据条件查询数据对象列表,如果不上传分页参数,将不会分页。后台自动分页,无需编程 |
|||
*/ |
|||
@RequestMapping(value="/list") |
|||
public Result listArchiveAttachment( @RequestParam Map<String,Object> params ){ |
|||
|
|||
IPage page= QueryTools.initPage(params); |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
params.put("qxUserid",user.getUserid()); |
|||
params.put("qxBranchId",user.getBranchId()); |
|||
params.put("qxRoleids",LoginUtils.getMyRoleids()); |
|||
params.put("qxDeptids",user.getDeptids()); |
|||
|
|||
RequestUtils.transformArray(params,"relyIdList"); |
|||
RequestUtils.transformArray(params,"relySidList"); |
|||
List<Map<String,Object>> datas = attachmentService.selectListMapByWhere(page,QueryTools.initQueryWrapper(Attachment.class,params),params); //列出ArchiveAttachment列表 |
|||
return Result.ok().setData(datas).setTotal(page.getTotal()); |
|||
} |
|||
@RequestMapping(value="/upload" ) |
|||
public Result filesUpload(Attachment att,HttpServletRequest request, @RequestParam("file") MultipartFile file) { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
Map<String,Object> map=new HashMap<>(); |
|||
//判断file数组不能为空并且长度大于0 |
|||
//保存文件 |
|||
try { |
|||
if(ObjectTools.isNotEmpty(att.getStoreName())){ |
|||
att.setStoreName(URLDecoder.decode(att.getStoreName(), StandardCharsets.UTF_8.name())); |
|||
} |
|||
if(ObjectTools.isNotEmpty(att.getRemark())){ |
|||
att.setRemark(URLDecoder.decode(att.getRemark(),"UTF-8")); |
|||
} |
|||
Attachment attachment=null; |
|||
String requestUrl=request.getRequestURL().toString(); |
|||
if(ObjectTools.isEmpty(att.getId())){ |
|||
attachment=saveFile(requestUrl,null,user.getBranchId(),user.getDeptid(),att.getCategoryId(),att.getArchiveId(),att.getBizId(),att.getRemark(),file,att.getStoreName()); |
|||
attachment.setArchiveType(att.getArchiveType()); |
|||
attachment.setCuserid(user.getUserid()); |
|||
attachment.setCusername(user.getUsername()); |
|||
attachment.setCdate(new Date()); |
|||
attachmentService.insert(attachment); |
|||
}else { |
|||
attachment=this.attachmentService.getById(att.getId()); |
|||
if(attachment==null){ |
|||
attachment=saveFile(requestUrl,null,user.getBranchId(),user.getDeptid(),att.getCategoryId(),att.getArchiveId(),att.getBizId(),att.getRemark(),file,att.getStoreName()); |
|||
attachment.setArchiveType(att.getArchiveType()); |
|||
attachment.setCuserid(user.getUserid()); |
|||
attachment.setCusername(user.getUsername()); |
|||
attachment.setCdate(new Date()); |
|||
attachmentService.insert(attachment); |
|||
}else{ |
|||
String originalFilename=file.getOriginalFilename(); |
|||
|
|||
if(originalFilename.endsWith(attachment.getFileSuffix())){ |
|||
this.coverFile(file,attachment); |
|||
}else { |
|||
return Result.error("file-suffix-no-match","文件类型不匹配,要求%s文件",attachment.getFileSuffix()); |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
return Result.ok().setData(attachment); |
|||
} catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error("文件保存出错"); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* |
|||
* 覆盖原有文件 |
|||
* |
|||
*/ |
|||
private Attachment coverFile( MultipartFile file,Attachment attachment) { |
|||
String dirPath=""; |
|||
String fullFilePath=""; |
|||
// 判断文件是否为空 |
|||
if (!file.isEmpty()) { |
|||
try { |
|||
// 文件保存路径 |
|||
String originalFilename=file.getOriginalFilename(); |
|||
dirPath=ArcTools.pathJoin(true,attachment.getRootPath(),attachment.getRelativePath()); |
|||
File file2=new File(dirPath); |
|||
if(!file2.exists()){ |
|||
file2.mkdirs(); |
|||
} |
|||
// 转存文件 |
|||
fullFilePath=ArcTools.pathJoin(true,dirPath,attachment.getStoreName()+attachment.getFileSuffix()); |
|||
file.transferTo(new File(fullFilePath)); |
|||
return attachment; |
|||
} catch (Exception e) { |
|||
logger.error("保存文件出错到"+fullFilePath+"出错"); |
|||
throw new BizException("保存文件出错"); |
|||
} |
|||
}else{ |
|||
throw new BizException("文件为空"); |
|||
} |
|||
} |
|||
/*** |
|||
* 保存文件 |
|||
* @param file |
|||
* @return |
|||
*/ |
|||
private Attachment saveFile(String requestUrl,String id,String branchId, String deptid, String categoryId, String archiveId, String bizId, String remark, MultipartFile file,String fixedName ) { |
|||
Attachment attachment=new Attachment(); |
|||
String dirPath=""; |
|||
String fullFilePath=""; |
|||
// 判断文件是否为空 |
|||
if (!file.isEmpty()) { |
|||
try { |
|||
// 文件保存路径 |
|||
String originalFilename=file.getOriginalFilename(); |
|||
attachment= attachmentService.createAttachment(requestUrl,id,branchId,deptid,categoryId,archiveId,bizId,originalFilename,remark,fixedName); |
|||
dirPath=ArcTools.pathJoin(true,attachment.getRootPath(),attachment.getRelativePath()); |
|||
File file2=new File(dirPath); |
|||
if(!file2.exists()){ |
|||
file2.mkdirs(); |
|||
} |
|||
// 转存文件 |
|||
fullFilePath=ArcTools.pathJoin(true,dirPath,attachment.getStoreName()+attachment.getFileSuffix()); |
|||
file.transferTo(new File(fullFilePath)); |
|||
return attachment; |
|||
} catch (Exception e) { |
|||
logger.error("保存文件出错到"+fullFilePath+"出错"); |
|||
throw new BizException("保存文件出错"); |
|||
} |
|||
}else{ |
|||
throw new BizException("文件为空"); |
|||
} |
|||
} |
|||
|
|||
|
|||
@RequestMapping("/**") |
|||
public ResponseEntity download(HttpServletRequest request,HttpServletResponse response, @RequestParam(value="name",required=false) String name, @RequestParam(value="preview",required=false) String preview ) { |
|||
|
|||
//下载文件路径 |
|||
String servletPath=request.getServletPath(); |
|||
String fullPath=this.attachmentService.getFullFilePathByUrl(servletPath); |
|||
if(StringUtils.isEmpty(name)){ |
|||
name=servletPath.substring(servletPath.lastIndexOf("/")+1); |
|||
|
|||
} |
|||
Resource resource=resourceLoader.getResource("file:"+fullPath); |
|||
String contentType = null; |
|||
try { |
|||
contentType = request.getServletContext().getMimeType(resource.getFile().getAbsolutePath()); |
|||
} catch (IOException e) { |
|||
logger.error("无法获取文件类型", e); |
|||
} |
|||
if (contentType == null) { |
|||
contentType = "application/octet-stream"; |
|||
} |
|||
if("1".equals(preview)){ |
|||
return ResponseEntity.ok() |
|||
.contentType(MediaType.parseMediaType(contentType)) |
|||
.body(resource); |
|||
}else { |
|||
return ResponseEntity.ok() |
|||
.contentType(MediaType.parseMediaType(contentType)) |
|||
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + name + "\"") |
|||
.body(resource); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 根据主键删除1条数据 |
|||
*/ |
|||
@RequestMapping(value="/del") |
|||
public Result delArchiveAttachment(@RequestBody Attachment archiveAttachment){ |
|||
|
|||
|
|||
try{ |
|||
attachmentService.deleteByPk(archiveAttachment); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package com.mdp.arc.att.ctrl; |
|||
|
|||
|
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 为了兼容原来的arc/file/*的请求,创建子类 |
|||
***/ |
|||
@Deprecated |
|||
@RestController("mdp.arc.AttachmentSubController") |
|||
@RequestMapping(value="/**/arc/file") |
|||
public class AttachmentSubController extends AttachmentController{ |
|||
|
|||
} |
|||
@ -0,0 +1,161 @@ |
|||
package com.mdp.arc.att.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-20 |
|||
*/ |
|||
@Data |
|||
@TableName("arc_attachment") |
|||
@ApiModel(description="档案附件表") |
|||
public class Attachment implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
|
|||
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
|
|||
@ApiModelProperty(notes="附件名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String name; |
|||
|
|||
|
|||
@ApiModelProperty(notes="访问路径",allowEmptyValue=true,example="",allowableValues="") |
|||
String url; |
|||
|
|||
|
|||
@ApiModelProperty(notes="硬盘存放路径",allowEmptyValue=true,example="",allowableValues="") |
|||
String relativePath; |
|||
|
|||
|
|||
@ApiModelProperty(notes="后缀名",allowEmptyValue=true,example="",allowableValues="") |
|||
String fileSuffix; |
|||
|
|||
|
|||
@ApiModelProperty(notes="内容加速器访问路径",allowEmptyValue=true,example="",allowableValues="") |
|||
String cdnUrl; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否图片",allowEmptyValue=true,example="",allowableValues="") |
|||
String isImg; |
|||
|
|||
|
|||
@ApiModelProperty(notes="档案主编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String archiveId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否使用CDN",allowEmptyValue=true,example="",allowableValues="") |
|||
String isCdn; |
|||
|
|||
|
|||
@ApiModelProperty(notes="根目录",allowEmptyValue=true,example="",allowableValues="") |
|||
String rootPath; |
|||
|
|||
|
|||
@ApiModelProperty(notes="存入时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date createDate; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否可下载",allowEmptyValue=true,example="",allowableValues="") |
|||
String canDown; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否可删除",allowEmptyValue=true,example="",allowableValues="") |
|||
String canDel; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否可读",allowEmptyValue=true,example="",allowableValues="") |
|||
String canRead; |
|||
|
|||
|
|||
@ApiModelProperty(notes="业务编号、产品编号、商品编号等",allowEmptyValue=true,example="",allowableValues="") |
|||
String bizId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="业务名称、产品名称、商品名称等",allowEmptyValue=true,example="",allowableValues="") |
|||
String remark; |
|||
|
|||
|
|||
@ApiModelProperty(notes="存储名字",allowEmptyValue=true,example="",allowableValues="") |
|||
String storeName; |
|||
|
|||
|
|||
@ApiModelProperty(notes="文件大小",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal fileSize; |
|||
|
|||
|
|||
@ApiModelProperty(notes="云用户机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="部门编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="0|知识库",allowEmptyValue=true,example="",allowableValues="") |
|||
String archiveType; |
|||
|
|||
|
|||
@ApiModelProperty(notes="分类编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String categoryId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考类型",allowEmptyValue=true,example="",allowableValues="") |
|||
String relyType; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String relyId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考子类型",allowEmptyValue=true,example="",allowableValues="") |
|||
String relyStype; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考子编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String relySid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="创建人编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="创建人姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String cusername; |
|||
|
|||
|
|||
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date cdate; |
|||
|
|||
|
|||
@ApiModelProperty(notes="扩展字段",allowEmptyValue=true,example="",allowableValues="") |
|||
String extInfos; |
|||
|
|||
|
|||
@ApiModelProperty(notes="标签",allowEmptyValue=true,example="",allowableValues="") |
|||
String tagIds; |
|||
|
|||
/** |
|||
*主键 |
|||
**/ |
|||
public Attachment(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 档案附件表 |
|||
**/ |
|||
public Attachment() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package com.mdp.arc.att.entity; |
|||
|
|||
public class Base64AttachmentVo { |
|||
String categoryId; |
|||
String name; |
|||
String fileData; |
|||
String archiveId; |
|||
String bizId; |
|||
String remark; |
|||
public String getCategoryId() { |
|||
return categoryId; |
|||
} |
|||
public void setCategoryId(String categoryId) { |
|||
this.categoryId = categoryId; |
|||
} |
|||
public String getName() { |
|||
return name; |
|||
} |
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
public String getFileData() { |
|||
return fileData; |
|||
} |
|||
public void setFileData(String fileData) { |
|||
this.fileData = fileData; |
|||
} |
|||
public String getArchiveId() { |
|||
return archiveId; |
|||
} |
|||
public void setArchiveId(String archiveId) { |
|||
this.archiveId = archiveId; |
|||
} |
|||
public String getBizId() { |
|||
return bizId; |
|||
} |
|||
public void setBizId(String bizId) { |
|||
this.bizId = bizId; |
|||
} |
|||
public String getRemark() { |
|||
return remark; |
|||
} |
|||
public void setRemark(String remark) { |
|||
this.remark = remark; |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.mdp.arc.att.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.att.entity.Attachment; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* @author maimeng-mdp code-gen |
|||
* @since 2023-9-1 |
|||
*/ |
|||
public interface AttachmentMapper extends BaseMapper<Attachment> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,70 @@ |
|||
<?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.mdp.arc.att.mapper.AttachmentMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
|
|||
|
|||
select res.* from arc_attachment res left join arc_category c on res.CATEGORY_ID=c.id |
|||
|
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<!--下面可以添加更多查询条件,正常的if 条件都是支持的--> |
|||
and ( |
|||
EXISTS ( SELECT 1 FROM arc_category r1 LEFT JOIN arc_category_qx qx ON qx.CATE_ID = r1.ID |
|||
WHERE |
|||
r1.branch_id=#{ext.qxBranchId} and r1.qx_lvl = '2' and qx.oth_query='1' |
|||
AND ( |
|||
FIND_IN_SET( #{ext.qxUserid}, ifnull(qx.QRY_USERIDS,'') )>0 |
|||
<if test="ext.qxDeptids!=null"> or |
|||
<foreach collection="ext.qxDeptids" item="item" index="index" open="(" separator=" or " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.QRY_DEPTIDS,'') )>0 |
|||
</foreach> |
|||
</if> |
|||
<if test="ext.qxRoleids!=null"> or |
|||
<foreach collection="ext.qxRoleids" item="item" index="index" open="(" separator=" or " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.QRY_ROLEIDS,'') )>0 |
|||
</foreach> |
|||
</if> |
|||
) |
|||
AND ( |
|||
FIND_IN_SET( #{ext.qxUserid}, ifnull(qx.NQ_USERIDS,'') )=0 |
|||
<if test="ext.qxDeptids!=null"> and |
|||
<foreach collection="ext.qxDeptids" item="item" index="index" open="(" separator=" and " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.NQ_DEPTIDS,'') )=0 |
|||
</foreach> |
|||
</if> |
|||
<if test="ext.qxRoleids!=null"> and |
|||
<foreach collection="ext.qxRoleids" item="item" index="index" open="(" separator=" and " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.NQ_ROLEIDS,'') )=0 |
|||
</foreach> |
|||
</if> |
|||
) |
|||
AND c.paths LIKE concat( r1.paths, '%' ) |
|||
) |
|||
or c.qx_lvl = '0' |
|||
OR c.qx_lvl IS NULL |
|||
OR ( c.qx_lvl = '1' AND c.BRANCH_ID = #{ext.qxBranchId}) |
|||
) |
|||
<if test="ext.crelyType!=null"> |
|||
and c.crely_type=#{ext.crelyType} |
|||
</if> |
|||
|
|||
<if test="ext.crelyId!=null"> |
|||
and c.crely_id=#{ext.crelyId} |
|||
</if> |
|||
|
|||
<if test="ext.crelyStype!=null"> |
|||
and c.crely_stype=#{ext.crelyStype} |
|||
</if> |
|||
|
|||
<if test="ext.crelySid!=null"> |
|||
and c.crely_sid=#{ext.crelySid} |
|||
</if> |
|||
</where> |
|||
<!--下面双引号内可以添加默认排序,如果前端没有上传排序,将使用引号内的排序规则--> |
|||
${@com.mdp.Util@trimOrderBy(ew.customSqlSegment,'')} |
|||
<!--下面双引号内可以添加默认分组,如果前端没有上传分组,将使用引号内的分组规则--> |
|||
${@com.mdp.Util@trimGroupBy(ew.customSqlSegment,'')} |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,160 @@ |
|||
package com.mdp.arc.att.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.ArcTools; |
|||
import com.mdp.arc.att.entity.Attachment; |
|||
import com.mdp.arc.att.mapper.AttachmentMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.core.utils.ObjectTools; |
|||
import com.mdp.meta.client.service.ItemService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author maimeng-mdp code-gen |
|||
* @since 2023-9-1 |
|||
*/ |
|||
@Service |
|||
@DS("arc-ds") |
|||
public class AttachmentService extends BaseService<AttachmentMapper,Attachment> { |
|||
static Logger logger =LoggerFactory.getLogger(AttachmentService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
|
|||
@Value(value="${mdp.arc.file-upload-root-path:}") |
|||
private String arcFileUploadRootPath; |
|||
|
|||
@Value(value="${mdp.arc.file-download-base-uri:}") |
|||
String arcFileDownloadBaseUri; |
|||
|
|||
public static String urlPrefix="arc/file/"; |
|||
|
|||
|
|||
public static final boolean isWindows; |
|||
public static final String splash; |
|||
public static final String root; |
|||
|
|||
static { |
|||
if (System.getProperty("os.name") != null && System.getProperty("os.name").toLowerCase().contains("windows")) { |
|||
isWindows = true; |
|||
splash = "\\"; |
|||
root="D:\\arc\\files\\"; |
|||
} else { |
|||
isWindows = false; |
|||
splash = "/"; |
|||
root="/arc/files/"; |
|||
} |
|||
} |
|||
|
|||
@Autowired |
|||
private ItemService itemService; |
|||
|
|||
@PostConstruct |
|||
public void checkPath(){ |
|||
if(StringUtils.isEmpty(arcFileUploadRootPath)){ |
|||
throw new RuntimeException("请配置档案附件上传根目录 如 mdp.arc.file-upload-root-path=D:/arc/files 参数"); |
|||
} |
|||
} |
|||
/** **/ |
|||
public Attachment createAttachment(String requestUrl,String id,String branchId, String deptid, String categoryId, String archiveId, String bizId, String originalFilename, String remark,String fixedName){ |
|||
Attachment aa=new Attachment(); |
|||
if(ObjectTools.isNotEmpty(id)){ |
|||
aa.setId(id); |
|||
}else{ |
|||
aa.setId(this.createKey("id")); |
|||
} |
|||
|
|||
if(StringUtils.isEmpty(bizId)){ |
|||
bizId=""; |
|||
} |
|||
if(StringUtils.isEmpty(branchId)||branchId.indexOf("undefined")>=0||branchId.indexOf("null")>=0){ |
|||
branchId=""; |
|||
} |
|||
if(StringUtils.isEmpty(categoryId)||categoryId.indexOf("undefined")>=0||categoryId.indexOf("null")>=0){ |
|||
categoryId=""; |
|||
} |
|||
if(StringUtils.isEmpty(archiveId)||archiveId.indexOf("undefined")>=0||archiveId.indexOf("null")>=0){ |
|||
archiveId=""; |
|||
} |
|||
if(StringUtils.isEmpty(deptid)||deptid.indexOf("undefined")>=0||deptid.indexOf("null")>=0){ |
|||
deptid=""; |
|||
} |
|||
String relativePath= ArcTools.pathJoin( true,branchId,categoryId,archiveId); |
|||
aa.setRelativePath(relativePath); |
|||
aa.setRootPath(arcFileUploadRootPath); |
|||
aa.setName(originalFilename); |
|||
aa.setArchiveId(archiveId); |
|||
int nameIndex=originalFilename.lastIndexOf("."); |
|||
String fileSuffix; |
|||
if(nameIndex!=-1) { |
|||
fileSuffix=originalFilename.substring(nameIndex); |
|||
}else { |
|||
fileSuffix=""; |
|||
} |
|||
if(StringUtils.hasText(fixedName)){ |
|||
aa.setStoreName(fixedName); |
|||
}else{ |
|||
aa.setStoreName(aa.getId()); |
|||
} |
|||
aa.setFileSuffix(fileSuffix); |
|||
String url2=ArcTools.pathJoin(true,urlPrefix,relativePath,aa.getStoreName()+aa.getFileSuffix()); |
|||
String preUrl=getPreUrlPathByUploadUrl(requestUrl); |
|||
String url=(ArcTools.pathJoin(false,preUrl,url2)); |
|||
aa.setUrl(url); |
|||
aa.setCdnUrl(url); |
|||
|
|||
aa.setCanDel("1"); |
|||
aa.setCanDown("1"); |
|||
aa.setCanRead("1"); |
|||
aa.setBizId(bizId); |
|||
aa.setBranchId(branchId); |
|||
aa.setDeptid(deptid); |
|||
aa.setRemark(remark); |
|||
aa.setCategoryId(categoryId); |
|||
return aa; |
|||
|
|||
} |
|||
public String getArcUploadRootPath() { |
|||
return arcFileUploadRootPath; |
|||
} |
|||
|
|||
public String getFullFilePath(String relativePath,String id,String fileSuffix){ |
|||
String path= ArcTools.pathJoin(true,this.arcFileUploadRootPath,relativePath,id+fileSuffix); |
|||
return path; |
|||
} |
|||
|
|||
public String getPreUrlPathByUploadUrl(String requestURL) { |
|||
if(StringUtils.hasText(this.arcFileDownloadBaseUri)){ |
|||
return this.arcFileDownloadBaseUri; |
|||
}else{ |
|||
int indexOf=requestURL.indexOf(urlPrefix); |
|||
return requestURL.substring(0,indexOf); |
|||
} |
|||
} |
|||
public String getFullFilePathByUrl(String servletPath) { |
|||
|
|||
int indexOf=servletPath.indexOf(urlPrefix); |
|||
return ArcTools.pathJoin(true,arcFileUploadRootPath,servletPath.substring(indexOf+urlPrefix.length())); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,49 @@ |
|||
package com.mdp.arc.att.service; |
|||
|
|||
import com.mdp.core.service.BaseService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.io.BufferedWriter; |
|||
import java.io.File; |
|||
import java.io.FileWriter; |
|||
|
|||
@Service |
|||
public class RichTextFileService extends BaseService { |
|||
|
|||
|
|||
public void writeStringToFile(String filePath,String context) { |
|||
try { |
|||
File file=new File(filePath); |
|||
|
|||
File fileParent = file.getParentFile(); |
|||
if(!fileParent.exists()){ |
|||
fileParent.mkdirs(); |
|||
} |
|||
if(!file.exists()) file.createNewFile(); |
|||
FileWriter fw = new FileWriter(filePath, false); |
|||
BufferedWriter bw = new BufferedWriter(fw); |
|||
bw.write(context);// 往已有的文件上添加字符串 |
|||
bw.close(); |
|||
fw.close(); |
|||
} catch (Exception e) { |
|||
log.error("",e); |
|||
} |
|||
} |
|||
|
|||
public void delFile(String filePath) { |
|||
try { |
|||
File file=new File(filePath); |
|||
if(file.exists() && file.isFile()) { |
|||
file.delete(); |
|||
} |
|||
return; |
|||
|
|||
} catch (Exception e) { |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,195 @@ |
|||
package com.mdp.arc.img.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.img.entity.ImageCategory; |
|||
import com.mdp.arc.img.service.ImageCategoryService; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.swagger.ApiEntityParams; |
|||
import io.swagger.annotations.*; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* url编制采用rest风格,如对ARC.arc_image_category 图片分类的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: arc/imageCategory/add <br> |
|||
* 查询: arc/imageCategory/list<br> |
|||
* 模糊查询: arc/imageCategory/listKey<br> |
|||
* 修改: arc/imageCategory/edit <br> |
|||
* 删除: arc/imageCategory/del<br> |
|||
* 批量删除: arc/imageCategory/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 arc 小模块 <br> |
|||
* 实体 ImageCategory 表 ARC.arc_image_category 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.arc.imageCategoryController") |
|||
@RequestMapping(value="/**/arc/img/imageCategory") |
|||
@Api(tags={"图片分类操作接口"}) |
|||
public class ImageCategoryController { |
|||
|
|||
static Log logger=LogFactory.getLog(ImageCategoryController.class); |
|||
|
|||
@Autowired |
|||
private ImageCategoryService imageCategoryService; |
|||
|
|||
|
|||
|
|||
|
|||
@ApiOperation( value = "查询图片分类信息列表",notes="listImageCategory,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name="id",value="主键,主键",required=false), |
|||
@ApiImplicitParam(name="categoryName",value="分类名称",required=false), |
|||
@ApiImplicitParam(name="branchId",value="机构编号",required=false), |
|||
@ApiImplicitParam(name="pid",value="上一级",required=false), |
|||
@ApiImplicitParam(name="isPub",value="是否是公共分类的图片 1是0 否",required=false), |
|||
@ApiImplicitParam(name="pageSize",value="每页记录数",required=false), |
|||
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false), |
|||
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), |
|||
@ApiImplicitParam(name="orderFields",value="排序列 如性别、学生编号排序 ['sex','studentId']",required=false), |
|||
@ApiImplicitParam(name="orderDirs",value="排序方式,与orderFields对应,升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']",required=false) |
|||
}) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=ImageCategory.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listImageCategory(@RequestParam Map<String,Object> params ){ |
|||
|
|||
IPage page= QueryTools.initPage(params); |
|||
List<Map<String,Object>> datas = imageCategoryService.selectListMapByWhere(page,QueryTools.initQueryWrapper(ImageCategory.class,params),params); //列出ImageCategory列表 |
|||
|
|||
return Result.ok().setData(datas).setTotal(page.getTotal()); |
|||
} |
|||
|
|||
/** |
|||
* 请求,如list/tree |
|||
* 根据条件查询数据对象列表,如果不上传分页参数,将不会分页。后台自动分页,无需编程 |
|||
*/ |
|||
@RequestMapping(value = "/list/trees") |
|||
public Map<String, Object> listCategoryTree(@RequestParam Map<String, Object> category) { |
|||
return this.listImageCategory(category); |
|||
} |
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "新增一条图片分类信息",notes="addImageCategory,主键如果为空,后台自动生成") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=ImageCategory.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addImageCategory(@RequestBody ImageCategory imageCategory) { |
|||
|
|||
|
|||
try{ |
|||
if(StringUtils.hasText(imageCategory.getId())){ |
|||
if(this.imageCategoryService.countByWhere(new ImageCategory(imageCategory.getId()))>0){ |
|||
return Result.error("id-is-exists","该分类编号已存在"); |
|||
} |
|||
}else{ |
|||
imageCategory.setId(imageCategoryService.createKey("id")); |
|||
} |
|||
|
|||
imageCategoryService.insert(imageCategory); |
|||
return Result.ok().setData(imageCategory); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "删除一条图片分类信息",notes="delImageCategory,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delImageCategory(@RequestBody ImageCategory imageCategory){ |
|||
|
|||
|
|||
try{ |
|||
ImageCategory imageCategoryQuery=new ImageCategory(); |
|||
imageCategoryQuery.setPid(imageCategory.getId()); |
|||
Long children=this.imageCategoryService.countByWhere(imageCategoryQuery); |
|||
if(children>0){ |
|||
return Result.error("have-children","还有子分类,不能删除,请先删除子分类"); |
|||
} |
|||
imageCategoryService.deleteByPk(imageCategory); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键修改一条图片分类信息",notes="editImageCategory") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=ImageCategory.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editImageCategory(@RequestBody ImageCategory imageCategory) { |
|||
|
|||
|
|||
try{ |
|||
imageCategoryService.updateByPk(imageCategory); |
|||
return Result.ok().setData(imageCategory); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation(value = "批量修改某些字段", notes = "") |
|||
@ApiEntityParams(value = ImageCategory.class, props = {}, remark = "档案信息表", paramType = "body") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, response = ImageCategory.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value = "/editSomeFields", method = RequestMethod.POST) |
|||
public Map<String, Object> editSomeFields(@ApiIgnore @RequestBody Map<String, Object> params) { |
|||
int i= this.imageCategoryService.editSomeFields(params); |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键列表批量删除图片分类信息",notes="batchDelImageCategory,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@HasRole(roles = {"platformAdmin", "shopAdmin"}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelImageCategory(@RequestBody List<ImageCategory> imageCategorys) { |
|||
|
|||
|
|||
try{ |
|||
imageCategoryService.batchDelete(imageCategorys); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
*/ |
|||
} |
|||
@ -0,0 +1,618 @@ |
|||
package com.mdp.arc.img.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.ArcTools; |
|||
import com.mdp.arc.img.entity.Base64ImageVo; |
|||
import com.mdp.arc.img.entity.Image; |
|||
import com.mdp.arc.img.service.ImageCompressService; |
|||
import com.mdp.arc.img.service.ImageService; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.entity.Tips; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.utils.ObjectTools; |
|||
import com.mdp.swagger.ApiEntityParams; |
|||
import io.swagger.annotations.*; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.core.io.Resource; |
|||
import org.springframework.core.io.ResourceLoader; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.util.Base64Utils; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import ws.schild.jave.MultimediaInfo; |
|||
import ws.schild.jave.MultimediaObject; |
|||
|
|||
import javax.imageio.ImageIO; |
|||
import javax.imageio.ImageReader; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.awt.image.BufferedImage; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.util.HashMap; |
|||
import java.util.Iterator; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import static com.mdp.core.utils.BaseUtils.map; |
|||
|
|||
/** |
|||
* url编制采用rest风格,如对ARC.arc_image 图片素材库的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: arc/image/add <br> |
|||
* 查询: arc/image/list<br> |
|||
* 模糊查询: arc/image/listKey<br> |
|||
* 修改: arc/image/edit <br> |
|||
* 删除: arc/image/del<br> |
|||
* 批量删除: arc/image/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 arc 小模块 <br> |
|||
* 实体 Image 表 ARC.arc_image 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.arc.imageController") |
|||
@RequestMapping(value="/**/arc/img/image") |
|||
@Api(tags={"图片素材库操作接口"}) |
|||
public class ImageController { |
|||
|
|||
static Log logger=LogFactory.getLog(ImageController.class); |
|||
|
|||
@Autowired |
|||
private ImageService imageService; |
|||
|
|||
@Autowired |
|||
ResourceLoader resourceLoader; |
|||
|
|||
@Autowired |
|||
private ImageCompressService imageCompressService; |
|||
|
|||
|
|||
@ApiOperation( value = "查询图片素材库信息列表",notes="listImage,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") |
|||
@ApiEntityParams(Image.class) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response= Image.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listImage(@RequestParam Map<String,Object> params ){ |
|||
|
|||
IPage page= QueryTools.initPage(params); |
|||
List<Map<String,Object>> datas=this.imageService.selectListMapByWhere(page,QueryTools.initQueryWrapper(Image.class,params),params); |
|||
|
|||
return Result.ok().setData(datas).setTotal(page.getTotal()); |
|||
} |
|||
|
|||
|
|||
@ApiOperation( value = "获取图片分类名",notes="listTags,条件之间是 and关系") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name="tag",value="标签",required=false), |
|||
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false), |
|||
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), |
|||
@ApiImplicitParam(name="orderFields",value="排序列 如性别、学生编号排序 ['sex','studentId']",required=false), |
|||
@ApiImplicitParam(name="orderDirs",value="排序方式,与orderFields对应,升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']",required=false) |
|||
}) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Image.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/listTags",method=RequestMethod.GET) |
|||
public Result listTags( @RequestParam Map<String,Object> params ){ |
|||
System.out.println("------------------"); |
|||
List<Map<String,Object>> imageList = imageService.selectTagsListMap(params); |
|||
return Result.ok().setData(imageList); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 上传固定名称图片 并压缩保存到硬盘 |
|||
* @param categoryId 分类 非必输 |
|||
* @param fixedName 固定文件名称,如用户编号等 |
|||
* @param file 文件流对象,form表单自动生成 必输 |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value="/upload/fixed") |
|||
public Result filesUpload(HttpServletRequest request, @RequestParam(value="categoryId",required=false) String categoryId, @RequestParam("file") MultipartFile file, @RequestParam(value="fixedName",required=false) String fixedName) { |
|||
|
|||
Map<String,Object> map=new HashMap<>(); |
|||
Float scale=1f; |
|||
Float outputQuality=0f; |
|||
if(!StringUtils.hasText(fixedName)){ |
|||
return Result.error("fixedName","请指定固定文件名称"); |
|||
} |
|||
//判断file数组不能为空并且长度大于0 |
|||
if(outputQuality==null || outputQuality==0) { |
|||
long fileSize= file.getSize(); |
|||
if(fileSize>=1024*2048) { |
|||
outputQuality=0.2f; |
|||
}else if(fileSize>=1024*1024) { |
|||
outputQuality=0.5f; |
|||
}else { |
|||
outputQuality=1f; |
|||
} |
|||
} |
|||
Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("JPEG"); |
|||
while (readers.hasNext()) { |
|||
System.out.println("reader: " + readers.next()); |
|||
logger.info("reader: " +readers.next()); |
|||
} |
|||
if(scale<0.1f ||scale>1f) { |
|||
return Result.error("scale-err", "scale", "缩放比例必须在0.1~1之间"); |
|||
}else if(outputQuality<0.1f||outputQuality>1f) { |
|||
return Result.error("outputQuality-err", "outputQuality", "压缩质量必须在0.1~1之间"); |
|||
}else { |
|||
//保存文件 |
|||
try { |
|||
String originalFilename=file.getOriginalFilename(); |
|||
String fileSuffix=originalFilename.substring(originalFilename.lastIndexOf(".")); |
|||
String requestURL=request.getRequestURL().toString(); |
|||
String rootPath= imageService.arcImageUploadRootPath; |
|||
String dirPath= ArcTools.pathJoin(true,rootPath,categoryId); |
|||
String fullFilePath=ArcTools.pathJoin(true,dirPath,fixedName+fileSuffix); |
|||
File file2=new File(dirPath); |
|||
if(!file2.exists()){ |
|||
file2.mkdirs(); |
|||
} |
|||
Tips tips=imageCompressService.compressAndSaveImage(file.getInputStream(),scale,outputQuality,fullFilePath); |
|||
Result.assertIsFalse(tips); |
|||
String fileSuffix2=originalFilename.substring(originalFilename.lastIndexOf(".")+1); |
|||
String fileSuffixNew="jpg"; |
|||
String fullFilePathNew=ArcTools.pathJoin(true,dirPath,fixedName+"."+fileSuffixNew); |
|||
if(StringUtils.hasText(fileSuffix2)){ |
|||
if(!fileSuffix.equalsIgnoreCase(fileSuffixNew)){ |
|||
BufferedImage originalImage = ImageIO.read(new File(fullFilePath)); |
|||
|
|||
|
|||
BufferedImage newImage = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), BufferedImage.TYPE_3BYTE_BGR); |
|||
|
|||
for (int x = 0; x < originalImage.getWidth(); x++) { |
|||
|
|||
for (int y = 0; y < originalImage.getHeight(); y++) { |
|||
|
|||
newImage.setRGB(x, y, originalImage.getRGB(x, y)); |
|||
|
|||
} |
|||
} |
|||
|
|||
ImageIO.write(newImage, fileSuffixNew, new File(fullFilePathNew)); |
|||
} |
|||
} |
|||
String url2=ArcTools.pathJoin(true,ImageService.urlPrefix,categoryId,fixedName+"."+fileSuffixNew); |
|||
String prePath=imageService.getPreUrlPathByUploadUrl(requestURL); |
|||
String url=ArcTools.pathJoin(false,prePath,url2); |
|||
map.put("data", map("url",url)); |
|||
return Result.ok().setData(map("url",url)); |
|||
} catch (BizException e) { |
|||
logger.error("上传图像失败",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("上传图像失败",e); |
|||
return Result.error("文件保存出错"); |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 图片上传并压缩保存到硬盘,同时记录到数据库 |
|||
* @param fileName 文件名 非必输 |
|||
* @param tag 标签 非必输 |
|||
* @param storedb 是否创建数据库记录 非必输,true|false默认不存 |
|||
* @param categoryId 分类 非必输 |
|||
* @param remark 备注 非必输 |
|||
* @param deptid 部门 非必输 |
|||
* @param branchId 归属机构 非必输 |
|||
* @param file 文件流对象,form表单自动生成 必输 |
|||
* @param scale 压缩比例 0.1~1之间 |
|||
* @param outputQuality 压缩质量0.1~1之间 |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value="/upload") |
|||
public Result filesUpload(HttpServletRequest request, |
|||
@RequestParam(value="id",required=false) String id, |
|||
@RequestParam(value="fileName",required=false) String fileName, |
|||
@RequestParam(value="tag",required=false) String tag, |
|||
@RequestParam(value="storedb",required=false) boolean storedb, |
|||
@RequestParam(value="categoryId",required=false) String categoryId, |
|||
@RequestParam(value="remark",required=false) String remark, |
|||
@RequestParam(value="deptid",required=false) String deptid, |
|||
@RequestParam(value="branchId",required=false) String branchId, |
|||
@RequestParam("file") MultipartFile file, |
|||
@RequestParam(value="scale",required=false) Float scale, |
|||
@RequestParam(value="outputQuality",required=false) Float outputQuality, |
|||
@RequestParam(value="fixedName",required=false) String fixedName) { |
|||
|
|||
Image image = null; |
|||
String fileSuffix=null; |
|||
//判断file数组不能为空并且长度大于0 |
|||
if(scale==null || scale==0) { |
|||
scale=1f; |
|||
} |
|||
if(outputQuality==null || outputQuality==0) { |
|||
long fileSize= file.getSize(); |
|||
if(fileSize>=1024*2048) { |
|||
outputQuality=0.2f; |
|||
}else if(fileSize>=1024*1024) { |
|||
outputQuality=0.5f; |
|||
}else { |
|||
outputQuality=0.5f; |
|||
} |
|||
|
|||
} |
|||
if(scale<0.1f ||scale>1f) { |
|||
return Result.error("scale-err", "scale", "缩放比例必须在0.1~1之间"); |
|||
}else if(outputQuality<0.1f||outputQuality>1f) { |
|||
return Result.error("outputQuality-err", "outputQuality", "压缩质量必须在0.1~1之间"); |
|||
}else { |
|||
//保存文件 |
|||
try { |
|||
|
|||
String requestURL=request.getRequestURL().toString(); |
|||
image=saveImage(requestURL,id,fileName,tag,storedb,categoryId,remark, deptid,branchId,file,scale,outputQuality,fixedName); |
|||
return Result.ok().setData(image); |
|||
} catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("文件保存出错",e); |
|||
return Result.error("文件保存出错"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@RequestMapping(value="/uploadMovie") |
|||
public Result movieUpload(HttpServletRequest request,@RequestParam(value="id",required=false) String id,@RequestParam(value="fileName",required=false) String fileName,@RequestParam(value="tag",required=false) String tag,@RequestParam(value="categoryId",required=false) String categoryId,@RequestParam(value="remark",required=false) String remark,@RequestParam(value="deptid",required=false) String deptid,@RequestParam(value="branchId",required=false) String branchId,@RequestParam("file") MultipartFile file,@RequestParam(value="scale",required=false) Float scale,@RequestParam(value="outputQuality",required=false) Float outputQuality,@RequestParam(value="fixedName",required=false) String fixedName) { |
|||
|
|||
Map<String,Object> map=new HashMap<>(); |
|||
Image image = null; |
|||
String fileSuffix=null; |
|||
System.out.println(file); |
|||
outputQuality=1f; |
|||
Long duration=null; |
|||
String requestURL=request.getRequestURL().toString(); |
|||
|
|||
scale=1f; |
|||
//保存文件 |
|||
try { |
|||
|
|||
// image=saveMovie(fileName,tag,categoryId,remark, deptid,branchId,file,scale,outputQuality); |
|||
Map<String,Object> MovieAndDuration=(Map<String,Object>)saveMovie(request,id,fileName,tag,categoryId,remark, deptid,branchId,file,scale,outputQuality,fixedName); |
|||
image=(Image) MovieAndDuration.get("movie"); |
|||
duration=(Long) MovieAndDuration.get("duration"); |
|||
map.put("data", image); |
|||
map.put("duration", duration); |
|||
return Result.ok().setData(image).put("duration",duration); |
|||
} catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error("文件保存出错"); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 图片上传保存到硬盘,同时记录到数据库 |
|||
*/ |
|||
public Result saveMovie(HttpServletRequest request,String id,String fileName,String tag,String categoryId,String remark,String deptid,String branchId,MultipartFile file,Float scale,Float outputQuality,String fixedName){ |
|||
Image i=null; |
|||
String dirPath=""; |
|||
String fullFilePath=""; |
|||
Map<String,Object> mmp=new HashMap<String,Object>();//返回短视频对象,和时长 |
|||
String requestURL=request.getRequestURL().toString(); |
|||
if(StringUtils.isEmpty(categoryId)) { |
|||
throw new BizException("categoryId","分类不能为空"); |
|||
} |
|||
if(!file.isEmpty()){ |
|||
File file2=null; |
|||
try { |
|||
String originalFilename = file.getOriginalFilename(); |
|||
long size = file.getSize(); |
|||
i = this.imageService.genImageInfo(requestURL,id,originalFilename,fileName, tag,categoryId,remark,deptid,branchId,size,fixedName); |
|||
dirPath=(i.getRootPath()+"/"+i.getRelativePath()).replaceAll("//", "/"); |
|||
file2=new File(dirPath); |
|||
if(!file2.exists()){ |
|||
file2.mkdirs(); |
|||
} |
|||
// 转存文件 |
|||
fullFilePath=(dirPath+"/"+i.getStorageName()+i.getFileSuffix()).replaceAll("//", "/"); |
|||
// Get the file and save it somewhere |
|||
byte[] bytes = file.getBytes(); |
|||
Path path = Paths.get(fullFilePath); |
|||
Files.write(path, bytes); |
|||
|
|||
//计算视频长度 |
|||
File f = null; |
|||
f = File.createTempFile("tmp", i.getFileSuffix()); |
|||
file.transferTo(f); |
|||
f.deleteOnExit(); |
|||
//获取视频时长 |
|||
MultimediaObject instance = new MultimediaObject(f); |
|||
MultimediaInfo result = instance.getInfo(); |
|||
long ls = (result.getDuration() / 1000); |
|||
|
|||
this.imageService.insert(i); |
|||
mmp.put("movie",i); |
|||
mmp.put("duration",ls); |
|||
return Result.ok().put("movie",i).put("duration",ls); |
|||
} catch (BizException e) { |
|||
throw e; |
|||
}catch (Exception e) { |
|||
logger.error("保存图片出错到"+fullFilePath+"出错",e); |
|||
throw new BizException("saveFileError01","保存图片出错"); |
|||
}finally { |
|||
if(file2!=null) { |
|||
file2=null; |
|||
} |
|||
} |
|||
|
|||
}else{ |
|||
throw new BizException("saveFileError02","图片为空"); |
|||
} |
|||
} |
|||
|
|||
@RequestMapping("/upload/base64") |
|||
public Map<String,Object> uplodBase64(@RequestBody Base64ImageVo imageVo,HttpServletRequest request){ |
|||
|
|||
Map<String,Object> map=new HashMap<>(); |
|||
|
|||
Float scale=imageVo.getScale(); |
|||
Float outputQuality=imageVo.getOutputQuality(); |
|||
if(scale==null||scale==0) { |
|||
scale=1f; |
|||
} |
|||
if(outputQuality==null || outputQuality==0) { |
|||
long fileSize= imageVo.getFileData().length(); |
|||
if(fileSize>=1024*2048) { |
|||
outputQuality=0.2f; |
|||
}else if(fileSize>=1024*1024) { |
|||
outputQuality=0.5f; |
|||
}else { |
|||
outputQuality=0.5f; |
|||
} |
|||
} |
|||
imageVo.setScale(scale); |
|||
imageVo.setOutputQuality(outputQuality); |
|||
if(scale<0.1f ||scale>1f) { |
|||
return Result.error("scale-err", "scale", "缩放比例必须在0.1~1之间"); |
|||
}else if(outputQuality<0.1f||outputQuality>1f) { |
|||
return Result.error("outputQuality-err", "outputQuality", "压缩质量必须在0.1~1之间"); |
|||
}else { |
|||
Image image=new Image(); |
|||
//判断file数组不能为空并且长度大于0 |
|||
//保存文件 |
|||
try { |
|||
image=this.saveBase64File( imageVo ,request.getRequestURL().toString()); |
|||
return Result.ok().setData(image); |
|||
} catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error("文件保存出错"); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@RequestMapping("/**") |
|||
public ResponseEntity download(HttpServletRequest request,HttpServletResponse response, @RequestParam(value="name",required=false) String name, @RequestParam(value="preview",required=false) String preview ) { |
|||
|
|||
//下载文件路径 |
|||
String requestURL=request.getRequestURL().toString(); |
|||
String fullPath=this.imageService.getFullFilePathByUrl(requestURL); |
|||
if(StringUtils.isEmpty(name)){ |
|||
name=requestURL.substring(requestURL.lastIndexOf("/")+1); |
|||
|
|||
} |
|||
// * 表示允许任何域名跨域访问 |
|||
response.setHeader("Access-Control-Allow-Origin", "*"); |
|||
Resource resource=resourceLoader.getResource("file:"+fullPath); |
|||
String contentType = null; |
|||
try { |
|||
contentType = request.getServletContext().getMimeType(resource.getFile().getAbsolutePath()); |
|||
} catch (IOException e) { |
|||
logger.error("无法获取文件类型", e); |
|||
} |
|||
if (contentType == null) { |
|||
contentType = "application/octet-stream"; |
|||
} |
|||
if("1".equals(preview)){ |
|||
return ResponseEntity.ok() |
|||
.contentType(MediaType.parseMediaType(contentType)) |
|||
.body(resource); |
|||
}else { |
|||
return ResponseEntity.ok() |
|||
.contentType(MediaType.parseMediaType(contentType)) |
|||
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + name + "\"") |
|||
.body(resource); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "删除一条图片素材库信息",notes="delImage,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delImage(@RequestBody Image image){ |
|||
|
|||
|
|||
try{ |
|||
imageService.deleteByPk(image); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "根据主键列表批量删除图片素材库信息",notes="batchDelImage,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelImage(@RequestBody List<Image> images) { |
|||
|
|||
|
|||
try{ |
|||
imageService.batchDelete(images); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 图片上传并压缩保存到硬盘,同时记录到数据库 |
|||
* @param fileName 文件名 非必输 |
|||
* @param tag 标签 非必输 |
|||
* @param categoryId 分类 非必输 |
|||
* @param remark 备注 非必输 |
|||
* @param deptid 部门 非必输 |
|||
* @param branchId 归属机构 非必输 |
|||
* @param file 文件流对象,form表单自动生成 必输 |
|||
* @param scale 非必输,默认为1, 压缩比例 0.1~1之间 |
|||
* @param outputQuality 非必输,默认为1,压缩质量0.1~1之间 |
|||
* @return |
|||
*/ |
|||
public Image saveImage(String requestURL,String id,String fileName,String tag,boolean storedb,String categoryId,String remark,String deptid,String branchId,MultipartFile file,Float scale,Float outputQuality,String fixedName){ |
|||
Image i=null; |
|||
String dirPath=""; |
|||
String fullFilePath=""; |
|||
boolean existsDb=false; |
|||
if(StringUtils.isEmpty(categoryId)) { |
|||
throw new BizException("categoryId","分类不能为空"); |
|||
} |
|||
if(!file.isEmpty()){ |
|||
File file2=null; |
|||
try { |
|||
String originalFilename = file.getOriginalFilename(); |
|||
long size = file.getSize(); |
|||
if(ObjectTools.isNotEmpty(id)){ |
|||
i=this.imageService.getById(id); |
|||
if(i==null){ |
|||
existsDb=false; |
|||
i = this.imageService.genImageInfo(requestURL,id,originalFilename,fileName, tag,categoryId,remark,deptid,branchId,size,fixedName); |
|||
}else { |
|||
if(!originalFilename.endsWith(i.getFileSuffix())){ |
|||
throw new BizException(LangTips.errMsg("file-suffix-no-match","文件类型不匹配,要求%s文件",i.getFileSuffix())); |
|||
} |
|||
existsDb=true; |
|||
} |
|||
}else{ |
|||
i = this.imageService.genImageInfo(requestURL,id,originalFilename,fileName, tag,categoryId,remark,deptid,branchId,size,fixedName); |
|||
} |
|||
dirPath= ArcTools.pathJoin(true,i.getRootPath(),i.getRelativePath()); |
|||
file2=new File(dirPath); |
|||
if(!file2.exists()){ |
|||
file2.mkdirs(); |
|||
} |
|||
// 转存文件 |
|||
fullFilePath=ArcTools.pathJoin(true,dirPath,i.getStorageName()+i.getFileSuffix()); |
|||
Tips tips=imageCompressService.compressAndSaveImage(file.getInputStream(),scale,outputQuality,fullFilePath); |
|||
if(tips.isOk()) { |
|||
if(storedb && !existsDb){ |
|||
this.imageService.insert(i); |
|||
} |
|||
}else { |
|||
throw new BizException(tips); |
|||
} |
|||
} catch (BizException e) { |
|||
throw e; |
|||
}catch (Exception e) { |
|||
logger.error("保存图片出错,保存路径【"+fullFilePath+"】",e); |
|||
throw new BizException("saveFileError01","保存图片出错"); |
|||
}finally { |
|||
if(file2!=null) { |
|||
file2=null; |
|||
} |
|||
} |
|||
|
|||
}else{ |
|||
throw new BizException("saveFileError02","图片为空"); |
|||
} |
|||
return i; |
|||
} |
|||
@ApiOperation( value = "根据主键修改一条图片素材库信息",notes="editImage") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Image.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editImage(@RequestBody Image image) { |
|||
|
|||
|
|||
try{ |
|||
imageService.updateByPk(image); |
|||
return Result.ok().setData(image); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
/*** |
|||
* 保存文件 |
|||
* @param |
|||
* @return |
|||
*/ |
|||
private Image saveBase64File( Base64ImageVo imageVo,String requestURL) { |
|||
Image i=null; |
|||
String dirPath=""; |
|||
String fullFilePath=""; |
|||
if(StringUtils.isEmpty(imageVo.getCategoryId())) { |
|||
throw new BizException("categoryId","分类不能为空"); |
|||
} |
|||
// 判断文件是否为空 |
|||
if (!StringUtils.isEmpty(imageVo.getFileData())) { |
|||
try { |
|||
// 文件保存路径 |
|||
String originalFilename=imageVo.getName(); |
|||
if(StringUtils.isEmpty(originalFilename)) { |
|||
throw new BizException("name","文件名不能为空,如 name = xxx.png"); |
|||
} |
|||
i=this.imageService.genImageInfo(requestURL,null,originalFilename,imageVo.getName(),imageVo.getTag(), imageVo.getCategoryId(),imageVo.getRemark(),imageVo.getDeptid(),imageVo.getBranchId(),(long) imageVo.getFileData().length(),""); |
|||
dirPath=(i.getRootPath()+"/"+i.getRelativePath()).replaceAll("//", "/"); |
|||
File file2=new File(dirPath); |
|||
if(!file2.exists()){ |
|||
file2.mkdirs(); |
|||
} |
|||
// 转存文件 |
|||
fullFilePath=(dirPath+"/"+i.getStorageName()+i.getFileSuffix()).replaceAll("//", "/"); |
|||
Tips tips=imageCompressService.compressAndSaveImage(Base64Utils.decode(imageVo.getFileData().substring("data:image/png;base64,".length()).getBytes()),imageVo.getScale(),imageVo.getOutputQuality(),fullFilePath); |
|||
if(tips.isOk()) { |
|||
if("1".equals(imageVo.getStoredb())) { |
|||
this.imageService.insert(i); |
|||
} |
|||
}else { |
|||
throw new BizException(tips); |
|||
} |
|||
|
|||
return i; |
|||
} catch (Exception e) { |
|||
logger.error("保存文件出错到"+fullFilePath+"出错"); |
|||
throw new BizException("保存文件出错"); |
|||
} |
|||
}else{ |
|||
throw new BizException("文件为空"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.mdp.arc.img.ctrl; |
|||
|
|||
import io.swagger.annotations.Api; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 为了兼容 arc/imageCategory这种请求 |
|||
***/ |
|||
@RestController("mdp.arc.iamge.ImageSubCategoryController") |
|||
@RequestMapping(value="/**/arc/imageCategory") |
|||
@Api(tags={"图片分类操作接口"}) |
|||
@Deprecated |
|||
public class ImageSubCategoryController extends ImageCategoryController{ |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package com.mdp.arc.img.ctrl; |
|||
|
|||
import io.swagger.annotations.Api; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 为了兼容原来的arc/image |
|||
***/ |
|||
@RestController("mdp.arc.ImageSubController") |
|||
@RequestMapping(value="/**/arc/image") |
|||
@Api(tags={"图片素材库操作接口"}) |
|||
@Deprecated |
|||
public class ImageSubController extends ImageController { |
|||
|
|||
} |
|||
@ -0,0 +1,111 @@ |
|||
package com.mdp.arc.img.entity; |
|||
|
|||
public class Base64ImageVo { |
|||
/** |
|||
* 分类编号 |
|||
*/ |
|||
String categoryId; |
|||
/** |
|||
* 文件名 如 aaaaa.jpej |
|||
*/ |
|||
String name; |
|||
|
|||
/** |
|||
* tag 标签 |
|||
*/ |
|||
String tag; |
|||
|
|||
/** |
|||
* 数据 |
|||
*/ |
|||
String fileData; |
|||
/** |
|||
* 备注 |
|||
*/ |
|||
String remark; |
|||
/** |
|||
* 部门 |
|||
*/ |
|||
String deptid; |
|||
/** |
|||
* 机构 |
|||
*/ |
|||
String branchId; |
|||
|
|||
/** |
|||
* 是否将图片信息存储入库0 否,1是 |
|||
*/ |
|||
String storedb; |
|||
|
|||
/** |
|||
* 压缩比例尺寸 0.1~1之间 |
|||
*/ |
|||
Float scale; |
|||
|
|||
/** |
|||
* 压缩质量 0.1~1之间 |
|||
*/ |
|||
Float outputQuality; |
|||
|
|||
public String getCategoryId() { |
|||
return categoryId; |
|||
} |
|||
public void setCategoryId(String categoryId) { |
|||
this.categoryId = categoryId; |
|||
} |
|||
public String getName() { |
|||
return name; |
|||
} |
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
public String getFileData() { |
|||
return fileData; |
|||
} |
|||
public void setFileData(String fileData) { |
|||
this.fileData = fileData; |
|||
} |
|||
|
|||
public String getRemark() { |
|||
return remark; |
|||
} |
|||
public void setRemark(String remark) { |
|||
this.remark = remark; |
|||
} |
|||
public String getDeptid() { |
|||
return deptid; |
|||
} |
|||
public void setDeptid(String deptid) { |
|||
this.deptid = deptid; |
|||
} |
|||
public String getBranchId() { |
|||
return branchId; |
|||
} |
|||
public void setBranchId(String branchId) { |
|||
this.branchId = branchId; |
|||
} |
|||
public String getStoredb() { |
|||
return storedb; |
|||
} |
|||
public void setStoredb(String storedb) { |
|||
this.storedb = storedb; |
|||
} |
|||
public Float getScale() { |
|||
return scale; |
|||
} |
|||
public void setScale(Float scale) { |
|||
this.scale = scale; |
|||
} |
|||
public Float getOutputQuality() { |
|||
return outputQuality; |
|||
} |
|||
public void setOutputQuality(Float outputQuality) { |
|||
this.outputQuality = outputQuality; |
|||
} |
|||
public String getTag() { |
|||
return tag; |
|||
} |
|||
public void setTag(String tag) { |
|||
this.tag = tag; |
|||
} |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
package com.mdp.arc.img.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-15 |
|||
*/ |
|||
@Data |
|||
@TableName("arc_image") |
|||
@ApiModel(description="图片素材库") |
|||
public class Image implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
|
|||
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
|
|||
@ApiModelProperty(notes="附件名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String name; |
|||
|
|||
|
|||
@ApiModelProperty(notes="访问路径",allowEmptyValue=true,example="",allowableValues="") |
|||
String url; |
|||
|
|||
|
|||
@ApiModelProperty(notes="硬盘存放路径",allowEmptyValue=true,example="",allowableValues="") |
|||
String relativePath; |
|||
|
|||
|
|||
@ApiModelProperty(notes="后缀名",allowEmptyValue=true,example="",allowableValues="") |
|||
String fileSuffix; |
|||
|
|||
|
|||
@ApiModelProperty(notes="根目录",allowEmptyValue=true,example="",allowableValues="") |
|||
String rootPath; |
|||
|
|||
|
|||
@ApiModelProperty(notes="存入时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date createDate; |
|||
|
|||
|
|||
@ApiModelProperty(notes="文件大小",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal fileSize; |
|||
|
|||
|
|||
@ApiModelProperty(notes="归属部门",allowEmptyValue=true,example="",allowableValues="") |
|||
String deptid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="标签",allowEmptyValue=true,example="",allowableValues="") |
|||
String tag; |
|||
|
|||
|
|||
@ApiModelProperty(notes="备注信息",allowEmptyValue=true,example="",allowableValues="") |
|||
String remark; |
|||
|
|||
|
|||
@ApiModelProperty(notes="图片分类",allowEmptyValue=true,example="",allowableValues="") |
|||
String categoryId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="硬盘存储名字(不带后缀)",allowEmptyValue=true,example="",allowableValues="") |
|||
String storageName; |
|||
|
|||
|
|||
@ApiModelProperty(notes="链接前缀",allowEmptyValue=true,example="",allowableValues="") |
|||
String urlPrefix; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否外部链接",allowEmptyValue=true,example="",allowableValues="") |
|||
String isOutUrl; |
|||
|
|||
|
|||
@ApiModelProperty(notes="外部链接",allowEmptyValue=true,example="",allowableValues="") |
|||
String outUrl; |
|||
|
|||
|
|||
@ApiModelProperty(notes="机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="0|知识库",allowEmptyValue=true,example="",allowableValues="") |
|||
String archiveType; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考类型,开放式字段,1-开源社区,2-项目论坛,逗号",allowEmptyValue=true,example="",allowableValues="") |
|||
String relyTypes; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考编号,逗号",allowEmptyValue=true,example="",allowableValues="") |
|||
String relyIds; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考子类型,逗号",allowEmptyValue=true,example="",allowableValues="") |
|||
String relySubTypes; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考子编号,逗号",allowEmptyValue=true,example="",allowableValues="") |
|||
String relySubIds; |
|||
|
|||
|
|||
@ApiModelProperty(notes="创建人编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="创建人姓名",allowEmptyValue=true,example="",allowableValues="") |
|||
String cusername; |
|||
|
|||
|
|||
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="") |
|||
Date cdate; |
|||
|
|||
/** |
|||
*主键 |
|||
**/ |
|||
public Image(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 图片素材库 |
|||
**/ |
|||
public Image() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
package com.mdp.arc.img.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-20 |
|||
*/ |
|||
@Data |
|||
@TableName("arc_image_category") |
|||
@ApiModel(description="图片分类") |
|||
public class ImageCategory implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
|
|||
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
|
|||
@ApiModelProperty(notes="分类名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String categoryName; |
|||
|
|||
|
|||
@ApiModelProperty(notes="机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="上一级",allowEmptyValue=true,example="",allowableValues="") |
|||
String pid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否是公共分类的图片",allowEmptyValue=true,example="",allowableValues="") |
|||
String isPub; |
|||
|
|||
|
|||
@ApiModelProperty(notes="扩展字段",allowEmptyValue=true,example="",allowableValues="") |
|||
String extInfos; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考类型",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelyType; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考类型编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelyId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="子参考类型",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelyStype; |
|||
|
|||
|
|||
@ApiModelProperty(notes="子参考类型编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelySid; |
|||
|
|||
/** |
|||
*主键 |
|||
**/ |
|||
public ImageCategory(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 图片分类 |
|||
**/ |
|||
public ImageCategory() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.arc.img.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.img.entity.ImageCategory; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface ImageCategoryMapper extends BaseMapper<ImageCategory> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,27 @@ |
|||
<?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.mdp.arc.img.mapper.ImageCategoryMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from arc_image_category res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<!--下面可以添加更多查询条件,正常的if 条件都是支持的--> |
|||
|
|||
</where> |
|||
<!--下面双引号内可以添加默认排序,如果前端没有上传排序,将使用引号内的排序规则--> |
|||
${@com.mdp.Util@trimOrderBy(ew.customSqlSegment,'')} |
|||
<!--下面双引号内可以添加默认分组,如果前端没有上传分组,将使用引号内的分组规则--> |
|||
${@com.mdp.Util@trimGroupBy(ew.customSqlSegment,'')} |
|||
</select> |
|||
|
|||
<select id="selectAllCategory" parameterType="HashMap" resultType="HashMap"> |
|||
select C.*,(select count(1) from arc_image A where A.category_id=C.id ) as count from arc_image_category C |
|||
</select> |
|||
<select id="selectCategoryBybranch" parameterType="HashMap" resultType="HashMap"> |
|||
select C.*,(select count(1) from arc_image A where A.category_id=C.id ) as count from arc_image_category C |
|||
<where> |
|||
<if test="key != null and key != ''"> </if> |
|||
</where> |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,26 @@ |
|||
package com.mdp.arc.img.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.img.entity.Image; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface ImageMapper extends BaseMapper<Image> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
List<Map<String, Object>> selectTagsListMap(Map<String, Object> map); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,24 @@ |
|||
<?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.mdp.arc.img.mapper.ImageMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from arc_image res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<!--下面可以添加更多查询条件,正常的if 条件都是支持的--> |
|||
<if test="ext.key!='' and ext.key!=null "> and (res.name like #{ext.key} or res.tag like #{ext.key} or res.url like #{ext.key})</if> |
|||
<if test="ext.type!='movie'"> |
|||
and (res.FILE_SUFFIX = '.bmp' or res.FILE_SUFFIX = '.jpg' or res.FILE_SUFFIX = '.jpeg' or res.FILE_SUFFIX = '.png' or res.FILE_SUFFIX = '.gif') |
|||
</if> |
|||
<if test="ext.type=='movie'"> |
|||
and (res.FILE_SUFFIX = '.mkv' or res.FILE_SUFFIX = '.mp4' or res.FILE_SUFFIX = '.avi' or res.FILE_SUFFIX = '.rmvb') |
|||
</if> |
|||
</where> |
|||
<!--下面双引号内可以添加默认排序,如果前端没有上传排序,将使用引号内的排序规则--> |
|||
${@com.mdp.Util@trimOrderBy(ew.customSqlSegment,'')} |
|||
<!--下面双引号内可以添加默认分组,如果前端没有上传分组,将使用引号内的分组规则--> |
|||
${@com.mdp.Util@trimGroupBy(ew.customSqlSegment,'')} |
|||
</select> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,36 @@ |
|||
package com.mdp.arc.img.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.img.entity.ImageCategory; |
|||
import com.mdp.arc.img.mapper.ImageCategoryMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com.mdp 顶级模块 arc 大模块 img 小模块 <br> |
|||
* 实体 ImageCategory 表 arc_image_category 当前主键(包括多主键): id; |
|||
***/ |
|||
@Service |
|||
@DS("arc-ds") |
|||
public class ImageCategoryService extends BaseService<ImageCategoryMapper,ImageCategory> { |
|||
static Logger logger =LoggerFactory.getLogger(ImageCategoryService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,73 @@ |
|||
package com.mdp.arc.img.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.mdp.arc.img.entity.Image; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Tips; |
|||
import net.coobird.thumbnailator.Thumbnails; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.imageio.ImageIO; |
|||
import java.awt.image.BufferedImage; |
|||
import java.io.ByteArrayInputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.util.List; |
|||
|
|||
@Service("mdp.arc.imageCompressService") |
|||
@DS("arc-ds") |
|||
public class ImageCompressService { |
|||
|
|||
public static void main(String[] args) { |
|||
|
|||
|
|||
} |
|||
|
|||
public List<Image> compressImages(List<Image> images){ |
|||
return images; |
|||
|
|||
} |
|||
/** |
|||
* 压缩保存图片 |
|||
* @param srcInputStream 文件输入流 |
|||
* @param scale 压缩比例 默认为1 0.1~1之间 |
|||
* @param outputQuality 压缩质量默认0.5f,0.1f~1之间, 0.5f,0.2f,01.f 一般按0.5f压缩 |
|||
* @param savePath 保存路径包括文件名及后缀 |
|||
* @return |
|||
*/ |
|||
public Tips compressAndSaveImage(InputStream srcInputStream,float scale,float outputQuality,String savePath){ |
|||
|
|||
try { |
|||
Thumbnails.of(srcInputStream). |
|||
scale(scale). |
|||
outputQuality(outputQuality).toFile( savePath); |
|||
} catch (IOException e) { |
|||
return LangTips.errMsg("compress-img-err", "压缩并保存文件失败"); |
|||
} |
|||
return LangTips.okMsg(); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 压缩保存图片(图片以base64格式上传时调用) |
|||
* @param fileContext 文件内容,扣除掉"data:image/png;base64," |
|||
* @param scale 压缩比例 默认为1 0.1~1之间 |
|||
* @param outputQuality 压缩质量默认0.5f,0.1f~1之间, 0.5f,0.2f,01.f 一般按0.5f压缩 |
|||
* @param savePath 保存路径包括文件名及后缀 |
|||
* @return |
|||
*/ |
|||
public Tips compressAndSaveImage(byte[] fileContext,float scale,float outputQuality,String savePath){ |
|||
|
|||
try { |
|||
ByteArrayInputStream in = new ByteArrayInputStream(fileContext); //将b作为输入流; |
|||
|
|||
BufferedImage image = ImageIO.read(in); |
|||
Thumbnails.of(image).scale(1f).outputQuality(outputQuality) |
|||
.toFile( savePath); |
|||
} catch (IOException e) { |
|||
return LangTips.errMsg("compress-img-err", "压缩并保存文件失败"); |
|||
} |
|||
return LangTips.okMsg(); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,176 @@ |
|||
package com.mdp.arc.img.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.ArcTools; |
|||
import com.mdp.arc.img.entity.Image; |
|||
import com.mdp.arc.img.mapper.ImageMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.core.utils.ObjectTools; |
|||
import com.mdp.meta.client.service.ItemService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com.mdp 顶级模块 arc 大模块 img 小模块 <br> |
|||
* 实体 Image 表 arc_image 当前主键(包括多主键): id; |
|||
***/ |
|||
@Service |
|||
@DS("arc-ds") |
|||
public class ImageService extends BaseService<ImageMapper,Image> { |
|||
static Logger logger =LoggerFactory.getLogger(ImageService.class); |
|||
|
|||
|
|||
|
|||
@Autowired |
|||
public ItemService itemService; |
|||
|
|||
@Value(value="${mdp.arc.image-upload-root-path:}") |
|||
public String arcImageUploadRootPath; |
|||
|
|||
@Value(value="${mdp.arc.image-download-base-uri:}") |
|||
String arcImageDownloadBaseUri; |
|||
|
|||
public static String urlPrefix="arc/image/"; |
|||
|
|||
|
|||
|
|||
public static final boolean isWindows; |
|||
public static final String splash; |
|||
public static final String root; |
|||
|
|||
static { |
|||
if (System.getProperty("os.name") != null && System.getProperty("os.name").toLowerCase().contains("windows")) { |
|||
isWindows = true; |
|||
splash = "\\"; |
|||
root="D:\\arc\\images\\"; |
|||
} else { |
|||
isWindows = false; |
|||
splash = "/"; |
|||
root="/arc/images/"; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
public List<Map<String, Object>> selectTagsListMap(Map<String, Object> map) { |
|||
return baseMapper.selectTagsListMap(map); |
|||
} |
|||
|
|||
public void insertImageInfoBytag(Image image){ |
|||
this.insert( image); |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* |
|||
* @param originalFilename |
|||
* @param fileName |
|||
* @param categoryId |
|||
* @param remark |
|||
* @param deptid |
|||
* @param size |
|||
* @return |
|||
*/ |
|||
public Image genImageInfo(String requestURL,String id,String originalFilename,String fileName,String tag,String categoryId,String remark,String deptid,String branchId,Long size,String fixdName){ |
|||
Image image = new Image(); |
|||
if(ObjectTools.isNotEmpty(id)){ |
|||
image.setId(id); |
|||
}else { |
|||
image.setId(this.createKey("id")); |
|||
} |
|||
|
|||
if(StringUtils.isEmpty(branchId)||branchId.indexOf("undefined")>=0||branchId.indexOf("null")>=0) { |
|||
branchId=""; |
|||
} |
|||
if(StringUtils.isEmpty(categoryId)||categoryId.indexOf("undefined")>=0||categoryId.indexOf("null")>=0) { |
|||
categoryId=""; |
|||
} |
|||
String relativePath= ArcTools.pathJoin(true,branchId,categoryId); |
|||
|
|||
image.setRelativePath(relativePath); |
|||
image.setRootPath(arcImageUploadRootPath); //先保存image,待会打印查看 |
|||
|
|||
if(StringUtils.isEmpty(fileName)) { |
|||
if(originalFilename==null || "".equals(originalFilename)) { |
|||
image.setName(image.getId()); |
|||
} else if(originalFilename.lastIndexOf(".")>0) { |
|||
image.setName(originalFilename.substring(0,originalFilename.lastIndexOf("."))); |
|||
}else { |
|||
image.setName(originalFilename); |
|||
} |
|||
}else { |
|||
if(fileName.lastIndexOf(".")>0) { |
|||
image.setName(fileName.substring(0,fileName.lastIndexOf("."))); |
|||
}else { |
|||
image.setName(fileName); |
|||
} |
|||
} |
|||
if(StringUtils.hasText(fixdName)){ |
|||
image.setStorageName(fixdName); |
|||
}else{ |
|||
image.setStorageName(image.getId()); |
|||
} |
|||
String fileSuffix=""; |
|||
if(originalFilename.contains(".")){ |
|||
fileSuffix=originalFilename.substring(originalFilename.lastIndexOf(".")); |
|||
} |
|||
image.setFileSuffix(fileSuffix); |
|||
String url2=ArcTools.pathJoin(true,urlPrefix,relativePath,image.getStorageName()+fileSuffix); |
|||
|
|||
|
|||
String prePath=this.getPreUrlPathByUploadUrl(requestURL); |
|||
image.setUrl(ArcTools.pathJoin(false,prePath,url2)); |
|||
image.setFileSize(BigDecimal.valueOf(size)); |
|||
image.setCreateDate(new Date()); |
|||
image.setRemark(remark); |
|||
image.setUrlPrefix(urlPrefix); |
|||
image.setCategoryId(categoryId); |
|||
image.setDeptid(deptid); |
|||
image.setBranchId(branchId); |
|||
image.setTag(tag); |
|||
return image; |
|||
} |
|||
|
|||
public String getPreUrlPathByUploadUrl(String requestURL) { |
|||
if(StringUtils.hasText(this.arcImageDownloadBaseUri)){ |
|||
return this.arcImageDownloadBaseUri; |
|||
}else{ |
|||
int indexOf=requestURL.indexOf(urlPrefix); |
|||
return requestURL.substring(0,indexOf); |
|||
} |
|||
} |
|||
|
|||
public String getFullFilePathByUrl(String requestURL) { |
|||
|
|||
int indexOf=requestURL.indexOf(urlPrefix); |
|||
return ArcTools.pathJoin(true,arcImageUploadRootPath,requestURL.substring(indexOf+urlPrefix.length())); |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
String filePath="/aaaa/bbb/ccc/////ddd/xx/ddd///xxx/fff"; |
|||
String filePath2=filePath.replaceAll("[/]{2,}+", "/"); |
|||
System.out.println(filePath2); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,38 @@ |
|||
package com.mdp; |
|||
|
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.boot.web.servlet.MultipartConfigFactory; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.util.unit.DataSize; |
|||
|
|||
import javax.servlet.MultipartConfigElement; |
|||
|
|||
@SpringBootApplication |
|||
//@SpringCloudApplication |
|||
//@EnableSwagger2 |
|||
public class ArcApplication { |
|||
|
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ArcApplication.class,args); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 文件上传配置 |
|||
* |
|||
* @return |
|||
*/ |
|||
@Bean |
|||
public MultipartConfigElement multipartConfigElement() { |
|||
MultipartConfigFactory factory = new MultipartConfigFactory(); |
|||
// 单个数据大小 |
|||
factory.setMaxFileSize(DataSize.ofMegabytes(5)); // KB,MB |
|||
/// 总上传数据大小 |
|||
factory.setMaxRequestSize(DataSize.ofMegabytes(1)); |
|||
return factory.createMultipartConfig(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,149 @@ |
|||
package com.mdp; |
|||
|
|||
import net.coobird.thumbnailator.Thumbnails; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
public class ImgCompressTest { |
|||
|
|||
public static void main(String[] args) { |
|||
try { |
|||
//1.jpg压缩测试 |
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/1.jpg") |
|||
.scale(1f) |
|||
.outputQuality(1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/1_1f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/1.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.5f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/1_0.5f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/1.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.2f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/1_0.2f.jpg"); |
|||
|
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/1.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/1_0.1f.jpg"); |
|||
|
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/1.jpg") |
|||
.scale(0.5f) |
|||
.outputQuality(0.5f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/1_0.5f_0.5f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/1.jpg") |
|||
.scale(0.5f) |
|||
.outputQuality(0.2f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/1_0.5f_0.2f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/1.jpg") |
|||
.scale(0.5f) |
|||
.outputQuality(0.1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/1_0.5f_0.1f.jpg"); |
|||
|
|||
|
|||
//2.jpg压缩测试 |
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/2.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.5f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/2_0.5f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/2.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.2f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/2_0.2f.jpg"); |
|||
|
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/2.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/2_0.1f.jpg"); |
|||
|
|||
|
|||
//3.jpg压缩测试 |
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/3.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.5f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/3_0.5f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/3.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.2f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/3_0.2f.jpg"); |
|||
|
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/3.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/3_0.1f.jpg"); |
|||
|
|||
//4.jpg压缩测试 |
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/4.jpg") |
|||
.scale(1f) |
|||
.outputQuality(1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/4_1f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/4.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.5f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/4_0.5f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/4.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.2f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/4_0.2f.jpg"); |
|||
|
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/4.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/4_0.1f.jpg"); |
|||
|
|||
//11.jpg风景图片压缩测试 |
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/11.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.5f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/11_0.5f.jpg"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/11.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.2f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/11_0.2f.jpg"); |
|||
|
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/11.jpg") |
|||
.scale(1f) |
|||
.outputQuality(0.1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/11_0.1f.jpg"); |
|||
|
|||
|
|||
//12.png png图片压缩测试 |
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/12.png") |
|||
.scale(1f) |
|||
.outputQuality(0.5f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/12_0.5f.png"); |
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/12.png") |
|||
.scale(1f) |
|||
.outputQuality(0.2f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/12_0.2f.png"); |
|||
|
|||
|
|||
Thumbnails.of("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/12.png") |
|||
.scale(1f) |
|||
.outputQuality(0.1f) |
|||
.toFile("C:/Users/陈裕财/wsp/mdp-arc/src/test/resources/商品图片/压缩后/12_0.1f.png"); |
|||
|
|||
} catch (IOException e) { |
|||
// TODO Auto-generated catch block |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.mdp; |
|||
|
|||
import com.mdp.safe.client.jwt.JwtAuthenticationConverter; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|||
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
|||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|||
import org.springframework.security.oauth2.jwt.JwtDecoder; |
|||
|
|||
/** |
|||
* com.qqkj.WebSecurityConfig |
|||
* |
|||
* @author chenyc |
|||
* @date 2019/10/10 |
|||
*/ |
|||
@EnableWebSecurity |
|||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|||
|
|||
@Autowired |
|||
JwtAuthenticationConverter jwtConverter; |
|||
|
|||
|
|||
@Autowired |
|||
JwtDecoder jwtDecoder; |
|||
|
|||
|
|||
@Override |
|||
public void configure(WebSecurity web) throws Exception { |
|||
web.ignoring().antMatchers("/webjars/**","/**/arc/image/**/**.*"); |
|||
} |
|||
|
|||
/** |
|||
* 允许匿名访问所有接口 主要是 oauth 接口 |
|||
* @param http |
|||
* @throws Exception |
|||
*/ |
|||
@Override |
|||
protected void configure(HttpSecurity http) throws Exception { |
|||
|
|||
http.authorizeRequests().antMatchers("/**/arc/image/**","/**/arc/archive/showArchive","/**/arc/file/**","/**/arc/archive/listNews", |
|||
"/**/arc/category/list/tree").permitAll().anyRequest().authenticated().and().oauth2Client().and().logout().disable(); |
|||
http.oauth2Client().and().logout().disable(); |
|||
http.formLogin().usernameParameter("userloginid"); |
|||
http.oauth2Login(); |
|||
http.oauth2ResourceServer().jwt().decoder(jwtDecoder).jwtAuthenticationConverter(jwtConverter); |
|||
http.csrf().disable(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.mdp.arc.att.service; |
|||
|
|||
import com.mdp.arc.att.entity.Attachment; |
|||
import com.mdp.core.utils.BaseUtils; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
|
|||
import java.util.Date; |
|||
import java.util.Map; |
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-1 |
|||
*/ |
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@SpringBootTest |
|||
public class TestAttachmentService { |
|||
|
|||
@Autowired |
|||
AttachmentService attachmentService; |
|||
|
|||
/** |
|||
* 新增一条数据 |
|||
***/ |
|||
@Test |
|||
public void insert() { |
|||
Map<String,Object> p=BaseUtils.map("id","24l5","name","7hGS","url","2CJ9","relativePath","IWOW","fileSuffix","iFZn","cdnUrl","MP6F","isImg","L","archiveId","hDER","isCdn","G","rootPath","z0xW","createDate",new Date("2023-09-01 1:31:3"),"canDown","h","canDel","6","canRead","b","bizId","dD0d","remark","GjPF","storeName","9PBZ","fileSize",6960,"branchId","I4xP","deptid","FSis","archiveType","V","categoryId","9IL7"); |
|||
Attachment attachment=BaseUtils.fromMap(p,Attachment.class); |
|||
attachmentService.save(attachment); |
|||
//Assert.assertEquals(1, result); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
package com.mdp.arc.img.service; |
|||
|
|||
import com.mdp.arc.img.entity.ImageCategory; |
|||
import com.mdp.core.utils.BaseUtils; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
|
|||
import java.util.Map; |
|||
/** |
|||
* ImageCategoryService的测试案例 |
|||
* 组织 com.mdp<br> |
|||
* 顶级模块 arc<br> |
|||
* 大模块 img<br> |
|||
* 小模块 <br> |
|||
* 表 arc_image_category 图片分类<br> |
|||
* 实体 ImageCategory<br> |
|||
* 表是指数据库结构中的表,实体是指java类型中的实体类<br> |
|||
* 当前实体所有属性名:<br> |
|||
* id,categoryName,branchId,pid,isPub;<br> |
|||
* 当前表的所有字段名:<br> |
|||
* id,category_name,branch_id,pid,is_pub;<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
***/ |
|||
|
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@SpringBootTest |
|||
public class TestImageCategoryService { |
|||
|
|||
@Autowired |
|||
ImageCategoryService imageCategoryService; |
|||
|
|||
/** |
|||
* 新增一条数据 |
|||
***/ |
|||
@Test |
|||
public void insert() { |
|||
Map<String,Object> p=BaseUtils.map("id","tGWT","categoryName","y8e1","branchId","6CfF","pid","Bs8L","isPub","wjmp"); |
|||
ImageCategory imageCategory=BaseUtils.fromMap(p,ImageCategory.class); |
|||
imageCategoryService.save(imageCategory); |
|||
//Assert.assertEquals(1, result); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
package com.mdp.arc.img.service; |
|||
|
|||
import com.mdp.arc.img.entity.Image; |
|||
import com.mdp.core.utils.BaseUtils; |
|||
import org.junit.Test; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|||
|
|||
import java.util.Date; |
|||
import java.util.Map; |
|||
/** |
|||
* ImageService的测试案例 |
|||
* 组织 com.mdp<br> |
|||
* 顶级模块 arc<br> |
|||
* 大模块 img<br> |
|||
* 小模块 <br> |
|||
* 表 arc_image 图片素材库<br> |
|||
* 实体 Image<br> |
|||
* 表是指数据库结构中的表,实体是指java类型中的实体类<br> |
|||
* 当前实体所有属性名:<br> |
|||
* id,name,url,relativePath,fileSuffix,rootPath,createDate,fileSize,deptid,tag,remark,categoryId,storageName,urlPrefix,isOutUrl,outUrl,branchId;<br> |
|||
* 当前表的所有字段名:<br> |
|||
* id,name,url,relative_path,file_suffix,root_path,create_date,file_size,deptid,tag,remark,category_id,storage_name,url_prefix,is_out_url,out_url,branch_id;<br> |
|||
* 当前主键(包括多主键):<br> |
|||
* id;<br> |
|||
***/ |
|||
|
|||
@RunWith(SpringJUnit4ClassRunner.class) |
|||
@SpringBootTest |
|||
public class TestImageService { |
|||
|
|||
@Autowired |
|||
ImageService imageService; |
|||
|
|||
/** |
|||
* 新增一条数据 |
|||
***/ |
|||
@Test |
|||
public void insert() { |
|||
Map<String,Object> p=BaseUtils.map("id","exjf","name","rH3O","url","qdly","relativePath","cwh5","fileSuffix","lH5O","rootPath","q7Gk","createDate",new Date("2023-08-27 18:27:13"),"fileSize",2900,"deptid","l6Wo","tag","pvOk","remark","7b19","categoryId","ncDc","storageName","K2Z4","urlPrefix","tBZ3","isOutUrl","5","outUrl","iAfM","branchId","Vf7R"); |
|||
Image image=BaseUtils.fromMap(p,Image.class); |
|||
imageService.save(image); |
|||
//Assert.assertEquals(1, result); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<artifactId>mdp-arc-pub</artifactId> |
|||
<packaging>jar</packaging> |
|||
<name>mdp-arc-pub 内容管理系统公共库</name> |
|||
<description>内容管理系统公共库</description> |
|||
<parent> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-lcode-backend</artifactId> |
|||
<version>2.0.0-RELEASE</version> |
|||
</parent> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.mdp</groupId> |
|||
<artifactId>mdp-boot-starter</artifactId> |
|||
<version>${mdp.version}</version> |
|||
</dependency> |
|||
</dependencies> |
|||
</project> |
|||
@ -0,0 +1,52 @@ |
|||
package com.mdp.arc.cache; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
@Service |
|||
public class TagCacheService { |
|||
|
|||
|
|||
@Autowired |
|||
RedisTemplate redisTemplate; |
|||
|
|||
String publicTagCacheKey="publicTagCacheKey_"; |
|||
|
|||
String pub_key="_pub"; |
|||
|
|||
|
|||
public void putPubTags(List<Map<String,Object>> tags) { |
|||
|
|||
redisTemplate.opsForHash().put(publicTagCacheKey+pub_key, pub_key, tags); |
|||
redisTemplate.expire(publicTagCacheKey+pub_key, 1, TimeUnit.DAYS); |
|||
} |
|||
|
|||
public List<Map<String,Object>> getPubTags(){ |
|||
return (List<Map<String, Object>>) redisTemplate.opsForHash().get(publicTagCacheKey+pub_key, pub_key); |
|||
|
|||
} |
|||
|
|||
public void removePubTabs(){ |
|||
redisTemplate.opsForHash().delete(publicTagCacheKey+pub_key,pub_key); |
|||
} |
|||
public void putNotPubTags(String branchId,List<Map<String,Object>> tags) { |
|||
|
|||
redisTemplate.opsForHash().put(publicTagCacheKey+branchId, branchId, tags); |
|||
redisTemplate.expire(publicTagCacheKey+branchId, 1, TimeUnit.DAYS); |
|||
} |
|||
|
|||
public List<Map<String,Object>> getNotPubTags(String branchId){ |
|||
return (List<Map<String, Object>>) redisTemplate.opsForHash().get(publicTagCacheKey+branchId, branchId); |
|||
|
|||
} |
|||
|
|||
public void removeNotPubTabs(String branchId){ |
|||
redisTemplate.opsForHash().delete(publicTagCacheKey+branchId,branchId); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,295 @@ |
|||
package com.mdp.arc.pub.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.Category; |
|||
import com.mdp.arc.pub.service.CategoryQxService; |
|||
import com.mdp.arc.pub.service.CategoryService; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.core.utils.NumberUtil; |
|||
import com.mdp.core.utils.ObjectTools; |
|||
import com.mdp.core.utils.RequestUtils; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.swagger.ApiEntityParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
***/ |
|||
@RestController("mdp.arc.categoryController") |
|||
@RequestMapping(value="/**/arc/pub/category") |
|||
public class CategoryController { |
|||
|
|||
static Log logger=LogFactory.getLog(CategoryController.class); |
|||
|
|||
@Autowired |
|||
private CategoryService categoryService; |
|||
|
|||
@Autowired |
|||
CategoryQxService qxService; |
|||
|
|||
@Value("${mdp.platform-branch-id:platform-branch-001}") |
|||
String platformBranchId; |
|||
|
|||
/** |
|||
* 请求,如list |
|||
* 分页参数 {pageNum:1,pageSize:10,total:0} |
|||
* 根据条件查询数据对象列表,如果不上传分页参数,将不会分页。后台自动分页,无需编程 |
|||
*/ |
|||
@RequestMapping(value="/list") |
|||
public Result listCategory(@RequestParam Map<String,Object> params ){ |
|||
|
|||
IPage page= QueryTools.initPage(params); |
|||
|
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
params.put("qxUserid",user.getUserid()); |
|||
params.put("qxBranchId",user.getBranchId()); |
|||
params.put("qxRoleids",LoginUtils.getMyRoleids()); |
|||
params.put("qxDeptids",user.getDeptids()); |
|||
RequestUtils.transformArray(params,"crelyIdList"); |
|||
RequestUtils.transformArray(params,"crelySidList"); |
|||
List<Map<String,Object>> datas = categoryService.selectListMapByWhere(page,QueryTools.initQueryWrapper(Category.class,params).in("branch_id",user.getBranchId(),platformBranchId),params); //列出Category列表 |
|||
return Result.ok().setData(datas).setTotal(page.getTotal()); |
|||
} |
|||
/** |
|||
* 请求,如list/tree |
|||
* 根据条件查询数据对象列表,如果不上传分页参数,将不会分页。后台自动分页,无需编程 |
|||
*/ |
|||
@RequestMapping(value="/list/tree") |
|||
public Result listCategoryTree( @RequestParam Map<String,Object> params ){ |
|||
return listCategory(params); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 新增一条数据 |
|||
*/ |
|||
@RequestMapping(value="/add") |
|||
public Result addCategory(@RequestBody Category category) { |
|||
|
|||
|
|||
try{ |
|||
if(StringUtils.isEmpty(category.getName())){ |
|||
return Result.error("name-null","分类名称不能为空"); |
|||
} |
|||
if(StringUtils.isEmpty(category.getCategoryType())){ |
|||
return Result.error("categoryType-null","主题不能为空"); |
|||
} |
|||
if(StringUtils.isEmpty(category.getId())){ |
|||
}else{ |
|||
if(this.categoryService.countByWhere(new Category(category.getId()))>0){ |
|||
return Result.error("id-exists","分类编号已存在"); |
|||
} |
|||
} |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
String pid=category.getPid(); |
|||
if(ObjectTools.isNotEmpty(pid) && !"0".equals(pid)){ |
|||
Category pcate=categoryService.getById(category.getPid()); |
|||
if(pcate==null){ |
|||
return Result.error("pcate-not-exists","上级分类不存在"); |
|||
} |
|||
String pQxLvl=ObjectTools.isNotEmpty(pcate.getQxLvl())? pcate.getQxLvl() : "0"; |
|||
String cQxLvl=ObjectTools.isNotEmpty(category.getQxLvl())? category.getQxLvl() : "0"; |
|||
//如果上级的权限小于下级,置下级的权限=上级的权限 |
|||
if(NumberUtil.getInteger(pQxLvl,0) > NumberUtil.getInteger(cQxLvl,0)){ |
|||
category.setQxLvl(pQxLvl); |
|||
}else{ |
|||
category.setQxLvl(cQxLvl); |
|||
} |
|||
if(pQxLvl.equals("2")){ |
|||
LangTips tips=categoryService.checkQx(pcate,"edit"); |
|||
if(!tips.isOk()){ |
|||
return Result.error(tips); |
|||
} |
|||
} |
|||
} |
|||
if(ObjectTools.isEmpty(category.getQxLvl())){ |
|||
category.setQxLvl("0"); |
|||
} |
|||
|
|||
String cbranchId=LoginUtils.getCurrentUserInfo().getBranchId(); |
|||
if(StringUtils.isEmpty(category.getBranchId())) { |
|||
category.setBranchId(cbranchId); |
|||
} |
|||
categoryService.insert(category); |
|||
return Result.ok().setData(category); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 根据主键删除1条数据 |
|||
*/ |
|||
@RequestMapping(value="/del") |
|||
public Result delCategory(@RequestBody Category category){ |
|||
|
|||
|
|||
try{ |
|||
Category delQ=new Category(); |
|||
delQ.setPid(category.getId()); |
|||
if(this.categoryService.countByWhere(delQ)>0){ |
|||
return Result.error("children-exists","还有子分类,不允许删除"); |
|||
} |
|||
categoryService.deleteByPk(category); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 根据主键修改一条数据 |
|||
*/ |
|||
@RequestMapping(value="/edit") |
|||
public Result editCategory(@RequestBody Category category) { |
|||
|
|||
|
|||
try{ |
|||
categoryService.updateSomeFieldByPk(category); |
|||
if("C0".equals(category.getPid())){ |
|||
categoryService.updatecategoryTypeByPid(category); |
|||
} |
|||
return Result.ok().setData(category); |
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation(value = "批量修改某些字段", notes = "") |
|||
@ApiEntityParams(value = Category.class, props = {}, remark = "档案信息表", paramType = "body") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, response = Category.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value = "/editSomeFields", method = RequestMethod.POST) |
|||
public Map<String, Object> editSomeFields(@ApiIgnore @RequestBody Map<String, Object> params) { |
|||
int i= this.categoryService.editSomeFields(params); |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 批量插入或者更新 |
|||
*/ |
|||
@RequestMapping(value="/batchSave") |
|||
public Result batchSave(@RequestBody List<Category> categorys) { |
|||
|
|||
|
|||
try{ |
|||
String cbranchId=LoginUtils.getCurrentUserInfo().getBranchId(); |
|||
if(categorys==null || categorys.size()<=0) { |
|||
return Result.error("data-is-null","分类不能为空"); |
|||
} |
|||
Map<String,Category> maps=new HashMap<>(); |
|||
for (Category category : categorys) { |
|||
if(!StringUtils.hasText(category.getId())){ |
|||
return Result.error("id-is-null","分类编号不能为空"); |
|||
} |
|||
if(!StringUtils.hasText(category.getPid())){ |
|||
return Result.error("pid-is-null","上级分类编号不能为空"); |
|||
} |
|||
category.setBranchId(cbranchId); |
|||
maps.put(category.getId(),category); |
|||
} |
|||
List<Category> updates=new ArrayList<>(); |
|||
|
|||
Map<String,Object> p=BaseService.map("ids",maps.keySet().stream().collect(Collectors.toList())); |
|||
IPage page=QueryTools.initPage(p); |
|||
List<Map<String,Object>> dbCates=this.categoryService.selectListMapByWhere(page,QueryTools.initQueryWrapper(Category.class,p),p); |
|||
for (Map<String, Object> dbCate : dbCates) { |
|||
String id= (String) dbCate.get("id"); |
|||
Category categoryFront=maps.get(id); |
|||
if(categoryFront!=null){ |
|||
updates.add(categoryFront); |
|||
} |
|||
maps.remove(id); |
|||
} |
|||
List<Category> addList=maps.values().stream().collect(Collectors.toList()); |
|||
if(addList!=null && addList.size()>0){ |
|||
for (Category c : addList) { |
|||
if(!StringUtils.hasText(c.getPid())){ |
|||
c.setPid("0"); |
|||
} |
|||
} |
|||
} |
|||
this.categoryService.batchSave(addList,updates); |
|||
|
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 批量删除 |
|||
*/ |
|||
@RequestMapping(value="/batchDel") |
|||
public Result batchDelCategory(@RequestBody List<Category> categorys) { |
|||
|
|||
|
|||
try{ |
|||
String cbranchId=LoginUtils.getCurrentUserInfo().getBranchId(); |
|||
if(categorys==null || categorys.size()<=0) { |
|||
return null; |
|||
} |
|||
for (Category c : categorys) { |
|||
if(cbranchId.equals(c.getBranchId())) { |
|||
categorys.add(c); |
|||
} |
|||
} |
|||
if(categorys.size()<=0) { |
|||
return Result.error("没有当前登录机构的分类可以删除"); |
|||
|
|||
}else { |
|||
categoryService.batchDeleteByMyBranchId(categorys,cbranchId); |
|||
return Result.ok("成功删除"+categorys.size()+"条记录。注意:只删除当前登录机构的记录"); |
|||
} |
|||
|
|||
}catch (BizException e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("执行异常",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,168 @@ |
|||
package com.mdp.arc.pub.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.CategoryQx; |
|||
import com.mdp.arc.pub.service.CategoryQxService; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import com.mdp.swagger.ApiEntityParams; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiResponse; |
|||
import io.swagger.annotations.ApiResponses; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import springfox.documentation.annotations.ApiIgnore; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
/** |
|||
* @author maimeng-mdp code-gen |
|||
* @since 2023-9-15 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(value="/mdp/arc/pub/categoryQx") |
|||
@Api(tags={"表单权限-操作接口"}) |
|||
public class CategoryQxController { |
|||
|
|||
static Logger logger =LoggerFactory.getLogger(CategoryQxController.class); |
|||
|
|||
@Autowired |
|||
private CategoryQxService categoryQxService; |
|||
|
|||
@ApiOperation( value = "表单权限-查询列表",notes=" ") |
|||
@ApiEntityParams(CategoryQx.class) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=CategoryQx.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listCategoryQx(@ApiIgnore @RequestParam Map<String,Object> params){ |
|||
try { |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
QueryWrapper<CategoryQx> qw = QueryTools.initQueryWrapper(CategoryQx.class , params); |
|||
IPage page=QueryTools.initPage(params); |
|||
List<Map<String,Object>> datas = categoryQxService.selectListMapByWhere(page,qw,params); |
|||
return Result.ok("query-ok","查询成功").setData(datas).setTotal(page.getTotal()); |
|||
}catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
@ApiOperation( value = "表单权限-新增",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=CategoryQx.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addCategoryQx(@RequestBody CategoryQx categoryQx) { |
|||
categoryQxService.save(categoryQx); |
|||
return Result.ok("add-ok","添加成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "表单权限-删除",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delCategoryQx(@RequestBody CategoryQx categoryQx){ |
|||
categoryQxService.removeById(categoryQx); |
|||
return Result.ok("del-ok","删除成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "表单权限-修改",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=CategoryQx.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editCategoryQx(@RequestBody CategoryQx categoryQx) { |
|||
categoryQxService.updateById(categoryQx); |
|||
return Result.ok("edit-ok","修改成功!"); |
|||
} |
|||
|
|||
@ApiOperation( value = "表单权限-批量修改某些字段",notes="") |
|||
@ApiEntityParams( value = CategoryQx.class, props={ }, remark = "表单权限", paramType = "body" ) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=CategoryQx.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST) |
|||
public Result editSomeFields( @ApiIgnore @RequestBody Map<String,Object> params) { |
|||
try{ |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
categoryQxService.editSomeFields(params); |
|||
return Result.ok("edit-ok","更新成功"); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
} |
|||
} |
|||
|
|||
@ApiOperation( value = "表单权限-批量删除",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelCategoryQx(@RequestBody List<CategoryQx> categoryQxs) { |
|||
User user= LoginUtils.getCurrentUserInfo(); |
|||
try{ |
|||
if(categoryQxs.size()<=0){ |
|||
return Result.error("categoryQx-batchDel-data-err-0","请上送待删除数据列表"); |
|||
} |
|||
List<CategoryQx> datasDb=categoryQxService.listByIds(categoryQxs.stream().map(i-> i.getCateId() ).collect(Collectors.toList())); |
|||
|
|||
List<CategoryQx> can=new ArrayList<>(); |
|||
List<CategoryQx> no=new ArrayList<>(); |
|||
for (CategoryQx data : datasDb) { |
|||
if(true){ |
|||
can.add(data); |
|||
}else{ |
|||
no.add(data); |
|||
} |
|||
} |
|||
List<String> msgs=new ArrayList<>(); |
|||
if(can.size()>0){ |
|||
categoryQxService.removeByIds(can); |
|||
msgs.add(LangTips.transMsg("del-ok-num","成功删除%s条数据.",can.size())); |
|||
} |
|||
|
|||
if(no.size()>0){ |
|||
msgs.add(LangTips.transMsg("not-allow-del-num","以下%s条数据不能删除:【%s】",no.size(),no.stream().map(i-> i.getCateId() ).collect(Collectors.joining(",")))); |
|||
} |
|||
if(can.size()>0){ |
|||
return Result.ok(msgs.stream().collect(Collectors.joining())); |
|||
}else { |
|||
return Result.error(msgs.stream().collect(Collectors.joining())); |
|||
} |
|||
}catch (BizException e) { |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
return Result.error(e); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@ApiOperation( value = "表单权限-根据主键查询一条数据",notes=" ") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=CategoryQx.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/queryById",method=RequestMethod.GET) |
|||
public Result queryById(CategoryQx categoryQx) { |
|||
CategoryQx data = (CategoryQx) categoryQxService.getById(categoryQx); |
|||
return Result.ok().setData(data); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
package com.mdp.arc.pub.ctrl; |
|||
|
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* 为了兼容就接口 arc/category/**的请求 |
|||
***/ |
|||
@RestController("mdp.arc.CategorySubController") |
|||
@RequestMapping(value="/**/arc/category") |
|||
@Deprecated |
|||
public class CategorySubController extends CategoryController { |
|||
|
|||
} |
|||
@ -0,0 +1,197 @@ |
|||
package com.mdp.arc.pub.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.cache.TagCacheService; |
|||
import com.mdp.arc.pub.entity.TagCategory; |
|||
import com.mdp.arc.pub.service.TagCategoryService; |
|||
import com.mdp.arc.pub.service.TagService; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.utils.RequestUtils; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import io.swagger.annotations.*; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* url编制采用rest风格,如对ARC.arc_tag_category arc_tag_category的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: arc/tagCategory/add <br> |
|||
* 查询: arc/tagCategory/list<br> |
|||
* 模糊查询: arc/tagCategory/listKey<br> |
|||
* 修改: arc/tagCategory/edit <br> |
|||
* 删除: arc/tagCategory/del<br> |
|||
* 批量删除: arc/tagCategory/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 arc 小模块 <br> |
|||
* 实体 TagCategory 表 ARC.arc_tag_category 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.arc.tagCategoryController") |
|||
@RequestMapping(value="/**/arc/tagCategory") |
|||
@Api(tags={"arc_tag_category操作接口"}) |
|||
public class TagCategoryController { |
|||
|
|||
static Log logger=LogFactory.getLog(TagCategoryController.class); |
|||
|
|||
@Autowired |
|||
private TagCategoryService tagCategoryService; |
|||
|
|||
|
|||
@Autowired |
|||
TagCacheService tagCacheService; |
|||
|
|||
|
|||
@Autowired |
|||
private TagService tagService; |
|||
|
|||
|
|||
@ApiOperation( value = "查询arc_tag_category信息列表",notes="listTagCategory,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name="id",value="分组编号,主键",required=false), |
|||
@ApiImplicitParam(name="branchId",value="机构号",required=false), |
|||
@ApiImplicitParam(name="shopId",value="商户编号",required=false), |
|||
@ApiImplicitParam(name="categoryName",value="分组名称",required=false), |
|||
@ApiImplicitParam(name="pageSize",value="每页记录数",required=false), |
|||
@ApiImplicitParam(name="currentPage",value="当前页码,从1开始",required=false), |
|||
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), |
|||
@ApiImplicitParam(name="orderFields",value="排序列 如性别、学生编号排序 ['sex','studentId']",required=false), |
|||
@ApiImplicitParam(name="orderDirs",value="排序方式,与orderFields对应,升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']",required=false) |
|||
}) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=TagCategory.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listTagCategory(@RequestParam Map<String,Object> params ){ |
|||
|
|||
RequestUtils.transformArray(params, "ids"); |
|||
IPage page= QueryTools.initPage(params); |
|||
List<Map<String,Object>> datas = tagCategoryService.selectListMapByWhere(page,QueryTools.initQueryWrapper(TagCategory.class,params),params); //列出TagCategory列表 |
|||
|
|||
return Result.ok().setData(datas).setTotal(page.getTotal()); |
|||
} |
|||
|
|||
|
|||
|
|||
/***/ |
|||
@ApiOperation( value = "新增一条arc_tag_category信息",notes="addTagCategory,主键如果为空,后台自动生成") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=TagCategory.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addTagCategory(@RequestBody TagCategory tagCategory) { |
|||
|
|||
|
|||
try{ |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
tagCategory.setBranchId(user.getBranchId()); |
|||
TagCategory tagCategoryQuery = new TagCategory(); |
|||
tagCategoryQuery.setCategoryName(tagCategory.getCategoryName()); |
|||
tagCategoryQuery.setBranchId(tagCategory.getBranchId()); |
|||
if(tagCategoryService.countByWhere(tagCategoryQuery)>0){ |
|||
return Result.error("名字已存在,不允许再添加"); |
|||
} |
|||
tagCategory.setId(this.tagCategoryService.createTagCategoryId(user.getBranchId())); |
|||
if(StringUtils.isEmpty(tagCategory.getIsPub())) { |
|||
tagCategory.setIsPub("0"); |
|||
} |
|||
if("1".equals(tagCategory.getIsPub())) {//如果添加的是公共标签需要检查是否有权限 |
|||
if(!LoginUtils.hasAnyRoles("superAdmin","platformAdmin")) { |
|||
return Result.error("tag-add-no-role-001", "isPub", "只有平台管理员和超级管理员可以添加公共标签"); |
|||
}; |
|||
} |
|||
int i=tagCategoryService.insert(tagCategory); |
|||
if(i>0 && "1".equals(tagCategory.getIsPub())) {//如果添加的是公共标签需要同步更新缓存 |
|||
tagCacheService.removePubTabs(); |
|||
}else { |
|||
tagCacheService.removeNotPubTabs(tagCategory.getBranchId()); |
|||
} |
|||
|
|||
return Result.ok().setData(tagCategory); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "删除一条arc_tag_category信息",notes="delTagCategory,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delTagCategory(@RequestBody TagCategory tagCategory){ |
|||
|
|||
|
|||
try{ |
|||
tagCategoryService.deleteByPk(tagCategory); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
return Result.ok(); |
|||
} |
|||
*/ |
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键修改一条arc_tag_category信息",notes="editTagCategory") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=TagCategory.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editTagCategory(@RequestBody TagCategory tagCategory) { |
|||
|
|||
|
|||
try{ |
|||
tagCategoryService.updateByPk(tagCategory); |
|||
return Result.ok().setData(tagCategory); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
return Result.ok(); |
|||
} |
|||
*/ |
|||
|
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键列表批量删除arc_tag_category信息",notes="batchDelTagCategory,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelTagCategory(@RequestBody List<TagCategory> tagCategorys) { |
|||
|
|||
|
|||
try{ |
|||
tagCategoryService.batchDelete(tagCategorys); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
return Result.ok(); |
|||
} |
|||
*/ |
|||
} |
|||
@ -0,0 +1,246 @@ |
|||
package com.mdp.arc.pub.ctrl; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.cache.TagCacheService; |
|||
import com.mdp.arc.pub.entity.Tag; |
|||
import com.mdp.arc.pub.entity.TagCategory; |
|||
import com.mdp.arc.pub.service.TagService; |
|||
import com.mdp.core.entity.Result; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.utils.RequestUtils; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import io.swagger.annotations.*; |
|||
import org.apache.commons.logging.Log; |
|||
import org.apache.commons.logging.LogFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.util.CollectionUtils; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* url编制采用rest风格,如对ARC.arc_tag arc_tag的操作有增删改查,对应的url分别为:<br> |
|||
* 新增: arc/tag/add <br> |
|||
* 查询: arc/tag/list<br> |
|||
* 模糊查询: arc/tag/listKey<br> |
|||
* 修改: arc/tag/edit <br> |
|||
* 删除: arc/tag/del<br> |
|||
* 批量删除: arc/tag/batchDel<br> |
|||
* 组织 com.qqkj 顶级模块 mdp 大模块 arc 小模块 <br> |
|||
* 实体 Tag 表 ARC.arc_tag 当前主键(包括多主键): id; |
|||
***/ |
|||
@RestController("mdp.arc.tagController") |
|||
@RequestMapping(value="/**/arc/tag") |
|||
@Api(tags={"arc_tag操作接口"}) |
|||
public class TagController { |
|||
|
|||
static Log logger=LogFactory.getLog(TagController.class); |
|||
|
|||
@Autowired |
|||
private TagService tagService; |
|||
|
|||
|
|||
@Autowired |
|||
TagCacheService tagCacheService; |
|||
|
|||
|
|||
@ApiOperation( value = "查询arc_tag信息列表",notes="listTag,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name="id",value="标签编号,主键",required=false), |
|||
@ApiImplicitParam(name="tagName",value="标签名",required=false), |
|||
@ApiImplicitParam(name="branchId",value="机构号",required=false), |
|||
@ApiImplicitParam(name="shopId",value="商户编号",required=false), |
|||
@ApiImplicitParam(name="categoryId",value="标签分组",required=false), |
|||
@ApiImplicitParam(name="pageSize",value="每页记录数",required=false), |
|||
@ApiImplicitParam(name="currentPage",value="当前页码,从1开始",required=false), |
|||
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), |
|||
@ApiImplicitParam(name="orderFields",value="排序列 如性别、学生编号排序 ['sex','studentId']",required=false), |
|||
@ApiImplicitParam(name="orderDirs",value="排序方式,与orderFields对应,升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']",required=false) |
|||
}) |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response= Tag.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},pageInfo:{total:总记录数},data:[数据对象1,数据对象2,...]}") |
|||
}) |
|||
@RequestMapping(value="/list",method=RequestMethod.GET) |
|||
public Result listTag(@RequestParam Map<String,Object> params ){ |
|||
|
|||
RequestUtils.transformArray(params, "ids"); |
|||
IPage page= QueryTools.initPage(params); |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
params.put("branchId",user.getBranchId()); |
|||
List<Map<String,Object>> datas = tagService.selectListMapByWhere(page,QueryTools.initQueryWrapper(Tag.class,params),params); //列出Tag列表 |
|||
|
|||
return Result.ok().setData(datas); |
|||
} |
|||
|
|||
|
|||
|
|||
@RequestMapping(value="/getAllTag",method=RequestMethod.GET) |
|||
public Result getAllTag(@RequestParam Map<String,Object> params) { |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
List<Map<String,Object>> datas=tagService.getAllTag(user.getBranchId());; |
|||
params.put("branchId",user.getBranchId()); |
|||
return Result.ok().setData(datas).setTotal(datas==null?0:datas.size()); |
|||
} |
|||
|
|||
@RequestMapping(value="/deleteTagCategory",method=RequestMethod.POST) |
|||
public Result deleteTagCategory(@RequestBody TagCategory tagCategory) { |
|||
|
|||
|
|||
try{ |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
tagCategory.setBranchId(user.getBranchId()); |
|||
if("1".equals(tagCategory.getIsPub())) {//如果添加的是公共标签需要检查是否有权限 |
|||
if(!LoginUtils.hasAnyRoles("superAdmin","platformAdmin")) { |
|||
return Result.error("tag-add-no-role-001", "isPub", "只有平台管理员和超级管理员可以添加公共标签"); |
|||
}; |
|||
} |
|||
int i=tagService.deleteTagCategory(tagCategory); |
|||
if(i>0 && "1".equals(tagCategory.getIsPub())) {//如果添加的是公共标签需要同步更新缓存 |
|||
tagCacheService.removePubTabs(); |
|||
}else { |
|||
tagCacheService.removeNotPubTabs(tagCategory.getBranchId()); |
|||
} |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
/** |
|||
* 添加之前先查询 如果有就不能添加 |
|||
* */ |
|||
@ApiOperation( value = "新增一条pub_tag信息",notes="addTag,主键如果为空,后台自动生成") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Tag.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/add",method=RequestMethod.POST) |
|||
public Result addTag(@RequestBody Tag tag) { |
|||
|
|||
|
|||
try{ |
|||
|
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
tag.setBranchId(user.getBranchId()); |
|||
Tag query=new Tag(); |
|||
query.setBranchId(user.getBranchId()); |
|||
query.setTagName(tag.getTagName()); |
|||
List<Tag> tagList = tagService.selectListByWhere(query); //列出Tag列表 |
|||
if(!CollectionUtils.isEmpty(tagList)) { |
|||
throw new BizException("该标签名字已经存在了,不能添加"); |
|||
} |
|||
String id=tagService.createTagId(user.getBranchId()); |
|||
tag.setId(id); |
|||
if(StringUtils.isEmpty(tag.getIsPub())) { |
|||
tag.setIsPub("0"); |
|||
} |
|||
if("1".equals(tag.getIsPub())) {//如果添加的是公共标签需要检查是否有权限 |
|||
if(!LoginUtils.hasAnyRoles("superAdmin","platformAdmin")) { |
|||
return Result.error("tag-add-no-role-001", "isPub", "只有平台管理员和超级管理员可以添加公共标签"); |
|||
}; |
|||
} |
|||
tag.setBranchId(user.getBranchId()); |
|||
int i=tagService.insert(tag); |
|||
if(i>0 && "1".equals(tag.getIsPub())) {//如果添加的是公共标签需要同步更新缓存 |
|||
tagCacheService.removePubTabs(); |
|||
}else { |
|||
tagCacheService.removeNotPubTabs(tag.getBranchId()); |
|||
} |
|||
return Result.ok().setData(tag); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
} |
|||
|
|||
/***/ |
|||
@ApiOperation( value = "删除一条arc_tag信息",notes="delTag,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|||
}) |
|||
@RequestMapping(value="/del",method=RequestMethod.POST) |
|||
public Result delTag(@RequestBody Tag tag){ |
|||
|
|||
|
|||
try{ |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
tag.setBranchId(user.getBranchId()); |
|||
if("1".equals(tag.getIsPub())) {//如果添加的是公共标签需要检查是否有权限 |
|||
if(!LoginUtils.hasAnyRoles("superAdmin","platformAdmin")) { |
|||
return Result.error("tag-add-no-role-001", "isPub", "只有平台管理员和超级管理员可以添加公共标签"); |
|||
}; |
|||
} |
|||
int i=tagService.deleteByPk(tag); |
|||
if(i>0 && "1".equals(tag.getIsPub())) {//如果添加的是公共标签需要同步更新缓存 |
|||
tagCacheService.removePubTabs(); |
|||
}else { |
|||
tagCacheService.removeNotPubTabs(tag.getBranchId()); |
|||
} |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
return Result.ok(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键修改一条arc_tag信息",notes="editTag") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200,response=Tag.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|||
}) |
|||
@RequestMapping(value="/edit",method=RequestMethod.POST) |
|||
public Result editTag(@RequestBody Tag tag) { |
|||
|
|||
|
|||
try{ |
|||
tagService.updateByPk(tag); |
|||
return Result.ok().setData(tag); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
return Result.ok(); |
|||
} |
|||
*/ |
|||
|
|||
|
|||
|
|||
/** |
|||
@ApiOperation( value = "根据主键列表批量删除arc_tag信息",notes="batchDelTag,仅需要上传主键字段") |
|||
@ApiResponses({ |
|||
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|||
}) |
|||
@RequestMapping(value="/batchDel",method=RequestMethod.POST) |
|||
public Result batchDelTag(@RequestBody List<Tag> tags) { |
|||
|
|||
|
|||
try{ |
|||
tagService.batchDelete(tags); |
|||
}catch (BizException e) { |
|||
logger.error("",e); |
|||
return Result.error(e); |
|||
}catch (Exception e) { |
|||
logger.error("",e); |
|||
return Result.error(e.getMessage()); |
|||
|
|||
} |
|||
return Result.ok(); |
|||
} |
|||
*/ |
|||
} |
|||
@ -0,0 +1,120 @@ |
|||
package com.mdp.arc.pub.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-20 |
|||
*/ |
|||
@Data |
|||
@TableName("arc_category") |
|||
@ApiModel(description="档案类目") |
|||
public class Category implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
|
|||
@ApiModelProperty(notes="分类主键,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
|
|||
@ApiModelProperty(notes="0知识库-1新闻类2企业内部通知公告类3平台通知公告4其它5论坛6公文7归档8网站栏目,关联基础数据categoryType",allowEmptyValue=true,example="",allowableValues="") |
|||
String categoryType; |
|||
|
|||
|
|||
@ApiModelProperty(notes="上级分类",allowEmptyValue=true,example="",allowableValues="") |
|||
String pid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="分类名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String name; |
|||
|
|||
|
|||
@ApiModelProperty(notes="分类排序",allowEmptyValue=true,example="",allowableValues="") |
|||
BigDecimal sortOrder; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否显示",allowEmptyValue=true,example="",allowableValues="") |
|||
String isShow; |
|||
|
|||
|
|||
@ApiModelProperty(notes="机构编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="图片列表逗号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String imageUrls; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否叶子节点0否1是,叶子节点不允许再建立下级,非叶子节点不允许挂文章",allowEmptyValue=true,example="",allowableValues="") |
|||
String isLeaf; |
|||
|
|||
|
|||
@ApiModelProperty(notes="文章限制,1-单篇文章,2-多篇文章",allowEmptyValue=true,example="",allowableValues="") |
|||
String limitType; |
|||
|
|||
|
|||
@ApiModelProperty(notes="文章是否需要审核0-否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String isAuth; |
|||
|
|||
|
|||
@ApiModelProperty(notes="上级分类路径,逗号分割,包括自身",allowEmptyValue=true,example="",allowableValues="") |
|||
String paths; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考类型",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelyType; |
|||
|
|||
|
|||
@ApiModelProperty(notes="参考类型编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelyId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="子参考类型",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelyStype; |
|||
|
|||
|
|||
@ApiModelProperty(notes="子参考类型编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String crelySid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="权限控制要求",allowEmptyValue=true,example="",allowableValues="") |
|||
String qxLvl; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否强制要求子类继承",allowEmptyValue=true,example="",allowableValues="") |
|||
String pqx; |
|||
|
|||
|
|||
@ApiModelProperty(notes="扩展字段",allowEmptyValue=true,example="",allowableValues="") |
|||
String extInfos; |
|||
|
|||
|
|||
@ApiModelProperty(notes="创建人编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String cuserid; |
|||
|
|||
|
|||
@ApiModelProperty(notes="标签",allowEmptyValue=true,example="",allowableValues="") |
|||
String tagIds; |
|||
|
|||
/** |
|||
*分类主键 |
|||
**/ |
|||
public Category(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* 档案类目 |
|||
**/ |
|||
public Category() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,138 @@ |
|||
package com.mdp.arc.pub.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-15 |
|||
*/ |
|||
@Data |
|||
@TableName("arc_category_qx") |
|||
@ApiModel(description="表单权限") |
|||
public class CategoryQx implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
|
|||
@ApiModelProperty(notes="分类编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String cateId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许那些角色查询,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String qryRoleids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许那些部门查询,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String qryDeptids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许哪些人查询,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String qryUserids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些角色查询",allowEmptyValue=true,example="",allowableValues="") |
|||
String nqRoleids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些部门查询",allowEmptyValue=true,example="",allowableValues="") |
|||
String nqDeptids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些人查询",allowEmptyValue=true,example="",allowableValues="") |
|||
String nqUserids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否允许其它人查询",allowEmptyValue=true,example="",allowableValues="") |
|||
String othQuery; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否允许其它人修改",allowEmptyValue=true,example="",allowableValues="") |
|||
String othEdit; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否允许其它人删除",allowEmptyValue=true,example="",allowableValues="") |
|||
String othDel; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否进行部门级别传递权限检查",allowEmptyValue=true,example="",allowableValues="") |
|||
String lvlCheck; |
|||
|
|||
|
|||
@ApiModelProperty(notes="最低级别查询权限",allowEmptyValue=true,example="",allowableValues="") |
|||
String qryMinLvl; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许那些角色更新,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String editRoleids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许那些部门更新,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String editDeptids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许哪些人更新号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String editUserids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些角色更新",allowEmptyValue=true,example="",allowableValues="") |
|||
String neRoleids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些部门更新",allowEmptyValue=true,example="",allowableValues="") |
|||
String neDeptids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些人更新",allowEmptyValue=true,example="",allowableValues="") |
|||
String neUserids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许那些角色删除,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String delRoleids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许那些部门删除,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String delDeptids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="允许哪些人删除,号分割",allowEmptyValue=true,example="",allowableValues="") |
|||
String delUserids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些角色删除",allowEmptyValue=true,example="",allowableValues="") |
|||
String ndRoleids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些部门删除",allowEmptyValue=true,example="",allowableValues="") |
|||
String ndDeptids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="禁止哪些人查询",allowEmptyValue=true,example="",allowableValues="") |
|||
String ndUserids; |
|||
|
|||
|
|||
@ApiModelProperty(notes="最低级别更新权限",allowEmptyValue=true,example="",allowableValues="") |
|||
String editMinLvl; |
|||
|
|||
|
|||
@ApiModelProperty(notes="最低级别删除权限",allowEmptyValue=true,example="",allowableValues="") |
|||
String delMinLvl; |
|||
|
|||
/** |
|||
*分类编号 |
|||
**/ |
|||
public CategoryQx(String cateId) { |
|||
this.cateId = cateId; |
|||
} |
|||
|
|||
/** |
|||
* 表单权限 |
|||
**/ |
|||
public CategoryQx() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package com.mdp.arc.pub.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.mdp.core.dao.annotation.TableIds; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-15 |
|||
*/ |
|||
@Data |
|||
@TableName("arc_tag") |
|||
@ApiModel(description="arc_tag") |
|||
public class Tag implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableIds |
|||
|
|||
@ApiModelProperty(notes="机构号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
@TableIds |
|||
|
|||
@ApiModelProperty(notes="标签编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
|
|||
|
|||
@ApiModelProperty(notes="标签名",allowEmptyValue=true,example="",allowableValues="") |
|||
String tagName; |
|||
|
|||
|
|||
@ApiModelProperty(notes="商户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="标签分组",allowEmptyValue=true,example="",allowableValues="") |
|||
String categoryId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否公共0否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String isPub; |
|||
|
|||
/** |
|||
*机构号,标签编号 |
|||
**/ |
|||
public Tag(String branchId,String id) { |
|||
this.branchId = branchId; |
|||
this.id = id; |
|||
} |
|||
|
|||
/** |
|||
* arc_tag |
|||
**/ |
|||
public Tag() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package com.mdp.arc.pub.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.mdp.core.dao.annotation.TableIds; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author code-gen |
|||
* @since 2023-9-15 |
|||
*/ |
|||
@Data |
|||
@TableName("arc_tag_category") |
|||
@ApiModel(description="arc_tag_category") |
|||
public class TagCategory implements java.io.Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@TableIds |
|||
|
|||
@ApiModelProperty(notes="分组编号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String id; |
|||
@TableIds |
|||
|
|||
@ApiModelProperty(notes="机构号,主键",allowEmptyValue=true,example="",allowableValues="") |
|||
String branchId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="商户编号",allowEmptyValue=true,example="",allowableValues="") |
|||
String shopId; |
|||
|
|||
|
|||
@ApiModelProperty(notes="分组名称",allowEmptyValue=true,example="",allowableValues="") |
|||
String categoryName; |
|||
|
|||
|
|||
@ApiModelProperty(notes="是否公共0否1是",allowEmptyValue=true,example="",allowableValues="") |
|||
String isPub; |
|||
|
|||
|
|||
@ApiModelProperty(notes="扩展字段",allowEmptyValue=true,example="",allowableValues="") |
|||
String extInfos; |
|||
|
|||
/** |
|||
*分组编号,机构号 |
|||
**/ |
|||
public TagCategory(String id,String branchId) { |
|||
this.id = id; |
|||
this.branchId = branchId; |
|||
} |
|||
|
|||
/** |
|||
* arc_tag_category |
|||
**/ |
|||
public TagCategory() { |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.mdp.arc.pub.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.Category; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface CategoryMapper extends BaseMapper<Category> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
void batchUpdatePaths(List<Category> all); |
|||
} |
|||
|
|||
@ -0,0 +1,75 @@ |
|||
<?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.mdp.arc.pub.mapper.CategoryMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from arc_category c |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<!--下面可以添加更多查询条件,正常的if 条件都是支持的--> |
|||
|
|||
<if test="ext.branchIds != null"> and (res.branch_id) in |
|||
<foreach collection="ext.branchIds" item="item" index="index" open="(" separator="," close=")" > |
|||
(#{item}) |
|||
</foreach> |
|||
</if> |
|||
<if test="ext.tagId!=null"> and FIND_IN_SET( #{ext.tagId}, c.tag_ids ) </if> |
|||
and ( |
|||
EXISTS ( SELECT 1 FROM arc_category r1 LEFT JOIN arc_category_qx qx ON qx.CATE_ID = r1.ID |
|||
WHERE |
|||
r1.branch_id=#{ext.qxBranchId} and r1.qx_lvl = '2' and qx.oth_query='1' |
|||
AND ( |
|||
|
|||
FIND_IN_SET( #{ext.qxUserid}, ifnull(qx.QRY_USERIDS,'') )>0 |
|||
<if test="ext.qxDeptids!=null"> or |
|||
<foreach collection="ext.qxDeptids" item="item" index="index" open="(" separator=" or " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.QRY_DEPTIDS,'') )>0 |
|||
</foreach> |
|||
</if> |
|||
<if test="ext.qxRoleids!=null"> or |
|||
<foreach collection="ext.qxRoleids" item="item" index="index" open="(" separator=" or " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.QRY_ROLEIDS,'') )>0 |
|||
</foreach> |
|||
</if> |
|||
) |
|||
AND ( |
|||
FIND_IN_SET( #{ext.qxUserid}, ifnull(qx.NQ_USERIDS,'') )=0 |
|||
<if test="ext.qxDeptids!=null"> and |
|||
<foreach collection="ext.qxDeptids" item="item" index="index" open="(" separator=" and " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.NQ_DEPTIDS,'') )=0 |
|||
</foreach> |
|||
</if> |
|||
<if test="ext.qxRoleids!=null"> and |
|||
<foreach collection="ext.qxRoleids" item="item" index="index" open="(" separator=" and " close=")" > |
|||
FIND_IN_SET( #{item}, ifnull(qx.NQ_ROLEIDS,'') )=0 |
|||
</foreach> |
|||
</if> |
|||
) |
|||
AND c.paths LIKE concat( r1.paths, '%' ) |
|||
) |
|||
or c.qx_lvl = '0' |
|||
OR c.qx_lvl IS NULL |
|||
OR ( c.qx_lvl = '1' AND c.BRANCH_ID = #{ext.qxBranchId}) |
|||
) |
|||
|
|||
</where> |
|||
<!--下面双引号内可以添加默认排序,如果前端没有上传排序,将使用引号内的排序规则--> |
|||
${@com.mdp.Util@trimOrderBy(ew.customSqlSegment,'')} |
|||
<!--下面双引号内可以添加默认分组,如果前端没有上传分组,将使用引号内的分组规则--> |
|||
${@com.mdp.Util@trimGroupBy(ew.customSqlSegment,'')} |
|||
</select> |
|||
<update id="updatecategoryTypeByPid" parameterType="com.mdp.arc.pub.entity.Category"> |
|||
update arc_category set category_type = #{categoryType} where pid = #{id} |
|||
</update> |
|||
|
|||
<update id="batchUpdatePaths"> |
|||
<foreach collection="list" item="item" index="index" separator=";" > |
|||
update arc_category |
|||
set paths=#{item.paths} |
|||
where id = #{item.id} |
|||
</foreach> |
|||
</update> |
|||
<select id="listSubCategorys" parameterType="HashMap" resultType="HashMap"> |
|||
select C.*,(select count(1) from ARC_ARCHIVE_CATEGORY A where A.category_id=C.id and exists(select 1 from arc_archive ac where ac.id = a.archive_id)) as count from ARC_CATEGORY C order by pid,id |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,27 @@ |
|||
package com.mdp.arc.pub.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.CategoryQx; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* @author maimeng-mdp code-gen |
|||
* @since 2023-9-15 |
|||
*/ |
|||
public interface CategoryQxMapper extends BaseMapper<CategoryQx> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,17 @@ |
|||
<?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.mdp.arc.pub.mapper.CategoryQxMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from arc_category_qx res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<!--下面可以添加更多查询条件,正常的if 条件都是支持的--> |
|||
|
|||
</where> |
|||
<!--下面双引号内可以添加默认排序,如果前端没有上传排序,将使用引号内的排序规则--> |
|||
${@com.mdp.Util@trimOrderBy(ew.customSqlSegment,'')} |
|||
<!--下面双引号内可以添加默认分组,如果前端没有上传分组,将使用引号内的分组规则--> |
|||
${@com.mdp.Util@trimGroupBy(ew.customSqlSegment,'')} |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,24 @@ |
|||
package com.mdp.arc.pub.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.TagCategory; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface TagCategoryMapper extends BaseMapper<TagCategory> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,17 @@ |
|||
<?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.mdp.arc.pub.mapper.TagCategoryMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from arc_tag_category res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<!--下面可以添加更多查询条件,正常的if 条件都是支持的--> |
|||
|
|||
</where> |
|||
<!--下面双引号内可以添加默认排序,如果前端没有上传排序,将使用引号内的排序规则--> |
|||
${@com.mdp.Util@trimOrderBy(ew.customSqlSegment,'')} |
|||
<!--下面双引号内可以添加默认分组,如果前端没有上传分组,将使用引号内的分组规则--> |
|||
${@com.mdp.Util@trimGroupBy(ew.customSqlSegment,'')} |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,31 @@ |
|||
package com.mdp.arc.pub.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.Tag; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface TagMapper extends BaseMapper<Tag> { |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> selectListMapByWhere(IPage page, @Param("ew") QueryWrapper ew,@Param("ext") Map<String,Object> ext); |
|||
|
|||
List<Map<String, Object>> selectNotPubTag(String branchId); |
|||
|
|||
List<Map<String, Object>> selectPubTag(String branchId); |
|||
|
|||
|
|||
|
|||
void deleteByCategoryId(Tag customerDeleteTagObject); |
|||
} |
|||
|
|||
@ -0,0 +1,31 @@ |
|||
<?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.mdp.arc.pub.mapper.TagMapper"> |
|||
|
|||
<select id="selectListMapByWhere" resultType="HashMap"> |
|||
select * from arc_tag res |
|||
<where> |
|||
${@com.mdp.Util@trimWhere(ew.customSqlSegment)} |
|||
<!--下面可以添加更多查询条件,正常的if 条件都是支持的--> |
|||
</where> |
|||
<!--下面双引号内可以添加默认排序,如果前端没有上传排序,将使用引号内的排序规则--> |
|||
${@com.mdp.Util@trimOrderBy(ew.customSqlSegment,'')} |
|||
<!--下面双引号内可以添加默认分组,如果前端没有上传分组,将使用引号内的分组规则--> |
|||
${@com.mdp.Util@trimGroupBy(ew.customSqlSegment,'')} |
|||
</select> |
|||
|
|||
<select id="selectNotPubTag" parameterType="String" resultType="HashMap"> |
|||
select res.tag_name,ifnull(res.category_id,c.id) category_id,res.id tag_id,res.is_pub pub_tag,c.category_name,c.is_pub pubc |
|||
from arc_tag res left join arc_tag_category c on res.category_id=c.id |
|||
where res.branch_id =#{branchId} and res.is_pub!='1' |
|||
</select> |
|||
<select id="selectPubTag" parameterType="String" resultType="HashMap"> |
|||
select res.tag_name,ifnull(res.category_id,c.id) category_id,res.id tag_id,res.is_pub pub_tag,c.category_name,c.is_pub pubc |
|||
from arc_tag res left join arc_tag_category c on res.category_id=c.id |
|||
where res.branch_id =#{branchId} and res.is_pub='1' |
|||
</select> |
|||
<!-- 按条件删除若干条记录--> |
|||
<delete id="deleteByCategoryId" parameterType="HashMap"> |
|||
delete from arc_tag where category_id=#{categoryId} and branch_id=#{branchId} |
|||
</delete> |
|||
</mapper> |
|||
@ -0,0 +1,41 @@ |
|||
package com.mdp.arc.pub.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.CategoryQx; |
|||
import com.mdp.arc.pub.mapper.CategoryQxMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* @author maimeng-mdp code-gen |
|||
* @since 2023-9-15 |
|||
*/ |
|||
|
|||
|
|||
@Service("mdp.arc.pub.service.CategoryQxService") |
|||
@DS("arc-ds") |
|||
public class CategoryQxService extends BaseService<CategoryQxMapper,CategoryQx> { |
|||
static Logger logger =LoggerFactory.getLogger(CategoryQxService.class); |
|||
|
|||
|
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
@ -0,0 +1,235 @@ |
|||
package com.mdp.arc.pub.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.Category; |
|||
import com.mdp.arc.pub.entity.CategoryQx; |
|||
import com.mdp.arc.pub.mapper.CategoryMapper; |
|||
import com.mdp.core.entity.LangTips; |
|||
import com.mdp.core.query.QueryTools; |
|||
import com.mdp.core.service.BaseService; |
|||
import com.mdp.core.utils.ObjectTools; |
|||
import com.mdp.safe.client.entity.User; |
|||
import com.mdp.safe.client.utils.LoginUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.util.CollectionUtils; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com.mdp 顶级模块 arc 大模块 pub 小模块 <br> |
|||
* 实体 Category 表 arc_category 当前主键(包括多主键): id; |
|||
***/ |
|||
@Service("mdp.arc.pub.service.CategoryService") |
|||
@DS("arc-ds") |
|||
public class CategoryService extends BaseService<CategoryMapper,Category> { |
|||
static Logger logger =LoggerFactory.getLogger(CategoryService.class); |
|||
|
|||
@Autowired |
|||
CategoryQxService qxService; |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
|
|||
/** 请在此类添加自定义函数 */ |
|||
|
|||
public int insert(Category category) { |
|||
category.setPaths(calcPidString(category)); |
|||
int i= super.insert(category); |
|||
return i; |
|||
|
|||
} |
|||
|
|||
public String calcPidString(Category category){ |
|||
StringBuilder sbIdPath = new StringBuilder(); |
|||
if (!StringUtils.hasText(category.getPid())||category.getPid().equals("0")||category.getId().equals(category.getPid())) { |
|||
sbIdPath.append("0,"); |
|||
sbIdPath.append(category.getId()); |
|||
} else { |
|||
List<Map<String, Object>> pListMap = getAllParentNode(category.getPid(), new ArrayList<>()); |
|||
List<String> lsId = new ArrayList<>(); |
|||
if (!CollectionUtils.isEmpty(pListMap)) { |
|||
int j = pListMap.size(); |
|||
for (int i = 0; i < j; i++) { |
|||
lsId.add((String) pListMap.get(j-i-1).get("id")); |
|||
} |
|||
|
|||
// JDK8 +. |
|||
// idPath = String.join(",", lsId); |
|||
sbIdPath.append("0,"); |
|||
sbIdPath.append(lsId.stream().collect(Collectors.joining(","))); |
|||
sbIdPath.append(","); |
|||
sbIdPath.append(category.getId()); |
|||
} |
|||
} |
|||
return sbIdPath.toString(); |
|||
} |
|||
|
|||
/** |
|||
* 递归获取所有上级所有节点 |
|||
* |
|||
* @param pcategoryId |
|||
* @param pListMap |
|||
* @return |
|||
*/ |
|||
public List<Map<String, Object>> getAllParentNode(String pcategoryId, List<Map<String, Object>> pListMap) { |
|||
if(!StringUtils.hasText(pcategoryId)||"0".equals(pcategoryId)){ |
|||
return pListMap; |
|||
} |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("id", pcategoryId); |
|||
List<Map<String, Object>> list = this.selectListMapByWhere(QueryTools.initPage(map),QueryTools.initQueryWrapper(Category.class,map),map); |
|||
if (!CollectionUtils.isEmpty(list)) { |
|||
Map<String,Object> data=list.get(0); |
|||
String pid= (String) data.get("pid"); |
|||
if(!StringUtils.hasText(pid) || pid.equals(pcategoryId)||"0".equals(pid)){ |
|||
pListMap.add(data); |
|||
return pListMap; |
|||
} |
|||
pListMap.add(data); |
|||
getAllParentNode(pid, pListMap); |
|||
} |
|||
return pListMap; |
|||
} |
|||
public int updateByPk(Category category) { |
|||
category.setPaths(calcPidString(category)); |
|||
int i= super.updateByPk(category); |
|||
return i; |
|||
} |
|||
|
|||
public int[] batchDeleteByMyBranchId(List<Category> categorys,String branchId) { |
|||
|
|||
|
|||
if(categorys==null || categorys.size()<=0) { |
|||
return null; |
|||
} |
|||
|
|||
int[] is= super.batchDelete(categorys); |
|||
return is; |
|||
} |
|||
|
|||
public int deleteByPk(Category category) { |
|||
|
|||
int i= super.deleteByPk(category); |
|||
return i; |
|||
} |
|||
|
|||
@Transactional |
|||
public void batchSave(List<Category> collect, List<Category> updates) { |
|||
List<Category> all=new ArrayList<>(); |
|||
if(collect!=null && collect.size()>0){ |
|||
this.batchInsert(collect); |
|||
all.addAll(collect); |
|||
} |
|||
|
|||
if(updates!=null && updates.size()>0){ |
|||
this.batchUpdate(updates); |
|||
all.addAll(updates); |
|||
} |
|||
for (Category category : all) { |
|||
category.setPaths(this.calcPidString(category)); |
|||
|
|||
} |
|||
baseMapper.batchUpdatePaths(all); |
|||
|
|||
|
|||
} |
|||
|
|||
/** |
|||
* |
|||
* @param pcate |
|||
* @param checkType qry,edit,del |
|||
* @return |
|||
*/ |
|||
public LangTips checkQx(Category pcate,String checkType){ |
|||
User user=LoginUtils.getCurrentUserInfo(); |
|||
String[] pids=pcate.getPaths().split(","); |
|||
CategoryQx categoryQx= qxService.getOne(QueryTools.initQueryWrapper(CategoryQx.class).in("cate_id",pids)); |
|||
String op="qry".equals(checkType)?categoryQx.getOthQuery():("edit".equals(checkType)?categoryQx.getOthEdit():categoryQx.getOthDel()); |
|||
String roleids="qry".equals(checkType)?categoryQx.getQryRoleids():("edit".equals(checkType)?categoryQx.getEditRoleids():categoryQx.getDelRoleids());; |
|||
String deptids="qry".equals(checkType)?categoryQx.getQryDeptids():("edit".equals(checkType)?categoryQx.getEditDeptids():categoryQx.getDelDeptids());; |
|||
String userids="qry".equals(checkType)?categoryQx.getQryUserids():("edit".equals(checkType)?categoryQx.getEditUserids():categoryQx.getDelUserids());; |
|||
|
|||
|
|||
String nroleids="qry".equals(checkType)?categoryQx.getNqRoleids():("edit".equals(checkType)?categoryQx.getNeRoleids():categoryQx.getNdRoleids());; |
|||
String ndeptids="qry".equals(checkType)?categoryQx.getNqDeptids():("edit".equals(checkType)?categoryQx.getNeDeptids():categoryQx.getNdDeptids());; |
|||
String nuserids="qry".equals(checkType)?categoryQx.getNqUserids():("edit".equals(checkType)?categoryQx.getNeUserids():categoryQx.getNdUserids());; |
|||
if(categoryQx!=null){ |
|||
if("1".equals(op)){ |
|||
boolean roleCheckOk=false; |
|||
boolean useridCheckOk=false; |
|||
boolean deptidCheckOk=false; |
|||
if(ObjectTools.isNotEmpty(roleids)){ |
|||
if(LoginUtils.hasAnyRoles(roleids.split(","))){ |
|||
roleCheckOk=true; |
|||
} |
|||
} |
|||
if(ObjectTools.isNotEmpty(userids)){ |
|||
if(Arrays.stream(userids.split(",")).filter(k->user.getUserid().equals(k)).findAny().isPresent()){ |
|||
useridCheckOk=true; |
|||
} |
|||
} |
|||
|
|||
if(ObjectTools.isNotEmpty(deptids)){ |
|||
if(Arrays.stream(deptids.split(",")).filter(k->user.getDeptid().equals(k)).findAny().isPresent()){ |
|||
deptidCheckOk=true; |
|||
} |
|||
} |
|||
boolean allowCheckOk=roleCheckOk||useridCheckOk||deptidCheckOk; |
|||
boolean notAllow=false; |
|||
if(ObjectTools.isNotEmpty(nroleids)){ |
|||
if(LoginUtils.hasAnyRoles(nroleids.split(","))){ |
|||
notAllow=true; |
|||
} |
|||
} |
|||
if(ObjectTools.isNotEmpty(nuserids)){ |
|||
if(Arrays.stream(nuserids.split(",")).filter(k->user.getUserid().equals(k)).findAny().isPresent()){ |
|||
notAllow=true; |
|||
} |
|||
} |
|||
|
|||
if(ObjectTools.isNotEmpty(ndeptids)){ |
|||
if(Arrays.stream(ndeptids.split(",")).filter(k->user.getDeptid().equals(k)).findAny().isPresent()){ |
|||
notAllow=true; |
|||
} |
|||
} |
|||
//禁止条款优先级最高 |
|||
//如果是被禁止的任一条款满足条件,则全部禁止 |
|||
if( notAllow ){ |
|||
return LangTips.errMsg("no-qx-edit","无权限在分类【%s】进行新增子分类、修改等操作",pcate.getName()); |
|||
}else if(!allowCheckOk){//如果被允许的任意条款满足,则允许 |
|||
if(ObjectTools.isNotEmpty(roleids)||ObjectTools.isNotEmpty(deptids)||ObjectTools.isNotEmpty(userids)){ |
|||
return LangTips.errMsg("no-qx-query","无权限查询"); |
|||
} |
|||
} |
|||
|
|||
} else{ |
|||
return LangTips.errMsg("no-qx-edit","无权限在分类【%s】进行新增子分类、修改等操作",pcate.getName()); |
|||
|
|||
} |
|||
|
|||
} |
|||
return LangTips.okMsg(); |
|||
} |
|||
|
|||
public void updatecategoryTypeByPid(Category category) { |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,47 @@ |
|||
package com.mdp.arc.pub.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.pub.entity.TagCategory; |
|||
import com.mdp.arc.pub.mapper.TagCategoryMapper; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com.mdp 顶级模块 arc 大模块 pub 小模块 <br> |
|||
* 实体 TagCategory 表 arc_tag_category 当前主键(包括多主键): id,branch_id; |
|||
***/ |
|||
@Service("mdp.arc.pub.service.TagCategoryService") |
|||
@DS("arc-ds") |
|||
public class TagCategoryService extends BaseService<TagCategoryMapper,TagCategory> { |
|||
static Logger logger =LoggerFactory.getLogger(TagCategoryService.class); |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
/** |
|||
* @param branchId |
|||
* @return |
|||
*/ |
|||
public String createTagCategoryId(String branchId) { |
|||
TagCategory tag=new TagCategory(); |
|||
tag.setBranchId(branchId); |
|||
long c=super.countByWhere(tag); |
|||
return (c+1)+""; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,126 @@ |
|||
package com.mdp.arc.pub.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.mdp.arc.cache.TagCacheService; |
|||
import com.mdp.arc.pub.entity.Tag; |
|||
import com.mdp.arc.pub.entity.TagCategory; |
|||
import com.mdp.arc.pub.mapper.TagMapper; |
|||
import com.mdp.core.err.BizException; |
|||
import com.mdp.core.service.BaseService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br> |
|||
* 组织 com.mdp 顶级模块 arc 大模块 pub 小模块 <br> |
|||
* 实体 Tag 表 arc_tag 当前主键(包括多主键): branch_id,id; |
|||
***/ |
|||
@Service("mdp.arc.pub.service.TagService") |
|||
@DS("arc-ds") |
|||
public class TagService extends BaseService<TagMapper,Tag> { |
|||
static Logger logger =LoggerFactory.getLogger(TagService.class); |
|||
|
|||
@Value(value = "${mdp.platform-branch-id:platform-branch-001}") |
|||
String platformBranchId; |
|||
|
|||
/** 请在此类添加自定义函数 */ |
|||
@Autowired |
|||
private TagCategoryService tagCategoryService; |
|||
|
|||
@Autowired |
|||
TagCacheService tagCacheService; |
|||
|
|||
/** |
|||
* 自定义查询,支持多表关联 |
|||
* @param page 分页条件 |
|||
* @param ew 一定要,并且必须加@Param("ew")注解 |
|||
* @param ext 如果xml中需要根据某些值进行特殊处理,可以通过这个进行传递,非必须,注解也可以不加 |
|||
* @return |
|||
*/ |
|||
public List<Map<String,Object>> selectListMapByWhere(IPage page, QueryWrapper ew, Map<String,Object> ext){ |
|||
return baseMapper.selectListMapByWhere(page,ew,ext); |
|||
} |
|||
|
|||
|
|||
/** 请在此类添加自定义函数 */ |
|||
public List<Map<String, Object>> getAllTag(String branchId) { |
|||
List<Map<String,Object>> pubTags= this.selectPubTagFromCacheFirst(); |
|||
List<Map<String,Object>> notPubTags= this.selectNotPubTagFromCacheFirst(branchId); |
|||
pubTags=pubTags==null?new ArrayList<>():pubTags; |
|||
if(notPubTags!=null && notPubTags.size()>0){ |
|||
pubTags.addAll(notPubTags); |
|||
} |
|||
return pubTags; |
|||
} |
|||
|
|||
/** 删除*/ |
|||
public int deleteTagCategory(TagCategory tagCategory) { |
|||
String categoryId=tagCategory.getId(); |
|||
String branchId=tagCategory.getBranchId(); |
|||
String shopId=tagCategory.getShopId(); |
|||
if(StringUtils.isEmpty(categoryId)) { |
|||
throw new BizException("请传递标签分类id"); |
|||
}else if(StringUtils.isEmpty(branchId)) { |
|||
throw new BizException("请传递branchId"); |
|||
} |
|||
// TagCategory customerDeleteTagCategoryObject=new TagCategory(); |
|||
// customerDeleteTagCategoryObject.setShopId(shopId); |
|||
// customerDeleteTagCategoryObject.setBranchId(branchId); |
|||
// customerDeleteTagCategoryObject.setId(categoryId); |
|||
int i=tagCategoryService.deleteByPk(tagCategory); |
|||
Tag customerDeleteTagObject=new Tag(); |
|||
customerDeleteTagObject.setCategoryId(categoryId); |
|||
customerDeleteTagObject.setShopId(shopId); |
|||
customerDeleteTagObject.setBranchId(branchId); |
|||
baseMapper.deleteByCategoryId(customerDeleteTagObject); |
|||
return i; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @param branchId |
|||
* @return |
|||
*/ |
|||
public String createTagId(String branchId) { |
|||
Tag tag=new Tag(); |
|||
tag.setBranchId(branchId); |
|||
long c=super.countByWhere(tag); |
|||
return (c+1)+""; |
|||
} |
|||
public List<Map<String,Object>> selectNotPubTagFromCacheFirst(String branchId){ |
|||
List<Map<String,Object>> datas=this.tagCacheService.getNotPubTags(branchId); |
|||
if(datas==null){ |
|||
datas=selectNotPubTag(branchId); |
|||
tagCacheService.putNotPubTags(branchId,datas); |
|||
} |
|||
return datas; |
|||
} |
|||
|
|||
private List<Map<String, Object>> selectNotPubTag(String branchId) { |
|||
return baseMapper.selectNotPubTag(branchId); |
|||
} |
|||
|
|||
public List<Map<String,Object>> selectPubTagFromCacheFirst(){ |
|||
List<Map<String,Object>> datas=this.tagCacheService.getPubTags(); |
|||
if(datas==null){ |
|||
datas=selectPubTag(); |
|||
tagCacheService.putPubTags(datas); |
|||
} |
|||
return datas; |
|||
} |
|||
|
|||
public List<Map<String, Object>> selectPubTag() { |
|||
return baseMapper.selectPubTag(platformBranchId); |
|||
} |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue