From 8084fce2b4695806f11e269314b70f3da2b8ae62 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 4 Nov 2020 17:03:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=AB=AF-=E5=BE=BD=E7=AB=A0?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 5 + .../com/epmet/controller/OssController.java | 34 +++ .../com/epmet/constant/BadgeConstant.java | 2 + .../dto/BadgeCertificationConfigDTO.java | 86 ++++++ .../src/main/java/com/epmet/dto/BadgeDTO.java | 96 +++++++ .../com/epmet/dto/form/AddBadgeFormDTO.java | 42 +++ .../java/com/epmet/dto/form/BadgeFormDTO.java | 16 ++ .../com/epmet/dto/form/EditBadgeFormDTO.java | 40 +++ .../dto/result/BadgeDetailResultDTO.java | 26 ++ .../epmet/dto/result/BadgeListResultDTO.java | 31 +++ .../com/epmet/controller/BadgeController.java | 104 ++++++++ .../dao/BadgeCertificationConfigDao.java | 54 ++++ .../src/main/java/com/epmet/dao/BadgeDao.java | 108 ++++++++ .../BadgeCertificationConfigEntity.java | 56 ++++ .../java/com/epmet/entity/BadgeEntity.java | 66 +++++ .../java/com/epmet/redis/UserBadgeRedis.java | 5 - .../BadgeCertificationConfigService.java | 127 +++++++++ .../java/com/epmet/service/BadgeService.java | 150 +++++++++++ .../BadgeCertificationConfigServiceImpl.java | 149 +++++++++++ .../epmet/service/impl/BadgeServiceImpl.java | 248 ++++++++++++++++++ .../mapper/BadgeCertificationConfigDao.xml | 42 +++ .../src/main/resources/mapper/BadgeDao.xml | 116 ++++++++ 22 files changed, 1598 insertions(+), 5 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java create mode 100644 epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml create mode 100644 epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index e4832a1c8b..2242a9ef9c 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -95,6 +95,9 @@ public enum EpmetErrorCode { SIGN_IN_TIME_NO(8513, "签到时间还未到~"), SIGN_IN_TIME_END(8514, "签到时间已结束~"), + //徽章管理 + DUPLICATE_BADGE_NAME(8515, "徽章名已存在"), + // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR(8702, "添加客户根级组织失败"), @@ -110,6 +113,8 @@ public enum EpmetErrorCode { OPER_CUSTOMER_FOOTBAR_EXISTS(8712, "footbar已存在"), OPER_CUSTOMER_FOOTBAR_NOT_FOUND(8713, "footbar不存在"), OPER_EXT_APP_SECRET_RESET_FAIL(8714, "秘钥更新失败"), + OPER_UPLOAD_IMG_TYPE_ERROR(8715, "请上传PNG格式的图片"), + OPER_UPLOAD_IMG_SIZE_ERROR(8716, "请上传200*200的图片"), // 党建声音 前端提示 88段 DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"), diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index 5b3e3bee6b..a7f37ab6e9 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -10,6 +10,7 @@ package com.epmet.controller; import com.epmet.cloud.CloudStorageConfig; import com.epmet.cloud.OssFactory; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; @@ -37,6 +38,9 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; import java.util.Arrays; import java.util.Map; @@ -218,4 +222,34 @@ public class OssController { return ossService.uploadImg(file); } + + @PostMapping("uploadimg/badgeicon") + public Result badgeIcon(@RequestParam("file") MultipartFile file) throws IOException { + + // 校验文件类型 + if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { + log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType()); + throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getCode() + , EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getMsg()); + } + + // 校验文件体积,不超过2m + long maxSize = 2 * 1024 * 1024; + long size = file.getSize(); + if (size > maxSize) { + throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() + , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); + } + + BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); + int width = bufferedImage.getWidth(); + int height = bufferedImage.getHeight(); + if (width != 200 || height != 200) { + throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getCode() + , EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getMsg()); + + } + return ossService.uploadImg(file); + } + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java index 7c2a6313c2..57661b4871 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java @@ -20,4 +20,6 @@ public interface BadgeConstant { String APPROVED = "approved"; + String NONE ="none"; + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java new file mode 100644 index 0000000000..5eb6e95749 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +public class BadgeCertificationConfigDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + private String id; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 认证信息类型 手机号:mobile;全名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + private String certificationType; + + /** + * 删除标识 1删除;0未删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java new file mode 100644 index 0000000000..dfeb6f055b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +public class BadgeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + private String id; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章名称 + */ + private String badgeName; + + /** + * 徽章图标url + */ + private String badgeIcon; + + /** + * 固有徽章类型 前端页面跳转标识,党员徽章:party;无:none + */ + private String fixationBadgeType; + + /** + * 状态 上线:online;下线:offline; + */ + private String badgeStatus; + + /** + * 删除标识 1删除;0未删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java new file mode 100644 index 0000000000..ceb07d1651 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 9:47 + */ +@NoArgsConstructor +@Data +public class AddBadgeFormDTO implements Serializable { + + private static final long serialVersionUID = -5220529162950147825L; + /** + * 徽章名称 + */ + @NotBlank(message = "徽章名称不能为空") + private String badgeName; + /** + * 徽章图标 + */ + @NotBlank(message = "徽章图标不能为空") + private String badgeIcon; + /** + * 徽章状态 上线:online;下线:offline; + */ + @NotBlank(message = "徽章状态不能为空") + private String badgeStatus; + /** + * 认证信息类型数组 手机号:mobile;姓名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + @NotEmpty(message = "认证信息类型不能为空") + private List certificationTypes; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java new file mode 100644 index 0000000000..4b35497e8b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java @@ -0,0 +1,16 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 14:22 + */ +@Data +public class BadgeFormDTO implements Serializable { + private static final long serialVersionUID = 9156247659994638103L; + private String badgeId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java new file mode 100644 index 0000000000..e11d2e107c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 14:23 + */ +@Data +public class EditBadgeFormDTO implements Serializable { + private static final long serialVersionUID = 1578890423002035200L; + private String badgeId; + /** + * 徽章名称 + */ + @NotBlank(message = "徽章名称不能为空") + private String badgeName; + /** + * 徽章图标 + */ + @NotBlank(message = "徽章图标不能为空") + private String badgeIcon; + /** + * 徽章状态 上线:online;下线:offline; + */ + @NotBlank(message = "徽章状态不能为空") + private String badgeStatus; + /** + * 认证信息类型数组 手机号:mobile;姓名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + @NotEmpty(message = "认证信息类型不能为空") + private List certificationTypes; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java new file mode 100644 index 0000000000..311c78f460 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 14:17 + */ +@NoArgsConstructor +@Data +public class BadgeDetailResultDTO implements Serializable { + + private static final long serialVersionUID = 7698898330565297328L; + + private String badgeId; + private String badgeName; + private String badgeIcon; + private String badgeStatus; + private List certificationTypes; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java new file mode 100644 index 0000000000..8d5d7c28ec --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/3 16:58 + */ +@NoArgsConstructor +@Data +public class BadgeListResultDTO { + + /** + * 徽章Id + */ + private String badgeId; + /** + * 徽章名称 + */ + private String badgeName; + /** + * 徽章图标url + */ + private String badgeIcon; + /** + * 徽章状态 上线:online;下线:offline; + */ + private String badgeStatus; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java new file mode 100644 index 0000000000..92a2621013 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java @@ -0,0 +1,104 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.AddBadgeFormDTO; +import com.epmet.dto.form.BadgeFormDTO; +import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.service.BadgeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/3 16:09 + */ +@RestController +@RequestMapping("badge") +public class BadgeController { + @Autowired + private BadgeService badgeService; + + /** + * 徽章列表 + * @author zhaoqifeng + * @date 2020/11/4 14:27 + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("list") + public Result> list(@LoginUser TokenDto tokenDto) { + List result = badgeService.getList(tokenDto.getCustomerId()); + return new Result>().ok(result); + } + + /** + * 添加徽章 + * @author zhaoqifeng + * @date 2020/11/4 14:27 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("add") + public Result add(@LoginUser TokenDto tokenDto, @RequestBody AddBadgeFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + badgeService.add(tokenDto, formDTO); + return new Result(); + } + + /** + * 徽章详情 + * @author zhaoqifeng + * @date 2020/11/4 14:27 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("detail") + public Result detail(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { + BadgeDetailResultDTO result = badgeService.detail(tokenDto, formDTO); + return new Result().ok(result); + } + + /** + * 修改 + * @author zhaoqifeng + * @date 2020/11/4 15:32 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("edit") + public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditBadgeFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + badgeService.edit(tokenDto, formDTO); + return new Result(); + } + + /** + * 删除徽章 + * @author zhaoqifeng + * @date 2020/11/4 15:34 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("delete") + public Result delete(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { + badgeService.deleteBadge(tokenDto, formDTO); + return new Result(); + } + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java new file mode 100644 index 0000000000..e60ac24fc5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java @@ -0,0 +1,54 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.BadgeCertificationConfigEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Mapper +public interface BadgeCertificationConfigDao extends BaseDao { + /** + * 获取认证信息类型 + * @author zhaoqifeng + * @date 2020/11/4 14:42 + * @param customerId + * @param badgeId + * @return java.util.List + */ + List getCertificationType(@Param("customerId") String customerId, @Param("badgeId") String badgeId); + + /** + * 删除认证信息 + * @author zhaoqifeng + * @date 2020/11/4 14:43 + * @param customerId + * @param badgeId + * @return int + */ + int deleteConfig(@Param("customerId") String customerId, @Param("badgeId") String badgeId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java new file mode 100644 index 0000000000..965f753b6e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java @@ -0,0 +1,108 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.entity.BadgeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; + +import java.util.List; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Mapper +public interface BadgeDao extends BaseDao { + + /** + * 获取徽章列表 + * @author zhaoqifeng + * @date 2020/11/3 17:30 + * @param customerId + * @return java.util.List + */ + List selectList(@Param("customerId") String customerId); + + /** + * 重名校验 + * @author zhaoqifeng + * @date 2020/11/4 10:40 + * @param customerId + * @param badgeName + * @return java.util.List + */ + List getDuplicateName(@Param("customerId") String customerId, @Param("badgeName") String badgeName); + + /** + * 编辑重名校验 + * @author zhaoqifeng + * @date 2020/11/4 15:09 + * @param customerId + * @param badgeId + * @param badgeName + * @return java.util.List + */ + List getDuplicateNameForEdit(@Param("customerId") String customerId, @Param("badgeId") String badgeId, + @Param("badgeName") String badgeName); + + /** + * 获取徽章详情 + * @author zhaoqifeng + * @date 2020/11/4 14:30 + * @param customerId + * @param badgeId + * @return com.epmet.dto.result.BadgeDetailResultDTO + */ + BadgeDetailResultDTO selectDetail(@Param("customerId") String customerId, @Param("badgeId") String badgeId); + + /** + * 获取徽章信息 + * @author zhaoqifeng + * @date 2020/11/4 15:16 + * @param customerId + * @param badgeId + * @return com.epmet.entity.BadgeEntity + */ + BadgeEntity selectBadgeInfo(@Param("customerId") String customerId, @Param("badgeId") String badgeId); + + /** + * 更新徽章信息 + * @author zhaoqifeng + * @date 2020/11/4 15:38 + * @param entity + * @return void + */ + void updateBadge(BadgeEntity entity); + + /** + * 删除徽章信息 + * @author zhaoqifeng + * @date 2020/11/4 15:39 + * @param customerId + * @param badgeId + * @return void + */ + void deleteBadge(@Param("customerId") String customerId, @Param("badgeId") String badgeId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java new file mode 100644 index 0000000000..90a6001940 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("badge_certification_config") +public class BadgeCertificationConfigEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 认证信息类型 手机号:mobile;全名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + private String certificationType; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java new file mode 100644 index 0000000000..c6aec0b820 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("badge") +public class BadgeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章名称 + */ + private String badgeName; + + /** + * 徽章图标url + */ + private String badgeIcon; + + /** + * 固有徽章类型 前端页面跳转标识,党员徽章:party;无:none + */ + private String fixationBadgeType; + + /** + * 状态 上线:online;下线:offline; + */ + private String badgeStatus; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java index 1b209e7dee..cf1a34f871 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java @@ -1,18 +1,13 @@ package com.epmet.redis; import com.alibaba.fastjson.JSON; -import com.epmet.common.token.constant.LoginConstant; -import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.BadgeConstant; import com.epmet.dto.result.UserBadgeListResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java new file mode 100644 index 0000000000..5c14ca740a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java @@ -0,0 +1,127 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.BadgeCertificationConfigDTO; +import com.epmet.entity.BadgeCertificationConfigEntity; + +import java.util.List; +import java.util.Map; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +public interface BadgeCertificationConfigService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-11-03 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-11-03 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return BadgeCertificationConfigDTO + * @author generator + * @date 2020-11-03 + */ + BadgeCertificationConfigDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void save(BadgeCertificationConfigDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void update(BadgeCertificationConfigDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-11-03 + */ + void delete(String[] ids); + + /** + * 获取认证信息类型 + * @author zhaoqifeng + * @date 2020/11/4 14:39 + * @param customerId + * @param badgeId + * @return java.util.List + */ + List getCertificationType(String customerId, String badgeId); + + /** + * 保存认证信息配置 + * @author zhaoqifeng + * @date 2020/11/4 15:29 + * @param customerId + * @param badgeId + * @param list + * @return void + */ + void saveConfig(String customerId, String badgeId, List list); + + /** + * 删除配置 + * @author zhaoqifeng + * @date 2020/11/4 15:41 + * @param customerId + * @param badgeId + * @return void + */ + void deleteConfig(String customerId, String badgeId); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java new file mode 100644 index 0000000000..7b73e28561 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java @@ -0,0 +1,150 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.BadgeDTO; +import com.epmet.dto.form.AddBadgeFormDTO; +import com.epmet.dto.form.BadgeFormDTO; +import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.entity.BadgeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +public interface BadgeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-11-03 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-11-03 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return BadgeDTO + * @author generator + * @date 2020-11-03 + */ + BadgeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void save(BadgeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void update(BadgeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-11-03 + */ + void delete(String[] ids); + + /** + * 获取徽章列表 + * @author zhaoqifeng + * @date 2020/11/3 17:04 + * @param customerId + * @return java.util.List + */ + List getList(String customerId); + + /** + * 添加徽章 + * @author zhaoqifeng + * @date 2020/11/4 10:09 + * @param tokenDto + * @param formDTO + * @return void + */ + void add(TokenDto tokenDto, AddBadgeFormDTO formDTO); + + /** + * 徽章详情 + * @author zhaoqifeng + * @date 2020/11/4 14:25 + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.BadgeDetailResultDTO + */ + BadgeDetailResultDTO detail(TokenDto tokenDto, BadgeFormDTO formDTO); + + /** + * 编辑徽章 + * @author zhaoqifeng + * @date 2020/11/4 14:28 + * @param tokenDto + * @param formDTO + * @return void + */ + void edit(TokenDto tokenDto, EditBadgeFormDTO formDTO); + + /** + * 删除徽章 + * @author zhaoqifeng + * @date 2020/11/4 15:34 + * @param tokenDto + * @param formDTO + * @return void + */ + void deleteBadge(TokenDto tokenDto, BadgeFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java new file mode 100644 index 0000000000..2af4587368 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java @@ -0,0 +1,149 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.BadgeCertificationConfigDao; +import com.epmet.dto.BadgeCertificationConfigDTO; +import com.epmet.entity.BadgeCertificationConfigEntity; +import com.epmet.service.BadgeCertificationConfigService; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Service +public class BadgeCertificationConfigServiceImpl extends BaseServiceImpl implements BadgeCertificationConfigService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, BadgeCertificationConfigDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, BadgeCertificationConfigDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public BadgeCertificationConfigDTO get(String id) { + BadgeCertificationConfigEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, BadgeCertificationConfigDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(BadgeCertificationConfigDTO dto) { + BadgeCertificationConfigEntity entity = ConvertUtils.sourceToTarget(dto, BadgeCertificationConfigEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(BadgeCertificationConfigDTO dto) { + BadgeCertificationConfigEntity entity = ConvertUtils.sourceToTarget(dto, BadgeCertificationConfigEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 获取认证信息类型 + * + * @param customerId + * @param badgeId + * @return java.util.List + * @author zhaoqifeng + * @date 2020/11/4 14:39 + */ + @Override + public List getCertificationType(String customerId, String badgeId) { + List list = baseDao.getCertificationType(customerId, badgeId); + if (CollectionUtils.isEmpty(list)) { + list = baseDao.getCertificationType("default", badgeId); + } + return list; + } + + /** + * 保存认证信息配置 + * + * @param list + * @return void + * @author zhaoqifeng + * @date 2020/11/4 15:28 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveConfig(String customerId, String badgeId, List list) { + baseDao.deleteConfig(customerId, badgeId); + insertBatch(list); + } + + /** + * 删除配置 + * + * @param customerId + * @param badgeId + * @return void + * @author zhaoqifeng + * @date 2020/11/4 15:41 + */ + @Override + public void deleteConfig(String customerId, String badgeId) { + baseDao.deleteConfig(customerId, badgeId); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java new file mode 100644 index 0000000000..021b0c734a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java @@ -0,0 +1,248 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.constant.BadgeConstant; +import com.epmet.dao.BadgeDao; +import com.epmet.dto.BadgeDTO; +import com.epmet.dto.form.AddBadgeFormDTO; +import com.epmet.dto.form.BadgeFormDTO; +import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.entity.BadgeCertificationConfigEntity; +import com.epmet.entity.BadgeEntity; +import com.epmet.service.BadgeCertificationConfigService; +import com.epmet.service.BadgeService; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Service +public class BadgeServiceImpl extends BaseServiceImpl implements BadgeService { + + @Autowired + private BadgeCertificationConfigService badgeCertificationConfigService; + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, BadgeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, BadgeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public BadgeDTO get(String id) { + BadgeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, BadgeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(BadgeDTO dto) { + BadgeEntity entity = ConvertUtils.sourceToTarget(dto, BadgeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(BadgeDTO dto) { + BadgeEntity entity = ConvertUtils.sourceToTarget(dto, BadgeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 获取徽章列表 + * + * @param customerId + * @return java.util.List + * @author zhaoqifeng + * @date 2020/11/3 17:04 + */ + @Override + public List getList(String customerId) { + return baseDao.selectList(customerId); + } + + /** + * 添加徽章 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/11/4 10:09 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void add(TokenDto tokenDto, AddBadgeFormDTO formDTO) { + //重名校验 + List list = baseDao.getDuplicateName(tokenDto.getCustomerId(), formDTO.getBadgeName()); + if (CollectionUtils.isNotEmpty(list)) { + throw new RenException(EpmetErrorCode.DUPLICATE_BADGE_NAME.getCode()); + } + BadgeEntity entity = ConvertUtils.sourceToTarget(formDTO, BadgeEntity.class); + entity.setCustomerId(tokenDto.getCustomerId()); + entity.setFixationBadgeType(BadgeConstant.NONE); + insert(entity); + //保存徽章认证配置 + List badgeList = new ArrayList<>(); + formDTO.getCertificationTypes().forEach(item -> { + BadgeCertificationConfigEntity badge = new BadgeCertificationConfigEntity(); + badge.setBadgeId(entity.getId()); + badge.setCertificationType(item); + badge.setCustomerId(tokenDto.getCustomerId()); + badgeList.add(badge); + }); + badgeCertificationConfigService.insertBatch(badgeList); + } + + /** + * 徽章详情 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.BadgeDetailResultDTO + * @author zhaoqifeng + * @date 2020/11/4 14:25 + */ + @Override + public BadgeDetailResultDTO detail(TokenDto tokenDto, BadgeFormDTO formDTO) { + BadgeDetailResultDTO result = baseDao.selectDetail(tokenDto.getCustomerId(), formDTO.getBadgeId()); + List types = badgeCertificationConfigService.getCertificationType(tokenDto.getCustomerId(), formDTO.getBadgeId()); + result.setCertificationTypes(types); + return result; + } + + /** + * 编辑徽章 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/11/4 14:28 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void edit(TokenDto tokenDto, EditBadgeFormDTO formDTO) { + //重名校验 + List list = baseDao.getDuplicateNameForEdit(tokenDto.getCustomerId(), formDTO.getBadgeId(), formDTO.getBadgeName()); + if (CollectionUtils.isNotEmpty(list)) { + throw new RenException(EpmetErrorCode.DUPLICATE_BADGE_NAME.getCode()); + } + + BadgeEntity badgeEntity = baseDao.selectBadgeInfo(tokenDto.getCustomerId(), formDTO.getBadgeId()); + if (null == badgeEntity) { + badgeEntity = baseDao.selectBadgeInfo("default", formDTO.getBadgeId()); + badgeEntity.setCustomerId(tokenDto.getCustomerId()); + badgeEntity.setBadgeName(formDTO.getBadgeName()); + badgeEntity.setBadgeIcon(formDTO.getBadgeIcon()); + badgeEntity.setBadgeStatus(formDTO.getBadgeStatus()); + baseDao.insert(badgeEntity); + } else { + badgeEntity.setBadgeName(formDTO.getBadgeName()); + badgeEntity.setBadgeIcon(formDTO.getBadgeIcon()); + badgeEntity.setBadgeStatus(formDTO.getBadgeStatus()); + baseDao.updateBadge(badgeEntity); + } + //保存徽章认证配置 + List badgeList = new ArrayList<>(); + formDTO.getCertificationTypes().forEach(item -> { + BadgeCertificationConfigEntity badge = new BadgeCertificationConfigEntity(); + badge.setBadgeId(formDTO.getBadgeId()); + badge.setCertificationType(item); + badge.setCustomerId(tokenDto.getCustomerId()); + badgeList.add(badge); + }); + badgeCertificationConfigService.saveConfig(tokenDto.getCustomerId(), formDTO.getBadgeId(), badgeList); + } + + /** + * 删除徽章 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/11/4 15:34 + */ + @Override + public void deleteBadge(TokenDto tokenDto, BadgeFormDTO formDTO) { + BadgeEntity badgeEntity = baseDao.selectBadgeInfo(tokenDto.getCustomerId(), formDTO.getBadgeId()); + if (null == badgeEntity) { + badgeEntity = baseDao.selectBadgeInfo("default", formDTO.getBadgeId()); + badgeEntity.setCustomerId(tokenDto.getCustomerId()); + badgeEntity.setDelFlag(NumConstant.ONE_STR); + baseDao.insert(badgeEntity); + } else { + baseDao.deleteBadge(tokenDto.getCustomerId(), formDTO.getBadgeId()); + } + badgeCertificationConfigService.deleteConfig(tokenDto.getCustomerId(), formDTO.getBadgeId()); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml new file mode 100644 index 0000000000..251523c8d3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + DELETE a + FROM + badge_certification_config a + WHERE + EXISTS ( + SELECT + * + FROM + ( SELECT ID FROM badge_certification_config + WHERE CUSTOMER_ID = #{customerId} + AND BADGE_ID = #{badgeId} + AND DEL_FLAG = '0' ) b + WHERE + a.ID = b.ID) + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml new file mode 100644 index 0000000000..322604bc70 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + update badge set + BADGE_NAME = #{badgeName}, + BADGE_ICON = #{badgeIcon}, + BADGE_STATUS = #{badgeStatus} + where ID = #{id} AND CUSTOMER_ID = #{customerId} + + + + update badge set + DEL_FLAG = '1' + where ID = #{badgeId} AND CUSTOMER_ID = #{customerId} + + + + + + + + + \ No newline at end of file