From ef10b99d3384a3d7f3892e770a2d108c8190a681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E7=BB=AA=E5=A3=AE?= <2235602974@qq.com> Date: Sat, 26 Mar 2022 14:41:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?:sparkles:=20=E5=B2=97=E4=BD=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/2pigxx.sql | 40 +++++ db/6pigxx_config.sql | 2 +- .../pigx/admin/api/entity/SysPost.java | 101 +++++++++++++ .../pigx/admin/api/vo/PostExcelVO.java | 64 ++++++++ .../admin/controller/SysPostController.java | 139 ++++++++++++++++++ .../pigx/admin/mapper/SysPostMapper.java | 33 +++++ .../pigx/admin/service/SysPostService.java | 50 +++++++ .../service/impl/SysPostServiceImpl.java | 111 ++++++++++++++ .../src/main/resources/file/post.xlsx | Bin 0 -> 8905 bytes 9 files changed, 539 insertions(+), 1 deletion(-) create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPost.java create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/PostExcelVO.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysPostService.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysPostServiceImpl.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/file/post.xlsx diff --git a/db/2pigxx.sql b/db/2pigxx.sql index ab36c632d..af31f87ba 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -73,6 +73,34 @@ INSERT INTO `sys_dept_relation` VALUES (7, 12); INSERT INTO `sys_dept_relation` VALUES (8, 8); COMMIT; +-- ---------------------------- +-- Table structure for sys_post +-- ---------------------------- +DROP TABLE IF EXISTS `sys_post`; +CREATE TABLE `sys_post` ( + `post_id` bigint NOT NULL COMMENT '岗位ID', + `post_code` varchar(64) CHARACTER SET utf8mb4 NOT NULL COMMENT '岗位编码', + `post_name` varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT '岗位名称', + `post_sort` int(0) NOT NULL COMMENT '岗位排序', + `remark` varchar(500) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '岗位描述', + `del_flag` char(1) CHARACTER SET utf8mb4 NOT NULL DEFAULT '0' COMMENT '是否删除 -1:已删除 0:正常', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间', + `create_by` varchar(64) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' COMMENT '创建人', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间', + `update_by` varchar(64) CHARACTER SET utf8mb4 NOT NULL DEFAULT '' COMMENT '更新人', + `tenant_id` bigint(0) NULL DEFAULT NULL COMMENT '租户ID', + PRIMARY KEY (`post_id`) USING BTREE +) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '岗位信息表'; + +-- ---------------------------- +-- Records of sys_post +-- ---------------------------- +BEGIN; +INSERT INTO `sys_post` VALUES (1, 'CTO', 'CTO', 0, 'CTO', '0', '2022-03-26 13:48:17', '', '2022-03-26 13:50:14', '', 1); +INSERT INTO `sys_post` VALUES (2, 'CEO', 'CEO', 1, 'CEO', '0', '2022-03-26 13:48:27', '', '2022-03-26 13:48:38', '', 1); +COMMIT; + + -- ---------------------------- -- Table structure for sys_dict -- ---------------------------- @@ -323,6 +351,12 @@ INSERT INTO `sys_menu` VALUES (1500, '租户管理', '', '/admin/tenant/index', INSERT INTO `sys_menu` VALUES (1501, '租户新增', 'admin_systenant_add', NULL, 1500, '1', 0, '0', '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:56:52', '0', 1); INSERT INTO `sys_menu` VALUES (1502, '租户修改', 'admin_systenant_edit', NULL, 1500, '1', 1, '0', '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:56:53', '0', 1); INSERT INTO `sys_menu` VALUES (1503, '租户删除', 'admin_systenant_del', NULL, 1500, '1', 2, '0', '1', ' ', '2018-05-15 21:35:18', ' ', '2020-03-24 08:56:54', '0', 1); +INSERT INTO `sys_menu` VALUES (1600, '岗位管理', NULL, '/admin/post/index', 1000, 'icon-record', 6, '0', '0', ' ', '2022-03-26 13:04:14', ' ', NULL, '0', 1); +INSERT INTO `sys_menu` VALUES (1601, '岗位信息查看', 'sys_post_view', NULL, 1600, NULL, 0, '0', '1', ' ', '2022-03-26 13:05:34', ' ', NULL, '0', 1); +INSERT INTO `sys_menu` VALUES (1602, '岗位信息新增', 'sys_post_add', NULL, 1600, NULL, 1, '0', '1', ' ', '2022-03-26 13:06:00', ' ', NULL, '0', 1); +INSERT INTO `sys_menu` VALUES (1603, '岗位信息修改', 'sys_post_edit', NULL, 1600, NULL, 2, '0', '1', ' ', '2022-03-26 13:06:31', ' ', '2022-03-26 13:06:38', '0', 1); +INSERT INTO `sys_menu` VALUES (1604, '岗位信息删除', 'sys_post_del', NULL, 1600, NULL, 3, '0', '1', ' ', '2022-03-26 13:06:31', ' ', NULL, '0', 1); +INSERT INTO `sys_menu` VALUES (1605, '岗位导入导出', 'sys_post_export', NULL, 1600, NULL, 4, '0', '1', ' ', '2022-03-26 13:06:31', ' ', '2022-03-26 06:32:02', '0', 1); INSERT INTO `sys_menu` VALUES (2000, '系统管理', NULL, '/system', -1, 'icon-xitongpeizhi', 1, '0', '0', ' ', '2017-11-07 20:56:00', ' ', '2022-02-05 16:15:14', '0', 1); INSERT INTO `sys_menu` VALUES (2100, '日志管理', NULL, '/admin/log/index', 2000, 'icon-rizhi', 5, '0', '0', ' ', '2017-11-20 14:06:22', ' ', '2020-03-24 08:56:56', '0', 1); INSERT INTO `sys_menu` VALUES (2101, '日志删除', 'sys_log_del', NULL, 2100, NULL, 1, '0', '1', ' ', '2017-11-20 20:37:37', ' ', '2021-05-25 03:12:55', '0', 1); @@ -578,6 +612,12 @@ INSERT INTO `sys_role_menu` VALUES (1, 1500); INSERT INTO `sys_role_menu` VALUES (1, 1501); INSERT INTO `sys_role_menu` VALUES (1, 1502); INSERT INTO `sys_role_menu` VALUES (1, 1503); +INSERT INTO `sys_role_menu` VALUES (1, 1600); +INSERT INTO `sys_role_menu` VALUES (1, 1601); +INSERT INTO `sys_role_menu` VALUES (1, 1602); +INSERT INTO `sys_role_menu` VALUES (1, 1603); +INSERT INTO `sys_role_menu` VALUES (1, 1604); +INSERT INTO `sys_role_menu` VALUES (1, 1605); INSERT INTO `sys_role_menu` VALUES (1, 2000); INSERT INTO `sys_role_menu` VALUES (1, 2100); INSERT INTO `sys_role_menu` VALUES (1, 2101); diff --git a/db/6pigxx_config.sql b/db/6pigxx_config.sql index f14bf11ce..3d20832f4 100644 --- a/db/6pigxx_config.sql +++ b/db/6pigxx_config.sql @@ -38,7 +38,7 @@ INSERT INTO `config_info` VALUES (3, 'pigx-codegen-dev.yml', 'DEFAULT_GROUP', '# INSERT INTO `config_info` VALUES (4, 'pigx-daemon-elastic-job-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n client-secret: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n scope: server\n## 定时任务\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true', '4124589805657db024b20772cccf57f5', '2019-04-18 02:12:57', '2020-11-09 16:18:05', NULL, '172.16.1.198', '', '', '定时任务-elastic-job配置', 'null', 'null', 'yaml', 'null'); INSERT INTO `config_info` VALUES (5, 'pigx-gateway-dev.yml', 'DEFAULT_GROUP', 'gateway:\n encode-key: \'pigxpigxpigxpigx\'\n\nswagger:\n ignore-providers:\n - pigx-monitor\n - pigx-auth\n - pigx-tx-manager\n\nribbon:\n rule:\n gray-enabled: true\n\n# 验证码相关配置参考: http://t.cn/A647jEdu\naj:\n captcha:\n cache-type: redis\n water-mark: pig4cloud', 'cd9f8a6a46e2c128f3b172be76ea3221', '2019-04-18 02:13:52', '2021-11-09 12:09:34', '', '127.0.0.1', '', '', '', '', '', 'yaml', ''); INSERT INTO `config_info` VALUES (6, 'pigx-monitor-dev.yml', 'DEFAULT_GROUP', 'spring:\n # 安全配置\n security:\n user:\n name: ENC(rZHA4LW5hHmhLAAzJoFNag==) # pigx\n password: ENC(bjeyh+Aeii3kHXkoo00ZUw==) # pigx\n autoconfigure:\n exclude: com.pig4cloud.pigx.common.core.config.JacksonConfiguration\n boot:\n admin:\n ui:\n title: \'pigx 服务状态监控\'\n brand: \'pigx 服务状态监控\'\n external-views:\n - label: \"SQL监控\"\n url: /druid/sql.html\n order: 2000\n iframe: true\nmanagement:\n endpoints:\n web:\n exposure:\n include: \'*\'\n endpoint:\n health:\n show-details: ALWAYS #显示详细信息\n\n\n# druid 监控的服务\nmonitor:\n applications:\n - pigx-upms-biz\n - pigx-pay-platform\n', 'cbc0b536fe11eeff0dcf81be11dab6e4', '2019-04-18 02:14:17', '2022-02-18 13:44:07', 'nacos', '127.0.0.1', '', '', '监控配置文件', 'null', 'null', 'yaml', 'null'); -INSERT INTO `config_info` VALUES (7, 'pigx-upms-biz-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(ltJPpR50wT0oIY9kfOe1Iw==)\n client-secret: ENC(ltJPpR50wT0oIY9kfOe1Iw==)\n scope: server\n ignore-urls:\n - /error\n - /druid/**\n - /actuator/**\n - /v2/api-docs\n\n# 数据源\nspring:\n autoconfigure:\n exclude: org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n stat-view-servlet:\n enabled: true\n allow: \"\"\n url-pattern: /druid/*\n #login-username: admin\n #login-password: admin\n filter:\n stat:\n enabled: true\n log-slow-sql: true\n slow-sql-millis: 10000\n merge-sql: false\n wall:\n config:\n multi-statement-allow: true\n\n# 文件系统 (minio测试环境,不可当生产使用)\noss:\n endpoint: http://minio.pig4cloud.com\n access-key: lengleng\n secret-key: lengleng\n bucket-name: tmp\n\n# Logger Config\nlogging:\n level:\n com.pig4cloud.pigx.admin.mapper: debug\n\n# 租户表维护\npigx:\n tenant:\n column: tenant_id\n tables:\n - sys_user\n - sys_role\n - sys_menu\n - sys_dept\n - sys_log\n - sys_social_details\n - sys_dict\n - sys_dict_item\n - sys_public_param\n - sys_log\n - sys_file\n - sys_oauth_client_details ', '1d1062f04c4b7c0a99984be0e05083c8', '2019-04-18 02:32:44', '2022-02-17 15:33:21', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', ''); +INSERT INTO `config_info` VALUES (7, 'pigx-upms-biz-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(ltJPpR50wT0oIY9kfOe1Iw==)\n client-secret: ENC(ltJPpR50wT0oIY9kfOe1Iw==)\n scope: server\n ignore-urls:\n - /error\n - /druid/**\n - /actuator/**\n - /v2/api-docs\n\n# 数据源\nspring:\n autoconfigure:\n exclude: org.springframework.cloud.gateway.config.GatewayAutoConfiguration,org.springframework.cloud.gateway.config.GatewayClassPathWarningAutoConfiguration\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n stat-view-servlet:\n enabled: true\n allow: \"\"\n url-pattern: /druid/*\n #login-username: admin\n #login-password: admin\n filter:\n stat:\n enabled: true\n log-slow-sql: true\n slow-sql-millis: 10000\n merge-sql: false\n wall:\n config:\n multi-statement-allow: true\n\n# 文件系统 (minio测试环境,不可当生产使用)\noss:\n endpoint: http://minio.pig4cloud.com\n access-key: lengleng\n secret-key: lengleng\n bucket-name: tmp\n\n# Logger Config\nlogging:\n level:\n com.pig4cloud.pigx.admin.mapper: debug\n\n# 租户表维护\npigx:\n tenant:\n column: tenant_id\n tables:\n - sys_user\n - sys_role\n - sys_menu\n - sys_dept\n - sys_log\n - sys_social_details\n - sys_dict\n - sys_dict_item\n - sys_public_param\n - sys_log\n - sys_file\n - sys_oauth_client_details\n - sys_post', '1d1062f04c4b7c0a99984be0e05083c8', '2019-04-18 02:32:44', '2022-02-17 15:33:21', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', ''); INSERT INTO `config_info` VALUES (8, 'pigx-tx-manager-dev.yml', 'DEFAULT_GROUP', '# 页面配置\nspring:\n mvc:\n static-path-pattern: /**\n resources:\n static-locations: classpath:/static/\n\n\n# LCN 配置\ntm:\n transaction:\n netty:\n delaytime: 5 # 客户端链接最大通讯时间 (秒)\n hearttime: 15 # 客户端心跳时间 (秒)\n redis:\n savemaxtime: 30 # redis 保存时间 (秒)\n socket:\n port: 9998 # 通讯端口\n maxconnection: 1000 #最大链接数\n compensate:\n auto: false #是否自动补偿\n notifyUrl: http://ip:port/path #补偿结果通知(配消息总线里面)\n tryTime: 30 # z再次重试时间间隔\n maxWaitTime: 5000 # 请求超时的最大时间 (毫秒)', '885f5c125f2df7a08692929ccce154be', '2019-04-18 02:54:03', '2019-04-18 02:54:03', NULL, '127.0.0.1', '', '', '分布式事务协调模块', NULL, NULL, 'yaml', NULL); INSERT INTO `config_info` VALUES (9, 'pigx-daemon-quartz-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n client-secret: ENC(tz2NM4GcmnE7sNJTYL8ZSg==)\n scope: server\n\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx_job}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n resources:\n static-locations: classpath:/static/,classpath:/views/\n quartz:\n #相关属性配置\n properties:\n org:\n quartz:\n scheduler:\n instanceName: clusteredScheduler\n instanceId: AUTO\n jobStore:\n class: org.springframework.scheduling.quartz.LocalDataSourceJobStore\n driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate\n tablePrefix: QRTZ_\n isClustered: true\n clusterCheckinInterval: 10000\n useProperties: false\n threadPool:\n class: org.quartz.simpl.SimpleThreadPool\n threadCount: 50\n threadPriority: 5\n threadsInheritContextClassLoaderOfInitializingThread: true\n #数据库方式\n job-store-type: jdbc\n #初始化表结构\n #jdbc:\n #initialize-schema: never\n\n', '9ff6e1d6f4d7f8776cb13e31c9dc8ce9', '2019-04-18 03:08:34', '2022-02-18 14:44:22', 'nacos', '127.0.0.1', '', '', '', '', '', 'yaml', ''); INSERT INTO `config_info` VALUES (10, 'pigx-pay-platform-dev.yml', 'DEFAULT_GROUP', '## spring security 配置\nsecurity:\n oauth2:\n client:\n client-id: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n client-secret: ENC(gPFcUOmJm8WqM3k3eSqS0Q==)\n scope: server\n ignore-urls:\n - /druid/**\n - /error\n - /actuator/**\n - /v2/api-docs\n# 数据源\nspring:\n datasource:\n type: com.alibaba.druid.pool.DruidDataSource\n druid:\n driver-class-name: com.mysql.cj.jdbc.Driver\n username: ${MYSQL_USER:root}\n password: ${MYSQL_PWD:root}\n url: jdbc:mysql://${MYSQL_HOST:pigx-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:pigxx_pay}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true\n freemarker:\n allow-request-override: false\n allow-session-override: false\n cache: true\n charset: UTF-8\n check-template-location: true\n content-type: text/html\n enabled: true\n expose-request-attributes: false\n expose-session-attributes: false\n expose-spring-macro-helpers: true\n prefer-file-system-access: true\n suffix: .ftl\n template-loader-path: classpath:/templates/\n# 租户表维护\npigx:\n pay:\n test: lengleng\n aliPayConfig:\n expire-time: 30\n return-url: http://pig4cloud.com\n notify-url: http://wechat.pigx.top/pay/notify/ali/callbak\n wxPayConfig:\n notify-url: https://admin.pig4cloud.com/pay/notify/wx/callbak\n mergePayConfig:\n return-url: http://pig4cloud.com\n notify-url: http://wechat.pigx.top/pay/notify/merge/callbak\n xsequence: #发号器相关配置\n db:\n retry-times: 3\n table-name: pay_sequence\n tenant:\n column: tenant_id\n tables:\n - pay_channel\n - pay_trade_order\n - pay_goods_order\n - pay_notify_record', 'ee15c87a8ec17f7272d0f2f4597ee764', '2019-05-28 11:46:27', '2022-02-18 14:44:43', 'nacos', '127.0.0.1', '', '', '支付模块配置', 'null', 'null', 'yaml', 'null'); diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPost.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPost.java new file mode 100644 index 000000000..4aa528da3 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysPost.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 岗位信息表 + * + * @author fxz + * @date 2022-03-26 12:50:43 + */ +@Data +@TableName("sys_post") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "岗位信息表") +public class SysPost extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 岗位ID + */ + @TableId(value = "post_id", type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "岗位ID") + private Long postId; + + /** + * 岗位编码 + */ + @NotBlank(message = "岗位编码不能为空") + @ApiModelProperty(value = "岗位编码") + private String postCode; + + /** + * 岗位名称 + */ + @NotBlank(message = "岗位名称不能为空") + @ApiModelProperty(value = "岗位名称") + private String postName; + + /** + * 岗位排序 + */ + @NotNull(message = "排序值不能为空") + @ApiModelProperty(value = "岗位排序") + private Integer postSort; + + /** + * 岗位描述 + */ + @ApiModelProperty(value = "岗位描述") + private String remark; + + /** + * 是否删除 -1:已删除 0:正常 + */ + @TableLogic + @ApiModelProperty(value = "是否删除 -1:已删除 0:正常") + private String delFlag; + + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/PostExcelVO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/PostExcelVO.java new file mode 100644 index 000000000..3c0a5d961 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/PostExcelVO.java @@ -0,0 +1,64 @@ +package com.pig4cloud.pigx.admin.api.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 岗位excel 对应的实体 + * + * @author fxz + * @date 2022/3/21 + */ +@Data +@ColumnWidth(30) +public class PostExcelVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @ExcelProperty("岗位编号") + private Long postId; + + /** + * 岗位名称 + */ + @NotBlank(message = "岗位名称不能为空") + @ExcelProperty("岗位名称") + private String postName; + + /** + * 岗位标识 + */ + @NotBlank(message = "岗位标识不能为空") + @ExcelProperty("岗位标识") + private String postCode; + + /** + * 岗位排序 + */ + @NotNull(message = "岗位排序不能为空") + @ExcelProperty("岗位排序") + private Integer postSort; + + /** + * 岗位描述 + */ + @NotBlank(message = "岗位描述不能为空") + @ExcelProperty(value = "岗位描述") + private String remark; + + /** + * 创建时间 + */ + @ExcelProperty(value = "创建时间") + private LocalDateTime createTime; + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java new file mode 100644 index 000000000..e953bcb3a --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.pig4cloud.pigx.admin.api.entity.SysPost; +import com.pig4cloud.pigx.admin.api.vo.PostExcelVO; +import com.pig4cloud.pigx.admin.service.SysPostService; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.excel.annotation.RequestExcel; +import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel; +import com.pig4cloud.pigx.common.log.annotation.SysLog; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 岗位信息表 + * + * @author fxz + * @date 2022-03-26 12:50:43 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/post") +@Api(value = "post", tags = "岗位信息表管理") +public class SysPostController { + + private final SysPostService sysPostService; + + /** + * 分页查询 + * @param page 分页对象 + * @param sysPost 岗位信息表 + * @return + */ + @ApiOperation(value = "分页查询", notes = "分页查询") + @GetMapping("/page") + @PreAuthorize("@pms.hasPermission('sys_post_view')") + public R getSysPostPage(Page page, SysPost sysPost) { + return R.ok(sysPostService.page(page, Wrappers.query(sysPost))); + } + + /** + * 通过id查询岗位信息表 + * @param postId id + * @return R + */ + @ApiOperation(value = "通过id查询", notes = "通过id查询") + @GetMapping("/{postId}") + @PreAuthorize("@pms.hasPermission('sys_post_view')") + public R getById(@PathVariable("postId") Long postId) { + return R.ok(sysPostService.getById(postId)); + } + + /** + * 新增岗位信息表 + * @param sysPost 岗位信息表 + * @return R + */ + @ApiOperation(value = "新增岗位信息表", notes = "新增岗位信息表") + @SysLog("新增岗位信息表") + @PostMapping + @PreAuthorize("@pms.hasPermission('sys_post_add')") + public R save(@RequestBody SysPost sysPost) { + return R.ok(sysPostService.save(sysPost)); + } + + /** + * 修改岗位信息表 + * @param sysPost 岗位信息表 + * @return R + */ + @ApiOperation(value = "修改岗位信息表", notes = "修改岗位信息表") + @SysLog("修改岗位信息表") + @PutMapping + @PreAuthorize("@pms.hasPermission('sys_post_edit')") + public R updateById(@RequestBody SysPost sysPost) { + return R.ok(sysPostService.updateById(sysPost)); + } + + /** + * 通过id删除岗位信息表 + * @param postId id + * @return R + */ + @ApiOperation(value = "通过id删除岗位信息表", notes = "通过id删除岗位信息表") + @SysLog("通过id删除岗位信息表") + @DeleteMapping("/{postId}") + @PreAuthorize("@pms.hasPermission('sys_post_del')") + public R removeById(@PathVariable Long postId) { + return R.ok(sysPostService.removeById(postId)); + } + + /** + * 导出excel 表格 + * @return excel 文件流 + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('sys_post_export')") + public List export() { + return sysPostService.listPost(); + } + + /** + * 导入岗位 + * @param excelVOList 岗位列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + @PostMapping("/import") + @PreAuthorize("@pms.hasPermission('sys_post_export')") + public R importRole(@RequestExcel List excelVOList, BindingResult bindingResult) { + return sysPostService.importPost(excelVOList, bindingResult); + } + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java new file mode 100644 index 000000000..b81edcd61 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.pig4cloud.pigx.admin.api.entity.SysPost; +import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 岗位信息表 + * + * @author fxz + * @date 2022-03-26 12:50:43 + */ +@Mapper +public interface SysPostMapper extends PigxBaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysPostService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysPostService.java new file mode 100644 index 000000000..43b3f1440 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysPostService.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.pig4cloud.pigx.admin.api.entity.SysPost; +import com.pig4cloud.pigx.admin.api.vo.PostExcelVO; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.validation.BindingResult; + +import java.util.List; + +/** + * 岗位信息表 + * + * @author fxz + * @date 2022-03-26 12:50:43 + */ +public interface SysPostService extends IService { + + /** + * 导出excel 表格 + * @return + */ + List listPost(); + + /** + * 导入岗位 + * @param excelVOList 岗位列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + R importPost(List excelVOList, BindingResult bindingResult); + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysPostServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysPostServiceImpl.java new file mode 100644 index 000000000..31b82e6d8 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysPostServiceImpl.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ +package com.pig4cloud.pigx.admin.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pig4cloud.pigx.admin.api.entity.SysPost; +import com.pig4cloud.pigx.admin.api.vo.PostExcelVO; +import com.pig4cloud.pigx.admin.mapper.SysPostMapper; +import com.pig4cloud.pigx.admin.service.SysPostService; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.excel.vo.ErrorMessage; +import org.springframework.stereotype.Service; +import org.springframework.validation.BindingResult; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * 岗位信息表 + * + * @author fxz + * @date 2022-03-26 12:50:43 + */ +@Service +public class SysPostServiceImpl extends ServiceImpl implements SysPostService { + + /** + * 导入岗位 + * @param excelVOList 岗位列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + @Override + public R importPost(List excelVOList, BindingResult bindingResult) { + // 通用校验获取失败的数据 + List errorMessageList = (List) bindingResult.getTarget(); + + // 个性化校验逻辑 + List postList = this.list(); + + // 执行数据插入操作 组装 PostDto + for (int i = 0; i < excelVOList.size(); i++) { + PostExcelVO excel = excelVOList.get(i); + Set errorMsg = new HashSet<>(); + // 检验岗位名称或者岗位编码是否存在 + boolean existPost = postList.stream().anyMatch(post -> excel.getPostName().equals(post.getPostName()) + || excel.getPostCode().equals(post.getPostCode())); + + if (existPost) { + errorMsg.add(String.format("%s %s 岗位名或岗位编码已经存在", excel.getPostName(), excel.getPostCode())); + } + + // 数据合法情况 + if (CollUtil.isEmpty(errorMsg)) { + insertExcelPost(excel); + } + else { + // 数据不合法 + errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); + } + } + if (CollUtil.isNotEmpty(errorMessageList)) { + return R.failed(errorMessageList); + } + return R.ok(); + } + + /** + * 导出excel 表格 + * @return + */ + @Override + public List listPost() { + List postList = this.list(Wrappers.emptyWrapper()); + // 转换成execl 对象输出 + return postList.stream().map(post -> { + PostExcelVO postExcelVO = new PostExcelVO(); + BeanUtil.copyProperties(post, postExcelVO); + return postExcelVO; + }).collect(Collectors.toList()); + } + + /** + * 插入excel Post + */ + private void insertExcelPost(PostExcelVO excel) { + SysPost sysPost = new SysPost(); + BeanUtil.copyProperties(excel, sysPost); + this.save(sysPost); + } + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/file/post.xlsx b/pigx-upms/pigx-upms-biz/src/main/resources/file/post.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..4e98211b965b0f799455a25bac73f76b6a308c7d GIT binary patch literal 8905 zcma)C1yqz>x2C&G8p)v>q$EVT1_Y$L85p`tI))BG8k7)}5|Boa96F`D8$oF<=>3ZS zyZ^dpt(kY$%#L$*oxS!mKm~XNG?@Dpro1eE|NLX2-hD6wn*yD{4$d6FJ2Ha1FHnAw zVdV+(2*Sd^NW#Iu;QXD;*ujC_!w!@g|3x023n%m-@BqgNJW7Pi)W8%N`Pu|~+`DhU z4ZcCH8=|mN<#F`*3@OWp43VmR7in8l#529;_WR(IL{NpD&BQbD70^K83aX`1H49{J z^~%kcPiO^0ZtB_iz_S7O03Yhu*h&otN;nd6B3jn31%x=e0pw-Z#)x7OhE8o1~B* zB>56gm)VY0u=LxSretPBE?WcAc&70?Me($1Ua&+WI!3>#$X7^}cgPTCw`WP9YRYoX zK+2ouk5AR&vcViw2P%exWohAFUOUiSSFLn>!9C0h0bV!Q2wJqTU|UJPMWs5mS2r+O zSg*W8gVP<#;c|G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BF{ME@!=w?IDGDBGOP%X9MXEptdxF9)+ADEmQ0V$Jz-g)Y$GrIT zB>))a7`J-cWU5h(wUBqY&vlrLq7<#PDJIzCLD$JY-i<`GrWh_^80M)*7}}+5;9QV; z^5Lxi%@M0`o1kxkmr#^0M#meB!qk|t$H#q+Oz|KEp-03`XO3$RCb&gMI?k4NX^wd} z#l6RXbS1&|F6QHZ-Jstm_P5c-p$x&5s!&kF}*h_TUew^vOV(k!--^v}oU$4d=QwP2OK-p!R-P$j-T<_= ze$nQE%%=-qIed6w!>Ntj8u*@KqEwDa#37~)2psHRjr z`4t^C1EyHkt(gMVlG7P`e$9o+GF)QqYaVRU6zz4zvt9?#bA;0@noQYU#V#BPMi5K_ z-+0!K{UY+HrqlQdq?;MZOA8-{-9nLFpez`{JfdncgyS3mt0@b5GH z`;zl}-6PsQcj@p)#{5(1!xD7Q^IK`opFF=(=D#Vs&&l8GUfKQn8`AzyeGjqrd*a{v z0DouuU*!Fvi5^18e{sj$h4i0F{{WO9vOmN>|6<3vgYEue{}T=UZ->4I`hKtbLtEXU zb$9jVzcKvNO5J3CD^L$N`mmDS>-lY^gTJ%=M_qd;=V4RxmmJnRXz|}#oQDz~&h!3~ z;CwgUyO;3ibnpLvb{6DctbYJZ|BR4_5Yt~8)&9=*7vS`8%MY8GzXUMdp;mWW{=3=! z+otc4+TZKm!x6tde9!zRZu`%jKSXZtd4GGY`agL8!f}BLh`*8*_wG*-$ai$5l=po9 E1CA*q?*IS* literal 0 HcmV?d00001 From 8969ad36ee20383e907b4406051f2af9ff74f2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E7=BB=AA=E5=A3=AE?= <2235602974@qq.com> Date: Sat, 26 Mar 2022 16:05:44 +0800 Subject: [PATCH 2/4] =?UTF-8?q?:sparkles:=20=E8=A7=92=E8=89=B2=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pigx/admin/api/vo/RoleExcelVO.java | 56 +++++++++++++ .../admin/controller/SysRoleController.java | 27 +++++++ .../pigx/admin/service/SysRoleService.java | 17 ++++ .../service/impl/SysRoleServiceImpl.java | 76 ++++++++++++++++++ .../src/main/resources/file/role.xlsx | Bin 0 -> 8834 bytes 5 files changed, 176 insertions(+) create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleExcelVO.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/file/role.xlsx diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleExcelVO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleExcelVO.java new file mode 100644 index 000000000..423ca3ac8 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/RoleExcelVO.java @@ -0,0 +1,56 @@ +package com.pig4cloud.pigx.admin.api.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 角色excel 对应的实体 + * + * @author fxz + * @date 2022/3/21 + */ +@Data +@ColumnWidth(30) +public class RoleExcelVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @ExcelProperty("角色编号") + private Long roleId; + + /** + * 角色名称 + */ + @NotBlank(message = "角色名称不能为空") + @ExcelProperty("角色名称") + private String roleName; + + /** + * 角色标识 + */ + @NotBlank(message = "角色标识不能为空") + @ExcelProperty("角色标识") + private String roleCode; + + /** + * 角色描述 + */ + @NotBlank(message = "角色描述不能为空") + @ExcelProperty("角色描述") + private String roleDesc; + + /** + * 创建时间 + */ + @ExcelProperty(value = "创建时间") + private LocalDateTime createTime; + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java index 01ac623e6..ff94564e7 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysRoleController.java @@ -24,15 +24,19 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.pig4cloud.pigx.admin.api.entity.SysRole; +import com.pig4cloud.pigx.admin.api.vo.RoleExcelVO; import com.pig4cloud.pigx.admin.api.vo.RoleVO; import com.pig4cloud.pigx.admin.service.SysRoleService; import com.pig4cloud.pigx.common.core.constant.CacheConstants; import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.excel.annotation.RequestExcel; +import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel; import com.pig4cloud.pigx.common.log.annotation.SysLog; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; import org.springframework.cache.annotation.CacheEvict; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -151,4 +155,27 @@ public class SysRoleController { return R.ok(sysRoleService.findRolesByRoleIds(roleIdList, CollUtil.join(roleIdList, StrUtil.UNDERLINE))); } + /** + * 导出excel 表格 + * @return + */ + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('sys_role_export')") + public List export() { + return sysRoleService.listRole(); + } + + /** + * 导入角色 + * @param excelVOList 角色列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + @PostMapping("/import") + @PreAuthorize("@pms.hasPermission('sys_role_export')") + public R importRole(@RequestExcel List excelVOList, BindingResult bindingResult) { + return sysRoleService.importRole(excelVOList, bindingResult); + } + } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java index 16c26d60d..7f1055060 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysRoleService.java @@ -21,7 +21,10 @@ package com.pig4cloud.pigx.admin.service; import com.baomidou.mybatisplus.extension.service.IService; import com.pig4cloud.pigx.admin.api.entity.SysRole; +import com.pig4cloud.pigx.admin.api.vo.RoleExcelVO; import com.pig4cloud.pigx.admin.api.vo.RoleVO; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.validation.BindingResult; import java.util.List; @@ -64,4 +67,18 @@ public interface SysRoleService extends IService { */ Boolean updateRoleMenus(RoleVO roleVo); + /** + * 导入角色 + * @param excelVOList 角色列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + R importRole(List excelVOList, BindingResult bindingResult); + + /** + * 查询全部的角色 + * @return list + */ + List listRole(); + } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java index abda10e42..a4af13179 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleServiceImpl.java @@ -19,21 +19,30 @@ package com.pig4cloud.pigx.admin.service.impl; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pig4cloud.pigx.admin.api.entity.SysRole; import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu; +import com.pig4cloud.pigx.admin.api.vo.RoleExcelVO; import com.pig4cloud.pigx.admin.api.vo.RoleVO; import com.pig4cloud.pigx.admin.mapper.SysRoleMapper; import com.pig4cloud.pigx.admin.service.SysRoleMenuService; import com.pig4cloud.pigx.admin.service.SysRoleService; import com.pig4cloud.pigx.common.core.constant.CacheConstants; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.excel.vo.ErrorMessage; import lombok.AllArgsConstructor; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.BindingResult; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; /** *

@@ -94,4 +103,71 @@ public class SysRoleServiceImpl extends ServiceImpl impl return roleMenuService.saveRoleMenus(sysRole.getRoleCode(), roleVo.getRoleId(), roleVo.getMenuIds()); } + /** + * 导入角色 + * @param excelVOList 角色列表 + * @param bindingResult 错误信息列表 + * @return ok fail + */ + @Override + public R importRole(List excelVOList, BindingResult bindingResult) { + // 通用校验获取失败的数据 + List errorMessageList = (List) bindingResult.getTarget(); + + // 个性化校验逻辑 + List roleList = this.list(); + + // 执行数据插入操作 组装 RoleDto + for (int i = 0; i < excelVOList.size(); i++) { + RoleExcelVO excel = excelVOList.get(i); + Set errorMsg = new HashSet<>(); + // 检验角色名称或者角色编码是否存在 + boolean existRole = roleList.stream().anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName()) + || excel.getRoleCode().equals(sysRole.getRoleCode())); + + if (existRole) { + errorMsg.add(String.format("%s %s 角色名或角色编码已经存在", excel.getRoleName(), excel.getRoleDesc())); + } + + // 数据合法情况 + if (CollUtil.isEmpty(errorMsg)) { + insertExcelRole(excel); + } + else { + // 数据不合法情况 + errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); + } + } + if (CollUtil.isNotEmpty(errorMessageList)) { + return R.failed(errorMessageList); + } + return R.ok(); + } + + /** + * 查询全部的角色 + * @return list + */ + @Override + public List listRole() { + List roleList = this.list(Wrappers.emptyWrapper()); + // 转换成execl 对象输出 + return roleList.stream().map(role -> { + RoleExcelVO roleExcelVO = new RoleExcelVO(); + BeanUtil.copyProperties(role, roleExcelVO); + return roleExcelVO; + }).collect(Collectors.toList()); + } + + /** + * 插入excel Role + */ + private void insertExcelRole(RoleExcelVO excel) { + SysRole sysRole = new SysRole(); + sysRole.setRoleName(excel.getRoleName()); + sysRole.setRoleDesc(excel.getRoleDesc()); + sysRole.setRoleCode(excel.getRoleCode()); + this.save(sysRole); + } + } diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/file/role.xlsx b/pigx-upms/pigx-upms-biz/src/main/resources/file/role.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..0c986e8bdee6e584a5648f86436797751f807516 GIT binary patch literal 8834 zcma)i1ys~q_cloP&>hlU(jC$vARs9*bPXj8-3?L#BGRCONQZQHmq<5A4Ba672mRiA zul(=#e&1PZm|4Sq&OYba=j`8J`x!MQICxZ;`w^zPB60uzpMe7XUh`4jER>}|eDNvzrpeOyJc zG_GQao?p9h^Wha*MOT=XnjDfEa`*Rs92;A%KAZPP? zo_!LGl-fD*Iu{X|rF*^7^5$JbtJ}rV;lqNo=$qu__o_|Pl4)lkvuV|{yK3G8qMNq@ zn+f1L7PNh|%3hWvDiXk208Y}tB)ufZ^gt%nuud^82Qvc7OpxUG$q_XHFK$w3NU_Zb zAJVE|0=M!6%8Z`=ljxZ5QoSlmWPK4kiYaq-9~YM1MPW6;lHoXqD3uyG_dB7T?BHUP z$7#HeJN?KmM?^=DSrJvWG3)dq|Ds zwWLS*p*Yux!de&)&Es64Y%c5}vV8sAW+u%~#6Kf&b-8B40F3}9Gy=GPMBtT+E6Dyn z2Kn)Zwn3bDq5DYJSdY)SD7E#Y^d=ai4ed&c&vAe(R@C%vEWkS-CPRL=vNXt%<4cN+ z^Y`Fmp_3&>hH>j8iEV7;Je<0%39*3TS=297oYmSY^R{%j-~>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D6=+4PrPSyNxUV1O)sR;EZw`e`+pJ=wZht|C}vqE6fdjjr;I^N zQE-S`np~&JG9UD?zLDF5=rid(yD1Zq`bF6LbCaUCQf ztHh}M5EtwP({}Mq_8=0hD~C%Og?Sj@hjy#Jbouc1U6#c*lJ4om!eo)rsSd2FXa0PV1!ZE&Q3n3o;OA{%Bwl^E^3j7U8%|xMmcT;t zZ$%1BB95=iVOdI#V95rReJZI(IfuXiXLgGgkXNHHd!y2lMyehLADKw2CaW@Y#)}iL zRoXyFZ4n28>Y{fMfaqlE_~%Wo+x{93DEL|%yx)KL^P2@7<_5cMxVKdA#pFcjNpcZz zHKHo@ZlqXmu$+{cL7k!R)PvK89sMFyyptJcd!NXn8c*ZDA>PhQ5Qs{u zx)%6vf|^}mbT{A+`nxYbo*xgDwpTKp_Mt+CmNwa>W_${_7EYVutD9LHj$4m`d^b>0 z4fYY6}{rF*IpuvHGg`tA}9VGkLIQ^dB-{qnEl=FMsOVPa0>+qi&^QY5?Dd-;a z+o|qfm|s`szd5@X1b&ZuXZPbD68WG09*X4m#=reB{1f(nB=d(9J=A{xM!$w0>A#%* zM+trie<)o34F^E=w!h(j$(a9b)AtJ9?{U9rE2zu{%{TuI@Fz~BHo;gTN~Gk;I80u@4`Oa3Qq|83Ft66^1AAK{4K5xxiiCAj{%@`sY^ gJ@$9hs{R-DZvj?K3E|ge#fJWx0SRhnPH~U>A6}sWSO5S3 literal 0 HcmV?d00001 From 1c246388e20b37f9d9021d686ec368826b0b1cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E7=BB=AA=E5=A3=AE?= <2235602974@qq.com> Date: Sat, 26 Mar 2022 16:08:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?:sparkles:=20=E8=A7=92=E8=89=B2=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/2pigxx.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/2pigxx.sql b/db/2pigxx.sql index af31f87ba..f2662034e 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -343,6 +343,7 @@ INSERT INTO `sys_menu` VALUES (1301, '角色新增', 'sys_role_add', NULL, 1300, INSERT INTO `sys_menu` VALUES (1302, '角色修改', 'sys_role_edit', NULL, 1300, NULL, 1, '0', '1', ' ', '2017-11-08 10:14:41', ' ', '2021-05-25 03:12:55', '0', 1); INSERT INTO `sys_menu` VALUES (1303, '角色删除', 'sys_role_del', NULL, 1300, NULL, 1, '0', '1', ' ', '2017-11-08 10:14:59', ' ', '2021-05-25 03:12:55', '0', 1); INSERT INTO `sys_menu` VALUES (1304, '分配权限', 'sys_role_perm', NULL, 1300, NULL, 1, '0', '1', ' ', '2018-04-20 07:22:55', ' ', '2021-05-25 03:12:55', '0', 1); +INSERT INTO `sys_menu` VALUES (1305, '角色导入导出', 'sys_role_export', NULL, 1300, NULL, 4, '0', '1', ' ', '2022-03-26 15:54:34', ' ', NULL, '0', 1); INSERT INTO `sys_menu` VALUES (1400, '部门管理', NULL, '/admin/dept/index', 1000, 'icon-web-icon-', 4, '0', '0', ' ', '2018-01-20 13:17:19', ' ', '2022-01-27 11:59:06', '0', 1); INSERT INTO `sys_menu` VALUES (1401, '部门新增', 'sys_dept_add', NULL, 1400, NULL, 1, '0', '1', ' ', '2018-01-20 14:56:16', ' ', '2021-05-25 03:12:55', '0', 1); INSERT INTO `sys_menu` VALUES (1402, '部门修改', 'sys_dept_edit', NULL, 1400, NULL, 1, '0', '1', ' ', '2018-01-20 14:56:59', ' ', '2021-05-25 03:12:55', '0', 1); @@ -604,6 +605,7 @@ INSERT INTO `sys_role_menu` VALUES (1, 1301); INSERT INTO `sys_role_menu` VALUES (1, 1302); INSERT INTO `sys_role_menu` VALUES (1, 1303); INSERT INTO `sys_role_menu` VALUES (1, 1304); +INSERT INTO `sys_role_menu` VALUES (1, 1305); INSERT INTO `sys_role_menu` VALUES (1, 1400); INSERT INTO `sys_role_menu` VALUES (1, 1401); INSERT INTO `sys_role_menu` VALUES (1, 1402); From f3b91a2aefcf7b947ca1f4fe91eb0af8888a8d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E7=BB=AA=E5=A3=AE?= <2235602974@qq.com> Date: Sat, 26 Mar 2022 16:57:16 +0800 Subject: [PATCH 4/4] =?UTF-8?q?:sparkles:=20=E7=94=A8=E6=88=B7=E5=B2=97?= =?UTF-8?q?=E4=BD=8D=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/2pigxx.sql | 16 ++++++ .../pig4cloud/pigx/admin/api/dto/UserDTO.java | 5 ++ .../pigx/admin/api/entity/SysUserPost.java | 49 +++++++++++++++++ .../pig4cloud/pigx/admin/api/vo/UserVO.java | 6 +++ .../admin/controller/SysPostController.java | 9 ++++ .../pigx/admin/mapper/SysPostMapper.java | 9 ++++ .../pigx/admin/mapper/SysUserPostMapper.java | 34 ++++++++++++ .../service/impl/SysUserServiceImpl.java | 17 ++++++ .../main/resources/mapper/SysPostMapper.xml | 53 +++++++++++++++++++ .../main/resources/mapper/SysUserMapper.xml | 3 ++ 10 files changed, 201 insertions(+) create mode 100644 pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserPost.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserPostMapper.java create mode 100644 pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysPostMapper.xml diff --git a/db/2pigxx.sql b/db/2pigxx.sql index f2662034e..63a0b309a 100644 --- a/db/2pigxx.sql +++ b/db/2pigxx.sql @@ -100,6 +100,22 @@ INSERT INTO `sys_post` VALUES (1, 'CTO', 'CTO', 0, 'CTO', '0', '2022-03-26 13:48 INSERT INTO `sys_post` VALUES (2, 'CEO', 'CEO', 1, 'CEO', '0', '2022-03-26 13:48:27', '', '2022-03-26 13:48:38', '', 1); COMMIT; +-- ---------------------------- +-- Table structure for sys_user_post +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user_post`; +CREATE TABLE `sys_user_post` ( + `user_id` bigint(0) NOT NULL COMMENT '用户ID', + `post_id` bigint(0) NOT NULL COMMENT '岗位ID', + PRIMARY KEY (`user_id`, `post_id`) USING BTREE +) ENGINE = InnoDB DEFAULT CHARACTER = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '用户与岗位关联表'; + +-- ---------------------------- +-- Records of sys_user_post +-- ---------------------------- +BEGIN; +INSERT INTO `sys_user_post` VALUES (1, 1); +COMMIT; -- ---------------------------- -- Table structure for sys_dict diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java index ad89c754a..d1467fceb 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/dto/UserDTO.java @@ -48,6 +48,11 @@ public class UserDTO extends SysUser { @ApiModelProperty(value = "部门id") private Long deptId; + /** + * 岗位ID + */ + private List post; + /** * 新密码 */ diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserPost.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserPost.java new file mode 100644 index 000000000..a83dce85e --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/entity/SysUserPost.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.pig4cloud.pigx.admin.api.entity; + +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + *

+ * 用户岗位表 + *

+ * + * @author fxz + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class SysUserPost extends Model { + + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + @ApiModelProperty(value = "用户id") + private Long userId; + + /** + * 岗位ID + */ + @ApiModelProperty(value = "岗位id") + private Long postId; + +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java index fabdfa96a..6d6574395 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/vo/UserVO.java @@ -19,6 +19,7 @@ package com.pig4cloud.pigx.admin.api.vo; +import com.pig4cloud.pigx.admin.api.entity.SysPost; import com.pig4cloud.pigx.admin.api.entity.SysRole; import com.pig4cloud.pigx.common.core.sensitive.Sensitive; import com.pig4cloud.pigx.common.core.sensitive.SensitiveTypeEnum; @@ -137,6 +138,11 @@ public class UserVO implements Serializable { @ApiModelProperty(value = "拥有的角色列表") private List roleList; + /** + * 岗位列表 + */ + private List postList; + /** * 昵称 */ diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java index e953bcb3a..61d20916b 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysPostController.java @@ -49,6 +49,15 @@ public class SysPostController { private final SysPostService sysPostService; + /** + * 获取岗位列表 + * @return 岗位列表 + */ + @GetMapping("/list") + public R> listPosts() { + return R.ok(sysPostService.list(Wrappers.emptyWrapper())); + } + /** * 分页查询 * @param page 分页对象 diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java index b81edcd61..bd289ea09 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysPostMapper.java @@ -21,6 +21,8 @@ import com.pig4cloud.pigx.admin.api.entity.SysPost; import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 岗位信息表 * @@ -30,4 +32,11 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface SysPostMapper extends PigxBaseMapper { + /** + * 通过用户ID,查询岗位信息 + * @param userId 用户id + * @return 岗位信息 + */ + List listPostsByUserId(Long userId); + } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserPostMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserPostMapper.java new file mode 100644 index 000000000..5fa646250 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserPostMapper.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.pig4cloud.pigx.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.pig4cloud.pigx.admin.api.entity.SysUserPost; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 用户岗位 Mapper 接口 + *

+ * + * @author fxz + * @since 2022/3/19 + */ +@Mapper +public interface SysUserPostMapper extends BaseMapper { + +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java index 7fe0fe1bd..229e8dcd9 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java @@ -32,6 +32,7 @@ import com.pig4cloud.pigx.admin.api.entity.*; import com.pig4cloud.pigx.admin.api.vo.UserExcelVO; import com.pig4cloud.pigx.admin.api.vo.UserVO; import com.pig4cloud.pigx.admin.mapper.SysUserMapper; +import com.pig4cloud.pigx.admin.mapper.SysUserPostMapper; import com.pig4cloud.pigx.admin.service.*; import com.pig4cloud.pigx.common.core.constant.CacheConstants; import com.pig4cloud.pigx.common.core.constant.CommonConstants; @@ -74,6 +75,8 @@ public class SysUserServiceImpl extends ServiceImpl impl private final SysUserRoleService sysUserRoleService; + private final SysUserPostMapper sysUserPostMapper; + /** * 保存用户信息 * @param userDto DTO 对象 @@ -87,6 +90,13 @@ public class SysUserServiceImpl extends ServiceImpl impl sysUser.setDelFlag(CommonConstants.STATUS_NORMAL); sysUser.setPassword(ENCODER.encode(userDto.getPassword())); baseMapper.insert(sysUser); + // 保存用户岗位信息 + userDto.getPost().stream().map(postId -> { + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(sysUser.getUserId()); + userPost.setPostId(postId); + return userPost; + }).forEach(sysUserPostMapper::insert); List userRoleList = userDto.getRole().stream().map(roleId -> { SysUserRole userRole = new SysUserRole(); userRole.setUserId(sysUser.getUserId()); @@ -199,6 +209,13 @@ public class SysUserServiceImpl extends ServiceImpl impl userRole.setRoleId(roleId); userRole.insert(); }); + sysUserPostMapper.delete(Wrappers.lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId())); + userDto.getPost().forEach(postId -> { + SysUserPost userPost = new SysUserPost(); + userPost.setUserId(sysUser.getUserId()); + userPost.setPostId(postId); + userPost.insert(); + }); return Boolean.TRUE; } diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysPostMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysPostMapper.xml new file mode 100644 index 000000000..690de24e9 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysPostMapper.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml index 3ad50fda0..18233698b 100644 --- a/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml +++ b/pigx-upms/pigx-upms-biz/src/main/resources/mapper/SysUserMapper.xml @@ -43,6 +43,9 @@ + +