From aae00a4bb9d6605b3b277600bc881628ccd428fd Mon Sep 17 00:00:00 2001 From: Diyu0904 <1819728964@qq.com> Date: Thu, 9 Jan 2025 11:14:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AE=9E=E5=90=8D=E8=AE=A4?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/comment/CommentController.java | 154 ++++---- .../controller/pay/WxPay/WxPayController.java | 65 ++++ .../resource/MallProductLikeController.java | 2 +- .../controller/system/SysUserController.java | 12 + .../web/controller/system/WXController.java | 14 +- .../java/com/mcwl/comment/domain/Comment.java | 106 +++--- .../domain/ProductCommentConditionEntity.java | 108 +++--- .../comment/domain/ProductCommentEntity.java | 96 ++--- .../domain/RequestConditionEntity.java | 82 ++--- .../comment/domain/RequestPageEntity.java | 144 ++++---- .../mcwl/comment/mapper/CommentMapper.java | 62 ++-- .../service/impl/CommentServiceImpl.java | 176 +++++----- .../mapper/comment/CommentMapper.xml | 95 ----- mcwl-common/pom.xml | 21 +- .../mcwl/common/constant/CacheConstants.java | 5 + .../common/core/domain/entity/SysUser.java | 28 ++ .../java/com/mcwl/common/utils/HttpUtils.java | 328 ++++++++++++++++++ .../com/mcwl/common/utils/VerifyCard.java | 55 +++ .../impl/SysUserAttentionServiceImpl.java | 3 +- .../com/mcwl/system/mapper/SysUserMapper.java | 4 + .../mcwl/system/service/ISysUserService.java | 2 + .../service/impl/SysUserServiceImpl.java | 50 +++ .../resources/mapper/system/SysUserMapper.xml | 13 +- 23 files changed, 1050 insertions(+), 575 deletions(-) create mode 100644 mcwl-admin/src/main/java/com/mcwl/web/controller/pay/WxPay/WxPayController.java delete mode 100644 mcwl-comment/src/main/resources/mapper/comment/CommentMapper.xml create mode 100644 mcwl-common/src/main/java/com/mcwl/common/utils/HttpUtils.java create mode 100644 mcwl-common/src/main/java/com/mcwl/common/utils/VerifyCard.java diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/comment/CommentController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/comment/CommentController.java index 5739ee1..83d8d28 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/comment/CommentController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/comment/CommentController.java @@ -1,77 +1,77 @@ -package com.mcwl.web.controller.comment; - - -import com.mcwl.comment.domain.ProductCommentConditionEntity; -import com.mcwl.comment.domain.ProductCommentEntity; -import com.mcwl.comment.service.impl.CommentServiceImpl; -import com.mcwl.common.utils.ResponsePageEntity; -import com.mcwl.resource.domain.MallProduct; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * @Author:ChenYan - * @Project:McWl - * @Package:com.mcwl.web.controller.comment - * @Filename:CommentController - * @Description TODO - * @Date:2025/1/4 18:56 - */ -@RestController -@RequestMapping("/comment") -public class CommentController { - - @Autowired - private CommentServiceImpl commentService; - - /** - * 通过id查询商品评论信息 - * - * @param id 系统ID - * @return 商品评论信息 - */ - @GetMapping("/findById") - public MallProduct findById(Long id) { - return commentService.findById(id); - } - - - - /** - * 添加商品评论 - * - * @param productCommentEntity 商品评论实体 - * @return 影响行数 - */ - @PostMapping("/insert") - public int insert(@RequestBody ProductCommentEntity productCommentEntity) { - return commentService.insert(productCommentEntity); - } - - /** - * 修改商品评论 - * - * @param productCommentEntity 商品评论实体 - * @return 影响行数 - */ - @PostMapping("/update") - public int update(@RequestBody ProductCommentEntity productCommentEntity) { - return commentService.update(productCommentEntity); - } - - /** - * 批量删除商品评论 - * - * @param ids 商品评论ID集合 - * @return 影响行数 - */ - @PostMapping("/deleteByIds") - public int deleteByIds(@RequestBody @NotNull List ids) { - return commentService.deleteByIds(ids); - } - - -} +//package com.mcwl.web.controller.comment; +// +// +//import com.mcwl.comment.domain.ProductCommentConditionEntity; +//import com.mcwl.comment.domain.ProductCommentEntity; +//import com.mcwl.comment.service.impl.CommentServiceImpl; +//import com.mcwl.common.utils.ResponsePageEntity; +//import com.mcwl.resource.domain.MallProduct; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.*; +// +//import javax.validation.constraints.NotNull; +//import java.util.List; +// +///** +// * @Author:ChenYan +// * @Project:McWl +// * @Package:com.mcwl.web.controller.comment +// * @Filename:CommentController +// * @Description TODO +// * @Date:2025/1/4 18:56 +// */ +//@RestController +//@RequestMapping("/comment") +//public class CommentController { +// +// @Autowired +// private CommentServiceImpl commentService; +// +// /** +// * 通过id查询商品评论信息 +// * +// * @param id 系统ID +// * @return 商品评论信息 +// */ +// @GetMapping("/findById") +// public MallProduct findById(Long id) { +// return commentService.findById(id); +// } +// +// +// +// /** +// * 添加商品评论 +// * +// * @param productCommentEntity 商品评论实体 +// * @return 影响行数 +// */ +// @PostMapping("/insert") +// public int insert(@RequestBody ProductCommentEntity productCommentEntity) { +// return commentService.insert(productCommentEntity); +// } +// +// /** +// * 修改商品评论 +// * +// * @param productCommentEntity 商品评论实体 +// * @return 影响行数 +// */ +// @PostMapping("/update") +// public int update(@RequestBody ProductCommentEntity productCommentEntity) { +// return commentService.update(productCommentEntity); +// } +// +// /** +// * 批量删除商品评论 +// * +// * @param ids 商品评论ID集合 +// * @return 影响行数 +// */ +// @PostMapping("/deleteByIds") +// public int deleteByIds(@RequestBody @NotNull List ids) { +// return commentService.deleteByIds(ids); +// } +// +// +//} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/WxPay/WxPayController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/WxPay/WxPayController.java new file mode 100644 index 0000000..ec2efe6 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/WxPay/WxPayController.java @@ -0,0 +1,65 @@ +package com.mcwl.web.controller.pay.WxPay; + +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.mcwl.web.controller.pay.WxPay.util.PayUtil; +import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; +import org.springframework.web.bind.annotation.*; + +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +/** + * 微信支付 + * + * @author DaiZibo + * @date 2025/1/6 + * @apiNote + */ + + +@RestController +@RequestMapping(value = "/wx/pay") +public class WxPayController { + + /** + * 预支付下单 + * + * @param orderSn 订单号 + * @param total 分 + * @param description 描述 + */ + @GetMapping(value = "/getPay") + public String getPay(String orderSn, int total, String description) { + PayUtil payUtil = new PayUtil(); + try { + return payUtil.requestwxChatPay(orderSn, total, description, "oYgFI91D00GpCwccdnKDR4KNxI4k"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + // 支付回调 + @PostMapping(value = "/returnNotify") + public Map returnNotify(@RequestBody JSONObject jsonObject) { + // v3 私钥 + String key = "xxxxx"; + String json = jsonObject.toString(); + String associated_data = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.associated_data"); + String ciphertext = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.ciphertext"); + String nonce = (String) JSONUtil.getByPath(JSONUtil.parse(json), "resource.nonce"); + try { + String decryptData = new AesUtil(key.getBytes(StandardCharsets.UTF_8)).decryptToString(associated_data.getBytes(StandardCharsets.UTF_8), nonce.getBytes(StandardCharsets.UTF_8), ciphertext); + System.out.println("decryptData = " + decryptData); + //TODO 业务校验 + } catch (Exception e) { + e.printStackTrace(); + } + HashMap stringStringHashMap = new HashMap<>(); + stringStringHashMap.put("code", "200"); + stringStringHashMap.put("message", "返回成功"); + // 返回这个说明应答成功 + return stringStringHashMap; + } +} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java index 844e024..dda90b0 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductLikeController.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*; * @apiNote */ -@RequestMapping("like") +@RequestMapping("/like") @RestController public class MallProductLikeController { diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java index 236581e..77ed1a6 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/SysUserController.java @@ -269,4 +269,16 @@ public class SysUserController extends BaseController userService.updateUserInfo(sysUser); return AjaxResult.success("修改成功"); } + + /** + * 实名认证 + * @param sysUser + * @return + */ + @PostMapping("/updateIdCard") + public AjaxResult updateIdCard(@RequestBody SysUser sysUser){ + + return userService.updateIdCard(sysUser); + } + } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/WXController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/WXController.java index 199c60c..014be8a 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/WXController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/WXController.java @@ -14,12 +14,13 @@ import com.mcwl.system.domain.SysUserThirdAccount; import com.mcwl.system.service.ISysUserService; import com.mcwl.system.service.ISysUserThirdAccountService; import com.mcwl.system.service.IWXService; -import com.mcwl.web.controller.common.OssUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.io.IOException; @@ -59,13 +60,6 @@ public class WXController { @Resource private SysPermissionService permissionService; - @Anonymous - @PostMapping("/test") - public AjaxResult test(@RequestParam MultipartFile file){ - - String s = OssUtil.uploadMultipartFile(file); - return AjaxResult.success(s); - } /** * 扫码登录用uuid生成 diff --git a/mcwl-comment/src/main/java/com/mcwl/comment/domain/Comment.java b/mcwl-comment/src/main/java/com/mcwl/comment/domain/Comment.java index 858cb4e..202c209 100644 --- a/mcwl-comment/src/main/java/com/mcwl/comment/domain/Comment.java +++ b/mcwl-comment/src/main/java/com/mcwl/comment/domain/Comment.java @@ -1,53 +1,53 @@ -package com.mcwl.comment.domain; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.mcwl.common.core.domain.BaseEntity; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @Author:ChenYan - * @Project:McWl - * @Package:com.mcwl.comment.domain - * @Filename:Comment - * @Description 评论表 - * @Date:2025/1/4 18:47 - */ -@AllArgsConstructor -@NoArgsConstructor -@Data -@TableName("mall_product_comment") -public class Comment extends BaseEntity { - - /** - * ID - */ - @TableId - private Long id; - /** - * 父评论ID - */ - private String parentId; - /** - * 商品ID - */ - private String productId; - /** - * 用户ID - */ - private String userId; - /** - * 评论内容 - */ - private String content; - /** - * 评分 - */ - private String rating; - /** - * 删除标志(0代表存在 2代表删除) - */ - private String delFlag; -} +//package com.mcwl.comment.domain; +// +//import com.baomidou.mybatisplus.annotation.TableId; +//import com.baomidou.mybatisplus.annotation.TableName; +//import com.mcwl.common.core.domain.BaseEntity; +//import lombok.AllArgsConstructor; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +///** +// * @Author:ChenYan +// * @Project:McWl +// * @Package:com.mcwl.comment.domain +// * @Filename:Comment +// * @Description 评论表 +// * @Date:2025/1/4 18:47 +// */ +//@AllArgsConstructor +//@NoArgsConstructor +//@Data +//@TableName("mall_product_comment") +//public class Comment extends BaseEntity { +// +// /** +// * ID +// */ +// @TableId +// private Long id; +// /** +// * 父评论ID +// */ +// private String parentId; +// /** +// * 商品ID +// */ +// private String productId; +// /** +// * 用户ID +// */ +// private String userId; +// /** +// * 评论内容 +// */ +// private String content; +// /** +// * 评分 +// */ +// private String rating; +// /** +// * 删除标志(0代表存在 2代表删除) +// */ +// private String delFlag; +//} diff --git a/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentConditionEntity.java b/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentConditionEntity.java index a2cf39e..e3c5832 100644 --- a/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentConditionEntity.java +++ b/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentConditionEntity.java @@ -1,56 +1,56 @@ -package com.mcwl.comment.domain; - - -import lombok.Data; - -import java.util.List; - -/** - * 商品评论查询条件实体 - */ -@Data -public class ProductCommentConditionEntity extends RequestConditionEntity { - - /** - * ID集合 - */ - private List idList; - - /** - * ID - */ - private Long id; - /** - * 父评论ID - */ - private Long parentId; - /** - * 商品ID - */ - private Long productId; - - /** - * 商品ID集合 - */ - private List productIdList; - /** - * 用户ID - */ - private Long userId; - /** - * 评论内容 - */ - private String content; - /** - * 评分 - */ - private Integer rating; - /** - * 删除标志(0代表存在 2代表删除) - */ - private String delFlag; +//package com.mcwl.comment.domain; +// +// +//import lombok.Data; +// +//import java.util.List; +// +///** +// * 商品评论查询条件实体 +// */ +//@Data +//public class ProductCommentConditionEntity extends RequestConditionEntity { +// // /** -// * 评论类型 +// * ID集合 // */ -// private Integer type; -} +// private List idList; +// +// /** +// * ID +// */ +// private Long id; +// /** +// * 父评论ID +// */ +// private Long parentId; +// /** +// * 商品ID +// */ +// private Long productId; +// +// /** +// * 商品ID集合 +// */ +// private List productIdList; +// /** +// * 用户ID +// */ +// private Long userId; +// /** +// * 评论内容 +// */ +// private String content; +// /** +// * 评分 +// */ +// private Integer rating; +// /** +// * 删除标志(0代表存在 2代表删除) +// */ +// private String delFlag; +//// /** +//// * 评论类型 +//// */ +//// private Integer type; +//} diff --git a/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentEntity.java b/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentEntity.java index c3780c6..ac099a7 100644 --- a/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentEntity.java +++ b/mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentEntity.java @@ -1,50 +1,50 @@ -package com.mcwl.comment.domain; - -import com.mcwl.common.core.domain.BaseEntity; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @Author:ChenYan - * @Project:McWl - * @Package:com.mcwl.comment.domain - * @Filename:ProductCommentEntity - * @Description 评论实体 - * @Date:2025/1/6 13:21 - */ -@AllArgsConstructor -@NoArgsConstructor -@Data -public class ProductCommentEntity extends BaseEntity { - - /** - * 父评论ID - */ - private Long parentId; - - /** - * 商品ID - */ - private Long productId; - - /** - * 用户ID - */ - private Long userId; - - /** - * 评论内容 - */ - private String content; - - /** - * 评分 - */ - private Integer rating; - +//package com.mcwl.comment.domain; +// +//import com.mcwl.common.core.domain.BaseEntity; +//import lombok.AllArgsConstructor; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +///** +// * @Author:ChenYan +// * @Project:McWl +// * @Package:com.mcwl.comment.domain +// * @Filename:ProductCommentEntity +// * @Description 评论实体 +// * @Date:2025/1/6 13:21 +// */ +//@AllArgsConstructor +//@NoArgsConstructor +//@Data +//public class ProductCommentEntity extends BaseEntity { +// // /** -// * 评论类型 +// * 父评论ID // */ -// private Integer type; -} +// private Long parentId; +// +// /** +// * 商品ID +// */ +// private Long productId; +// +// /** +// * 用户ID +// */ +// private Long userId; +// +// /** +// * 评论内容 +// */ +// private String content; +// +// /** +// * 评分 +// */ +// private Integer rating; +// +//// /** +//// * 评论类型 +//// */ +//// private Integer type; +//} diff --git a/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestConditionEntity.java b/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestConditionEntity.java index 0522e90..0f3e740 100644 --- a/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestConditionEntity.java +++ b/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestConditionEntity.java @@ -1,41 +1,41 @@ -package com.mcwl.comment.domain; - -import com.mcwl.common.utils.RequestPageEntity; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -/** - * 请求条件实体 - */ -@Data -public class RequestConditionEntity extends RequestPageEntity { - - - /** - * 创建日期范围 - */ - @ApiModelProperty("创建日期范围") - private List betweenTime; - - /** - * 创建开始时间 - */ - private String createBeginTime; - - /** - * 创建结束时间 - */ - private String createEndTime; - - /** - * 自定义excel表头列表 - */ - private List customizeColumnNameList; - - /** - * 查询条件 - */ - private String blurry; -} +//package com.mcwl.comment.domain; +// +//import com.mcwl.common.utils.RequestPageEntity; +//import io.swagger.annotations.ApiModelProperty; +//import lombok.Data; +// +//import java.util.List; +// +///** +// * 请求条件实体 +// */ +//@Data +//public class RequestConditionEntity extends RequestPageEntity { +// +// +// /** +// * 创建日期范围 +// */ +// @ApiModelProperty("创建日期范围") +// private List betweenTime; +// +// /** +// * 创建开始时间 +// */ +// private String createBeginTime; +// +// /** +// * 创建结束时间 +// */ +// private String createEndTime; +// +// /** +// * 自定义excel表头列表 +// */ +// private List customizeColumnNameList; +// +// /** +// * 查询条件 +// */ +// private String blurry; +//} diff --git a/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestPageEntity.java b/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestPageEntity.java index ff21aa0..fff5643 100644 --- a/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestPageEntity.java +++ b/mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestPageEntity.java @@ -1,72 +1,72 @@ -package com.mcwl.comment.domain; - -import cn.hutool.core.collection.CollectionUtil; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.util.List; -import java.util.Objects; - -/** - * 分页请求实体 - */ -@AllArgsConstructor -@NoArgsConstructor -@Data -public class RequestPageEntity implements Serializable { - - private static final int DEFAULT_PAGE_SIZE = 10; - - /** - * 页码,默认从一页开始 - */ - private Integer pageNo = 1; - - /** - * 每页大小,默认一页查询10条数据 - */ - private Integer pageSize = DEFAULT_PAGE_SIZE; - - /** - * 排序字段 - */ - private List sortField; - - - /** - * 获取分页开始位置 - * - * @return 分页开始位置 - */ - public Integer getPageBegin() { - if (Objects.isNull(this.pageNo) || this.pageNo <= 0) { - this.pageNo = 1; - } - - if (Objects.isNull(this.pageSize)) { - this.pageSize = DEFAULT_PAGE_SIZE; - } - - return (this.pageNo - 1) * this.pageSize; - } - - /** - * 获取用户自定义排序集合 - * - * @return 排序集合实体 - */ - public String getSortString() { - List sortField = this.getSortField(); - if (CollectionUtil.isEmpty(sortField)) { - return null; - } - StringBuilder sortBuilder = new StringBuilder(); - for (String field : sortField) { - String[] values = field.split(","); - sortBuilder.append(String.format("%s %s", values[0], values[1])).append(","); - } - return sortBuilder.deleteCharAt(sortBuilder.length() - 1).toString(); - } -} +//package com.mcwl.comment.domain; +// +//import cn.hutool.core.collection.CollectionUtil; +//import lombok.AllArgsConstructor; +//import lombok.Data; +//import lombok.NoArgsConstructor; +// +//import java.io.Serializable; +//import java.util.List; +//import java.util.Objects; +// +///** +// * 分页请求实体 +// */ +//@AllArgsConstructor +//@NoArgsConstructor +//@Data +//public class RequestPageEntity implements Serializable { +// +// private static final int DEFAULT_PAGE_SIZE = 10; +// +// /** +// * 页码,默认从一页开始 +// */ +// private Integer pageNo = 1; +// +// /** +// * 每页大小,默认一页查询10条数据 +// */ +// private Integer pageSize = DEFAULT_PAGE_SIZE; +// +// /** +// * 排序字段 +// */ +// private List sortField; +// +// +// /** +// * 获取分页开始位置 +// * +// * @return 分页开始位置 +// */ +// public Integer getPageBegin() { +// if (Objects.isNull(this.pageNo) || this.pageNo <= 0) { +// this.pageNo = 1; +// } +// +// if (Objects.isNull(this.pageSize)) { +// this.pageSize = DEFAULT_PAGE_SIZE; +// } +// +// return (this.pageNo - 1) * this.pageSize; +// } +// +// /** +// * 获取用户自定义排序集合 +// * +// * @return 排序集合实体 +// */ +// public String getSortString() { +// List sortField = this.getSortField(); +// if (CollectionUtil.isEmpty(sortField)) { +// return null; +// } +// StringBuilder sortBuilder = new StringBuilder(); +// for (String field : sortField) { +// String[] values = field.split(","); +// sortBuilder.append(String.format("%s %s", values[0], values[1])).append(","); +// } +// return sortBuilder.deleteCharAt(sortBuilder.length() - 1).toString(); +// } +//} diff --git a/mcwl-comment/src/main/java/com/mcwl/comment/mapper/CommentMapper.java b/mcwl-comment/src/main/java/com/mcwl/comment/mapper/CommentMapper.java index 4a0fcb8..79038a8 100644 --- a/mcwl-comment/src/main/java/com/mcwl/comment/mapper/CommentMapper.java +++ b/mcwl-comment/src/main/java/com/mcwl/comment/mapper/CommentMapper.java @@ -1,31 +1,31 @@ -package com.mcwl.comment.mapper; - - -import com.mcwl.comment.domain.ProductCommentConditionEntity; -import com.mcwl.comment.domain.ProductCommentEntity; -import com.mcwl.common.web.BaseMapper; -import com.mcwl.resource.domain.MallProduct; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * @Author:ChenYan - * @Project:McWl - * @Package:com.mcwl.comment.mapper - * @Filename:CommentMapper - * @Description TODO - * @Date:2025/1/4 19:04 - */ -public interface CommentMapper extends BaseMapper { - - MallProduct findById(@Param("id") Long id); - - int insert(ProductCommentEntity productCommentEntity); - - int upda(ProductCommentEntity productCommentEntity); - - List findByIds(List ids); - - int deleteByIds(List ids, ProductCommentEntity productCommentEntity); -} +//package com.mcwl.comment.mapper; +// +// +//import com.mcwl.comment.domain.ProductCommentConditionEntity; +//import com.mcwl.comment.domain.ProductCommentEntity; +//import com.mcwl.common.web.BaseMapper; +//import com.mcwl.resource.domain.MallProduct; +//import org.apache.ibatis.annotations.Param; +// +//import java.util.List; +// +///** +// * @Author:ChenYan +// * @Project:McWl +// * @Package:com.mcwl.comment.mapper +// * @Filename:CommentMapper +// * @Description TODO +// * @Date:2025/1/4 19:04 +// */ +//public interface CommentMapper extends BaseMapper { +// +// MallProduct findById(@Param("id") Long id); +// +// int insert(ProductCommentEntity productCommentEntity); +// +// int upda(ProductCommentEntity productCommentEntity); +// +// List findByIds(List ids); +// +// int deleteByIds(List ids, ProductCommentEntity productCommentEntity); +//} diff --git a/mcwl-comment/src/main/java/com/mcwl/comment/service/impl/CommentServiceImpl.java b/mcwl-comment/src/main/java/com/mcwl/comment/service/impl/CommentServiceImpl.java index 6c43a7b..f3bae10 100644 --- a/mcwl-comment/src/main/java/com/mcwl/comment/service/impl/CommentServiceImpl.java +++ b/mcwl-comment/src/main/java/com/mcwl/comment/service/impl/CommentServiceImpl.java @@ -1,88 +1,88 @@ -package com.mcwl.comment.service.impl; - - -import com.mcwl.comment.domain.ProductCommentConditionEntity; -import com.mcwl.comment.domain.ProductCommentEntity; -import com.mcwl.comment.mapper.CommentMapper; -import com.mcwl.common.core.domain.AjaxResult; -import com.mcwl.common.utils.AssertUtil; -import com.mcwl.common.utils.FillUserUtil; -import com.mcwl.common.utils.ResponsePageEntity; -import com.mcwl.common.utils.SecurityUtils; -import com.mcwl.common.utils.bean.BaseService; - -import com.mcwl.common.web.BaseMapper; -import com.mcwl.resource.domain.MallProduct; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Objects; - -import static com.mcwl.common.utils.SecurityUtils.getUsername; - -/** - * @Author:ChenYan - * @Project:McWl - * @Package:com.mcwl.comment.service.impl - * @Filename:CommentServiceImpl - * @Description TODO - * @Date:2025/1/4 19:04 - */ -@Service -public class CommentServiceImpl extends BaseService { - - @Autowired - private CommentMapper commentMapper; - - - public MallProduct findById(Long id) { - return commentMapper.findById(id); - } - - - public int insert(ProductCommentEntity productCommentEntity) { - // 获取当前用户 - Long userId = SecurityUtils.getUserId(); - productCommentEntity.setUserId(userId); - productCommentEntity.setCreateBy(getUsername()); - checkParam(productCommentEntity); - return commentMapper.insert(productCommentEntity); - } - - - public int update(ProductCommentEntity productCommentEntity) { - // 获取当前用户 - Long userId = SecurityUtils.getUserId(); - productCommentEntity.setUserId(userId); - productCommentEntity.setUpdateBy(getUsername()); - checkParam(productCommentEntity); - return commentMapper.upda(productCommentEntity); - } - - - public int deleteByIds(List ids) { - List entities = commentMapper.findByIds(ids); - AssertUtil.notEmpty(entities, "商品评论已被删除"); - - ProductCommentEntity entity = new ProductCommentEntity(); - FillUserUtil.fillUpdateUserInfo(entity); - return commentMapper.deleteByIds(ids, entity); - } - private void checkParam(ProductCommentEntity productCommentEntity) { - if (Objects.nonNull(productCommentEntity.getParentId()) && productCommentEntity.getParentId() > 0) { - MallProduct productEntity = commentMapper.findById(productCommentEntity.getParentId()); - AssertUtil.notNull(productEntity, "该父评论在系统中不存在"); - } - - MallProduct userEntity = commentMapper.findById(productCommentEntity.getUserId()); - AssertUtil.notNull(userEntity, "该用户在系统中不存在"); - - MallProduct productEntity = commentMapper.findById(productCommentEntity.getProductId()); - AssertUtil.notNull(productEntity, "该商品在系统中不存在"); - } - - @Override - protected BaseMapper getBaseMapper() { - return commentMapper; - } -} +//package com.mcwl.comment.service.impl; +// +// +//import com.mcwl.comment.domain.ProductCommentConditionEntity; +//import com.mcwl.comment.domain.ProductCommentEntity; +//import com.mcwl.comment.mapper.CommentMapper; +//import com.mcwl.common.core.domain.AjaxResult; +//import com.mcwl.common.utils.AssertUtil; +//import com.mcwl.common.utils.FillUserUtil; +//import com.mcwl.common.utils.ResponsePageEntity; +//import com.mcwl.common.utils.SecurityUtils; +//import com.mcwl.common.utils.bean.BaseService; +// +//import com.mcwl.common.web.BaseMapper; +//import com.mcwl.resource.domain.MallProduct; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +//import java.util.List; +//import java.util.Objects; +// +//import static com.mcwl.common.utils.SecurityUtils.getUsername; +// +///** +// * @Author:ChenYan +// * @Project:McWl +// * @Package:com.mcwl.comment.service.impl +// * @Filename:CommentServiceImpl +// * @Description TODO +// * @Date:2025/1/4 19:04 +// */ +//@Service +//public class CommentServiceImpl extends BaseService { +// +// @Autowired +// private CommentMapper commentMapper; +// +// +// public MallProduct findById(Long id) { +// return commentMapper.findById(id); +// } +// +// +// public int insert(ProductCommentEntity productCommentEntity) { +// // 获取当前用户 +// Long userId = SecurityUtils.getUserId(); +// productCommentEntity.setUserId(userId); +// productCommentEntity.setCreateBy(getUsername()); +// checkParam(productCommentEntity); +// return commentMapper.insert(productCommentEntity); +// } +// +// +// public int update(ProductCommentEntity productCommentEntity) { +// // 获取当前用户 +// Long userId = SecurityUtils.getUserId(); +// productCommentEntity.setUserId(userId); +// productCommentEntity.setUpdateBy(getUsername()); +// checkParam(productCommentEntity); +// return commentMapper.upda(productCommentEntity); +// } +// +// +// public int deleteByIds(List ids) { +// List entities = commentMapper.findByIds(ids); +// AssertUtil.notEmpty(entities, "商品评论已被删除"); +// +// ProductCommentEntity entity = new ProductCommentEntity(); +// FillUserUtil.fillUpdateUserInfo(entity); +// return commentMapper.deleteByIds(ids, entity); +// } +// private void checkParam(ProductCommentEntity productCommentEntity) { +// if (Objects.nonNull(productCommentEntity.getParentId()) && productCommentEntity.getParentId() > 0) { +// MallProduct productEntity = commentMapper.findById(productCommentEntity.getParentId()); +// AssertUtil.notNull(productEntity, "该父评论在系统中不存在"); +// } +// +// MallProduct userEntity = commentMapper.findById(productCommentEntity.getUserId()); +// AssertUtil.notNull(userEntity, "该用户在系统中不存在"); +// +// MallProduct productEntity = commentMapper.findById(productCommentEntity.getProductId()); +// AssertUtil.notNull(productEntity, "该商品在系统中不存在"); +// } +// +// @Override +// protected BaseMapper getBaseMapper() { +// return commentMapper; +// } +//} diff --git a/mcwl-comment/src/main/resources/mapper/comment/CommentMapper.xml b/mcwl-comment/src/main/resources/mapper/comment/CommentMapper.xml deleted file mode 100644 index 5ce895c..0000000 --- a/mcwl-comment/src/main/resources/mapper/comment/CommentMapper.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - insert into mall_product_comment(id, parent_id, product_id, user_id, content, rating, create_by, create_time, - update_by, update_time, del_flag, remark) - values (#{id}, #{parentId}, #{productId}, #{userId}, #{content}, #{rating}, #{createBy}, #{createTime}, - #{updateBy}, #{updateTime}, #{remark}, #{delFlag}) - - - update mall_product_comment - - - parent_id = #{parentId}, - - - product_id = #{productId}, - - - user_id = #{userId}, - - - content = #{content}, - - - rating = #{rating}, - - - create_by = #{createBy}, - - - create_time = #{createTime}, - - - update_by = #{updateBy}, - - - update_time = #{updateTime}, - - - remark = #{remark}, - - - del_flag = #{delFlag}, - - - where id = #{id} - - - - delete - from mall_product_comment - where id in - - #{id} - - - - - diff --git a/mcwl-common/pom.xml b/mcwl-common/pom.xml index 84f00c1..f56a827 100644 --- a/mcwl-common/pom.xml +++ b/mcwl-common/pom.xml @@ -341,7 +341,26 @@ 3.5.0 - + + + + + + + org.apache.httpcomponents + httpclient + 4.2.1 + + + org.apache.httpcomponents + httpcore + 4.2.1 + + + commons-lang + commons-lang + 2.6 + diff --git a/mcwl-common/src/main/java/com/mcwl/common/constant/CacheConstants.java b/mcwl-common/src/main/java/com/mcwl/common/constant/CacheConstants.java index aa05d09..8182e6b 100644 --- a/mcwl-common/src/main/java/com/mcwl/common/constant/CacheConstants.java +++ b/mcwl-common/src/main/java/com/mcwl/common/constant/CacheConstants.java @@ -47,5 +47,10 @@ public class CacheConstants */ public static final String WX_OPENID_KEY = "wx_openid:"; + /** + * 类型 + */ public static final String WE_CHAT = "we_chat"; + + public static final String ID_CARD_COUNT = "id_card_count:"; } diff --git a/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java b/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java index a73cc15..1f39eeb 100644 --- a/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java +++ b/mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java @@ -95,6 +95,16 @@ public class SysUser extends BaseEntity /** 简介 */ private String brief; + /** + * 姓名 + */ + private String name; + + /** + * 身份证 + */ + private String idCard; + public SysUser() { @@ -228,6 +238,22 @@ public class SysUser extends BaseEntity return delFlag; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIdCard() { + return idCard; + } + + public void setIdCard(String idCard) { + this.idCard = idCard; + } + public void setDelFlag(String delFlag) { this.delFlag = delFlag; @@ -333,6 +359,8 @@ public class SysUser extends BaseEntity ", postIds=" + Arrays.toString(postIds) + ", roleId=" + roleId + ", brief='" + brief + '\'' + + ", name='" + name + '\'' + + ", idCard='" + idCard + '\'' + '}'; } } diff --git a/mcwl-common/src/main/java/com/mcwl/common/utils/HttpUtils.java b/mcwl-common/src/main/java/com/mcwl/common/utils/HttpUtils.java new file mode 100644 index 0000000..ee016fe --- /dev/null +++ b/mcwl-common/src/main/java/com/mcwl/common/utils/HttpUtils.java @@ -0,0 +1,328 @@ +package com.mcwl.common.utils; + +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.message.BasicNameValuePair; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +/** + * 校验实名认证信息 + * @author DaiZibo + * @date 2025/1/8 + * @apiNote + */ + +public class HttpUtils { + + /** + * get + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @return + * @throws Exception + */ + public static HttpResponse doGet(String host, String path, String method, + Map headers, + Map querys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpGet request = new HttpGet(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + return httpClient.execute(request); + } + + /** + * post form + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param bodys + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + Map bodys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (bodys != null) { + List nameValuePairList = new ArrayList(); + + for (String key : bodys.keySet()) { + nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); + } + UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); + formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); + request.setEntity(formEntity); + } + + return httpClient.execute(request); + } + + /** + * Post String + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + String body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (StringUtils.isNotBlank(body)) { + request.setEntity(new StringEntity(body, "utf-8")); + } + + return httpClient.execute(request); + } + + /** + * Post stream + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + byte[] body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (body != null) { + request.setEntity(new ByteArrayEntity(body)); + } + + return httpClient.execute(request); + } + + /** + * Put String + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPut(String host, String path, String method, + Map headers, + Map querys, + String body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPut request = new HttpPut(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (StringUtils.isNotBlank(body)) { + request.setEntity(new StringEntity(body, "utf-8")); + } + + return httpClient.execute(request); + } + + /** + * Put stream + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPut(String host, String path, String method, + Map headers, + Map querys, + byte[] body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPut request = new HttpPut(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (body != null) { + request.setEntity(new ByteArrayEntity(body)); + } + + return httpClient.execute(request); + } + + /** + * Delete + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @return + * @throws Exception + */ + public static HttpResponse doDelete(String host, String path, String method, + Map headers, + Map querys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + return httpClient.execute(request); + } + + private static String buildUrl(String host, String path, Map querys) throws UnsupportedEncodingException { + StringBuilder sbUrl = new StringBuilder(); + sbUrl.append(host); + if (!StringUtils.isBlank(path)) { + sbUrl.append(path); + } + if (null != querys) { + StringBuilder sbQuery = new StringBuilder(); + for (Map.Entry query : querys.entrySet()) { + if (0 < sbQuery.length()) { + sbQuery.append("&"); + } + if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { + sbQuery.append(query.getValue()); + } + if (!StringUtils.isBlank(query.getKey())) { + sbQuery.append(query.getKey()); + if (!StringUtils.isBlank(query.getValue())) { + sbQuery.append("="); + sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); + } + } + } + if (0 < sbQuery.length()) { + sbUrl.append("?").append(sbQuery); + } + } + + return sbUrl.toString(); + } + + private static HttpClient wrapClient(String host) { + HttpClient httpClient = new DefaultHttpClient(); + if (host.startsWith("https://")) { + sslClient(httpClient); + } + + return httpClient; + } + + private static void sslClient(HttpClient httpClient) { + try { + SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager tm = new X509TrustManager() { + + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + @Override + public void checkClientTrusted(X509Certificate[] xcs, String str) { + + } + + @Override + public void checkServerTrusted(X509Certificate[] xcs, String str) { + + } + }; + ctx.init(null, new TrustManager[]{tm}, null); + SSLSocketFactory ssf = new SSLSocketFactory(ctx); + ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + ClientConnectionManager ccm = httpClient.getConnectionManager(); + SchemeRegistry registry = ccm.getSchemeRegistry(); + registry.register(new Scheme("https", 443, ssf)); + } catch (KeyManagementException ex) { + throw new RuntimeException(ex); + } catch (NoSuchAlgorithmException ex) { + throw new RuntimeException(ex); + } + } + +} diff --git a/mcwl-common/src/main/java/com/mcwl/common/utils/VerifyCard.java b/mcwl-common/src/main/java/com/mcwl/common/utils/VerifyCard.java new file mode 100644 index 0000000..916afef --- /dev/null +++ b/mcwl-common/src/main/java/com/mcwl/common/utils/VerifyCard.java @@ -0,0 +1,55 @@ +package com.mcwl.common.utils; + +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * 身份证校验 + * + * @author DaiZibo + * @date 2025/1/8 + * @apiNote + */ +public class VerifyCard { + + public static String idCard(String name, String card) { + String host = "https://kzidcardv1.market.alicloudapi.com"; + String path = "/api-mall/api/id_card/check"; + String method = "POST"; + String appcode = "680661d47eb740bcb85472cec9774ecf"; + Map headers = new HashMap(); + //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 + headers.put("Authorization", "APPCODE " + appcode); + //根据API的要求,定义相对应的Content-Type + headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + Map querys = new HashMap(); + Map bodys = new HashMap(); + bodys.put("name", name); + bodys.put("idcard", card); + + + try { + /** + * 重要提示如下: + * HttpUtils请从 + * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java + * 下载 + * + * 相应的依赖请参照 + * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml + */ + HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); + System.out.println(response.toString()); + //获取response的body + //System.out.println(EntityUtils.toString(response.getEntity())); + return EntityUtils.toString(response.getEntity()); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java index 4de0d65..5971fea 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/SysUserAttentionServiceImpl.java @@ -71,9 +71,8 @@ public class SysUserAttentionServiceImpl implements SysUserAttentionService { public SysUserInfo selectUserInfo() { Long userId = SecurityUtils.getUserId(); - return SysUserInfo.builder().bean(sysUserAttentionMapper.selectBean(userId)) - .download(mallProductMapper.sumNumber(userId)) +// .download(mallProductMapper.sumNumber(userId)) .likeCount(mallProductLikeMapper.countLike(userId)) .attention(sysUserAttentionMapper.selectAttentionCount(userId)).build(); } diff --git a/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java b/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java index 8cd762f..79bd9be 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java +++ b/mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java @@ -132,4 +132,8 @@ public interface SysUserMapper SysUser selectUserInfoById(@Param("userId") Long userId); + void updateIdCard(SysUser sysUser); + + SysUser selectByIdCard(@Param("idCard") String idCard); + } diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java index f3df3e2..3af1402 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserService.java @@ -1,5 +1,6 @@ package com.mcwl.system.service; +import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.entity.SysUser; import java.util.List; @@ -213,4 +214,5 @@ public interface ISysUserService SysUser selectUserInfoById(Long userId); + AjaxResult updateIdCard(SysUser sysUser); } diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java index 6c203b6..9cd5a26 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java @@ -1,12 +1,17 @@ package com.mcwl.system.service.impl; +import com.alibaba.fastjson2.JSONObject; import com.mcwl.common.annotation.DataScope; +import com.mcwl.common.constant.CacheConstants; import com.mcwl.common.constant.UserConstants; +import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.entity.SysRole; import com.mcwl.common.core.domain.entity.SysUser; +import com.mcwl.common.core.redis.RedisCache; import com.mcwl.common.exception.ServiceException; import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.StringUtils; +import com.mcwl.common.utils.VerifyCard; import com.mcwl.common.utils.bean.BeanValidators; import com.mcwl.common.utils.spring.SpringUtils; import com.mcwl.system.domain.SysPost; @@ -29,6 +34,7 @@ import javax.validation.Validator; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -41,6 +47,9 @@ public class SysUserServiceImpl implements ISysUserService { private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); + @Autowired + private RedisCache redisCache; + @Autowired private SysUserMapper userMapper; @@ -599,6 +608,47 @@ public class SysUserServiceImpl implements ISysUserService return userMapper.selectUserInfoById(userId); } + @Override + public AjaxResult updateIdCard(SysUser sysUser) { + + //获取次数 + Integer s = redisCache.getCacheObject(CacheConstants.ID_CARD_COUNT + sysUser.getUserId()); + Integer count = 0; + if (s != null){ + + if (3<=s){ + + return AjaxResult.error("次数上限"); + }else { + //次数+1 + s++; + count = s; + } + } + + //存入次数 + redisCache.setCacheObject(CacheConstants.ID_CARD_COUNT+sysUser.getUserId(),count,1, TimeUnit.DAYS); + + //查看身份证是否唯一 + SysUser user = userMapper.selectByIdCard(sysUser.getIdCard()); + if (user != null){ + return AjaxResult.error("该信息已绑定"); + } + //校验 + String s1 = VerifyCard.idCard(sysUser.getName(), sysUser.getIdCard()); + JSONObject jsonObject = JSONObject.parseObject(s1); + Integer code = jsonObject.getInteger("code"); + if (code != 200){ + + return AjaxResult.error(jsonObject.getString("msg")); + } + log.info("实名认证校验的结果:{}",s1); + //修改数据库 + userMapper.updateIdCard(sysUser); + + return AjaxResult.success("实名认证成功"); + } + /** * 生成随机密码 * @param length diff --git a/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml b/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml index 4c7d436..2bb0cd0 100644 --- a/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/mcwl-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -148,7 +148,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -223,7 +226,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where user_id = #{userId} - + + update sys_user set name = #{name}, + id_card = #{idCard} + where user_id = #{userId} + + + update sys_user set del_flag = '2' where user_id = #{userId}