Showing
52 changed files
with
3874 additions
and
0 deletions
Too many changes to show.
To preserve performance only 52 of 382 files are displayed.
.gitignore
0 → 100644
| 1 | +# Created by .ignore support plugin (hsz.mobi) | |
| 2 | +### Node template | |
| 3 | +# Logs | |
| 4 | +logs | |
| 5 | +*.log | |
| 6 | +npm-debug.log* | |
| 7 | +yarn-debug.log* | |
| 8 | +yarn-error.log* | |
| 9 | +lerna-debug.log* | |
| 10 | + | |
| 11 | +# Diagnostic reports (https://nodejs.org/api/report.html) | |
| 12 | +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | |
| 13 | + | |
| 14 | +# Runtime data | |
| 15 | +pids | |
| 16 | +*.pid | |
| 17 | +*.seed | |
| 18 | +*.pid.lock | |
| 19 | + | |
| 20 | +# Directory for instrumented libs generated by jscoverage/JSCover | |
| 21 | +lib-cov | |
| 22 | + | |
| 23 | +# Coverage directory used by tools like istanbul | |
| 24 | +coverage | |
| 25 | +*.lcov | |
| 26 | + | |
| 27 | +# nyc test coverage | |
| 28 | +.nyc_output | |
| 29 | + | |
| 30 | +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | |
| 31 | +.grunt | |
| 32 | + | |
| 33 | +# Bower dependency directory (https://bower.io/) | |
| 34 | +bower_components | |
| 35 | + | |
| 36 | +# node-waf configuration | |
| 37 | +.lock-wscript | |
| 38 | + | |
| 39 | +# Compiled binary addons (https://nodejs.org/api/addons.html) | |
| 40 | +build/Release | |
| 41 | + | |
| 42 | +# Dependency directories | |
| 43 | +node_modules/ | |
| 44 | +jspm_packages/ | |
| 45 | + | |
| 46 | +# Snowpack dependency directory (https://snowpack.dev/) | |
| 47 | +web_modules/ | |
| 48 | + | |
| 49 | +# TypeScript cache | |
| 50 | +*.tsbuildinfo | |
| 51 | + | |
| 52 | +# Optional npm cache directory | |
| 53 | +.npm | |
| 54 | + | |
| 55 | +# Optional eslint cache | |
| 56 | +.eslintcache | |
| 57 | + | |
| 58 | +# Microbundle cache | |
| 59 | +.rpt2_cache/ | |
| 60 | +.rts2_cache_cjs/ | |
| 61 | +.rts2_cache_es/ | |
| 62 | +.rts2_cache_umd/ | |
| 63 | + | |
| 64 | +# Optional REPL history | |
| 65 | +.node_repl_history | |
| 66 | + | |
| 67 | +# Output of 'npm pack' | |
| 68 | +*.tgz | |
| 69 | + | |
| 70 | +# Yarn Integrity file | |
| 71 | +.yarn-integrity | |
| 72 | + | |
| 73 | +# dotenv environment variables file | |
| 74 | +.env | |
| 75 | +.env.test | |
| 76 | + | |
| 77 | +# parcel-bundler cache (https://parceljs.org/) | |
| 78 | +.cache | |
| 79 | +.parcel-cache | |
| 80 | + | |
| 81 | +# Next.js build output | |
| 82 | +.next | |
| 83 | + | |
| 84 | +# Nuxt.js build / generate output | |
| 85 | +.nuxt | |
| 86 | +dist | |
| 87 | + | |
| 88 | +# Gatsby files | |
| 89 | +.cache/ | |
| 90 | +# Comment in the public line in if your project uses Gatsby and not Next.js | |
| 91 | +# https://nextjs.org/blog/next-9-1#public-directory-support | |
| 92 | +# public | |
| 93 | + | |
| 94 | +# vuepress build output | |
| 95 | +.vuepress/dist | |
| 96 | + | |
| 97 | +# Serverless directories | |
| 98 | +.serverless/ | |
| 99 | + | |
| 100 | +# FuseBox cache | |
| 101 | +.fusebox/ | |
| 102 | + | |
| 103 | +# DynamoDB Local files | |
| 104 | +.dynamodb/ | |
| 105 | + | |
| 106 | +# TernJS port file | |
| 107 | +.tern-port | |
| 108 | + | |
| 109 | +# Stores VSCode versions used for testing VSCode extensions | |
| 110 | +.vscode-test | |
| 111 | + | |
| 112 | +# yarn v2 | |
| 113 | + | |
| 114 | +.yarn/cache | |
| 115 | +.yarn/unplugged | |
| 116 | +.yarn/build-state.yml | |
| 117 | +.pnp.* | |
| 118 | + | |
| 119 | +### Vue template | |
| 120 | +# gitignore template for Vue.js projects | |
| 121 | +# | |
| 122 | +# Recommended template: Node.gitignore | |
| 123 | + | ... | ... |
.idea/.gitignore
0 → 100644
.idea/inspectionProfiles/Project_Default.xml
0 → 100644
| 1 | +<component name="InspectionProjectProfileManager"> | |
| 2 | + <profile version="1.0"> | |
| 3 | + <option name="myName" value="Project Default" /> | |
| 4 | + <inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true"> | |
| 5 | + <option name="TOP_LEVEL_CLASS_OPTIONS"> | |
| 6 | + <value> | |
| 7 | + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | |
| 8 | + <option name="REQUIRED_TAGS" value="" /> | |
| 9 | + </value> | |
| 10 | + </option> | |
| 11 | + <option name="INNER_CLASS_OPTIONS"> | |
| 12 | + <value> | |
| 13 | + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | |
| 14 | + <option name="REQUIRED_TAGS" value="" /> | |
| 15 | + </value> | |
| 16 | + </option> | |
| 17 | + <option name="METHOD_OPTIONS"> | |
| 18 | + <value> | |
| 19 | + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | |
| 20 | + <option name="REQUIRED_TAGS" value="@return@param@throws or @exception" /> | |
| 21 | + </value> | |
| 22 | + </option> | |
| 23 | + <option name="FIELD_OPTIONS"> | |
| 24 | + <value> | |
| 25 | + <option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" /> | |
| 26 | + <option name="REQUIRED_TAGS" value="" /> | |
| 27 | + </value> | |
| 28 | + </option> | |
| 29 | + <option name="IGNORE_DEPRECATED" value="false" /> | |
| 30 | + <option name="IGNORE_JAVADOC_PERIOD" value="true" /> | |
| 31 | + <option name="IGNORE_DUPLICATED_THROWS" value="false" /> | |
| 32 | + <option name="IGNORE_POINT_TO_ITSELF" value="false" /> | |
| 33 | + <option name="myAdditionalJavadocTags" value="date" /> | |
| 34 | + </inspection_tool> | |
| 35 | + </profile> | |
| 36 | +</component> | |
| \ No newline at end of file | ... | ... |
.idea/junjie_yunhui.iml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<module type="JAVA_MODULE" version="4"> | |
| 3 | + <component name="NewModuleRootManager" inherit-compiler-output="true"> | |
| 4 | + <exclude-output /> | |
| 5 | + <content url="file://$MODULE_DIR$"> | |
| 6 | + <excludeFolder url="file://$MODULE_DIR$/xieyunhui-ui/admin/node_modules" /> | |
| 7 | + </content> | |
| 8 | + <content url="file://$MODULE_DIR$/xieyunhui-ui/admin/node_modules" /> | |
| 9 | + <orderEntry type="inheritedJdk" /> | |
| 10 | + <orderEntry type="sourceFolder" forTests="false" /> | |
| 11 | + </component> | |
| 12 | +</module> | |
| \ No newline at end of file | ... | ... |
.idea/misc.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="JavaScriptSettings"> | |
| 4 | + <option name="languageLevel" value="ES6" /> | |
| 5 | + </component> | |
| 6 | + <component name="ProjectRootManager"> | |
| 7 | + <output url="file://$PROJECT_DIR$/out" /> | |
| 8 | + </component> | |
| 9 | +</project> | |
| \ No newline at end of file | ... | ... |
.idea/modules.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project version="4"> | |
| 3 | + <component name="ProjectModuleManager"> | |
| 4 | + <modules> | |
| 5 | + <module fileurl="file://$PROJECT_DIR$/.idea/junjie_yunhui.iml" filepath="$PROJECT_DIR$/.idea/junjie_yunhui.iml" /> | |
| 6 | + </modules> | |
| 7 | + </component> | |
| 8 | +</project> | |
| \ No newline at end of file | ... | ... |
.idea/vcs.xml
0 → 100644
qgyun-xieyunhui/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | + <modelVersion>4.0.0</modelVersion> | |
| 6 | + <parent> | |
| 7 | + <artifactId>qgyun-dev</artifactId> | |
| 8 | + <groupId>com.qgutech.qgyun.parent</groupId> | |
| 9 | + <version>1.0.0-SNAPSHOT</version> | |
| 10 | + </parent> | |
| 11 | + | |
| 12 | + <artifactId>qgyun-xieyunhui</artifactId> | |
| 13 | + <version>1.0-SNAPSHOT</version> | |
| 14 | + | |
| 15 | + <properties> | |
| 16 | + <jdk.version>1.8</jdk.version> | |
| 17 | + </properties> | |
| 18 | + <dependencies> | |
| 19 | + <dependency> | |
| 20 | + <groupId>com.qgutech.qgyun.framework</groupId> | |
| 21 | + <artifactId>qgyun-cloud-nacos</artifactId> | |
| 22 | + <version>2.1.0-SNAPSHOT</version> | |
| 23 | + </dependency> | |
| 24 | + | |
| 25 | + <dependency> | |
| 26 | + <groupId>com.qgutech.qgyun.framework</groupId> | |
| 27 | + <artifactId>qgyun-core-mybatis</artifactId> | |
| 28 | + <version>2.1.0-SNAPSHOT</version> | |
| 29 | + </dependency> | |
| 30 | + | |
| 31 | + <dependency> | |
| 32 | + <groupId>com.qgutech.qgyun.framework</groupId> | |
| 33 | + <artifactId>qgyun-core-starter-web</artifactId> | |
| 34 | + <version>2.1.0-SNAPSHOT</version> | |
| 35 | + </dependency> | |
| 36 | + <dependency> | |
| 37 | + <groupId>com.qgutech.qgyun.framework</groupId> | |
| 38 | + <artifactId>qgyun-core-starter-redis</artifactId> | |
| 39 | + <version>2.1.0-SNAPSHOT</version> | |
| 40 | + </dependency> | |
| 41 | + <dependency> | |
| 42 | + <groupId>mysql</groupId> | |
| 43 | + <artifactId>mysql-connector-java</artifactId> | |
| 44 | + <version>5.1.43</version> | |
| 45 | + </dependency> | |
| 46 | + <dependency> | |
| 47 | + <groupId>com.alibaba</groupId> | |
| 48 | + <artifactId>druid-spring-boot-starter</artifactId> | |
| 49 | + <version>1.1.10</version> | |
| 50 | + </dependency> | |
| 51 | + <dependency> | |
| 52 | + <groupId>redis.clients</groupId> | |
| 53 | + <artifactId>jedis</artifactId> | |
| 54 | + <version>2.9.0</version> | |
| 55 | + </dependency> | |
| 56 | + <dependency> | |
| 57 | + <groupId>com.alibaba</groupId> | |
| 58 | + <artifactId>fastjson</artifactId> | |
| 59 | + <version>1.2.7</version> | |
| 60 | + </dependency> | |
| 61 | + <dependency> | |
| 62 | + <groupId>com.alibaba</groupId> | |
| 63 | + <artifactId>easyexcel</artifactId> | |
| 64 | + <version>1.1.2-beta5</version> | |
| 65 | + </dependency> | |
| 66 | + <dependency> | |
| 67 | + <groupId>org.apache.httpcomponents</groupId> | |
| 68 | + <artifactId>httpclient</artifactId> | |
| 69 | + <version>4.5.6</version> | |
| 70 | + </dependency> | |
| 71 | + <dependency> | |
| 72 | + <groupId>com.google.code.gson</groupId> | |
| 73 | + <artifactId>gson</artifactId> | |
| 74 | + </dependency> | |
| 75 | + <dependency> | |
| 76 | + <groupId>com.itextpdf</groupId> | |
| 77 | + <artifactId>itextpdf</artifactId> | |
| 78 | + <version>5.5.6</version> | |
| 79 | + </dependency> | |
| 80 | + <dependency> | |
| 81 | + <groupId>com.itextpdf.tool</groupId> | |
| 82 | + <artifactId>xmlworker</artifactId> | |
| 83 | + <version>5.5.6</version> | |
| 84 | + </dependency> | |
| 85 | + <dependency> | |
| 86 | + <artifactId>dev-client</artifactId> | |
| 87 | + <groupId>com.qgutech.qgyun.parent</groupId> | |
| 88 | + <version>1.0.0-SNAPSHOT</version> | |
| 89 | + </dependency> | |
| 90 | + <dependency> | |
| 91 | + <groupId>com.qgutech.qgyun.service</groupId> | |
| 92 | + <artifactId>qgyun-service-fs-client</artifactId> | |
| 93 | + <version>2.0.0-SNAPSHOT</version> | |
| 94 | + </dependency> | |
| 95 | + <dependency> | |
| 96 | + <groupId>com.qgutech.qgyun.saas</groupId> | |
| 97 | + <artifactId>saas-app-api</artifactId> | |
| 98 | + <version>1.0.0-SNAPSHOT</version> | |
| 99 | + <scope>compile</scope> | |
| 100 | + </dependency> | |
| 101 | + </dependencies> | |
| 102 | + <build> | |
| 103 | + <plugins> | |
| 104 | + <plugin> | |
| 105 | + <groupId>org.springframework.boot</groupId> | |
| 106 | + <artifactId>spring-boot-maven-plugin</artifactId> | |
| 107 | + </plugin> | |
| 108 | + </plugins> | |
| 109 | + </build> | |
| 110 | +</project> | |
| \ No newline at end of file | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui; | |
| 2 | + | |
| 3 | +import org.springframework.boot.SpringApplication; | |
| 4 | +import org.springframework.cloud.client.SpringCloudApplication; | |
| 5 | +import org.springframework.cloud.openfeign.EnableFeignClients; | |
| 6 | +import org.springframework.context.annotation.ComponentScan; | |
| 7 | +import tk.mybatis.spring.annotation.MapperScan; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * xieyunhui 项目启动类文件 | |
| 11 | + * | |
| 12 | + * @author auto | |
| 13 | + * @version 1.0 | |
| 14 | + * @since 2021-01-29 17:02:04 | |
| 15 | + */ | |
| 16 | +@EnableFeignClients({"com.qgutech.qgyun.xieyunhui.**","com.qgutech.qgyun.dev.client.**","com.qgutech.qgyun.fs.client"}) | |
| 17 | +@SpringCloudApplication | |
| 18 | +@ComponentScan({"com.qgutech.qgyun.dev.client.**","com.qgutech.qgyun.xieyunhui.**"}) | |
| 19 | +@MapperScan({"com.qgutech.qgyun.xieyunhui.**.mapper"}) | |
| 20 | +public class XieyunhuiApplication { | |
| 21 | + public static void main(String[] args) { | |
| 22 | + SpringApplication.run(XieyunhuiApplication.class, args); | |
| 23 | + } | |
| 24 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.controller; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.common.result.JsonResult; | |
| 4 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 5 | +import com.qgutech.qgyun.framework.starter.web.swagger.annotations.ParamHide; | |
| 6 | +import com.qgutech.qgyun.framework.starter.web.validator.annotations.Check; | |
| 7 | +import com.qgutech.qgyun.xieyunhui.exportmodel.BookExportData; | |
| 8 | +import com.qgutech.qgyun.xieyunhui.model.Book; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.service.BookService; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.utils.DownloadUtils; | |
| 11 | +import javax.annotation.Resource; | |
| 12 | +import io.swagger.annotations.*; | |
| 13 | +import org.springframework.web.bind.annotation.*; | |
| 14 | +import javax.servlet.http.HttpServletRequest; | |
| 15 | +import javax.servlet.http.HttpServletResponse; | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * BookController 服务提供类 | |
| 21 | + * | |
| 22 | + * @author auto | |
| 23 | + * @version 1.0 | |
| 24 | + * @since 2021-01-29 17:02:04 | |
| 25 | + */ | |
| 26 | +@RestController | |
| 27 | +@RequestMapping(value = "/book") | |
| 28 | +@Api(value = "BookController" , tags = {"BookController 服务提供类"}) | |
| 29 | +public class BookController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private BookService bookService; | |
| 33 | + | |
| 34 | + @GetMapping(value = "/page") | |
| 35 | + @ApiOperation(value = "获取分页") | |
| 36 | + @ApiImplicitParams({ | |
| 37 | + @ApiImplicitParam(name = "code", value = "书本编号", dataType = "String", paramType = "query"), | |
| 38 | + @ApiImplicitParam(name = "name", value = "书本名称", dataType = "String", paramType = "query"), | |
| 39 | + @ApiImplicitParam(name = "introduce", value = "书本介绍", dataType = "String", paramType = "query"), | |
| 40 | + @ApiImplicitParam(name = "showorder", value = "书本排序", dataType = "Double", paramType = "query"), | |
| 41 | + @ApiImplicitParam(name = "createdOrg", value = "所属部门", dataType = "String", paramType = "query"), | |
| 42 | + @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", paramType = "query"), | |
| 43 | + @ApiImplicitParam(name = "pageSize", value = "页大小", dataType = "Integer", paramType = "query") | |
| 44 | + }) | |
| 45 | + public JsonResult<Page<Book>> search(@ParamHide Book book, @ParamHide Page<Book> page) { | |
| 46 | + page = bookService.search(book, page); | |
| 47 | + return new JsonResult<>(true, "查询成功", page); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @GetMapping(value = "/listAll") | |
| 51 | + @ApiOperation(value = "获取所有数据") | |
| 52 | + public JsonResult<List<Book>> listAll() { | |
| 53 | + return new JsonResult<>(true, "查询成功", bookService.listAll()); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @PostMapping("/add") | |
| 57 | + @ApiOperation(value = "新增接口") | |
| 58 | + @ApiImplicitParams({ | |
| 59 | + @ApiImplicitParam(name = "code", value = "书本编号", dataType = "String", paramType = "query"), | |
| 60 | + @ApiImplicitParam(name = "name", value = "书本名称", dataType = "String", paramType = "query"), | |
| 61 | + @ApiImplicitParam(name = "introduce", value = "书本介绍", dataType = "String", paramType = "query"), | |
| 62 | + @ApiImplicitParam(name = "showorder", value = "书本排序", dataType = "Double", paramType = "query"), | |
| 63 | + }) | |
| 64 | + public JsonResult<String> addBook(@RequestBody Book book) { | |
| 65 | + String id = bookService.add(book); | |
| 66 | + return new JsonResult<>(true, "添加成功", id); | |
| 67 | + } | |
| 68 | + | |
| 69 | + @PutMapping("/edit") | |
| 70 | + @ApiOperation(value = "编辑接口") | |
| 71 | + @ApiImplicitParams({ | |
| 72 | + @ApiImplicitParam(name = "code", value = "书本编号", dataType = "String", paramType = "query"), | |
| 73 | + @ApiImplicitParam(name = "name", value = "书本名称", dataType = "String", paramType = "query"), | |
| 74 | + @ApiImplicitParam(name = "introduce", value = "书本介绍", dataType = "String", paramType = "query"), | |
| 75 | + @ApiImplicitParam(name = "showorder", value = "书本排序", dataType = "Double", paramType = "query"), | |
| 76 | + @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "query") | |
| 77 | + }) | |
| 78 | + public JsonResult editBook(@RequestBody @Check(field = {"id"}) Book book) { | |
| 79 | + bookService.edit(book); | |
| 80 | + return new JsonResult(true, "编辑成功"); | |
| 81 | + } | |
| 82 | + | |
| 83 | + @GetMapping(value = "/{id}") | |
| 84 | + @ApiOperation(value = "根据id获取数据") | |
| 85 | + @ApiImplicitParams(@ApiImplicitParam(name = "id", value = "主键id", paramType = "path", required = true)) | |
| 86 | + public JsonResult<Book> getBook(@PathVariable(value = "id") String id) { | |
| 87 | + Book book = bookService.get(id); | |
| 88 | + return new JsonResult<>(true, "查询成功", book); | |
| 89 | + } | |
| 90 | + | |
| 91 | + @DeleteMapping(value = "/delete") | |
| 92 | + @ApiOperation(value = "根据传入的Id,删除数据") | |
| 93 | + public JsonResult<String> batchDelete(@RequestBody List<String> ids) { | |
| 94 | + bookService.deleteByIds(ids); | |
| 95 | + return new JsonResult<>(true, "删除成功"); | |
| 96 | + } | |
| 97 | + | |
| 98 | + @GetMapping(value = "/export") | |
| 99 | + @ApiOperation(value = "book导出") | |
| 100 | + public void exportData(Book book, HttpServletRequest request, HttpServletResponse response) { | |
| 101 | + String filePath = bookService.exportData(book, BookExportData.class); | |
| 102 | + DownloadUtils.download(filePath, "book.xlsx", response); | |
| 103 | + } | |
| 104 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/controller/CategoryController.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.controller; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.common.result.JsonResult; | |
| 4 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 5 | +import com.qgutech.qgyun.framework.starter.web.swagger.annotations.ParamHide; | |
| 6 | +import com.qgutech.qgyun.framework.starter.web.validator.annotations.Check; | |
| 7 | +import com.qgutech.qgyun.xieyunhui.exportmodel.CategoryExportData; | |
| 8 | +import com.qgutech.qgyun.xieyunhui.model.Category; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.service.CategoryService; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.utils.DownloadUtils; | |
| 11 | +import javax.annotation.Resource; | |
| 12 | +import io.swagger.annotations.*; | |
| 13 | +import org.springframework.web.bind.annotation.*; | |
| 14 | +import javax.servlet.http.HttpServletRequest; | |
| 15 | +import javax.servlet.http.HttpServletResponse; | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * CategoryController 服务提供类 | |
| 21 | + * | |
| 22 | + * @author auto | |
| 23 | + * @version 1.0 | |
| 24 | + * @since 2021-01-29 17:02:04 | |
| 25 | + */ | |
| 26 | +@RestController | |
| 27 | +@RequestMapping(value = "/category") | |
| 28 | +@Api(value = "CategoryController" , tags = {"CategoryController 服务提供类"}) | |
| 29 | +public class CategoryController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private CategoryService categoryService; | |
| 33 | + | |
| 34 | + @GetMapping(value = "/page") | |
| 35 | + @ApiOperation(value = "获取分页") | |
| 36 | + @ApiImplicitParams({ | |
| 37 | + @ApiImplicitParam(name = "name", value = "分类名称", dataType = "String", paramType = "query"), | |
| 38 | + @ApiImplicitParam(name = "createdOrg", value = "所属部门", dataType = "String", paramType = "query"), | |
| 39 | + @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", paramType = "query"), | |
| 40 | + @ApiImplicitParam(name = "pageSize", value = "页大小", dataType = "Integer", paramType = "query") | |
| 41 | + }) | |
| 42 | + public JsonResult<Page<Category>> search(@ParamHide Category category, @ParamHide Page<Category> page) { | |
| 43 | + page = categoryService.search(category, page); | |
| 44 | + return new JsonResult<>(true, "查询成功", page); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @GetMapping(value = "/listAll") | |
| 48 | + @ApiOperation(value = "获取所有数据") | |
| 49 | + public JsonResult<List<Category>> listAll() { | |
| 50 | + return new JsonResult<>(true, "查询成功", categoryService.listAll()); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @PostMapping("/add") | |
| 54 | + @ApiOperation(value = "新增接口") | |
| 55 | + @ApiImplicitParams({ | |
| 56 | + @ApiImplicitParam(name = "name", value = "分类名称", dataType = "String", paramType = "query"), | |
| 57 | + }) | |
| 58 | + public JsonResult<String> addCategory(@RequestBody Category category) { | |
| 59 | + String id = categoryService.add(category); | |
| 60 | + return new JsonResult<>(true, "添加成功", id); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @PutMapping("/edit") | |
| 64 | + @ApiOperation(value = "编辑接口") | |
| 65 | + @ApiImplicitParams({ | |
| 66 | + @ApiImplicitParam(name = "name", value = "分类名称", dataType = "String", paramType = "query"), | |
| 67 | + @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "query") | |
| 68 | + }) | |
| 69 | + public JsonResult editCategory(@RequestBody @Check(field = {"id"}) Category category) { | |
| 70 | + categoryService.edit(category); | |
| 71 | + return new JsonResult(true, "编辑成功"); | |
| 72 | + } | |
| 73 | + | |
| 74 | + @GetMapping(value = "/{id}") | |
| 75 | + @ApiOperation(value = "根据id获取数据") | |
| 76 | + @ApiImplicitParams(@ApiImplicitParam(name = "id", value = "主键id", paramType = "path", required = true)) | |
| 77 | + public JsonResult<Category> getCategory(@PathVariable(value = "id") String id) { | |
| 78 | + Category category = categoryService.get(id); | |
| 79 | + return new JsonResult<>(true, "查询成功", category); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @DeleteMapping(value = "/delete") | |
| 83 | + @ApiOperation(value = "根据传入的Id,删除数据") | |
| 84 | + public JsonResult<String> batchDelete(@RequestBody List<String> ids) { | |
| 85 | + categoryService.deleteByIds(ids); | |
| 86 | + return new JsonResult<>(true, "删除成功"); | |
| 87 | + } | |
| 88 | + | |
| 89 | + @GetMapping(value = "/export") | |
| 90 | + @ApiOperation(value = "category导出") | |
| 91 | + public void exportData(Category category, HttpServletRequest request, HttpServletResponse response) { | |
| 92 | + String filePath = categoryService.exportData(category, CategoryExportData.class); | |
| 93 | + DownloadUtils.download(filePath, "category.xlsx", response); | |
| 94 | + } | |
| 95 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/controller/FileRelController.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.controller; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.common.result.JsonResult; | |
| 4 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 5 | +import com.qgutech.qgyun.framework.starter.web.swagger.annotations.ParamHide; | |
| 6 | +import com.qgutech.qgyun.framework.starter.web.validator.annotations.Check; | |
| 7 | +import com.qgutech.qgyun.xieyunhui.exportmodel.FileRelExportData; | |
| 8 | +import com.qgutech.qgyun.xieyunhui.model.FileRel; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.service.FileRelService; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.utils.DownloadUtils; | |
| 11 | +import javax.annotation.Resource; | |
| 12 | +import io.swagger.annotations.*; | |
| 13 | +import org.springframework.web.bind.annotation.*; | |
| 14 | +import javax.servlet.http.HttpServletRequest; | |
| 15 | +import javax.servlet.http.HttpServletResponse; | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * FileRelController 服务提供类 | |
| 21 | + * | |
| 22 | + * @author auto | |
| 23 | + * @version 1.0 | |
| 24 | + * @since 2021-01-29 17:02:04 | |
| 25 | + */ | |
| 26 | +@RestController | |
| 27 | +@RequestMapping(value = "/fileRel") | |
| 28 | +@Api(value = "FileRelController" , tags = {"FileRelController 服务提供类"}) | |
| 29 | +public class FileRelController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private FileRelService fileRelService; | |
| 33 | + | |
| 34 | + @GetMapping(value = "/page") | |
| 35 | + @ApiOperation(value = "获取分页") | |
| 36 | + @ApiImplicitParams({ | |
| 37 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 38 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 39 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 40 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 41 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 42 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 43 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 44 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 45 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 46 | + @ApiImplicitParam(name = "fileId", value = "文件ID", dataType = "String", paramType = "query"), | |
| 47 | + @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", paramType = "query"), | |
| 48 | + @ApiImplicitParam(name = "pageSize", value = "页大小", dataType = "Integer", paramType = "query") | |
| 49 | + }) | |
| 50 | + public JsonResult<Page<FileRel>> search(@ParamHide FileRel fileRel, @ParamHide Page<FileRel> page) { | |
| 51 | + page = fileRelService.search(fileRel, page); | |
| 52 | + return new JsonResult<>(true, "查询成功", page); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @GetMapping(value = "/listAll") | |
| 56 | + @ApiOperation(value = "获取所有数据") | |
| 57 | + public JsonResult<List<FileRel>> listAll() { | |
| 58 | + return new JsonResult<>(true, "查询成功", fileRelService.listAll()); | |
| 59 | + } | |
| 60 | + | |
| 61 | + @PostMapping("/add") | |
| 62 | + @ApiOperation(value = "新增接口") | |
| 63 | + @ApiImplicitParams({ | |
| 64 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 65 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 66 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 67 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 68 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 69 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 70 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 71 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 72 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 73 | + @ApiImplicitParam(name = "fileId", value = "文件ID", dataType = "String", paramType = "query"), | |
| 74 | + }) | |
| 75 | + public JsonResult<String> addFileRel(@RequestBody FileRel fileRel) { | |
| 76 | + String id = fileRelService.add(fileRel); | |
| 77 | + return new JsonResult<>(true, "添加成功", id); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @PutMapping("/edit") | |
| 81 | + @ApiOperation(value = "编辑接口") | |
| 82 | + @ApiImplicitParams({ | |
| 83 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 84 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 85 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 86 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 87 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 88 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 89 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 90 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 91 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 92 | + @ApiImplicitParam(name = "fileId", value = "文件ID", dataType = "String", paramType = "query"), | |
| 93 | + @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "query") | |
| 94 | + }) | |
| 95 | + public JsonResult editFileRel(@RequestBody @Check(field = {"id"}) FileRel fileRel) { | |
| 96 | + fileRelService.edit(fileRel); | |
| 97 | + return new JsonResult(true, "编辑成功"); | |
| 98 | + } | |
| 99 | + | |
| 100 | + @GetMapping(value = "/{id}") | |
| 101 | + @ApiOperation(value = "根据id获取数据") | |
| 102 | + @ApiImplicitParams(@ApiImplicitParam(name = "id", value = "主键id", paramType = "path", required = true)) | |
| 103 | + public JsonResult<FileRel> getFileRel(@PathVariable(value = "id") String id) { | |
| 104 | + FileRel fileRel = fileRelService.get(id); | |
| 105 | + return new JsonResult<>(true, "查询成功", fileRel); | |
| 106 | + } | |
| 107 | + | |
| 108 | + @DeleteMapping(value = "/delete") | |
| 109 | + @ApiOperation(value = "根据传入的Id,删除数据") | |
| 110 | + public JsonResult<String> batchDelete(@RequestBody List<String> ids) { | |
| 111 | + fileRelService.deleteByIds(ids); | |
| 112 | + return new JsonResult<>(true, "删除成功"); | |
| 113 | + } | |
| 114 | + | |
| 115 | + @GetMapping(value = "/export") | |
| 116 | + @ApiOperation(value = "导出") | |
| 117 | + public void exportData(FileRel fileRel, HttpServletRequest request, HttpServletResponse response) { | |
| 118 | + String filePath = fileRelService.exportData(fileRel, FileRelExportData.class); | |
| 119 | + DownloadUtils.download(filePath, ".xlsx", response); | |
| 120 | + } | |
| 121 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/controller/OrgRelController.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.controller; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.common.result.JsonResult; | |
| 4 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 5 | +import com.qgutech.qgyun.framework.starter.web.swagger.annotations.ParamHide; | |
| 6 | +import com.qgutech.qgyun.framework.starter.web.validator.annotations.Check; | |
| 7 | +import com.qgutech.qgyun.xieyunhui.exportmodel.OrgRelExportData; | |
| 8 | +import com.qgutech.qgyun.xieyunhui.model.OrgRel; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.service.OrgRelService; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.utils.DownloadUtils; | |
| 11 | +import javax.annotation.Resource; | |
| 12 | +import io.swagger.annotations.*; | |
| 13 | +import org.springframework.web.bind.annotation.*; | |
| 14 | +import javax.servlet.http.HttpServletRequest; | |
| 15 | +import javax.servlet.http.HttpServletResponse; | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * OrgRelController 服务提供类 | |
| 21 | + * | |
| 22 | + * @author auto | |
| 23 | + * @version 1.0 | |
| 24 | + * @since 2021-01-29 17:02:04 | |
| 25 | + */ | |
| 26 | +@RestController | |
| 27 | +@RequestMapping(value = "/orgRel") | |
| 28 | +@Api(value = "OrgRelController" , tags = {"OrgRelController 服务提供类"}) | |
| 29 | +public class OrgRelController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private OrgRelService orgRelService; | |
| 33 | + | |
| 34 | + @GetMapping(value = "/page") | |
| 35 | + @ApiOperation(value = "获取分页") | |
| 36 | + @ApiImplicitParams({ | |
| 37 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 38 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 39 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 40 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 41 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 42 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 43 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 44 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 45 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 46 | + @ApiImplicitParam(name = "orgId", value = "部门ID", dataType = "String", paramType = "query"), | |
| 47 | + @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", paramType = "query"), | |
| 48 | + @ApiImplicitParam(name = "pageSize", value = "页大小", dataType = "Integer", paramType = "query") | |
| 49 | + }) | |
| 50 | + public JsonResult<Page<OrgRel>> search(@ParamHide OrgRel orgRel, @ParamHide Page<OrgRel> page) { | |
| 51 | + page = orgRelService.search(orgRel, page); | |
| 52 | + return new JsonResult<>(true, "查询成功", page); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @GetMapping(value = "/listAll") | |
| 56 | + @ApiOperation(value = "获取所有数据") | |
| 57 | + public JsonResult<List<OrgRel>> listAll() { | |
| 58 | + return new JsonResult<>(true, "查询成功", orgRelService.listAll()); | |
| 59 | + } | |
| 60 | + | |
| 61 | + @PostMapping("/add") | |
| 62 | + @ApiOperation(value = "新增接口") | |
| 63 | + @ApiImplicitParams({ | |
| 64 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 65 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 66 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 67 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 68 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 69 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 70 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 71 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 72 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 73 | + @ApiImplicitParam(name = "orgId", value = "部门ID", dataType = "String", paramType = "query"), | |
| 74 | + }) | |
| 75 | + public JsonResult<String> addOrgRel(@RequestBody OrgRel orgRel) { | |
| 76 | + String id = orgRelService.add(orgRel); | |
| 77 | + return new JsonResult<>(true, "添加成功", id); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @PutMapping("/edit") | |
| 81 | + @ApiOperation(value = "编辑接口") | |
| 82 | + @ApiImplicitParams({ | |
| 83 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 84 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 85 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 86 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 87 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 88 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 89 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 90 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 91 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 92 | + @ApiImplicitParam(name = "orgId", value = "部门ID", dataType = "String", paramType = "query"), | |
| 93 | + @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "query") | |
| 94 | + }) | |
| 95 | + public JsonResult editOrgRel(@RequestBody @Check(field = {"id"}) OrgRel orgRel) { | |
| 96 | + orgRelService.edit(orgRel); | |
| 97 | + return new JsonResult(true, "编辑成功"); | |
| 98 | + } | |
| 99 | + | |
| 100 | + @GetMapping(value = "/{id}") | |
| 101 | + @ApiOperation(value = "根据id获取数据") | |
| 102 | + @ApiImplicitParams(@ApiImplicitParam(name = "id", value = "主键id", paramType = "path", required = true)) | |
| 103 | + public JsonResult<OrgRel> getOrgRel(@PathVariable(value = "id") String id) { | |
| 104 | + OrgRel orgRel = orgRelService.get(id); | |
| 105 | + return new JsonResult<>(true, "查询成功", orgRel); | |
| 106 | + } | |
| 107 | + | |
| 108 | + @DeleteMapping(value = "/delete") | |
| 109 | + @ApiOperation(value = "根据传入的Id,删除数据") | |
| 110 | + public JsonResult<String> batchDelete(@RequestBody List<String> ids) { | |
| 111 | + orgRelService.deleteByIds(ids); | |
| 112 | + return new JsonResult<>(true, "删除成功"); | |
| 113 | + } | |
| 114 | + | |
| 115 | + @GetMapping(value = "/export") | |
| 116 | + @ApiOperation(value = "导出") | |
| 117 | + public void exportData(OrgRel orgRel, HttpServletRequest request, HttpServletResponse response) { | |
| 118 | + String filePath = orgRelService.exportData(orgRel, OrgRelExportData.class); | |
| 119 | + DownloadUtils.download(filePath, ".xlsx", response); | |
| 120 | + } | |
| 121 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/controller/UserRelController.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.controller; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.common.result.JsonResult; | |
| 4 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 5 | +import com.qgutech.qgyun.framework.starter.web.swagger.annotations.ParamHide; | |
| 6 | +import com.qgutech.qgyun.framework.starter.web.validator.annotations.Check; | |
| 7 | +import com.qgutech.qgyun.xieyunhui.exportmodel.UserRelExportData; | |
| 8 | +import com.qgutech.qgyun.xieyunhui.model.UserRel; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.service.UserRelService; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.utils.DownloadUtils; | |
| 11 | +import javax.annotation.Resource; | |
| 12 | +import io.swagger.annotations.*; | |
| 13 | +import org.springframework.web.bind.annotation.*; | |
| 14 | +import javax.servlet.http.HttpServletRequest; | |
| 15 | +import javax.servlet.http.HttpServletResponse; | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * UserRelController 服务提供类 | |
| 21 | + * | |
| 22 | + * @author auto | |
| 23 | + * @version 1.0 | |
| 24 | + * @since 2021-01-29 17:02:04 | |
| 25 | + */ | |
| 26 | +@RestController | |
| 27 | +@RequestMapping(value = "/userRel") | |
| 28 | +@Api(value = "UserRelController" , tags = {"UserRelController 服务提供类"}) | |
| 29 | +public class UserRelController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private UserRelService userRelService; | |
| 33 | + | |
| 34 | + @GetMapping(value = "/page") | |
| 35 | + @ApiOperation(value = "获取分页") | |
| 36 | + @ApiImplicitParams({ | |
| 37 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 38 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 39 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 40 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 41 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 42 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 43 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 44 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 45 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 46 | + @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "String", paramType = "query"), | |
| 47 | + @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", paramType = "query"), | |
| 48 | + @ApiImplicitParam(name = "pageSize", value = "页大小", dataType = "Integer", paramType = "query") | |
| 49 | + }) | |
| 50 | + public JsonResult<Page<UserRel>> search(@ParamHide UserRel userRel, @ParamHide Page<UserRel> page) { | |
| 51 | + page = userRelService.search(userRel, page); | |
| 52 | + return new JsonResult<>(true, "查询成功", page); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @GetMapping(value = "/listAll") | |
| 56 | + @ApiOperation(value = "获取所有数据") | |
| 57 | + public JsonResult<List<UserRel>> listAll() { | |
| 58 | + return new JsonResult<>(true, "查询成功", userRelService.listAll()); | |
| 59 | + } | |
| 60 | + | |
| 61 | + @PostMapping("/add") | |
| 62 | + @ApiOperation(value = "新增接口") | |
| 63 | + @ApiImplicitParams({ | |
| 64 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 65 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 66 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 67 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 68 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 69 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 70 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 71 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 72 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 73 | + @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "String", paramType = "query"), | |
| 74 | + }) | |
| 75 | + public JsonResult<String> addUserRel(@RequestBody UserRel userRel) { | |
| 76 | + String id = userRelService.add(userRel); | |
| 77 | + return new JsonResult<>(true, "添加成功", id); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @PutMapping("/edit") | |
| 81 | + @ApiOperation(value = "编辑接口") | |
| 82 | + @ApiImplicitParams({ | |
| 83 | + @ApiImplicitParam(name = "id", value = "ID", dataType = "String", paramType = "query"), | |
| 84 | + @ApiImplicitParam(name = "referId", value = "关联ID", dataType = "String", paramType = "query"), | |
| 85 | + @ApiImplicitParam(name = "funCode", value = "关联应用编号", dataType = "String", paramType = "query"), | |
| 86 | + @ApiImplicitParam(name = "fieldName", value = "关联对应字段列名", dataType = "String", paramType = "query"), | |
| 87 | + @ApiImplicitParam(name = "corpCode", value = "corpCode", dataType = "String", paramType = "query"), | |
| 88 | + @ApiImplicitParam(name = "createdAt", value = "createdAt", dataType = "Date", paramType = "query"), | |
| 89 | + @ApiImplicitParam(name = "updatedAt", value = "updatedAt", dataType = "Date", paramType = "query"), | |
| 90 | + @ApiImplicitParam(name = "createdBy", value = "createdBy", dataType = "String", paramType = "query"), | |
| 91 | + @ApiImplicitParam(name = "updatedBy", value = "updatedBy", dataType = "String", paramType = "query"), | |
| 92 | + @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "String", paramType = "query"), | |
| 93 | + @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "query") | |
| 94 | + }) | |
| 95 | + public JsonResult editUserRel(@RequestBody @Check(field = {"id"}) UserRel userRel) { | |
| 96 | + userRelService.edit(userRel); | |
| 97 | + return new JsonResult(true, "编辑成功"); | |
| 98 | + } | |
| 99 | + | |
| 100 | + @GetMapping(value = "/{id}") | |
| 101 | + @ApiOperation(value = "根据id获取数据") | |
| 102 | + @ApiImplicitParams(@ApiImplicitParam(name = "id", value = "主键id", paramType = "path", required = true)) | |
| 103 | + public JsonResult<UserRel> getUserRel(@PathVariable(value = "id") String id) { | |
| 104 | + UserRel userRel = userRelService.get(id); | |
| 105 | + return new JsonResult<>(true, "查询成功", userRel); | |
| 106 | + } | |
| 107 | + | |
| 108 | + @DeleteMapping(value = "/delete") | |
| 109 | + @ApiOperation(value = "根据传入的Id,删除数据") | |
| 110 | + public JsonResult<String> batchDelete(@RequestBody List<String> ids) { | |
| 111 | + userRelService.deleteByIds(ids); | |
| 112 | + return new JsonResult<>(true, "删除成功"); | |
| 113 | + } | |
| 114 | + | |
| 115 | + @GetMapping(value = "/export") | |
| 116 | + @ApiOperation(value = "导出") | |
| 117 | + public void exportData(UserRel userRel, HttpServletRequest request, HttpServletResponse response) { | |
| 118 | + String filePath = userRelService.exportData(userRel, UserRelExportData.class); | |
| 119 | + DownloadUtils.download(filePath, ".xlsx", response); | |
| 120 | + } | |
| 121 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/exportmodel/BookExportData.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.exportmodel; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 4 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | +import java.util.Date; | |
| 7 | +import lombok.Getter; | |
| 8 | +import lombok.Setter; | |
| 9 | +import lombok.ToString; | |
| 10 | +import io.swagger.annotations.ApiModel; | |
| 11 | +import io.swagger.annotations.ApiModelProperty; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * book 导出实体类 | |
| 15 | + * | |
| 16 | + * @author auto | |
| 17 | + * @version 1.0 | |
| 18 | + * @since 2021-01-29 17:02:05 | |
| 19 | + */ | |
| 20 | +@Getter | |
| 21 | +@Setter | |
| 22 | +@ToString | |
| 23 | +@ApiModel(value = "BookExportData", description = "book导出实体类") | |
| 24 | +public class BookExportData extends BaseRowModel { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 书本编号 | |
| 28 | + */ | |
| 29 | + @ExcelProperty(value = {"书本编号"}, index = 0) | |
| 30 | + private String code; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 书本名称 | |
| 34 | + */ | |
| 35 | + @ExcelProperty(value = {"书本名称"}, index = 1) | |
| 36 | + private String name; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 书本介绍 | |
| 40 | + */ | |
| 41 | + @ExcelProperty(value = {"书本介绍"}, index = 2) | |
| 42 | + private String introduce; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 书本排序 | |
| 46 | + */ | |
| 47 | + @ExcelProperty(value = {"书本排序"}, index = 3) | |
| 48 | + private Double showorder; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 所属部门 | |
| 52 | + */ | |
| 53 | + @ExcelProperty(value = {"所属部门"}, index = 4) | |
| 54 | + private String createdOrg; | |
| 55 | + | |
| 56 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/exportmodel/CategoryExportData.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.exportmodel; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 4 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | +import java.util.Date; | |
| 7 | +import lombok.Getter; | |
| 8 | +import lombok.Setter; | |
| 9 | +import lombok.ToString; | |
| 10 | +import io.swagger.annotations.ApiModel; | |
| 11 | +import io.swagger.annotations.ApiModelProperty; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * category 导出实体类 | |
| 15 | + * | |
| 16 | + * @author auto | |
| 17 | + * @version 1.0 | |
| 18 | + * @since 2021-01-29 17:02:05 | |
| 19 | + */ | |
| 20 | +@Getter | |
| 21 | +@Setter | |
| 22 | +@ToString | |
| 23 | +@ApiModel(value = "CategoryExportData", description = "category导出实体类") | |
| 24 | +public class CategoryExportData extends BaseRowModel { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 分类名称 | |
| 28 | + */ | |
| 29 | + @ExcelProperty(value = {"分类名称"}, index = 0) | |
| 30 | + private String name; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 所属部门 | |
| 34 | + */ | |
| 35 | + @ExcelProperty(value = {"所属部门"}, index = 1) | |
| 36 | + private String createdOrg; | |
| 37 | + | |
| 38 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/exportmodel/FileRelExportData.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.exportmodel; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 4 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | +import java.util.Date; | |
| 7 | +import lombok.Getter; | |
| 8 | +import lombok.Setter; | |
| 9 | +import lombok.ToString; | |
| 10 | +import io.swagger.annotations.ApiModel; | |
| 11 | +import io.swagger.annotations.ApiModelProperty; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 导出实体类 | |
| 15 | + * | |
| 16 | + * @author auto | |
| 17 | + * @version 1.0 | |
| 18 | + * @since 2021-01-29 17:02:05 | |
| 19 | + */ | |
| 20 | +@Getter | |
| 21 | +@Setter | |
| 22 | +@ToString | |
| 23 | +@ApiModel(value = "FileRelExportData", description = "导出实体类") | |
| 24 | +public class FileRelExportData extends BaseRowModel { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 关联ID | |
| 28 | + */ | |
| 29 | + @ExcelProperty(value = {"关联ID"}, index = 0) | |
| 30 | + private String referId; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 关联应用编号 | |
| 34 | + */ | |
| 35 | + @ExcelProperty(value = {"关联应用编号"}, index = 1) | |
| 36 | + private String funCode; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 关联对应字段列名 | |
| 40 | + */ | |
| 41 | + @ExcelProperty(value = {"关联对应字段列名"}, index = 2) | |
| 42 | + private String fieldName; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 文件ID | |
| 46 | + */ | |
| 47 | + @ExcelProperty(value = {"文件ID"}, index = 3) | |
| 48 | + private String fileId; | |
| 49 | + | |
| 50 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/exportmodel/OrgRelExportData.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.exportmodel; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 4 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | +import java.util.Date; | |
| 7 | +import lombok.Getter; | |
| 8 | +import lombok.Setter; | |
| 9 | +import lombok.ToString; | |
| 10 | +import io.swagger.annotations.ApiModel; | |
| 11 | +import io.swagger.annotations.ApiModelProperty; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 导出实体类 | |
| 15 | + * | |
| 16 | + * @author auto | |
| 17 | + * @version 1.0 | |
| 18 | + * @since 2021-01-29 17:02:05 | |
| 19 | + */ | |
| 20 | +@Getter | |
| 21 | +@Setter | |
| 22 | +@ToString | |
| 23 | +@ApiModel(value = "OrgRelExportData", description = "导出实体类") | |
| 24 | +public class OrgRelExportData extends BaseRowModel { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 关联ID | |
| 28 | + */ | |
| 29 | + @ExcelProperty(value = {"关联ID"}, index = 0) | |
| 30 | + private String referId; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 关联应用编号 | |
| 34 | + */ | |
| 35 | + @ExcelProperty(value = {"关联应用编号"}, index = 1) | |
| 36 | + private String funCode; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 关联对应字段列名 | |
| 40 | + */ | |
| 41 | + @ExcelProperty(value = {"关联对应字段列名"}, index = 2) | |
| 42 | + private String fieldName; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 部门ID | |
| 46 | + */ | |
| 47 | + @ExcelProperty(value = {"部门ID"}, index = 3) | |
| 48 | + private String orgId; | |
| 49 | + | |
| 50 | +} | |
| \ No newline at end of file | ... | ... |
qgyun-xieyunhui/src/main/java/com/qgutech/qgyun/xieyunhui/exportmodel/UserRelExportData.java
0 → 100644
| 1 | +package com.qgutech.qgyun.xieyunhui.exportmodel; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 4 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | +import java.util.Date; | |
| 7 | +import lombok.Getter; | |
| 8 | +import lombok.Setter; | |
| 9 | +import lombok.ToString; | |
| 10 | +import io.swagger.annotations.ApiModel; | |
| 11 | +import io.swagger.annotations.ApiModelProperty; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 导出实体类 | |
| 15 | + * | |
| 16 | + * @author auto | |
| 17 | + * @version 1.0 | |
| 18 | + * @since 2021-01-29 17:02:05 | |
| 19 | + */ | |
| 20 | +@Getter | |
| 21 | +@Setter | |
| 22 | +@ToString | |
| 23 | +@ApiModel(value = "UserRelExportData", description = "导出实体类") | |
| 24 | +public class UserRelExportData extends BaseRowModel { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 关联ID | |
| 28 | + */ | |
| 29 | + @ExcelProperty(value = {"关联ID"}, index = 0) | |
| 30 | + private String referId; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 关联应用编号 | |
| 34 | + */ | |
| 35 | + @ExcelProperty(value = {"关联应用编号"}, index = 1) | |
| 36 | + private String funCode; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 关联对应字段列名 | |
| 40 | + */ | |
| 41 | + @ExcelProperty(value = {"关联对应字段列名"}, index = 2) | |
| 42 | + private String fieldName; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 用户ID | |
| 46 | + */ | |
| 47 | + @ExcelProperty(value = {"用户ID"}, index = 3) | |
| 48 | + private String userId; | |
| 49 | + | |
| 50 | +} | |
| \ No newline at end of file | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.mapper; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.mybatis.registermapper.QguBaseMapper; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.Book; | |
| 5 | +import org.apache.ibatis.annotations.Param; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @author auto | |
| 11 | + * @version 1.0 | |
| 12 | + * @since 2021-01-29 17:02:04 | |
| 13 | + */ | |
| 14 | +public interface BookMapper extends QguBaseMapper<Book> { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 根据实体字段条件获取对应实体集合--分页公用(分页由PageHelper实现-解耦合) | |
| 18 | + * | |
| 19 | + * @param book 实体对象 | |
| 20 | + * @return 对象集合 | |
| 21 | + */ | |
| 22 | + List<Book> search(@Param("con") Book book); | |
| 23 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.mapper; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.mybatis.registermapper.QguBaseMapper; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.Category; | |
| 5 | +import org.apache.ibatis.annotations.Param; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @author auto | |
| 11 | + * @version 1.0 | |
| 12 | + * @since 2021-01-29 17:02:04 | |
| 13 | + */ | |
| 14 | +public interface CategoryMapper extends QguBaseMapper<Category> { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 根据实体字段条件获取对应实体集合--分页公用(分页由PageHelper实现-解耦合) | |
| 18 | + * | |
| 19 | + * @param category 实体对象 | |
| 20 | + * @return 对象集合 | |
| 21 | + */ | |
| 22 | + List<Category> search(@Param("con") Category category); | |
| 23 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.mapper; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.mybatis.registermapper.QguBaseMapper; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.FileRel; | |
| 5 | +import org.apache.ibatis.annotations.Param; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @author auto | |
| 11 | + * @version 1.0 | |
| 12 | + * @since 2021-01-29 17:02:04 | |
| 13 | + */ | |
| 14 | +public interface FileRelMapper extends QguBaseMapper<FileRel> { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 根据实体字段条件获取对应实体集合--分页公用(分页由PageHelper实现-解耦合) | |
| 18 | + * | |
| 19 | + * @param fileRel 实体对象 | |
| 20 | + * @return 对象集合 | |
| 21 | + */ | |
| 22 | + List<FileRel> search(@Param("con") FileRel fileRel); | |
| 23 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.mapper; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.mybatis.registermapper.QguBaseMapper; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.OrgRel; | |
| 5 | +import org.apache.ibatis.annotations.Param; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @author auto | |
| 11 | + * @version 1.0 | |
| 12 | + * @since 2021-01-29 17:02:04 | |
| 13 | + */ | |
| 14 | +public interface OrgRelMapper extends QguBaseMapper<OrgRel> { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 根据实体字段条件获取对应实体集合--分页公用(分页由PageHelper实现-解耦合) | |
| 18 | + * | |
| 19 | + * @param orgRel 实体对象 | |
| 20 | + * @return 对象集合 | |
| 21 | + */ | |
| 22 | + List<OrgRel> search(@Param("con") OrgRel orgRel); | |
| 23 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.mapper; | |
| 2 | + | |
| 3 | +import com.qgutech.qgyun.framework.database.mybatis.registermapper.QguBaseMapper; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.UserRel; | |
| 5 | +import org.apache.ibatis.annotations.Param; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @author auto | |
| 11 | + * @version 1.0 | |
| 12 | + * @since 2021-01-29 17:02:04 | |
| 13 | + */ | |
| 14 | +public interface UserRelMapper extends QguBaseMapper<UserRel> { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 根据实体字段条件获取对应实体集合--分页公用(分页由PageHelper实现-解耦合) | |
| 18 | + * | |
| 19 | + * @param userRel 实体对象 | |
| 20 | + * @return 对象集合 | |
| 21 | + */ | |
| 22 | + List<UserRel> search(@Param("con") UserRel userRel); | |
| 23 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.model; | |
| 2 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 3 | +import java.util.Date; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.Setter; | |
| 6 | +import lombok.ToString; | |
| 7 | +import javax.persistence.Table; | |
| 8 | +import io.swagger.annotations.ApiModel; | |
| 9 | +import io.swagger.annotations.ApiModelProperty; | |
| 10 | +import javax.persistence.Transient; | |
| 11 | +import java.util.List; | |
| 12 | +/** | |
| 13 | + * book model | |
| 14 | + * | |
| 15 | + * @author auto | |
| 16 | + * @version 1.0 | |
| 17 | + * @since 2021-01-29 17:02:05 | |
| 18 | + */ | |
| 19 | +@Getter | |
| 20 | +@Setter | |
| 21 | +@ToString | |
| 22 | +@ApiModel(value = "Book", description = "book") | |
| 23 | +@Table(name = "t_auto_xieyunhui_book") | |
| 24 | +public class Book extends BaseCorpModel { | |
| 25 | + public static final String ENTITY_FUN_CODE = "book"; | |
| 26 | + public static final String CODE = "code"; | |
| 27 | + public static final String NAME = "name"; | |
| 28 | + public static final String INTRODUCE = "introduce"; | |
| 29 | + public static final String SHOWORDER = "showorder"; | |
| 30 | + public static final String CREATED_ORG = "createdOrg"; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 书本编号 | |
| 34 | + */ | |
| 35 | + @ApiModelProperty(value = "书本编号") | |
| 36 | + private String code; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 书本名称 | |
| 40 | + */ | |
| 41 | + @ApiModelProperty(value = "书本名称") | |
| 42 | + private String name; | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 书本介绍 | |
| 46 | + */ | |
| 47 | + @ApiModelProperty(value = "书本介绍") | |
| 48 | + private String introduce; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 书本排序 | |
| 52 | + */ | |
| 53 | + @ApiModelProperty(value = "书本排序") | |
| 54 | + private Double showorder; | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 所属部门 | |
| 58 | + */ | |
| 59 | + @ApiModelProperty(value = "所属部门") | |
| 60 | + private String createdOrg; | |
| 61 | + | |
| 62 | + @Transient | |
| 63 | + private Double showorderLeft; | |
| 64 | + | |
| 65 | + @Transient | |
| 66 | + private Double showorderRight; | |
| 67 | + | |
| 68 | + @Transient | |
| 69 | + private List<String> createdOrgList; | |
| 70 | + | |
| 71 | + @Transient | |
| 72 | + private String createdByName; | |
| 73 | + | |
| 74 | + @Transient | |
| 75 | + private String updatedByName; | |
| 76 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.model; | |
| 2 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 3 | +import java.util.Date; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.Setter; | |
| 6 | +import lombok.ToString; | |
| 7 | +import javax.persistence.Table; | |
| 8 | +import io.swagger.annotations.ApiModel; | |
| 9 | +import io.swagger.annotations.ApiModelProperty; | |
| 10 | +import javax.persistence.Transient; | |
| 11 | +import java.util.List; | |
| 12 | +/** | |
| 13 | + * category model | |
| 14 | + * | |
| 15 | + * @author auto | |
| 16 | + * @version 1.0 | |
| 17 | + * @since 2021-01-29 17:02:05 | |
| 18 | + */ | |
| 19 | +@Getter | |
| 20 | +@Setter | |
| 21 | +@ToString | |
| 22 | +@ApiModel(value = "Category", description = "category") | |
| 23 | +@Table(name = "t_auto_xieyunhui_category") | |
| 24 | +public class Category extends BaseCorpModel { | |
| 25 | + public static final String ENTITY_FUN_CODE = "category"; | |
| 26 | + public static final String NAME = "name"; | |
| 27 | + public static final String CREATED_ORG = "createdOrg"; | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 分类名称 | |
| 31 | + */ | |
| 32 | + @ApiModelProperty(value = "分类名称") | |
| 33 | + private String name; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 所属部门 | |
| 37 | + */ | |
| 38 | + @ApiModelProperty(value = "所属部门") | |
| 39 | + private String createdOrg; | |
| 40 | + | |
| 41 | + @Transient | |
| 42 | + private List<String> createdOrgList; | |
| 43 | + | |
| 44 | + @Transient | |
| 45 | + private String createdByName; | |
| 46 | + | |
| 47 | + @Transient | |
| 48 | + private String updatedByName; | |
| 49 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.model; | |
| 2 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 3 | +import java.util.Date; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.Setter; | |
| 6 | +import lombok.ToString; | |
| 7 | +import javax.persistence.Table; | |
| 8 | +import io.swagger.annotations.ApiModel; | |
| 9 | +import io.swagger.annotations.ApiModelProperty; | |
| 10 | +import javax.persistence.Transient; | |
| 11 | +import java.util.List; | |
| 12 | +/** | |
| 13 | + * model | |
| 14 | + * | |
| 15 | + * @author auto | |
| 16 | + * @version 1.0 | |
| 17 | + * @since 2021-01-29 17:02:05 | |
| 18 | + */ | |
| 19 | +@Getter | |
| 20 | +@Setter | |
| 21 | +@ToString | |
| 22 | +@ApiModel(value = "FileRel", description = "") | |
| 23 | +@Table(name = "t_auto_xieyunhui_file_rel") | |
| 24 | +public class FileRel extends BaseCorpModel { | |
| 25 | + public static final String ENTITY_FUN_CODE = "fileRel"; | |
| 26 | + public static final String REFER_ID = "referId"; | |
| 27 | + public static final String FUN_CODE = "funCode"; | |
| 28 | + public static final String FIELD_NAME = "fieldName"; | |
| 29 | + public static final String FILE_ID = "fileId"; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 关联ID | |
| 33 | + */ | |
| 34 | + @ApiModelProperty(value = "关联ID") | |
| 35 | + private String referId; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 关联应用编号 | |
| 39 | + */ | |
| 40 | + @ApiModelProperty(value = "关联应用编号") | |
| 41 | + private String funCode; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 关联对应字段列名 | |
| 45 | + */ | |
| 46 | + @ApiModelProperty(value = "关联对应字段列名") | |
| 47 | + private String fieldName; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 文件ID | |
| 51 | + */ | |
| 52 | + @ApiModelProperty(value = "文件ID") | |
| 53 | + private String fileId; | |
| 54 | + | |
| 55 | + @Transient | |
| 56 | + private String createdByName; | |
| 57 | + | |
| 58 | + @Transient | |
| 59 | + private String updatedByName; | |
| 60 | + | |
| 61 | + @Transient | |
| 62 | + private List<String> referIds; | |
| 63 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.model; | |
| 2 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 3 | +import java.util.Date; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.Setter; | |
| 6 | +import lombok.ToString; | |
| 7 | +import javax.persistence.Table; | |
| 8 | +import io.swagger.annotations.ApiModel; | |
| 9 | +import io.swagger.annotations.ApiModelProperty; | |
| 10 | +import javax.persistence.Transient; | |
| 11 | +import java.util.List; | |
| 12 | +/** | |
| 13 | + * model | |
| 14 | + * | |
| 15 | + * @author auto | |
| 16 | + * @version 1.0 | |
| 17 | + * @since 2021-01-29 17:02:05 | |
| 18 | + */ | |
| 19 | +@Getter | |
| 20 | +@Setter | |
| 21 | +@ToString | |
| 22 | +@ApiModel(value = "OrgRel", description = "") | |
| 23 | +@Table(name = "t_auto_xieyunhui_org_rel") | |
| 24 | +public class OrgRel extends BaseCorpModel { | |
| 25 | + public static final String ENTITY_FUN_CODE = "orgRel"; | |
| 26 | + public static final String REFER_ID = "referId"; | |
| 27 | + public static final String FUN_CODE = "funCode"; | |
| 28 | + public static final String FIELD_NAME = "fieldName"; | |
| 29 | + public static final String ORG_ID = "orgId"; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 关联ID | |
| 33 | + */ | |
| 34 | + @ApiModelProperty(value = "关联ID") | |
| 35 | + private String referId; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 关联应用编号 | |
| 39 | + */ | |
| 40 | + @ApiModelProperty(value = "关联应用编号") | |
| 41 | + private String funCode; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 关联对应字段列名 | |
| 45 | + */ | |
| 46 | + @ApiModelProperty(value = "关联对应字段列名") | |
| 47 | + private String fieldName; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 部门ID | |
| 51 | + */ | |
| 52 | + @ApiModelProperty(value = "部门ID") | |
| 53 | + private String orgId; | |
| 54 | + | |
| 55 | + @Transient | |
| 56 | + private String createdByName; | |
| 57 | + | |
| 58 | + @Transient | |
| 59 | + private String updatedByName; | |
| 60 | + | |
| 61 | + @Transient | |
| 62 | + private List<String> referIds; | |
| 63 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.model; | |
| 2 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | |
| 3 | +import java.util.Date; | |
| 4 | +import lombok.Getter; | |
| 5 | +import lombok.Setter; | |
| 6 | +import lombok.ToString; | |
| 7 | +import javax.persistence.Table; | |
| 8 | +import io.swagger.annotations.ApiModel; | |
| 9 | +import io.swagger.annotations.ApiModelProperty; | |
| 10 | +import javax.persistence.Transient; | |
| 11 | +import java.util.List; | |
| 12 | +/** | |
| 13 | + * model | |
| 14 | + * | |
| 15 | + * @author auto | |
| 16 | + * @version 1.0 | |
| 17 | + * @since 2021-01-29 17:02:05 | |
| 18 | + */ | |
| 19 | +@Getter | |
| 20 | +@Setter | |
| 21 | +@ToString | |
| 22 | +@ApiModel(value = "UserRel", description = "") | |
| 23 | +@Table(name = "t_auto_xieyunhui_user_rel") | |
| 24 | +public class UserRel extends BaseCorpModel { | |
| 25 | + public static final String ENTITY_FUN_CODE = "userRel"; | |
| 26 | + public static final String REFER_ID = "referId"; | |
| 27 | + public static final String FUN_CODE = "funCode"; | |
| 28 | + public static final String FIELD_NAME = "fieldName"; | |
| 29 | + public static final String USER_ID = "userId"; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 关联ID | |
| 33 | + */ | |
| 34 | + @ApiModelProperty(value = "关联ID") | |
| 35 | + private String referId; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 关联应用编号 | |
| 39 | + */ | |
| 40 | + @ApiModelProperty(value = "关联应用编号") | |
| 41 | + private String funCode; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 关联对应字段列名 | |
| 45 | + */ | |
| 46 | + @ApiModelProperty(value = "关联对应字段列名") | |
| 47 | + private String fieldName; | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 用户ID | |
| 51 | + */ | |
| 52 | + @ApiModelProperty(value = "用户ID") | |
| 53 | + private String userId; | |
| 54 | + | |
| 55 | + @Transient | |
| 56 | + private String createdByName; | |
| 57 | + | |
| 58 | + @Transient | |
| 59 | + private String updatedByName; | |
| 60 | + | |
| 61 | + @Transient | |
| 62 | + private List<String> referIds; | |
| 63 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.service; | |
| 2 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 3 | +import com.google.gson.reflect.TypeToken; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.*; | |
| 5 | +import com.qgutech.qgyun.dev.client.uc.UcFeignClient; | |
| 6 | +import com.qgutech.qgyun.framework.common.utils.SqlUtil; | |
| 7 | +import com.qgutech.qgyun.framework.database.model.BaseModel; | |
| 8 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.exportmodel.BookExportData; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.service.impl.base.AbstractExportBaseServiceImpl; | |
| 11 | +import com.qgutech.qgyun.xieyunhui.mapper.BookMapper; | |
| 12 | +import org.apache.commons.collections4.MapUtils; | |
| 13 | +import org.apache.commons.lang.StringUtils; | |
| 14 | +import org.apache.commons.collections4.CollectionUtils; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Isolation; | |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 18 | +import tk.mybatis.mapper.entity.Example; | |
| 19 | +import tk.mybatis.mapper.util.Assert; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import java.time.LocalDate; | |
| 23 | +import java.time.LocalDateTime; | |
| 24 | +import java.util.*; | |
| 25 | +import java.util.stream.Collectors; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * BookService 服务提供类 | |
| 29 | + * | |
| 30 | + * @author auto | |
| 31 | + * @version 1.0 | |
| 32 | + * @since 2021-01-29 17:02:05 | |
| 33 | + */ | |
| 34 | +@Service | |
| 35 | +public class BookService extends AbstractExportBaseServiceImpl<Book> { | |
| 36 | + @Resource | |
| 37 | + private BookMapper bookMapper; | |
| 38 | + @Resource | |
| 39 | + private UcFeignClient ucFeignClient; | |
| 40 | + | |
| 41 | + public List<Book> listAll() { | |
| 42 | + return bookMapper.selectAll(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 46 | + public Page<Book> search(Book book, Page<Book> page) { | |
| 47 | + Assert.notNull(book, "book can not be null!"); | |
| 48 | + Example example = genConditionExample(book); | |
| 49 | + BaseModel.Sort sort = book.getSort(); | |
| 50 | + if (sort != null) { | |
| 51 | + String orderBy = sort.getOrderBy(); | |
| 52 | + if (sort.isAsc()) { | |
| 53 | + example.orderBy(orderBy).asc(); | |
| 54 | + } else { | |
| 55 | + example.orderBy(orderBy).desc(); | |
| 56 | + } | |
| 57 | + } else { | |
| 58 | + example.orderBy(Book.UPDATED_AT).desc(); | |
| 59 | + } | |
| 60 | + | |
| 61 | + page = search(example, page); | |
| 62 | + List<Book> list = page.getList(); | |
| 63 | + if (CollectionUtils.isEmpty(list)) { | |
| 64 | + return page; | |
| 65 | + } | |
| 66 | + | |
| 67 | + page = new Page<>(list); | |
| 68 | + packBookData(list); | |
| 69 | + return page; | |
| 70 | + } | |
| 71 | + | |
| 72 | + private Example genConditionExample(Book model) { | |
| 73 | + Example example = new Example(entityClass); | |
| 74 | + Example.Criteria criteria = example.createCriteria(); | |
| 75 | + String code = model.getCode(); | |
| 76 | + if (StringUtils.isNotBlank(code)) { | |
| 77 | + criteria.andLike(Book.CODE, SqlUtil.asLike(code)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + String name = model.getName(); | |
| 81 | + if (StringUtils.isNotBlank(name)) { | |
| 82 | + criteria.andLike(Book.NAME, SqlUtil.asLike(name)); | |
| 83 | + } | |
| 84 | + | |
| 85 | + String introduce = model.getIntroduce(); | |
| 86 | + if (StringUtils.isNotBlank(introduce)) { | |
| 87 | + criteria.andLike(Book.INTRODUCE, SqlUtil.asLike(introduce)); | |
| 88 | + } | |
| 89 | + | |
| 90 | + Double showorderLeft = model.getShoworderLeft(); | |
| 91 | + Double showorderRight = model.getShoworderRight(); | |
| 92 | + if (null != showorderLeft || null != showorderRight) { | |
| 93 | + if (null != showorderLeft){ | |
| 94 | + criteria.andGreaterThanOrEqualTo(Book.SHOWORDER, showorderLeft); | |
| 95 | + } | |
| 96 | + | |
| 97 | + if (null != showorderRight){ | |
| 98 | + criteria.andLessThan(Book.SHOWORDER, showorderRight); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + List<String> createdOrgList = model.getCreatedOrgList(); | |
| 103 | + if (null != createdOrgList) { | |
| 104 | + criteria.andIn(Book.CREATED_ORG, createdOrgList); | |
| 105 | + } | |
| 106 | + | |
| 107 | + LocalDateTime createdAt = model.getCreatedAt(); | |
| 108 | + if (null != createdAt) { | |
| 109 | + criteria.andEqualTo(Book.CREATED_AT, createdAt); | |
| 110 | + } | |
| 111 | + | |
| 112 | + String createdBy = model.getCreatedBy(); | |
| 113 | + if (StringUtils.isNotBlank(createdBy)) { | |
| 114 | + criteria.andEqualTo(Book.CREATED_BY, createdBy); | |
| 115 | + } | |
| 116 | + | |
| 117 | + | |
| 118 | + return example; | |
| 119 | + } | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * 分页数据处理 | |
| 123 | + */ | |
| 124 | + private void packBookData(List<Book> bookList) { | |
| 125 | + if (CollectionUtils.isEmpty(bookList)) { | |
| 126 | + return; | |
| 127 | + } | |
| 128 | + | |
| 129 | + dealReferInfo(bookList); | |
| 130 | + } | |
| 131 | + | |
| 132 | + private void dealReferInfo(Book book) { | |
| 133 | + List<Book> bookList = Collections.singletonList(book); | |
| 134 | + dealReferInfo(bookList); | |
| 135 | + } | |
| 136 | + | |
| 137 | + private void dealReferInfo(List<Book> bookList) { | |
| 138 | + dealUserRel(bookList); | |
| 139 | + } | |
| 140 | + | |
| 141 | + private void dealUserRel(List<Book> bookList) { | |
| 142 | + //处理人员 | |
| 143 | + List<String> userIds = bookList.stream().map(Book::getUpdatedBy).collect(Collectors.toList()); | |
| 144 | + userIds.addAll(bookList.stream().map(Book::getCreatedBy).collect(Collectors.toList())); | |
| 145 | + Map<String, String> userMap = ucFeignClient.getUserIdAndNameMap(userIds); | |
| 146 | + for (Book book : bookList) { | |
| 147 | + //处理人员 | |
| 148 | + if (MapUtils.isNotEmpty(userMap)) { | |
| 149 | + book.setCreatedByName(userMap.get(book.getCreatedBy())); | |
| 150 | + book.setUpdatedByName(userMap.get(book.getUpdatedBy())); | |
| 151 | + } | |
| 152 | + } | |
| 153 | + } | |
| 154 | + | |
| 155 | + | |
| 156 | + @Override | |
| 157 | + public Book get(String id) { | |
| 158 | + Book book = super.get(id); | |
| 159 | + dealReferInfo(book); | |
| 160 | + return book; | |
| 161 | + } | |
| 162 | + | |
| 163 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 164 | + public List<String> listIdsByExample(Book book) { | |
| 165 | + Assert.notNull(book, "book can not be null"); | |
| 166 | + Example example = genConditionExample(book); | |
| 167 | + example.selectProperties(Book.ID); | |
| 168 | + List<Book> bookList = bookMapper.selectByExample(example); | |
| 169 | + return CollectionUtils.isEmpty(bookList) ? new ArrayList<>(0) : | |
| 170 | + bookList.stream().map(Book::getId).collect(Collectors.toList()); | |
| 171 | + } | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * 新增 | |
| 175 | + */ | |
| 176 | + public String add(Book book) { | |
| 177 | + return super.insert(book); | |
| 178 | + } | |
| 179 | + | |
| 180 | + /** | |
| 181 | + * 修改 | |
| 182 | + */ | |
| 183 | + public void edit(Book book) { | |
| 184 | + super.update(book); | |
| 185 | + } | |
| 186 | + | |
| 187 | + /** | |
| 188 | + * 批量删除 | |
| 189 | + */ | |
| 190 | + public void deleteByIds(List<String> ids) { | |
| 191 | + super.batchDelete(ids); | |
| 192 | + } | |
| 193 | + | |
| 194 | + @Override | |
| 195 | + protected List<? extends BaseRowModel> getExcelDataList(List<Book> sourceList) { | |
| 196 | + return gson.fromJson(gson.toJson(sourceList), new TypeToken<ArrayList<BookExportData>>() { | |
| 197 | + }.getType()); | |
| 198 | + } | |
| 199 | + | |
| 200 | + @Override | |
| 201 | + protected Page<Book> searchForExport(Book sourceCondition, Page<Book> page) { | |
| 202 | + return search(sourceCondition,page); | |
| 203 | + } | |
| 204 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.service; | |
| 2 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 3 | +import com.google.gson.reflect.TypeToken; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.*; | |
| 5 | +import com.qgutech.qgyun.dev.client.uc.UcFeignClient; | |
| 6 | +import com.qgutech.qgyun.framework.common.utils.SqlUtil; | |
| 7 | +import com.qgutech.qgyun.framework.database.model.BaseModel; | |
| 8 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.exportmodel.CategoryExportData; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.service.impl.base.AbstractExportBaseServiceImpl; | |
| 11 | +import com.qgutech.qgyun.xieyunhui.mapper.CategoryMapper; | |
| 12 | +import org.apache.commons.collections4.MapUtils; | |
| 13 | +import org.apache.commons.lang.StringUtils; | |
| 14 | +import org.apache.commons.collections4.CollectionUtils; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Isolation; | |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 18 | +import tk.mybatis.mapper.entity.Example; | |
| 19 | +import tk.mybatis.mapper.util.Assert; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import java.time.LocalDate; | |
| 23 | +import java.time.LocalDateTime; | |
| 24 | +import java.util.*; | |
| 25 | +import java.util.stream.Collectors; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * CategoryService 服务提供类 | |
| 29 | + * | |
| 30 | + * @author auto | |
| 31 | + * @version 1.0 | |
| 32 | + * @since 2021-01-29 17:02:05 | |
| 33 | + */ | |
| 34 | +@Service | |
| 35 | +public class CategoryService extends AbstractExportBaseServiceImpl<Category> { | |
| 36 | + @Resource | |
| 37 | + private CategoryMapper categoryMapper; | |
| 38 | + @Resource | |
| 39 | + private UcFeignClient ucFeignClient; | |
| 40 | + | |
| 41 | + public List<Category> listAll() { | |
| 42 | + return categoryMapper.selectAll(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 46 | + public Page<Category> search(Category category, Page<Category> page) { | |
| 47 | + Assert.notNull(category, "category can not be null!"); | |
| 48 | + Example example = genConditionExample(category); | |
| 49 | + BaseModel.Sort sort = category.getSort(); | |
| 50 | + if (sort != null) { | |
| 51 | + String orderBy = sort.getOrderBy(); | |
| 52 | + if (sort.isAsc()) { | |
| 53 | + example.orderBy(orderBy).asc(); | |
| 54 | + } else { | |
| 55 | + example.orderBy(orderBy).desc(); | |
| 56 | + } | |
| 57 | + } else { | |
| 58 | + example.orderBy(Category.UPDATED_AT).desc(); | |
| 59 | + } | |
| 60 | + | |
| 61 | + page = search(example, page); | |
| 62 | + List<Category> list = page.getList(); | |
| 63 | + if (CollectionUtils.isEmpty(list)) { | |
| 64 | + return page; | |
| 65 | + } | |
| 66 | + | |
| 67 | + page = new Page<>(list); | |
| 68 | + packCategoryData(list); | |
| 69 | + return page; | |
| 70 | + } | |
| 71 | + | |
| 72 | + private Example genConditionExample(Category model) { | |
| 73 | + Example example = new Example(entityClass); | |
| 74 | + Example.Criteria criteria = example.createCriteria(); | |
| 75 | + String name = model.getName(); | |
| 76 | + if (StringUtils.isNotBlank(name)) { | |
| 77 | + criteria.andLike(Category.NAME, SqlUtil.asLike(name)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + List<String> createdOrgList = model.getCreatedOrgList(); | |
| 81 | + if (null != createdOrgList) { | |
| 82 | + criteria.andIn(Category.CREATED_ORG, createdOrgList); | |
| 83 | + } | |
| 84 | + | |
| 85 | + LocalDateTime createdAt = model.getCreatedAt(); | |
| 86 | + if (null != createdAt) { | |
| 87 | + criteria.andEqualTo(Category.CREATED_AT, createdAt); | |
| 88 | + } | |
| 89 | + | |
| 90 | + String createdBy = model.getCreatedBy(); | |
| 91 | + if (StringUtils.isNotBlank(createdBy)) { | |
| 92 | + criteria.andEqualTo(Category.CREATED_BY, createdBy); | |
| 93 | + } | |
| 94 | + | |
| 95 | + | |
| 96 | + return example; | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * 分页数据处理 | |
| 101 | + */ | |
| 102 | + private void packCategoryData(List<Category> categoryList) { | |
| 103 | + if (CollectionUtils.isEmpty(categoryList)) { | |
| 104 | + return; | |
| 105 | + } | |
| 106 | + | |
| 107 | + dealReferInfo(categoryList); | |
| 108 | + } | |
| 109 | + | |
| 110 | + private void dealReferInfo(Category category) { | |
| 111 | + List<Category> categoryList = Collections.singletonList(category); | |
| 112 | + dealReferInfo(categoryList); | |
| 113 | + } | |
| 114 | + | |
| 115 | + private void dealReferInfo(List<Category> categoryList) { | |
| 116 | + dealUserRel(categoryList); | |
| 117 | + } | |
| 118 | + | |
| 119 | + private void dealUserRel(List<Category> categoryList) { | |
| 120 | + //处理人员 | |
| 121 | + List<String> userIds = categoryList.stream().map(Category::getUpdatedBy).collect(Collectors.toList()); | |
| 122 | + userIds.addAll(categoryList.stream().map(Category::getCreatedBy).collect(Collectors.toList())); | |
| 123 | + Map<String, String> userMap = ucFeignClient.getUserIdAndNameMap(userIds); | |
| 124 | + for (Category category : categoryList) { | |
| 125 | + //处理人员 | |
| 126 | + if (MapUtils.isNotEmpty(userMap)) { | |
| 127 | + category.setCreatedByName(userMap.get(category.getCreatedBy())); | |
| 128 | + category.setUpdatedByName(userMap.get(category.getUpdatedBy())); | |
| 129 | + } | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | + | |
| 134 | + @Override | |
| 135 | + public Category get(String id) { | |
| 136 | + Category category = super.get(id); | |
| 137 | + dealReferInfo(category); | |
| 138 | + return category; | |
| 139 | + } | |
| 140 | + | |
| 141 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 142 | + public List<String> listIdsByExample(Category category) { | |
| 143 | + Assert.notNull(category, "category can not be null"); | |
| 144 | + Example example = genConditionExample(category); | |
| 145 | + example.selectProperties(Category.ID); | |
| 146 | + List<Category> categoryList = categoryMapper.selectByExample(example); | |
| 147 | + return CollectionUtils.isEmpty(categoryList) ? new ArrayList<>(0) : | |
| 148 | + categoryList.stream().map(Category::getId).collect(Collectors.toList()); | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * 新增 | |
| 153 | + */ | |
| 154 | + public String add(Category category) { | |
| 155 | + return super.insert(category); | |
| 156 | + } | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * 修改 | |
| 160 | + */ | |
| 161 | + public void edit(Category category) { | |
| 162 | + super.update(category); | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * 批量删除 | |
| 167 | + */ | |
| 168 | + public void deleteByIds(List<String> ids) { | |
| 169 | + super.batchDelete(ids); | |
| 170 | + } | |
| 171 | + | |
| 172 | + @Override | |
| 173 | + protected List<? extends BaseRowModel> getExcelDataList(List<Category> sourceList) { | |
| 174 | + return gson.fromJson(gson.toJson(sourceList), new TypeToken<ArrayList<CategoryExportData>>() { | |
| 175 | + }.getType()); | |
| 176 | + } | |
| 177 | + | |
| 178 | + @Override | |
| 179 | + protected Page<Category> searchForExport(Category sourceCondition, Page<Category> page) { | |
| 180 | + return search(sourceCondition,page); | |
| 181 | + } | |
| 182 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.service; | |
| 2 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 3 | +import com.google.gson.reflect.TypeToken; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.*; | |
| 5 | +import com.qgutech.qgyun.dev.client.uc.UcFeignClient; | |
| 6 | +import com.qgutech.qgyun.framework.common.utils.SqlUtil; | |
| 7 | +import com.qgutech.qgyun.framework.database.model.BaseModel; | |
| 8 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.exportmodel.FileRelExportData; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.service.impl.base.AbstractExportBaseServiceImpl; | |
| 11 | +import com.qgutech.qgyun.xieyunhui.mapper.FileRelMapper; | |
| 12 | +import org.apache.commons.collections4.MapUtils; | |
| 13 | +import org.apache.commons.lang.StringUtils; | |
| 14 | +import org.apache.commons.collections4.CollectionUtils; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Isolation; | |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 18 | +import tk.mybatis.mapper.entity.Example; | |
| 19 | +import tk.mybatis.mapper.util.Assert; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import java.time.LocalDate; | |
| 23 | +import java.time.LocalDateTime; | |
| 24 | +import java.util.*; | |
| 25 | +import java.util.stream.Collectors; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * FileRelService 服务提供类 | |
| 29 | + * | |
| 30 | + * @author auto | |
| 31 | + * @version 1.0 | |
| 32 | + * @since 2021-01-29 17:02:05 | |
| 33 | + */ | |
| 34 | +@Service | |
| 35 | +public class FileRelService extends AbstractExportBaseServiceImpl<FileRel> { | |
| 36 | + @Resource | |
| 37 | + private FileRelMapper fileRelMapper; | |
| 38 | + @Resource | |
| 39 | + private UcFeignClient ucFeignClient; | |
| 40 | + | |
| 41 | + public List<FileRel> listAll() { | |
| 42 | + return fileRelMapper.selectAll(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 46 | + public Page<FileRel> search(FileRel fileRel, Page<FileRel> page) { | |
| 47 | + Assert.notNull(fileRel, "fileRel can not be null!"); | |
| 48 | + Example example = genConditionExample(fileRel); | |
| 49 | + BaseModel.Sort sort = fileRel.getSort(); | |
| 50 | + if (sort != null) { | |
| 51 | + String orderBy = sort.getOrderBy(); | |
| 52 | + if (sort.isAsc()) { | |
| 53 | + example.orderBy(orderBy).asc(); | |
| 54 | + } else { | |
| 55 | + example.orderBy(orderBy).desc(); | |
| 56 | + } | |
| 57 | + } else { | |
| 58 | + example.orderBy(FileRel.UPDATED_AT).desc(); | |
| 59 | + } | |
| 60 | + | |
| 61 | + page = search(example, page); | |
| 62 | + List<FileRel> list = page.getList(); | |
| 63 | + if (CollectionUtils.isEmpty(list)) { | |
| 64 | + return page; | |
| 65 | + } | |
| 66 | + | |
| 67 | + page = new Page<>(list); | |
| 68 | + packFileRelData(list); | |
| 69 | + return page; | |
| 70 | + } | |
| 71 | + | |
| 72 | + private Example genConditionExample(FileRel model) { | |
| 73 | + Example example = new Example(entityClass); | |
| 74 | + Example.Criteria criteria = example.createCriteria(); | |
| 75 | + List<String> referIds = model.getReferIds(); | |
| 76 | + if (CollectionUtils.isNotEmpty(referIds)) { | |
| 77 | + criteria.andIn(FileRel.REFER_ID, referIds); | |
| 78 | + } | |
| 79 | + | |
| 80 | + String id = model.getId(); | |
| 81 | + if (StringUtils.isNotBlank(id)) { | |
| 82 | + criteria.andEqualTo(FileRel.ID, id); | |
| 83 | + } | |
| 84 | + | |
| 85 | + String referId = model.getReferId(); | |
| 86 | + if (StringUtils.isNotBlank(referId)) { | |
| 87 | + criteria.andEqualTo(FileRel.REFER_ID, referId); | |
| 88 | + } | |
| 89 | + | |
| 90 | + String funCode = model.getFunCode(); | |
| 91 | + if (StringUtils.isNotBlank(funCode)) { | |
| 92 | + criteria.andEqualTo(FileRel.FUN_CODE, funCode); | |
| 93 | + } | |
| 94 | + | |
| 95 | + String fieldName = model.getFieldName(); | |
| 96 | + if (StringUtils.isNotBlank(fieldName)) { | |
| 97 | + criteria.andEqualTo(FileRel.FIELD_NAME, fieldName); | |
| 98 | + } | |
| 99 | + | |
| 100 | + String corpCode = model.getCorpCode(); | |
| 101 | + if (StringUtils.isNotBlank(corpCode)) { | |
| 102 | + criteria.andEqualTo(FileRel.CORP_CODE, corpCode); | |
| 103 | + } | |
| 104 | + | |
| 105 | + LocalDateTime createdAt = model.getCreatedAt(); | |
| 106 | + if (null != createdAt) { | |
| 107 | + criteria.andEqualTo(FileRel.CREATED_AT, createdAt); | |
| 108 | + } | |
| 109 | + | |
| 110 | + LocalDateTime updatedAt = model.getUpdatedAt(); | |
| 111 | + if (null != updatedAt) { | |
| 112 | + criteria.andEqualTo(FileRel.UPDATED_AT, updatedAt); | |
| 113 | + } | |
| 114 | + | |
| 115 | + String createdBy = model.getCreatedBy(); | |
| 116 | + if (StringUtils.isNotBlank(createdBy)) { | |
| 117 | + criteria.andEqualTo(FileRel.CREATED_BY, createdBy); | |
| 118 | + } | |
| 119 | + | |
| 120 | + String updatedBy = model.getUpdatedBy(); | |
| 121 | + if (StringUtils.isNotBlank(updatedBy)) { | |
| 122 | + criteria.andEqualTo(FileRel.UPDATED_BY, updatedBy); | |
| 123 | + } | |
| 124 | + | |
| 125 | + String fileId = model.getFileId(); | |
| 126 | + if (StringUtils.isNotBlank(fileId)) { | |
| 127 | + criteria.andEqualTo(FileRel.FILE_ID, fileId); | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 131 | + return example; | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * 分页数据处理 | |
| 136 | + */ | |
| 137 | + private void packFileRelData(List<FileRel> fileRelList) { | |
| 138 | + if (CollectionUtils.isEmpty(fileRelList)) { | |
| 139 | + return; | |
| 140 | + } | |
| 141 | + | |
| 142 | + dealReferInfo(fileRelList); | |
| 143 | + } | |
| 144 | + | |
| 145 | + private void dealReferInfo(FileRel fileRel) { | |
| 146 | + List<FileRel> fileRelList = Collections.singletonList(fileRel); | |
| 147 | + dealReferInfo(fileRelList); | |
| 148 | + } | |
| 149 | + | |
| 150 | + private void dealReferInfo(List<FileRel> fileRelList) { | |
| 151 | + dealUserRel(fileRelList); | |
| 152 | + } | |
| 153 | + | |
| 154 | + private void dealUserRel(List<FileRel> fileRelList) { | |
| 155 | + //处理人员 | |
| 156 | + List<String> userIds = fileRelList.stream().map(FileRel::getUpdatedBy).collect(Collectors.toList()); | |
| 157 | + userIds.addAll(fileRelList.stream().map(FileRel::getCreatedBy).collect(Collectors.toList())); | |
| 158 | + Map<String, String> userMap = ucFeignClient.getUserIdAndNameMap(userIds); | |
| 159 | + for (FileRel fileRel : fileRelList) { | |
| 160 | + //处理人员 | |
| 161 | + if (MapUtils.isNotEmpty(userMap)) { | |
| 162 | + fileRel.setCreatedByName(userMap.get(fileRel.getCreatedBy())); | |
| 163 | + fileRel.setUpdatedByName(userMap.get(fileRel.getUpdatedBy())); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + @Override | |
| 170 | + public FileRel get(String id) { | |
| 171 | + FileRel fileRel = super.get(id); | |
| 172 | + dealReferInfo(fileRel); | |
| 173 | + return fileRel; | |
| 174 | + } | |
| 175 | + | |
| 176 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 177 | + public List<String> listIdsByExample(FileRel fileRel) { | |
| 178 | + Assert.notNull(fileRel, "fileRel can not be null"); | |
| 179 | + Example example = genConditionExample(fileRel); | |
| 180 | + example.selectProperties(FileRel.ID); | |
| 181 | + List<FileRel> fileRelList = fileRelMapper.selectByExample(example); | |
| 182 | + return CollectionUtils.isEmpty(fileRelList) ? new ArrayList<>(0) : | |
| 183 | + fileRelList.stream().map(FileRel::getId).collect(Collectors.toList()); | |
| 184 | + } | |
| 185 | + | |
| 186 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 187 | + public Map<String, List<FileRel>> listReferIdMap(FileRel fileRel) { | |
| 188 | + Assert.notNull(fileRel, "fileRel can not be null"); | |
| 189 | + Example example = genConditionExample(fileRel); | |
| 190 | + example.selectProperties(FileRel.REFER_ID, FileRel.FIELD_NAME, FileRel.FILE_ID); | |
| 191 | + List<FileRel> fileRelList = fileRelMapper.selectByExample(example); | |
| 192 | + return CollectionUtils.isEmpty(fileRelList) ? Collections.emptyMap(): | |
| 193 | + fileRelList.stream().collect(Collectors.groupingBy(FileRel::getReferId)); | |
| 194 | + } | |
| 195 | + | |
| 196 | + /** | |
| 197 | + * 新增 | |
| 198 | + */ | |
| 199 | + public String add(FileRel fileRel) { | |
| 200 | + return super.insert(fileRel); | |
| 201 | + } | |
| 202 | + | |
| 203 | + /** | |
| 204 | + * 修改 | |
| 205 | + */ | |
| 206 | + public void edit(FileRel fileRel) { | |
| 207 | + super.update(fileRel); | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 211 | + * 批量删除 | |
| 212 | + */ | |
| 213 | + public void deleteByIds(List<String> ids) { | |
| 214 | + super.batchDelete(ids); | |
| 215 | + } | |
| 216 | + | |
| 217 | + @Override | |
| 218 | + protected List<? extends BaseRowModel> getExcelDataList(List<FileRel> sourceList) { | |
| 219 | + return gson.fromJson(gson.toJson(sourceList), new TypeToken<ArrayList<FileRelExportData>>() { | |
| 220 | + }.getType()); | |
| 221 | + } | |
| 222 | + | |
| 223 | + @Override | |
| 224 | + protected Page<FileRel> searchForExport(FileRel sourceCondition, Page<FileRel> page) { | |
| 225 | + return search(sourceCondition,page); | |
| 226 | + } | |
| 227 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.service; | |
| 2 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 3 | +import com.google.gson.reflect.TypeToken; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.*; | |
| 5 | +import com.qgutech.qgyun.dev.client.uc.UcFeignClient; | |
| 6 | +import com.qgutech.qgyun.framework.common.utils.SqlUtil; | |
| 7 | +import com.qgutech.qgyun.framework.database.model.BaseModel; | |
| 8 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.exportmodel.OrgRelExportData; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.service.impl.base.AbstractExportBaseServiceImpl; | |
| 11 | +import com.qgutech.qgyun.xieyunhui.mapper.OrgRelMapper; | |
| 12 | +import org.apache.commons.collections4.MapUtils; | |
| 13 | +import org.apache.commons.lang.StringUtils; | |
| 14 | +import org.apache.commons.collections4.CollectionUtils; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Isolation; | |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 18 | +import tk.mybatis.mapper.entity.Example; | |
| 19 | +import tk.mybatis.mapper.util.Assert; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import java.time.LocalDate; | |
| 23 | +import java.time.LocalDateTime; | |
| 24 | +import java.util.*; | |
| 25 | +import java.util.stream.Collectors; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * OrgRelService 服务提供类 | |
| 29 | + * | |
| 30 | + * @author auto | |
| 31 | + * @version 1.0 | |
| 32 | + * @since 2021-01-29 17:02:05 | |
| 33 | + */ | |
| 34 | +@Service | |
| 35 | +public class OrgRelService extends AbstractExportBaseServiceImpl<OrgRel> { | |
| 36 | + @Resource | |
| 37 | + private OrgRelMapper orgRelMapper; | |
| 38 | + @Resource | |
| 39 | + private UcFeignClient ucFeignClient; | |
| 40 | + | |
| 41 | + public List<OrgRel> listAll() { | |
| 42 | + return orgRelMapper.selectAll(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 46 | + public Page<OrgRel> search(OrgRel orgRel, Page<OrgRel> page) { | |
| 47 | + Assert.notNull(orgRel, "orgRel can not be null!"); | |
| 48 | + Example example = genConditionExample(orgRel); | |
| 49 | + BaseModel.Sort sort = orgRel.getSort(); | |
| 50 | + if (sort != null) { | |
| 51 | + String orderBy = sort.getOrderBy(); | |
| 52 | + if (sort.isAsc()) { | |
| 53 | + example.orderBy(orderBy).asc(); | |
| 54 | + } else { | |
| 55 | + example.orderBy(orderBy).desc(); | |
| 56 | + } | |
| 57 | + } else { | |
| 58 | + example.orderBy(OrgRel.UPDATED_AT).desc(); | |
| 59 | + } | |
| 60 | + | |
| 61 | + page = search(example, page); | |
| 62 | + List<OrgRel> list = page.getList(); | |
| 63 | + if (CollectionUtils.isEmpty(list)) { | |
| 64 | + return page; | |
| 65 | + } | |
| 66 | + | |
| 67 | + page = new Page<>(list); | |
| 68 | + packOrgRelData(list); | |
| 69 | + return page; | |
| 70 | + } | |
| 71 | + | |
| 72 | + private Example genConditionExample(OrgRel model) { | |
| 73 | + Example example = new Example(entityClass); | |
| 74 | + Example.Criteria criteria = example.createCriteria(); | |
| 75 | + List<String> referIds = model.getReferIds(); | |
| 76 | + if (CollectionUtils.isNotEmpty(referIds)) { | |
| 77 | + criteria.andIn(OrgRel.REFER_ID, referIds); | |
| 78 | + } | |
| 79 | + | |
| 80 | + String id = model.getId(); | |
| 81 | + if (StringUtils.isNotBlank(id)) { | |
| 82 | + criteria.andEqualTo(OrgRel.ID, id); | |
| 83 | + } | |
| 84 | + | |
| 85 | + String referId = model.getReferId(); | |
| 86 | + if (StringUtils.isNotBlank(referId)) { | |
| 87 | + criteria.andEqualTo(OrgRel.REFER_ID, referId); | |
| 88 | + } | |
| 89 | + | |
| 90 | + String funCode = model.getFunCode(); | |
| 91 | + if (StringUtils.isNotBlank(funCode)) { | |
| 92 | + criteria.andEqualTo(OrgRel.FUN_CODE, funCode); | |
| 93 | + } | |
| 94 | + | |
| 95 | + String fieldName = model.getFieldName(); | |
| 96 | + if (StringUtils.isNotBlank(fieldName)) { | |
| 97 | + criteria.andEqualTo(OrgRel.FIELD_NAME, fieldName); | |
| 98 | + } | |
| 99 | + | |
| 100 | + String corpCode = model.getCorpCode(); | |
| 101 | + if (StringUtils.isNotBlank(corpCode)) { | |
| 102 | + criteria.andEqualTo(OrgRel.CORP_CODE, corpCode); | |
| 103 | + } | |
| 104 | + | |
| 105 | + LocalDateTime createdAt = model.getCreatedAt(); | |
| 106 | + if (null != createdAt) { | |
| 107 | + criteria.andEqualTo(OrgRel.CREATED_AT, createdAt); | |
| 108 | + } | |
| 109 | + | |
| 110 | + LocalDateTime updatedAt = model.getUpdatedAt(); | |
| 111 | + if (null != updatedAt) { | |
| 112 | + criteria.andEqualTo(OrgRel.UPDATED_AT, updatedAt); | |
| 113 | + } | |
| 114 | + | |
| 115 | + String createdBy = model.getCreatedBy(); | |
| 116 | + if (StringUtils.isNotBlank(createdBy)) { | |
| 117 | + criteria.andEqualTo(OrgRel.CREATED_BY, createdBy); | |
| 118 | + } | |
| 119 | + | |
| 120 | + String updatedBy = model.getUpdatedBy(); | |
| 121 | + if (StringUtils.isNotBlank(updatedBy)) { | |
| 122 | + criteria.andEqualTo(OrgRel.UPDATED_BY, updatedBy); | |
| 123 | + } | |
| 124 | + | |
| 125 | + String orgId = model.getOrgId(); | |
| 126 | + if (StringUtils.isNotBlank(orgId)) { | |
| 127 | + criteria.andEqualTo(OrgRel.ORG_ID, orgId); | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 131 | + return example; | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * 分页数据处理 | |
| 136 | + */ | |
| 137 | + private void packOrgRelData(List<OrgRel> orgRelList) { | |
| 138 | + if (CollectionUtils.isEmpty(orgRelList)) { | |
| 139 | + return; | |
| 140 | + } | |
| 141 | + | |
| 142 | + dealReferInfo(orgRelList); | |
| 143 | + } | |
| 144 | + | |
| 145 | + private void dealReferInfo(OrgRel orgRel) { | |
| 146 | + List<OrgRel> orgRelList = Collections.singletonList(orgRel); | |
| 147 | + dealReferInfo(orgRelList); | |
| 148 | + } | |
| 149 | + | |
| 150 | + private void dealReferInfo(List<OrgRel> orgRelList) { | |
| 151 | + dealUserRel(orgRelList); | |
| 152 | + } | |
| 153 | + | |
| 154 | + private void dealUserRel(List<OrgRel> orgRelList) { | |
| 155 | + //处理人员 | |
| 156 | + List<String> userIds = orgRelList.stream().map(OrgRel::getUpdatedBy).collect(Collectors.toList()); | |
| 157 | + userIds.addAll(orgRelList.stream().map(OrgRel::getCreatedBy).collect(Collectors.toList())); | |
| 158 | + Map<String, String> userMap = ucFeignClient.getUserIdAndNameMap(userIds); | |
| 159 | + for (OrgRel orgRel : orgRelList) { | |
| 160 | + //处理人员 | |
| 161 | + if (MapUtils.isNotEmpty(userMap)) { | |
| 162 | + orgRel.setCreatedByName(userMap.get(orgRel.getCreatedBy())); | |
| 163 | + orgRel.setUpdatedByName(userMap.get(orgRel.getUpdatedBy())); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + @Override | |
| 170 | + public OrgRel get(String id) { | |
| 171 | + OrgRel orgRel = super.get(id); | |
| 172 | + dealReferInfo(orgRel); | |
| 173 | + return orgRel; | |
| 174 | + } | |
| 175 | + | |
| 176 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 177 | + public List<String> listIdsByExample(OrgRel orgRel) { | |
| 178 | + Assert.notNull(orgRel, "orgRel can not be null"); | |
| 179 | + Example example = genConditionExample(orgRel); | |
| 180 | + example.selectProperties(OrgRel.ID); | |
| 181 | + List<OrgRel> orgRelList = orgRelMapper.selectByExample(example); | |
| 182 | + return CollectionUtils.isEmpty(orgRelList) ? new ArrayList<>(0) : | |
| 183 | + orgRelList.stream().map(OrgRel::getId).collect(Collectors.toList()); | |
| 184 | + } | |
| 185 | + | |
| 186 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 187 | + public Map<String, List<OrgRel>> listReferIdMap(OrgRel orgRel) { | |
| 188 | + Assert.notNull(orgRel, "orgRel can not be null"); | |
| 189 | + Example example = genConditionExample(orgRel); | |
| 190 | + example.selectProperties(OrgRel.REFER_ID, OrgRel.FIELD_NAME, OrgRel.ORG_ID); | |
| 191 | + List<OrgRel> orgRelList = orgRelMapper.selectByExample(example); | |
| 192 | + return CollectionUtils.isEmpty(orgRelList) ? Collections.emptyMap(): | |
| 193 | + orgRelList.stream().collect(Collectors.groupingBy(OrgRel::getReferId)); | |
| 194 | + } | |
| 195 | + | |
| 196 | + /** | |
| 197 | + * 新增 | |
| 198 | + */ | |
| 199 | + public String add(OrgRel orgRel) { | |
| 200 | + return super.insert(orgRel); | |
| 201 | + } | |
| 202 | + | |
| 203 | + /** | |
| 204 | + * 修改 | |
| 205 | + */ | |
| 206 | + public void edit(OrgRel orgRel) { | |
| 207 | + super.update(orgRel); | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 211 | + * 批量删除 | |
| 212 | + */ | |
| 213 | + public void deleteByIds(List<String> ids) { | |
| 214 | + super.batchDelete(ids); | |
| 215 | + } | |
| 216 | + | |
| 217 | + @Override | |
| 218 | + protected List<? extends BaseRowModel> getExcelDataList(List<OrgRel> sourceList) { | |
| 219 | + return gson.fromJson(gson.toJson(sourceList), new TypeToken<ArrayList<OrgRelExportData>>() { | |
| 220 | + }.getType()); | |
| 221 | + } | |
| 222 | + | |
| 223 | + @Override | |
| 224 | + protected Page<OrgRel> searchForExport(OrgRel sourceCondition, Page<OrgRel> page) { | |
| 225 | + return search(sourceCondition,page); | |
| 226 | + } | |
| 227 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.service; | |
| 2 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 3 | +import com.google.gson.reflect.TypeToken; | |
| 4 | +import com.qgutech.qgyun.xieyunhui.model.*; | |
| 5 | +import com.qgutech.qgyun.dev.client.uc.UcFeignClient; | |
| 6 | +import com.qgutech.qgyun.framework.common.utils.SqlUtil; | |
| 7 | +import com.qgutech.qgyun.framework.database.model.BaseModel; | |
| 8 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 9 | +import com.qgutech.qgyun.xieyunhui.exportmodel.UserRelExportData; | |
| 10 | +import com.qgutech.qgyun.xieyunhui.service.impl.base.AbstractExportBaseServiceImpl; | |
| 11 | +import com.qgutech.qgyun.xieyunhui.mapper.UserRelMapper; | |
| 12 | +import org.apache.commons.collections4.MapUtils; | |
| 13 | +import org.apache.commons.lang.StringUtils; | |
| 14 | +import org.apache.commons.collections4.CollectionUtils; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Isolation; | |
| 17 | +import org.springframework.transaction.annotation.Transactional; | |
| 18 | +import tk.mybatis.mapper.entity.Example; | |
| 19 | +import tk.mybatis.mapper.util.Assert; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import java.time.LocalDate; | |
| 23 | +import java.time.LocalDateTime; | |
| 24 | +import java.util.*; | |
| 25 | +import java.util.stream.Collectors; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * UserRelService 服务提供类 | |
| 29 | + * | |
| 30 | + * @author auto | |
| 31 | + * @version 1.0 | |
| 32 | + * @since 2021-01-29 17:02:05 | |
| 33 | + */ | |
| 34 | +@Service | |
| 35 | +public class UserRelService extends AbstractExportBaseServiceImpl<UserRel> { | |
| 36 | + @Resource | |
| 37 | + private UserRelMapper userRelMapper; | |
| 38 | + @Resource | |
| 39 | + private UcFeignClient ucFeignClient; | |
| 40 | + | |
| 41 | + public List<UserRel> listAll() { | |
| 42 | + return userRelMapper.selectAll(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 46 | + public Page<UserRel> search(UserRel userRel, Page<UserRel> page) { | |
| 47 | + Assert.notNull(userRel, "userRel can not be null!"); | |
| 48 | + Example example = genConditionExample(userRel); | |
| 49 | + BaseModel.Sort sort = userRel.getSort(); | |
| 50 | + if (sort != null) { | |
| 51 | + String orderBy = sort.getOrderBy(); | |
| 52 | + if (sort.isAsc()) { | |
| 53 | + example.orderBy(orderBy).asc(); | |
| 54 | + } else { | |
| 55 | + example.orderBy(orderBy).desc(); | |
| 56 | + } | |
| 57 | + } else { | |
| 58 | + example.orderBy(UserRel.UPDATED_AT).desc(); | |
| 59 | + } | |
| 60 | + | |
| 61 | + page = search(example, page); | |
| 62 | + List<UserRel> list = page.getList(); | |
| 63 | + if (CollectionUtils.isEmpty(list)) { | |
| 64 | + return page; | |
| 65 | + } | |
| 66 | + | |
| 67 | + page = new Page<>(list); | |
| 68 | + packUserRelData(list); | |
| 69 | + return page; | |
| 70 | + } | |
| 71 | + | |
| 72 | + private Example genConditionExample(UserRel model) { | |
| 73 | + Example example = new Example(entityClass); | |
| 74 | + Example.Criteria criteria = example.createCriteria(); | |
| 75 | + List<String> referIds = model.getReferIds(); | |
| 76 | + if (CollectionUtils.isNotEmpty(referIds)) { | |
| 77 | + criteria.andIn(UserRel.REFER_ID, referIds); | |
| 78 | + } | |
| 79 | + | |
| 80 | + String id = model.getId(); | |
| 81 | + if (StringUtils.isNotBlank(id)) { | |
| 82 | + criteria.andEqualTo(UserRel.ID, id); | |
| 83 | + } | |
| 84 | + | |
| 85 | + String referId = model.getReferId(); | |
| 86 | + if (StringUtils.isNotBlank(referId)) { | |
| 87 | + criteria.andEqualTo(UserRel.REFER_ID, referId); | |
| 88 | + } | |
| 89 | + | |
| 90 | + String funCode = model.getFunCode(); | |
| 91 | + if (StringUtils.isNotBlank(funCode)) { | |
| 92 | + criteria.andEqualTo(UserRel.FUN_CODE, funCode); | |
| 93 | + } | |
| 94 | + | |
| 95 | + String fieldName = model.getFieldName(); | |
| 96 | + if (StringUtils.isNotBlank(fieldName)) { | |
| 97 | + criteria.andEqualTo(UserRel.FIELD_NAME, fieldName); | |
| 98 | + } | |
| 99 | + | |
| 100 | + String corpCode = model.getCorpCode(); | |
| 101 | + if (StringUtils.isNotBlank(corpCode)) { | |
| 102 | + criteria.andEqualTo(UserRel.CORP_CODE, corpCode); | |
| 103 | + } | |
| 104 | + | |
| 105 | + LocalDateTime createdAt = model.getCreatedAt(); | |
| 106 | + if (null != createdAt) { | |
| 107 | + criteria.andEqualTo(UserRel.CREATED_AT, createdAt); | |
| 108 | + } | |
| 109 | + | |
| 110 | + LocalDateTime updatedAt = model.getUpdatedAt(); | |
| 111 | + if (null != updatedAt) { | |
| 112 | + criteria.andEqualTo(UserRel.UPDATED_AT, updatedAt); | |
| 113 | + } | |
| 114 | + | |
| 115 | + String createdBy = model.getCreatedBy(); | |
| 116 | + if (StringUtils.isNotBlank(createdBy)) { | |
| 117 | + criteria.andEqualTo(UserRel.CREATED_BY, createdBy); | |
| 118 | + } | |
| 119 | + | |
| 120 | + String updatedBy = model.getUpdatedBy(); | |
| 121 | + if (StringUtils.isNotBlank(updatedBy)) { | |
| 122 | + criteria.andEqualTo(UserRel.UPDATED_BY, updatedBy); | |
| 123 | + } | |
| 124 | + | |
| 125 | + String userId = model.getUserId(); | |
| 126 | + if (StringUtils.isNotBlank(userId)) { | |
| 127 | + criteria.andEqualTo(UserRel.USER_ID, userId); | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 131 | + return example; | |
| 132 | + } | |
| 133 | + | |
| 134 | + /** | |
| 135 | + * 分页数据处理 | |
| 136 | + */ | |
| 137 | + private void packUserRelData(List<UserRel> userRelList) { | |
| 138 | + if (CollectionUtils.isEmpty(userRelList)) { | |
| 139 | + return; | |
| 140 | + } | |
| 141 | + | |
| 142 | + dealReferInfo(userRelList); | |
| 143 | + } | |
| 144 | + | |
| 145 | + private void dealReferInfo(UserRel userRel) { | |
| 146 | + List<UserRel> userRelList = Collections.singletonList(userRel); | |
| 147 | + dealReferInfo(userRelList); | |
| 148 | + } | |
| 149 | + | |
| 150 | + private void dealReferInfo(List<UserRel> userRelList) { | |
| 151 | + dealUserRel(userRelList); | |
| 152 | + } | |
| 153 | + | |
| 154 | + private void dealUserRel(List<UserRel> userRelList) { | |
| 155 | + //处理人员 | |
| 156 | + List<String> userIds = userRelList.stream().map(UserRel::getUpdatedBy).collect(Collectors.toList()); | |
| 157 | + userIds.addAll(userRelList.stream().map(UserRel::getCreatedBy).collect(Collectors.toList())); | |
| 158 | + Map<String, String> userMap = ucFeignClient.getUserIdAndNameMap(userIds); | |
| 159 | + for (UserRel userRel : userRelList) { | |
| 160 | + //处理人员 | |
| 161 | + if (MapUtils.isNotEmpty(userMap)) { | |
| 162 | + userRel.setCreatedByName(userMap.get(userRel.getCreatedBy())); | |
| 163 | + userRel.setUpdatedByName(userMap.get(userRel.getUpdatedBy())); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + @Override | |
| 170 | + public UserRel get(String id) { | |
| 171 | + UserRel userRel = super.get(id); | |
| 172 | + dealReferInfo(userRel); | |
| 173 | + return userRel; | |
| 174 | + } | |
| 175 | + | |
| 176 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 177 | + public List<String> listIdsByExample(UserRel userRel) { | |
| 178 | + Assert.notNull(userRel, "userRel can not be null"); | |
| 179 | + Example example = genConditionExample(userRel); | |
| 180 | + example.selectProperties(UserRel.ID); | |
| 181 | + List<UserRel> userRelList = userRelMapper.selectByExample(example); | |
| 182 | + return CollectionUtils.isEmpty(userRelList) ? new ArrayList<>(0) : | |
| 183 | + userRelList.stream().map(UserRel::getId).collect(Collectors.toList()); | |
| 184 | + } | |
| 185 | + | |
| 186 | + @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) | |
| 187 | + public Map<String, List<UserRel>> listReferIdMap(UserRel userRel) { | |
| 188 | + Assert.notNull(userRel, "userRel can not be null"); | |
| 189 | + Example example = genConditionExample(userRel); | |
| 190 | + example.selectProperties(UserRel.REFER_ID, UserRel.FIELD_NAME, UserRel.USER_ID); | |
| 191 | + List<UserRel> userRelList = userRelMapper.selectByExample(example); | |
| 192 | + return CollectionUtils.isEmpty(userRelList) ? Collections.emptyMap(): | |
| 193 | + userRelList.stream().collect(Collectors.groupingBy(UserRel::getReferId)); | |
| 194 | + } | |
| 195 | + | |
| 196 | + /** | |
| 197 | + * 新增 | |
| 198 | + */ | |
| 199 | + public String add(UserRel userRel) { | |
| 200 | + return super.insert(userRel); | |
| 201 | + } | |
| 202 | + | |
| 203 | + /** | |
| 204 | + * 修改 | |
| 205 | + */ | |
| 206 | + public void edit(UserRel userRel) { | |
| 207 | + super.update(userRel); | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 211 | + * 批量删除 | |
| 212 | + */ | |
| 213 | + public void deleteByIds(List<String> ids) { | |
| 214 | + super.batchDelete(ids); | |
| 215 | + } | |
| 216 | + | |
| 217 | + @Override | |
| 218 | + protected List<? extends BaseRowModel> getExcelDataList(List<UserRel> sourceList) { | |
| 219 | + return gson.fromJson(gson.toJson(sourceList), new TypeToken<ArrayList<UserRelExportData>>() { | |
| 220 | + }.getType()); | |
| 221 | + } | |
| 222 | + | |
| 223 | + @Override | |
| 224 | + protected Page<UserRel> searchForExport(UserRel sourceCondition, Page<UserRel> page) { | |
| 225 | + return search(sourceCondition,page); | |
| 226 | + } | |
| 227 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.service.impl.base; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.metadata.BaseRowModel; | |
| 4 | +import com.google.gson.Gson; | |
| 5 | +import com.google.gson.GsonBuilder; | |
| 6 | +import com.qgutech.qgyun.framework.common.utils.excel.ExcelWriterFactory; | |
| 7 | +import com.qgutech.qgyun.framework.common.utils.excel.ExportExcelUtil; | |
| 8 | +import com.qgutech.qgyun.framework.database.model.BaseModel; | |
| 9 | +import com.qgutech.qgyun.framework.database.mybatis.model.Page; | |
| 10 | +import com.qgutech.qgyun.framework.database.mybatis.service.BaseServiceImpl; | |
| 11 | +import lombok.extern.slf4j.Slf4j; | |
| 12 | +import org.springframework.beans.factory.annotation.Value; | |
| 13 | + | |
| 14 | +import java.util.ArrayList; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +/** | |
| 18 | +* 导出基本服务抽象实现类 | |
| 19 | +* | |
| 20 | +* @author auto | |
| 21 | +* @version 1.0 | |
| 22 | +* @since 2021-01-29 17:02:04 | |
| 23 | +*/ | |
| 24 | +@Slf4j | |
| 25 | +public abstract class AbstractExportBaseServiceImpl<T extends BaseModel> extends BaseServiceImpl<T> { | |
| 26 | + | |
| 27 | + @Value("${export.system.path:/tmp/download/}") | |
| 28 | + private String exportPath; | |
| 29 | + | |
| 30 | + protected Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 获取下载路径 | |
| 34 | + * | |
| 35 | + * @return | |
| 36 | + */ | |
| 37 | + protected String getDownLoadPath() { | |
| 38 | + return exportPath; | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 获取分页的大小 | |
| 43 | + * | |
| 44 | + * @return | |
| 45 | + */ | |
| 46 | + protected int getPageSize() { | |
| 47 | + return 5000; | |
| 48 | + } | |
| 49 | + | |
| 50 | + protected Page<T> searchForExport(T sourceCondition, Page<T> page) { | |
| 51 | + return search(sourceCondition, page); | |
| 52 | + } | |
| 53 | + | |
| 54 | + public String exportData(T sourceCondition, Class<? extends BaseRowModel> targetClass) { | |
| 55 | + String downloadPath = getDownLoadPath(); | |
| 56 | + ExcelWriterFactory excelWriterFactory = ExportExcelUtil.start(downloadPath); | |
| 57 | + String filePath = excelWriterFactory.getPath(); | |
| 58 | + Page<T> page = new Page<>(); | |
| 59 | + page.setPageSize(getPageSize()); | |
| 60 | + Page<T> resultPage = searchForExport(sourceCondition, page); | |
| 61 | + if (0 == resultPage.getTotal()) { | |
| 62 | + excelWriterFactory.newSheet(targetClass).write(new ArrayList<>(0)); | |
| 63 | + excelWriterFactory.finish(); | |
| 64 | + return filePath; | |
| 65 | + } | |
| 66 | + | |
| 67 | + List<? extends BaseRowModel> dataList = getExcelDataList(resultPage.getList()); | |
| 68 | + excelWriterFactory.newSheet(targetClass).write(dataList); | |
| 69 | + if (1 == resultPage.getPages()) { | |
| 70 | + excelWriterFactory.finish(); | |
| 71 | + return filePath; | |
| 72 | + } | |
| 73 | + | |
| 74 | + for (int i = 1; i < page.getPages(); i++) { | |
| 75 | + page.setPageNum(i + 1); | |
| 76 | + resultPage = searchForExport(sourceCondition, page); | |
| 77 | + dataList = getExcelDataList(resultPage.getList()); | |
| 78 | + excelWriterFactory.newSheet(targetClass).write(dataList); | |
| 79 | + } | |
| 80 | + | |
| 81 | + excelWriterFactory.finish(); | |
| 82 | + return filePath; | |
| 83 | + } | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * ali 导出数据元数据转换成导出数据必须要实现的方法 | |
| 87 | + * @param sourceList 元数据 | |
| 88 | + * @return 导出数据 | |
| 89 | + */ | |
| 90 | + protected abstract List<? extends BaseRowModel> getExcelDataList(List<T> sourceList); | |
| 91 | +} | ... | ... |
| 1 | +package com.qgutech.qgyun.xieyunhui.utils; | |
| 2 | + | |
| 3 | +import com.itextpdf.text.Document; | |
| 4 | +import com.itextpdf.text.Image; | |
| 5 | +import com.itextpdf.text.Rectangle; | |
| 6 | +import com.itextpdf.text.Utilities; | |
| 7 | +import com.itextpdf.text.pdf.PdfWriter; | |
| 8 | +import org.apache.commons.io.FileUtils; | |
| 9 | +import org.apache.commons.io.IOUtils; | |
| 10 | + | |
| 11 | +import javax.imageio.ImageIO; | |
| 12 | +import javax.servlet.http.HttpServletResponse; | |
| 13 | +import java.awt.image.BufferedImage; | |
| 14 | +import java.io.File; | |
| 15 | +import java.io.IOException; | |
| 16 | +import java.io.InputStream; | |
| 17 | +import java.io.OutputStream; | |
| 18 | +import java.net.URL; | |
| 19 | +import java.net.URLEncoder; | |
| 20 | +import java.util.Collections; | |
| 21 | +import java.util.List; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 下载文件工具类 | |
| 25 | + * | |
| 26 | + * @author auto | |
| 27 | + * @version 1.0 | |
| 28 | + * @since 2021-01-29 17:02:04 | |
| 29 | + */ | |
| 30 | +public class DownloadUtils { | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 下载excel | |
| 34 | + * | |
| 35 | + * @param filePath 文件路径 | |
| 36 | + * @param downloadFileName 下载文件名称 | |
| 37 | + */ | |
| 38 | + public static void download(String filePath, String downloadFileName, HttpServletResponse response) { | |
| 39 | + try (OutputStream output = response.getOutputStream(); | |
| 40 | + InputStream in = Utilities.toURL(filePath).openStream()) { | |
| 41 | + response.setContentType("application/force-download"); | |
| 42 | + response.setHeader("Content-Transfer-Encoding", "binary"); | |
| 43 | + response.setHeader("Content-Disposition", "attachment; filename=\"" + | |
| 44 | + URLEncoder.encode(downloadFileName, "UTF-8") + "\""); | |
| 45 | + IOUtils.copy(in, output); | |
| 46 | + response.flushBuffer(); | |
| 47 | + } catch (IOException e) { | |
| 48 | + e.printStackTrace(); | |
| 49 | + }finally { | |
| 50 | + try { | |
| 51 | + FileUtils.forceDelete(new File(filePath)); | |
| 52 | + } catch (IOException e) { | |
| 53 | + // | |
| 54 | + } | |
| 55 | + } | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 下载图片为pdf | |
| 60 | + * | |
| 61 | + * @param imagePath 图片路径 | |
| 62 | + * @param downloadFileName 下载文件名称 | |
| 63 | + */ | |
| 64 | + public static void downloadPdf(String imagePath, String downloadFileName, HttpServletResponse response) { | |
| 65 | + downloadPdf(Collections.singletonList(imagePath), downloadFileName, response); | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 批量下载图片为pdf | |
| 70 | + * | |
| 71 | + * @param imagePaths 图片路径列表 | |
| 72 | + * @param downloadFileName 下载文件名称 | |
| 73 | + */ | |
| 74 | + public static void downloadPdf(List<String> imagePaths, String downloadFileName, HttpServletResponse response) { | |
| 75 | + float margin = 0; | |
| 76 | + Document doc = null; | |
| 77 | + OutputStream os = null; | |
| 78 | + try { | |
| 79 | + response.setContentType("application/pdf"); | |
| 80 | + response.setContentType("application/x-download"); | |
| 81 | + response.addHeader("Content-Disposition", "attachment;fileName=" + | |
| 82 | + URLEncoder.encode(downloadFileName, "UTF-8") + ".pdf"); | |
| 83 | + doc = new Document(null, margin, margin, margin, margin); | |
| 84 | + URL url = Utilities.toURL(imagePaths.get(0)); | |
| 85 | + BufferedImage img = ImageIO.read(url); | |
| 86 | + doc.setPageSize(new Rectangle(img.getWidth(), img.getHeight())); | |
| 87 | + os = response.getOutputStream(); | |
| 88 | + PdfWriter.getInstance(doc, os); | |
| 89 | + doc.open(); | |
| 90 | + for (String imagePath : imagePaths) { | |
| 91 | + Image image = Image.getInstance(imagePath); | |
| 92 | + doc.add(image); | |
| 93 | + os.flush(); | |
| 94 | + } | |
| 95 | + | |
| 96 | + os.flush(); | |
| 97 | + } catch (Exception e) { | |
| 98 | + e.printStackTrace(); | |
| 99 | + } finally { | |
| 100 | + if (doc != null) { | |
| 101 | + doc.close(); | |
| 102 | + } | |
| 103 | + | |
| 104 | + IOUtils.closeQuietly(os); | |
| 105 | + } | |
| 106 | + } | |
| 107 | + | |
| 108 | +} | ... | ... |
| 1 | +server: | |
| 2 | + #配置服务器启动端口 | |
| 3 | + port: 8085 | |
| 4 | + | |
| 5 | +spring: | |
| 6 | + application: | |
| 7 | + name: qgyun-xieyunhui | |
| 8 | + datasource: | |
| 9 | + url: jdbc:mysql://192.168.0.35:3306/qgyun-online?characterEncoding=utf-8&useSSL=false | |
| 10 | + username: root | |
| 11 | + password: qgutech.com | |
| 12 | + type: com.alibaba.druid.pool.DruidDataSource | |
| 13 | + driver-class-name: com.mysql.jdbc.Driver | |
| 14 | + druid: | |
| 15 | + initialSize: 5 | |
| 16 | + minIdle: 5 | |
| 17 | + maxActive: 20 | |
| 18 | + maxWait: 60000 | |
| 19 | + timeBetweenEvictionRunsMillis: 60000 | |
| 20 | + minEvictableIdleTimeMillis: 30000 | |
| 21 | + validationQuery: SELECT 1 | |
| 22 | + testWhileIdle: true | |
| 23 | + testOnBorrow: false | |
| 24 | + testOnReturn: false | |
| 25 | + poolPreparedStatements: true | |
| 26 | + maxPoolPreparedStatementPerConnectionSize: 20 | |
| 27 | + filters: stat,wall | |
| 28 | + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 | |
| 29 | + useGlobalDataSourceStat: true | |
| 30 | + redis: | |
| 31 | + port: 6379 | |
| 32 | + host: qgyun.server.redis | |
| 33 | +swagger: | |
| 34 | + enable: true | |
| 35 | + | |
| 36 | +#mybatis配置别名 | |
| 37 | +#mapper资源地址必须为mapper文件夹下,eg:mapper/user | |
| 38 | +mybatis: | |
| 39 | + type-aliases-package: com.qgutech.xieyunhui.qgyun.**.model | |
| 40 | + | |
| 41 | +# 打印sql | |
| 42 | +logging: | |
| 43 | + level: | |
| 44 | + com.qgutech.xieyunhui.qgyun: DEBUG | |
| 45 | + | |
| 46 | +#mybatis初始配置,是读取枚举类型字段 | |
| 47 | +mapper: | |
| 48 | + enumAsSimpleType: true | |
| 49 | + | |
| 50 | +context: | |
| 51 | + keys: | |
| 52 | + - userId | |
| 53 | + - username | |
| 54 | + - corpCode | |
| 55 | + - superAdmin | |
| 56 | + - sessionId | |
| 57 | +qgyun: | |
| 58 | + dynamicDataSource: | |
| 59 | + enabled: false | |
| 60 | + | |
| 61 | +export: | |
| 62 | + system: | |
| 63 | + path: /tmp/download/ | |
| \ No newline at end of file | ... | ... |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.qgutech.qgyun.xieyunhui.mapper.BookMapper"> | |
| 4 | + <resultMap id="bookMap" type="com.qgutech.qgyun.xieyunhui.model.Book"> | |
| 5 | + <result column="id" property="id"/> | |
| 6 | + <result column="code" property="code"/> | |
| 7 | + <result column="name" property="name"/> | |
| 8 | + <result column="introduce" property="introduce"/> | |
| 9 | + <result column="showorder" property="showorder"/> | |
| 10 | + <result column="created_org" property="createdOrg"/> | |
| 11 | + <result column="corp_code" property="corpCode"/> | |
| 12 | + <result column="created_at" property="createdAt"/> | |
| 13 | + <result column="updated_at" property="updatedAt"/> | |
| 14 | + <result column="created_by" property="createdBy"/> | |
| 15 | + <result column="updated_by" property="updatedBy"/> | |
| 16 | + </resultMap> | |
| 17 | + <sql id="tableName">t_auto_xieyunhui_book book</sql> | |
| 18 | + <sql id="condition"> | |
| 19 | + <if test="con.id != null and con.id != ''"> | |
| 20 | + and book.id = #{con.id} | |
| 21 | + </if> | |
| 22 | + <if test="con.code != null and con.code != ''"> | |
| 23 | + and book.code like concat(concat('%',#{con.code}),'%') | |
| 24 | + </if> | |
| 25 | + <if test="con.name != null and con.name != ''"> | |
| 26 | + and book.name like concat(concat('%',#{con.name}),'%') | |
| 27 | + </if> | |
| 28 | + <if test="con.introduce != null and con.introduce != ''"> | |
| 29 | + and book.introduce like concat(concat('%',#{con.introduce}),'%') | |
| 30 | + </if> | |
| 31 | + <if test="con.showorderLeft != null and con.showorderRight != null"> | |
| 32 | + and book.showorder <![CDATA[ >= ]]> #{con.showorderLeft} | |
| 33 | + and book.showorder <![CDATA[ <= ]]> #{con.showorderRight} | |
| 34 | + </if> | |
| 35 | + <if test="con.createdOrgList != null and con.createdOrgList.size() != 0"> | |
| 36 | + and book.created_org in | |
| 37 | + <foreach collection="con.createdOrgList" item="id" index="index" open="(" close=")" separator=","> | |
| 38 | + #{id} | |
| 39 | + </foreach> | |
| 40 | + </if> | |
| 41 | + <if test="con.corpCode != null and con.corpCode != ''"> | |
| 42 | + and book.corp_code = #{con.corpCode} | |
| 43 | + </if> | |
| 44 | + <if test="con.createdAt != null"> | |
| 45 | + and book.created_at = #{con.createdAt} | |
| 46 | + </if> | |
| 47 | + <if test="con.updatedAt != null"> | |
| 48 | + and book.updated_at = #{con.updatedAt} | |
| 49 | + </if> | |
| 50 | + <if test="con.createdBy != null and con.createdBy != ''"> | |
| 51 | + and book.created_by = #{con.createdBy} | |
| 52 | + </if> | |
| 53 | + <if test="con.updatedBy != null and con.updatedBy != ''"> | |
| 54 | + and book.updated_by = #{con.updatedBy} | |
| 55 | + </if> | |
| 56 | + </sql> | |
| 57 | + | |
| 58 | + <select id="search" resultMap="bookMap"> | |
| 59 | + select book.* | |
| 60 | + from <include refid="tableName"/> | |
| 61 | + WHERE 1=1 <include refid="condition"/> | |
| 62 | + order by book.created_at DESC | |
| 63 | + </select> | |
| 64 | +</mapper> | |
| \ No newline at end of file | ... | ... |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.qgutech.qgyun.xieyunhui.mapper.CategoryMapper"> | |
| 4 | + <resultMap id="categoryMap" type="com.qgutech.qgyun.xieyunhui.model.Category"> | |
| 5 | + <result column="id" property="id"/> | |
| 6 | + <result column="name" property="name"/> | |
| 7 | + <result column="created_org" property="createdOrg"/> | |
| 8 | + <result column="corp_code" property="corpCode"/> | |
| 9 | + <result column="created_at" property="createdAt"/> | |
| 10 | + <result column="updated_at" property="updatedAt"/> | |
| 11 | + <result column="created_by" property="createdBy"/> | |
| 12 | + <result column="updated_by" property="updatedBy"/> | |
| 13 | + </resultMap> | |
| 14 | + <sql id="tableName">t_auto_xieyunhui_category category</sql> | |
| 15 | + <sql id="condition"> | |
| 16 | + <if test="con.id != null and con.id != ''"> | |
| 17 | + and category.id = #{con.id} | |
| 18 | + </if> | |
| 19 | + <if test="con.name != null and con.name != ''"> | |
| 20 | + and category.name like concat(concat('%',#{con.name}),'%') | |
| 21 | + </if> | |
| 22 | + <if test="con.createdOrgList != null and con.createdOrgList.size() != 0"> | |
| 23 | + and category.created_org in | |
| 24 | + <foreach collection="con.createdOrgList" item="id" index="index" open="(" close=")" separator=","> | |
| 25 | + #{id} | |
| 26 | + </foreach> | |
| 27 | + </if> | |
| 28 | + <if test="con.corpCode != null and con.corpCode != ''"> | |
| 29 | + and category.corp_code = #{con.corpCode} | |
| 30 | + </if> | |
| 31 | + <if test="con.createdAt != null"> | |
| 32 | + and category.created_at = #{con.createdAt} | |
| 33 | + </if> | |
| 34 | + <if test="con.updatedAt != null"> | |
| 35 | + and category.updated_at = #{con.updatedAt} | |
| 36 | + </if> | |
| 37 | + <if test="con.createdBy != null and con.createdBy != ''"> | |
| 38 | + and category.created_by = #{con.createdBy} | |
| 39 | + </if> | |
| 40 | + <if test="con.updatedBy != null and con.updatedBy != ''"> | |
| 41 | + and category.updated_by = #{con.updatedBy} | |
| 42 | + </if> | |
| 43 | + </sql> | |
| 44 | + | |
| 45 | + <select id="search" resultMap="categoryMap"> | |
| 46 | + select category.* | |
| 47 | + from <include refid="tableName"/> | |
| 48 | + WHERE 1=1 <include refid="condition"/> | |
| 49 | + order by category.created_at DESC | |
| 50 | + </select> | |
| 51 | +</mapper> | |
| \ No newline at end of file | ... | ... |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.qgutech.qgyun.xieyunhui.mapper.FileRelMapper"> | |
| 4 | + <resultMap id="fileRelMap" type="com.qgutech.qgyun.xieyunhui.model.FileRel"> | |
| 5 | + <result column="id" property="id"/> | |
| 6 | + <result column="refer_id" property="referId"/> | |
| 7 | + <result column="fun_code" property="funCode"/> | |
| 8 | + <result column="field_name" property="fieldName"/> | |
| 9 | + <result column="corp_code" property="corpCode"/> | |
| 10 | + <result column="created_at" property="createdAt"/> | |
| 11 | + <result column="updated_at" property="updatedAt"/> | |
| 12 | + <result column="created_by" property="createdBy"/> | |
| 13 | + <result column="updated_by" property="updatedBy"/> | |
| 14 | + <result column="file_id" property="fileId"/> | |
| 15 | + </resultMap> | |
| 16 | + <sql id="tableName">t_auto_xieyunhui_file_rel fileRel</sql> | |
| 17 | + <sql id="condition"> | |
| 18 | + <if test="con.id != null and con.id != ''"> | |
| 19 | + and fileRel.id = #{con.id} | |
| 20 | + </if> | |
| 21 | + <if test="con.referId != null and con.referId != ''"> | |
| 22 | + and fileRel.refer_id = #{con.referId} | |
| 23 | + </if> | |
| 24 | + <if test="con.funCode != null and con.funCode != ''"> | |
| 25 | + and fileRel.fun_code = #{con.funCode} | |
| 26 | + </if> | |
| 27 | + <if test="con.fieldName != null and con.fieldName != ''"> | |
| 28 | + and fileRel.field_name = #{con.fieldName} | |
| 29 | + </if> | |
| 30 | + <if test="con.corpCode != null and con.corpCode != ''"> | |
| 31 | + and fileRel.corp_code = #{con.corpCode} | |
| 32 | + </if> | |
| 33 | + <if test="con.createdAt != null"> | |
| 34 | + and fileRel.created_at = #{con.createdAt} | |
| 35 | + </if> | |
| 36 | + <if test="con.updatedAt != null"> | |
| 37 | + and fileRel.updated_at = #{con.updatedAt} | |
| 38 | + </if> | |
| 39 | + <if test="con.createdBy != null and con.createdBy != ''"> | |
| 40 | + and fileRel.created_by = #{con.createdBy} | |
| 41 | + </if> | |
| 42 | + <if test="con.updatedBy != null and con.updatedBy != ''"> | |
| 43 | + and fileRel.updated_by = #{con.updatedBy} | |
| 44 | + </if> | |
| 45 | + <if test="con.fileId != null and con.fileId != ''"> | |
| 46 | + and fileRel.file_id = #{con.fileId} | |
| 47 | + </if> | |
| 48 | + </sql> | |
| 49 | + | |
| 50 | + <select id="search" resultMap="fileRelMap"> | |
| 51 | + select fileRel.* | |
| 52 | + from <include refid="tableName"/> | |
| 53 | + WHERE 1=1 <include refid="condition"/> | |
| 54 | + order by fileRel.created_at DESC | |
| 55 | + </select> | |
| 56 | +</mapper> | |
| \ No newline at end of file | ... | ... |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.qgutech.qgyun.xieyunhui.mapper.OrgRelMapper"> | |
| 4 | + <resultMap id="orgRelMap" type="com.qgutech.qgyun.xieyunhui.model.OrgRel"> | |
| 5 | + <result column="id" property="id"/> | |
| 6 | + <result column="refer_id" property="referId"/> | |
| 7 | + <result column="fun_code" property="funCode"/> | |
| 8 | + <result column="field_name" property="fieldName"/> | |
| 9 | + <result column="corp_code" property="corpCode"/> | |
| 10 | + <result column="created_at" property="createdAt"/> | |
| 11 | + <result column="updated_at" property="updatedAt"/> | |
| 12 | + <result column="created_by" property="createdBy"/> | |
| 13 | + <result column="updated_by" property="updatedBy"/> | |
| 14 | + <result column="org_id" property="orgId"/> | |
| 15 | + </resultMap> | |
| 16 | + <sql id="tableName">t_auto_xieyunhui_org_rel orgRel</sql> | |
| 17 | + <sql id="condition"> | |
| 18 | + <if test="con.id != null and con.id != ''"> | |
| 19 | + and orgRel.id = #{con.id} | |
| 20 | + </if> | |
| 21 | + <if test="con.referId != null and con.referId != ''"> | |
| 22 | + and orgRel.refer_id = #{con.referId} | |
| 23 | + </if> | |
| 24 | + <if test="con.funCode != null and con.funCode != ''"> | |
| 25 | + and orgRel.fun_code = #{con.funCode} | |
| 26 | + </if> | |
| 27 | + <if test="con.fieldName != null and con.fieldName != ''"> | |
| 28 | + and orgRel.field_name = #{con.fieldName} | |
| 29 | + </if> | |
| 30 | + <if test="con.corpCode != null and con.corpCode != ''"> | |
| 31 | + and orgRel.corp_code = #{con.corpCode} | |
| 32 | + </if> | |
| 33 | + <if test="con.createdAt != null"> | |
| 34 | + and orgRel.created_at = #{con.createdAt} | |
| 35 | + </if> | |
| 36 | + <if test="con.updatedAt != null"> | |
| 37 | + and orgRel.updated_at = #{con.updatedAt} | |
| 38 | + </if> | |
| 39 | + <if test="con.createdBy != null and con.createdBy != ''"> | |
| 40 | + and orgRel.created_by = #{con.createdBy} | |
| 41 | + </if> | |
| 42 | + <if test="con.updatedBy != null and con.updatedBy != ''"> | |
| 43 | + and orgRel.updated_by = #{con.updatedBy} | |
| 44 | + </if> | |
| 45 | + <if test="con.orgId != null and con.orgId != ''"> | |
| 46 | + and orgRel.org_id = #{con.orgId} | |
| 47 | + </if> | |
| 48 | + </sql> | |
| 49 | + | |
| 50 | + <select id="search" resultMap="orgRelMap"> | |
| 51 | + select orgRel.* | |
| 52 | + from <include refid="tableName"/> | |
| 53 | + WHERE 1=1 <include refid="condition"/> | |
| 54 | + order by orgRel.created_at DESC | |
| 55 | + </select> | |
| 56 | +</mapper> | |
| \ No newline at end of file | ... | ... |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="com.qgutech.qgyun.xieyunhui.mapper.UserRelMapper"> | |
| 4 | + <resultMap id="userRelMap" type="com.qgutech.qgyun.xieyunhui.model.UserRel"> | |
| 5 | + <result column="id" property="id"/> | |
| 6 | + <result column="refer_id" property="referId"/> | |
| 7 | + <result column="fun_code" property="funCode"/> | |
| 8 | + <result column="field_name" property="fieldName"/> | |
| 9 | + <result column="corp_code" property="corpCode"/> | |
| 10 | + <result column="created_at" property="createdAt"/> | |
| 11 | + <result column="updated_at" property="updatedAt"/> | |
| 12 | + <result column="created_by" property="createdBy"/> | |
| 13 | + <result column="updated_by" property="updatedBy"/> | |
| 14 | + <result column="user_id" property="userId"/> | |
| 15 | + </resultMap> | |
| 16 | + <sql id="tableName">t_auto_xieyunhui_user_rel userRel</sql> | |
| 17 | + <sql id="condition"> | |
| 18 | + <if test="con.id != null and con.id != ''"> | |
| 19 | + and userRel.id = #{con.id} | |
| 20 | + </if> | |
| 21 | + <if test="con.referId != null and con.referId != ''"> | |
| 22 | + and userRel.refer_id = #{con.referId} | |
| 23 | + </if> | |
| 24 | + <if test="con.funCode != null and con.funCode != ''"> | |
| 25 | + and userRel.fun_code = #{con.funCode} | |
| 26 | + </if> | |
| 27 | + <if test="con.fieldName != null and con.fieldName != ''"> | |
| 28 | + and userRel.field_name = #{con.fieldName} | |
| 29 | + </if> | |
| 30 | + <if test="con.corpCode != null and con.corpCode != ''"> | |
| 31 | + and userRel.corp_code = #{con.corpCode} | |
| 32 | + </if> | |
| 33 | + <if test="con.createdAt != null"> | |
| 34 | + and userRel.created_at = #{con.createdAt} | |
| 35 | + </if> | |
| 36 | + <if test="con.updatedAt != null"> | |
| 37 | + and userRel.updated_at = #{con.updatedAt} | |
| 38 | + </if> | |
| 39 | + <if test="con.createdBy != null and con.createdBy != ''"> | |
| 40 | + and userRel.created_by = #{con.createdBy} | |
| 41 | + </if> | |
| 42 | + <if test="con.updatedBy != null and con.updatedBy != ''"> | |
| 43 | + and userRel.updated_by = #{con.updatedBy} | |
| 44 | + </if> | |
| 45 | + <if test="con.userId != null and con.userId != ''"> | |
| 46 | + and userRel.user_id = #{con.userId} | |
| 47 | + </if> | |
| 48 | + </sql> | |
| 49 | + | |
| 50 | + <select id="search" resultMap="userRelMap"> | |
| 51 | + select userRel.* | |
| 52 | + from <include refid="tableName"/> | |
| 53 | + WHERE 1=1 <include refid="condition"/> | |
| 54 | + order by userRel.created_at DESC | |
| 55 | + </select> | |
| 56 | +</mapper> | |
| \ No newline at end of file | ... | ... |
xieyunhui-ui/admin/.editorconfig
0 → 100644
xieyunhui-ui/admin/.env.dev
0 → 100644
| 1 | +#环境标识,在vue.config.js中用到 | |
| 2 | +NODE_ENV = 'development' | |
| 3 | + | |
| 4 | +# api请求前缀,如果连公司无线网,无法访问可配置hosts:192.168.0.56 yapi.qgutech.com | |
| 5 | +#VUE_APP_BASE_API = http://qgyun.qgutech.com/qgyun-api | |
| 6 | +VUE_APP_BASE_API= http://192.168.0.36/qgyun-api | |
| 7 | + | |
| 8 | +VUE_APP_SOCKET_API = '192.168.0.36:9092/' | |
| 9 | + | |
| 10 | +# 控制babel-plugin-dynamic-import-node插件是否启用,将所有import()转换为require(),可以显著提高热更新的速度 | |
| 11 | +VUE_CLI_BABEL_TRANSPILE_MODULES = true | ... | ... |
xieyunhui-ui/admin/.env.prod
0 → 100644
| 1 | +#环境标识,在vue.config.js中用到 | |
| 2 | +NODE_ENV = 'production' | |
| 3 | + | |
| 4 | +# api请求前缀 | |
| 5 | +VUE_APP_BASE_API = '/qgyun-api' | |
| 6 | + | |
| 7 | +VUE_APP_SOCKET_API = '/qsocket/' | |
| 8 | + | |
| 9 | + | |
| 10 | +#远程代码地址和账户 | |
| 11 | +HOST = '192.168.0.35' | |
| 12 | +PORT = '22' | |
| 13 | +USERNAME = 'root' | |
| 14 | +PASSWORD = 'qixiao.123' | |
| 15 | + | |
| 16 | +#待推动代码目录(命名规则:前端模块名_DIST_PATH),目录地址为相对此文件的地址 | |
| 17 | +ADMIN_DIST_PATH = './dist' | |
| 18 | + | |
| 19 | +#推动代码到达服务器目录 | |
| 20 | +ADMIN_REMOTE_PATH = '/service/qgyun/ui/admin' | ... | ... |
xieyunhui-ui/admin/.eslintignore
0 → 100644
xieyunhui-ui/admin/.eslintrc.js
0 → 100644
| 1 | +module.exports = { | |
| 2 | + root: true, | |
| 3 | + parserOptions: { | |
| 4 | + parser: 'babel-eslint', | |
| 5 | + sourceType: 'module' | |
| 6 | + }, | |
| 7 | + env: { | |
| 8 | + browser: true, | |
| 9 | + node: true, | |
| 10 | + es6: true | |
| 11 | + }, | |
| 12 | + extends: ['plugin:vue/recommended', 'eslint:recommended'], | |
| 13 | + | |
| 14 | + // add your custom rules here | |
| 15 | + //it is base on https://github.com/vuejs/eslint-config-vue | |
| 16 | + | |
| 17 | + // 等级分为三级: 0-不显示;1-显示警告warning; 2-显示错误error | |
| 18 | + rules: { | |
| 19 | + // 多个特性的元素应该分多行撰写,每个特性一行 | |
| 20 | + 'vue/max-attributes-per-line': [ | |
| 21 | + 2, | |
| 22 | + { | |
| 23 | + singleline: 10, | |
| 24 | + multiline: { | |
| 25 | + max: 1, | |
| 26 | + allowFirstLine: false | |
| 27 | + } | |
| 28 | + } | |
| 29 | + ], | |
| 30 | + | |
| 31 | + // vue template 缩进 4空格 | |
| 32 | + 'vue/html-indent': [2, 4], | |
| 33 | + | |
| 34 | + // js 缩进 4空格 | |
| 35 | + 'vue/script-indent': [ | |
| 36 | + 'error', | |
| 37 | + 4, | |
| 38 | + { | |
| 39 | + baseIndent: 1, | |
| 40 | + switchCase: 1 | |
| 41 | + } | |
| 42 | + ], | |
| 43 | + /** | |
| 44 | + * 模版中开始标签的反尖括号前禁止有空格,自闭和标签前必须有空格 | |
| 45 | + * @category Improving Readability | |
| 46 | + * @fixable | |
| 47 | + */ | |
| 48 | + 'vue/html-closing-bracket-spacing': [ | |
| 49 | + 'error', | |
| 50 | + { | |
| 51 | + selfClosingTag: 'never' | |
| 52 | + } | |
| 53 | + ], | |
| 54 | + // 在单行元素的内容前后需要换行符 (关闭) | |
| 55 | + 'vue/singleline-html-element-content-newline': 'off', | |
| 56 | + | |
| 57 | + // 在多行元素的内容之前和之后需要换行符 (关闭) | |
| 58 | + 'vue/multiline-html-element-content-newline': 'off', | |
| 59 | + | |
| 60 | + // JS/JSX中的组件名应该始终是帕斯卡命名法 | |
| 61 | + 'vue/name-property-casing': ['error', 'PascalCase'], | |
| 62 | + | |
| 63 | + // 禁止使用 v-html (关闭) | |
| 64 | + 'vue/no-v-html': 'off', | |
| 65 | + | |
| 66 | + // 强制箭头函数的箭头前后使用一致的空格 | |
| 67 | + 'arrow-spacing': [ | |
| 68 | + 2, | |
| 69 | + { | |
| 70 | + before: true, | |
| 71 | + after: true | |
| 72 | + } | |
| 73 | + ], | |
| 74 | + | |
| 75 | + // 强制在代码块中开括号前和闭括号后有空格 | |
| 76 | + 'block-spacing': [2, 'always'], | |
| 77 | + | |
| 78 | + // 强制在代码块中使用一致的大括号风格 | |
| 79 | + 'brace-style': [ | |
| 80 | + 2, | |
| 81 | + '1tbs', | |
| 82 | + { | |
| 83 | + allowSingleLine: true // 允许单行大括号 | |
| 84 | + } | |
| 85 | + ], | |
| 86 | + | |
| 87 | + // 强制驼峰命名法 | |
| 88 | + camelcase: [ | |
| 89 | + 2, | |
| 90 | + { | |
| 91 | + properties: 'always', | |
| 92 | + allow: [ | |
| 93 | + '^\\$_' | |
| 94 | + // use $_ for mixins properties | |
| 95 | + // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential | |
| 96 | + ] | |
| 97 | + } | |
| 98 | + ], | |
| 99 | + | |
| 100 | + // 禁止末尾逗号 | |
| 101 | + 'comma-dangle': [2, 'never'], | |
| 102 | + | |
| 103 | + // 逗号前无需空格,逗号后要求空格 | |
| 104 | + 'comma-spacing': [ | |
| 105 | + 2, | |
| 106 | + { | |
| 107 | + before: false, | |
| 108 | + after: true | |
| 109 | + } | |
| 110 | + ], | |
| 111 | + | |
| 112 | + // 逗号风格,在每行最后 | |
| 113 | + 'comma-style': [2, 'last'], | |
| 114 | + | |
| 115 | + // 构造函数中必须有 super | |
| 116 | + 'constructor-super': 2, | |
| 117 | + | |
| 118 | + // 大括号不能省略 | |
| 119 | + curly: [2, 'all'], | |
| 120 | + | |
| 121 | + // 禁止文件末尾保留一行空行 https://eslint.bootcss.com/docs/4.0.0/rules/eol-last/ | |
| 122 | + 'eol-last': [2, 'always'], | |
| 123 | + | |
| 124 | + // 强制使用 === | !== | |
| 125 | + eqeqeq: [ | |
| 126 | + 'error', | |
| 127 | + 'always', | |
| 128 | + { | |
| 129 | + null: 'ignore' // 除了与 null 字面量进行比较时,总是强制使用绝对相等 | |
| 130 | + } | |
| 131 | + ], | |
| 132 | + | |
| 133 | + // 代码缩进 | |
| 134 | + indent: 'off', | |
| 135 | + | |
| 136 | + // 强制在对象字面量的键和值之间使用一致的空格 | |
| 137 | + 'key-spacing': [ | |
| 138 | + 2, | |
| 139 | + { | |
| 140 | + beforeColon: false, | |
| 141 | + afterColon: true | |
| 142 | + } | |
| 143 | + ], | |
| 144 | + | |
| 145 | + // 强制在关键字前后使用一致的空格 | |
| 146 | + 'keyword-spacing': [ | |
| 147 | + 2, | |
| 148 | + { | |
| 149 | + before: true, | |
| 150 | + after: true | |
| 151 | + } | |
| 152 | + ], | |
| 153 | + | |
| 154 | + // 要求构造函数首字母大写 | |
| 155 | + 'new-cap': [ | |
| 156 | + 2, | |
| 157 | + { | |
| 158 | + newIsCap: true, | |
| 159 | + capIsNew: false | |
| 160 | + } | |
| 161 | + ], | |
| 162 | + | |
| 163 | + // 禁止使用 Array 构造函数 | |
| 164 | + 'no-array-constructor': 2, | |
| 165 | + | |
| 166 | + // 禁用 console(关闭) | |
| 167 | + 'no-console': 'off', | |
| 168 | + | |
| 169 | + // 不允许修改类声明的变量 | |
| 170 | + 'no-class-assign': 2, | |
| 171 | + | |
| 172 | + // 禁止条件表达式中出现赋值操作符 | |
| 173 | + 'no-cond-assign': 2, | |
| 174 | + | |
| 175 | + // 禁止修改 const 声明的变量 | |
| 176 | + 'no-const-assign': 2, | |
| 177 | + | |
| 178 | + // 禁止在正则表达式中使用控制字符 | |
| 179 | + 'no-control-regex': 0, | |
| 180 | + | |
| 181 | + // 禁止删除变量 | |
| 182 | + 'no-delete-var': 2, | |
| 183 | + | |
| 184 | + // 禁止 function 定义中出现重名参数 | |
| 185 | + 'no-dupe-args': 2, | |
| 186 | + | |
| 187 | + // 禁止类成员中出现重复的名称 | |
| 188 | + 'no-dupe-class-members': 2, | |
| 189 | + | |
| 190 | + // 禁止对象字面量中出现重复的 key | |
| 191 | + 'no-dupe-keys': 2, | |
| 192 | + | |
| 193 | + // 禁止出现重复的 case 标签 | |
| 194 | + 'no-duplicate-case': 2, | |
| 195 | + | |
| 196 | + // 禁止在正则表达式中使用空字符集 | |
| 197 | + 'no-empty-character-class': 2, | |
| 198 | + | |
| 199 | + // 禁止使用空解构模式 | |
| 200 | + 'no-empty-pattern': 2, | |
| 201 | + | |
| 202 | + // 禁止对 catch 子句的参数重新赋值 | |
| 203 | + 'no-ex-assign': 2, | |
| 204 | + | |
| 205 | + // 禁止扩展原生类型 | |
| 206 | + 'no-extend-native': 2, | |
| 207 | + | |
| 208 | + // 禁止不必要的函数绑定 | |
| 209 | + 'no-extra-bind': 2, | |
| 210 | + | |
| 211 | + // 禁止不必要的布尔转换 | |
| 212 | + 'no-extra-boolean-cast': 2, | |
| 213 | + | |
| 214 | + // 禁止不必要的括号 | |
| 215 | + 'no-extra-parens': [2, 'functions'], | |
| 216 | + | |
| 217 | + // 禁止 case 语句落空 | |
| 218 | + 'no-fallthrough': 2, | |
| 219 | + | |
| 220 | + // 禁止数字字面量中使用前导和末尾小数点(.5 -> 0.5) | |
| 221 | + 'no-floating-decimal': 2, | |
| 222 | + | |
| 223 | + // 禁止对 function 声明重新赋值 | |
| 224 | + 'no-func-assign': 2, | |
| 225 | + | |
| 226 | + // 禁止在嵌套的块中出现变量声明或 function 声明 | |
| 227 | + 'no-inner-declarations': [2, 'functions'], | |
| 228 | + | |
| 229 | + // 禁止 RegExp 构造函数中存在无效的正则表达式字符串 | |
| 230 | + 'no-invalid-regexp': 2, | |
| 231 | + | |
| 232 | + // 禁止不规则的空白 | |
| 233 | + 'no-irregular-whitespace': 2, | |
| 234 | + | |
| 235 | + // 不允许标签与变量同名 | |
| 236 | + 'no-label-var': 2, | |
| 237 | + | |
| 238 | + // 禁用标签语句 | |
| 239 | + 'no-labels': [ | |
| 240 | + 2, | |
| 241 | + { | |
| 242 | + allowLoop: false, | |
| 243 | + allowSwitch: false | |
| 244 | + } | |
| 245 | + ], | |
| 246 | + | |
| 247 | + // 禁用不必要的嵌套块 | |
| 248 | + 'no-lone-blocks': 2, | |
| 249 | + | |
| 250 | + // 禁止空格和 tab 的混合缩进 | |
| 251 | + 'no-mixed-spaces-and-tabs': 2, | |
| 252 | + | |
| 253 | + // 禁止使用多个空格 | |
| 254 | + 'no-multi-spaces': 2, | |
| 255 | + | |
| 256 | + // 禁止使用多行字符串 | |
| 257 | + 'no-multi-str': 2, | |
| 258 | + | |
| 259 | + // 禁止出现多行空行 | |
| 260 | + 'no-multiple-empty-lines': [ | |
| 261 | + 2, | |
| 262 | + { | |
| 263 | + max: 1 | |
| 264 | + } | |
| 265 | + ], | |
| 266 | + | |
| 267 | + // 禁止对原生对象或只读的全局对象进行赋值 | |
| 268 | + 'no-global-assign': 2, | |
| 269 | + | |
| 270 | + // 禁止对关系运算符的左操作数使用否定操作符 | |
| 271 | + 'no-unsafe-negation': 2, | |
| 272 | + | |
| 273 | + // 禁用 Object 的构造函数 | |
| 274 | + 'no-new-object': 2, | |
| 275 | + | |
| 276 | + // 禁止调用 require 时使用 new 操作符 | |
| 277 | + 'no-new-require': 2, | |
| 278 | + | |
| 279 | + // 禁止 Symbolnew 操作符和 new 一起使用 | |
| 280 | + 'no-new-symbol': 2, | |
| 281 | + | |
| 282 | + // 禁止对 String,Number 和 Boolean 使用 new 操作符 | |
| 283 | + 'no-new-wrappers': 2, | |
| 284 | + | |
| 285 | + // 禁止把全局对象作为函数调用 | |
| 286 | + 'no-obj-calls': 2, | |
| 287 | + | |
| 288 | + // 禁止多次声明同一变量 | |
| 289 | + 'no-redeclare': 2, | |
| 290 | + | |
| 291 | + // 禁止正则表达式字面量中出现多个空格 | |
| 292 | + 'no-regex-spaces': 2, | |
| 293 | + | |
| 294 | + // 禁止在 return 语句中使用赋值语句 | |
| 295 | + 'no-return-assign': [2, 'except-parens'], | |
| 296 | + | |
| 297 | + // 禁止自我赋值 | |
| 298 | + 'no-self-assign': 2, | |
| 299 | + | |
| 300 | + // 禁止自身比较 | |
| 301 | + 'no-self-compare': 2, | |
| 302 | + | |
| 303 | + // 禁用逗号操作符 | |
| 304 | + 'no-sequences': 2, | |
| 305 | + | |
| 306 | + // 禁止将标识符定义为受限的名字 | |
| 307 | + 'no-shadow-restricted-names': 2, | |
| 308 | + | |
| 309 | + // 要求或禁止在函数标识符和其调用之间有空格 | |
| 310 | + 'func-call-spacing': 2, | |
| 311 | + | |
| 312 | + // 禁用稀疏数组 | |
| 313 | + 'no-sparse-arrays': 2, | |
| 314 | + | |
| 315 | + // 禁止在构造函数中,在调用 super() 之前使用 this 或 super | |
| 316 | + 'no-this-before-super': 2, | |
| 317 | + | |
| 318 | + // 禁止抛出异常字面量 | |
| 319 | + 'no-throw-literal': 2, | |
| 320 | + | |
| 321 | + // 禁用行尾空格 | |
| 322 | + 'no-trailing-spaces': 2, | |
| 323 | + | |
| 324 | + // 禁用未声明的变量,除非它们在 /*global */ 注释中被提到 | |
| 325 | + 'no-undef': 2, | |
| 326 | + | |
| 327 | + // 禁止将变量初始化为 undefined | |
| 328 | + 'no-undef-init': 2, | |
| 329 | + | |
| 330 | + // 禁止出现令人困惑的多行表达式 | |
| 331 | + 'no-unexpected-multiline': 2, | |
| 332 | + | |
| 333 | + // 禁用一成不变的循环条件 | |
| 334 | + 'no-unmodified-loop-condition': 2, | |
| 335 | + | |
| 336 | + // 禁止可以在有更简单的可替代的表达式时使用三元操作符 | |
| 337 | + 'no-unneeded-ternary': [ | |
| 338 | + 2, | |
| 339 | + { | |
| 340 | + defaultAssignment: false // 禁止条件表达式作为默认的赋值模式 | |
| 341 | + } | |
| 342 | + ], | |
| 343 | + | |
| 344 | + // 禁止在 return、throw、continue 和 break 语句之后出现不可达代码 | |
| 345 | + 'no-unreachable': 2, | |
| 346 | + | |
| 347 | + // 禁止在 finally 语句块中出现控制流语句 | |
| 348 | + 'no-unsafe-finally': 2, | |
| 349 | + | |
| 350 | + // 禁止出现未使用过的变量 | |
| 351 | + 'no-unused-vars': [ | |
| 352 | + 2, | |
| 353 | + { | |
| 354 | + vars: 'all', | |
| 355 | + args: 'none' | |
| 356 | + } | |
| 357 | + ], | |
| 358 | + | |
| 359 | + // 禁止不必要的 .call() 和 .apply() | |
| 360 | + 'no-useless-call': 2, | |
| 361 | + | |
| 362 | + // 禁止在对象中使用不必要的计算属性 | |
| 363 | + 'no-useless-computed-key': 2, | |
| 364 | + | |
| 365 | + // 禁用不必要的构造函数 | |
| 366 | + 'no-useless-constructor': 2, | |
| 367 | + | |
| 368 | + // 禁用不必要的转义字符 | |
| 369 | + 'no-useless-escape': 0, | |
| 370 | + | |
| 371 | + // 禁止属性前有空白 | |
| 372 | + 'no-whitespace-before-property': 2, | |
| 373 | + | |
| 374 | + // 强制函数中的变量要么一起声明要么分开声明 | |
| 375 | + 'one-var': [ | |
| 376 | + 2, | |
| 377 | + { | |
| 378 | + initialized: 'never' // 要求每个作用域的初始化的变量有多个变量声明 | |
| 379 | + } | |
| 380 | + ], | |
| 381 | + | |
| 382 | + // 强制操作符使用一致的换行符 | |
| 383 | + 'operator-linebreak': [ | |
| 384 | + 2, | |
| 385 | + 'after', | |
| 386 | + { | |
| 387 | + overrides: { | |
| 388 | + '?': 'before', | |
| 389 | + ':': 'before' | |
| 390 | + } | |
| 391 | + } | |
| 392 | + ], | |
| 393 | + | |
| 394 | + // 禁止块语句和类的开始或末尾有空行 | |
| 395 | + 'padded-blocks': [2, 'never'], | |
| 396 | + | |
| 397 | + // 要求尽可能地使用单引号 | |
| 398 | + quotes: [ | |
| 399 | + 2, | |
| 400 | + 'single', | |
| 401 | + { | |
| 402 | + avoidEscape: true, // 允许字符串使用单引号或双引号 | |
| 403 | + allowTemplateLiterals: true // 允许字符串使用反勾号 | |
| 404 | + } | |
| 405 | + ], | |
| 406 | + | |
| 407 | + // 要求在语句末尾使用分号 | |
| 408 | + semi: ['error', 'always'], | |
| 409 | + | |
| 410 | + // 强制分号之前和之后使用一致的空格 | |
| 411 | + 'semi-spacing': [ | |
| 412 | + 2, | |
| 413 | + { | |
| 414 | + before: false, | |
| 415 | + after: true | |
| 416 | + } | |
| 417 | + ], | |
| 418 | + | |
| 419 | + // 强制在块之前使用一致的空格 | |
| 420 | + 'space-before-blocks': [2, 'always'], | |
| 421 | + | |
| 422 | + // 禁止在参数的 ( 前面有空格 | |
| 423 | + 'space-before-function-paren': [2, 'never'], | |
| 424 | + | |
| 425 | + // 强制圆括号内没有空格 | |
| 426 | + 'space-in-parens': [2, 'never'], | |
| 427 | + | |
| 428 | + // 要求操作符周围有空格 | |
| 429 | + 'space-infix-ops': 2, | |
| 430 | + | |
| 431 | + // 强制在一元操作符前后使用一致的空格 | |
| 432 | + 'space-unary-ops': [ | |
| 433 | + 2, | |
| 434 | + { | |
| 435 | + words: true, | |
| 436 | + nonwords: false | |
| 437 | + } | |
| 438 | + ], | |
| 439 | + | |
| 440 | + // 强制在注释中 // 或 /* 使用一致的空格 | |
| 441 | + 'spaced-comment': [ | |
| 442 | + 2, | |
| 443 | + 'always', | |
| 444 | + { | |
| 445 | + markers: [ | |
| 446 | + 'global', | |
| 447 | + 'globals', | |
| 448 | + 'eslint', | |
| 449 | + 'eslint-disable', | |
| 450 | + '*package', | |
| 451 | + '!', | |
| 452 | + ',' | |
| 453 | + ] | |
| 454 | + } | |
| 455 | + ], | |
| 456 | + | |
| 457 | + // 禁止花括号内出现空格 TODO 开启会导致 import(`@/views${ file }.vue`) 报错 | |
| 458 | + 'template-curly-spacing': 'off', | |
| 459 | + | |
| 460 | + // 要求使用 isNaN() 检查 NaN | |
| 461 | + 'use-isnan': 2, | |
| 462 | + | |
| 463 | + // 强制 typeof 表达式与有效的字符串进行比较 | |
| 464 | + 'valid-typeof': 2, | |
| 465 | + | |
| 466 | + // 需要把立即执行的函数包裹起来 | |
| 467 | + 'wrap-iife': [2, 'any'], | |
| 468 | + | |
| 469 | + // 要求使用 const 声明那些声明后不再被修改的变量 | |
| 470 | + 'prefer-const': 2, | |
| 471 | + | |
| 472 | + // 禁用 debugger(生产环境) | |
| 473 | + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, | |
| 474 | + | |
| 475 | + // TODO idea如果满足,需要修改js配置 | |
| 476 | + // 要求以对象元素开始或结尾的对象的花括号中有空格 | |
| 477 | + // "object-curly-spacing": [ | |
| 478 | + // 2, | |
| 479 | + // "always", | |
| 480 | + // { | |
| 481 | + // objectsInObjects: false | |
| 482 | + // } | |
| 483 | + // ], | |
| 484 | + 'object-curly-spacing': [2, 'never'], | |
| 485 | + | |
| 486 | + // 禁止在括号内使用空格 | |
| 487 | + 'array-bracket-spacing': [2, 'never'] | |
| 488 | + } | |
| 489 | +}; | ... | ... |
xieyunhui-ui/admin/README.md
0 → 100644
| 1 | +#管理端模板 | |
| 2 | + | |
| 3 | +> 注意:本模板配置自带git提交钩子,如无法通过eslint校验,则无法提交。 | |
| 4 | + | |
| 5 | + | |
| 6 | +#### 准备 | |
| 7 | + | |
| 8 | +- 安装[node](http://nodejs.cn/) | |
| 9 | + | |
| 10 | +- 切换青谷前端私服 [参考资料](http://npm.qgutech.com/) | |
| 11 | + | |
| 12 | +#####开发框架 | |
| 13 | + | |
| 14 | +- Vue.js | |
| 15 | + | |
| 16 | + > 学习参考资料 [https://cn.vuejs.org/](https://cn.vuejs.org/): | |
| 17 | + | |
| 18 | +- ElementUI | |
| 19 | + > 学习参考资料 [https://element.eleme.cn/2.0/#/zh-CN/component/installation](hhttps://element.eleme.cn/2.0/#/zh-CN/component/installation): | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | +####已含第三方组件 | |
| 24 | + | |
| 25 | +- 二维码:`qrcode.vue` | |
| 26 | +- 复制:`vue-clipboard2` | |
| 27 | + | |
| 28 | +#### issue | |
| 29 | +- 如果windows第一次运行前端项目会遇到安装node-sass的问题,请使用管理员权限运行 `npm install --global --production windows-build-tools`后,再安装依赖 | |
| 30 | +具体参考链接:[https://www.npmjs.com/package/node-gyp] | |
| 31 | + | |
| 32 | +#### | |
| \ No newline at end of file | ... | ... |
xieyunhui-ui/admin/babel.config.js
0 → 100644
xieyunhui-ui/admin/gulpfile.js
0 → 100644
| 1 | +const gulp = require('gulp'); | |
| 2 | +const { | |
| 3 | + series | |
| 4 | +} = require('gulp'); | |
| 5 | +const GulpSSH = require('gulp-ssh'); | |
| 6 | +var through = require('through2'); | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 获取参数,目前支持--env和--moudle | |
| 10 | + * @param {Array} argv | |
| 11 | + */ | |
| 12 | +const params = (argv) => { | |
| 13 | + console.log(argv); | |
| 14 | + const obj = {}; | |
| 15 | + if (!argv && argv.length < 3) { | |
| 16 | + return obj; | |
| 17 | + } | |
| 18 | + for (let i = 2; i < argv.length; i++) { | |
| 19 | + console.log(argv[i]); | |
| 20 | + if (argv[i].indexOf('--') === 0 && argv[i + 1].indexOf('--') === -1) { | |
| 21 | + obj[argv[i].substring(2)] = argv[i + 1]; | |
| 22 | + } | |
| 23 | + } | |
| 24 | + return obj; | |
| 25 | +}; | |
| 26 | +/** | |
| 27 | + * 读取配置文件信息 .env.dev 、.env.pro、.env.test | |
| 28 | + * @param {String} content | |
| 29 | + */ | |
| 30 | +const filesToConfig = (content) => { | |
| 31 | + const lines = content.split('\n'); | |
| 32 | + const obj = {}; | |
| 33 | + for (let i = 0; i < lines.length; i++) { | |
| 34 | + const item = lines[i]; | |
| 35 | + if (item.indexOf('#') === 0 || !item) { | |
| 36 | + continue; | |
| 37 | + } | |
| 38 | + const KeyValue = item.split('='); | |
| 39 | + if (KeyValue !== 2 && !KeyValue[0].trim() && !KeyValue[1].trim()) { | |
| 40 | + continue; | |
| 41 | + } | |
| 42 | + const value = KeyValue[1].trim(); | |
| 43 | + const key = KeyValue[0].trim().toLocaleLowerCase(); | |
| 44 | + console.log(value.indexOf('\''), value.lastIndexOf('\''), value.length - 1); | |
| 45 | + if (value.indexOf('\'') === 0 && value.lastIndexOf('\'') === value.length - 1) { | |
| 46 | + obj[key] = value.substring(1, value.length - 1); | |
| 47 | + continue; | |
| 48 | + } | |
| 49 | + obj[key] = ''; | |
| 50 | + } | |
| 51 | + console.log(obj); | |
| 52 | + return obj; | |
| 53 | +}; | |
| 54 | + | |
| 55 | +let gulpSSH = null; | |
| 56 | +let staticPath = ''; | |
| 57 | +let distPath = ''; | |
| 58 | + | |
| 59 | +function getGupSSH(cb) { | |
| 60 | + const PARAMS = params(process.argv); | |
| 61 | + const ENV = PARAMS.env; | |
| 62 | + const QGMODULE = PARAMS.qgModule; | |
| 63 | + return gulp.src(`./.env.${ENV}`).pipe(through.obj(function(file, encode, callback) { | |
| 64 | + const obj = filesToConfig(file.contents.toString()); | |
| 65 | + gulpSSH = new GulpSSH({ | |
| 66 | + ignoreErrors: false, | |
| 67 | + sshConfig: obj | |
| 68 | + }); | |
| 69 | + staticPath = obj[QGMODULE + '_remote_path']; | |
| 70 | + distPath = obj[QGMODULE + '_dist_path']; | |
| 71 | + | |
| 72 | + callback(); | |
| 73 | + })).on('data', (data) => { | |
| 74 | + }).on('end', () => { | |
| 75 | + if (!distPath || !staticPath) { | |
| 76 | + // TODO | |
| 77 | + console.log('获取路径失败', distPath, staticPath); | |
| 78 | + return new Error('获取路径失败'); | |
| 79 | + } | |
| 80 | + console.log('获取路径成功', distPath, staticPath); | |
| 81 | + }); | |
| 82 | +} | |
| 83 | + | |
| 84 | +/** | |
| 85 | + * 将远程服务器代码清除 | |
| 86 | + */ | |
| 87 | +function clean(cb) { | |
| 88 | + return gulpSSH.shell(`rm -rf ${staticPath}`); | |
| 89 | +} | |
| 90 | + | |
| 91 | +/** | |
| 92 | + * 根据环境和模块获取相应配置文件后,将打包后的代码部署到服务器上 | |
| 93 | + * @param {*} cb | |
| 94 | + */ | |
| 95 | +function deploy(cb) { | |
| 96 | + return gulp | |
| 97 | + .src([`${distPath}/**`]) | |
| 98 | + .pipe(gulpSSH.dest(staticPath)); | |
| 99 | +} | |
| 100 | + | |
| 101 | +exports.default = series(getGupSSH, clean, deploy); | |
| 102 | + | ... | ... |