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 000000000..4e98211b9 Binary files /dev/null and b/pigx-upms/pigx-upms-biz/src/main/resources/file/post.xlsx differ