Merge branch 'feature/admin' into preview
# Conflicts: # mcwl-admin/src/main/java/com/mcwl/web/controller/comment/CommentController.java # mcwl-comment/src/main/java/com/mcwl/comment/domain/Comment.java # mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentConditionEntity.java # mcwl-comment/src/main/java/com/mcwl/comment/domain/ProductCommentEntity.java # mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestConditionEntity.java # mcwl-comment/src/main/java/com/mcwl/comment/domain/RequestPageEntity.java # mcwl-comment/src/main/java/com/mcwl/comment/mapper/CommentMapper.java # mcwl-comment/src/main/java/com/mcwl/comment/service/impl/CommentServiceImpl.java # mcwl-comment/src/main/resources/mapper/comment/CommentMapper.xml # mcwl-common/src/main/java/com/mcwl/common/core/domain/entity/SysUser.java # mcwl-system/src/main/java/com/mcwl/system/mapper/SysUserMapper.java # mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.javafeature/comment
commit
a938a05b72
|
@ -0,0 +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<Long> ids) {
|
||||||
|
// return commentService.deleteByIds(ids);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//}
|
|
@ -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<String, String> stringStringHashMap = new HashMap<>();
|
||||||
|
stringStringHashMap.put("code", "200");
|
||||||
|
stringStringHashMap.put("message", "返回成功");
|
||||||
|
// 返回这个说明应答成功
|
||||||
|
return stringStringHashMap;
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
* @apiNote
|
* @apiNote
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RequestMapping("like")
|
@RequestMapping("/like")
|
||||||
@RestController
|
@RestController
|
||||||
public class MallProductLikeController {
|
public class MallProductLikeController {
|
||||||
|
|
||||||
|
|
|
@ -269,4 +269,16 @@ public class SysUserController extends BaseController
|
||||||
userService.updateUserInfo(sysUser);
|
userService.updateUserInfo(sysUser);
|
||||||
return AjaxResult.success("修改成功");
|
return AjaxResult.success("修改成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实名认证
|
||||||
|
* @param sysUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateIdCard")
|
||||||
|
public AjaxResult updateIdCard(@RequestBody SysUser sysUser){
|
||||||
|
|
||||||
|
return userService.updateIdCard(sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,13 @@ import com.mcwl.system.domain.SysUserThirdAccount;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import com.mcwl.system.service.ISysUserThirdAccountService;
|
import com.mcwl.system.service.ISysUserThirdAccountService;
|
||||||
import com.mcwl.system.service.IWXService;
|
import com.mcwl.system.service.IWXService;
|
||||||
import com.mcwl.web.controller.common.OssUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
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 javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -59,13 +60,6 @@ public class WXController {
|
||||||
@Resource
|
@Resource
|
||||||
private SysPermissionService permissionService;
|
private SysPermissionService permissionService;
|
||||||
|
|
||||||
@Anonymous
|
|
||||||
@PostMapping("/test")
|
|
||||||
public AjaxResult test(@RequestParam MultipartFile file){
|
|
||||||
|
|
||||||
String s = OssUtil.uploadMultipartFile(file);
|
|
||||||
return AjaxResult.success(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码登录用uuid生成
|
* 扫码登录用uuid生成
|
||||||
|
|
|
@ -0,0 +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;
|
||||||
|
//}
|
|
@ -0,0 +1,56 @@
|
||||||
|
//package com.mcwl.comment.domain;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//import lombok.Data;
|
||||||
|
//
|
||||||
|
//import java.util.List;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * 商品评论查询条件实体
|
||||||
|
// */
|
||||||
|
//@Data
|
||||||
|
//public class ProductCommentConditionEntity extends RequestConditionEntity {
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * ID集合
|
||||||
|
// */
|
||||||
|
// private List<Long> idList;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * ID
|
||||||
|
// */
|
||||||
|
// private Long id;
|
||||||
|
// /**
|
||||||
|
// * 父评论ID
|
||||||
|
// */
|
||||||
|
// private Long parentId;
|
||||||
|
// /**
|
||||||
|
// * 商品ID
|
||||||
|
// */
|
||||||
|
// private Long productId;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 商品ID集合
|
||||||
|
// */
|
||||||
|
// private List<Long> productIdList;
|
||||||
|
// /**
|
||||||
|
// * 用户ID
|
||||||
|
// */
|
||||||
|
// private Long userId;
|
||||||
|
// /**
|
||||||
|
// * 评论内容
|
||||||
|
// */
|
||||||
|
// private String content;
|
||||||
|
// /**
|
||||||
|
// * 评分
|
||||||
|
// */
|
||||||
|
// private Integer rating;
|
||||||
|
// /**
|
||||||
|
// * 删除标志(0代表存在 2代表删除)
|
||||||
|
// */
|
||||||
|
// private String delFlag;
|
||||||
|
//// /**
|
||||||
|
//// * 评论类型
|
||||||
|
//// */
|
||||||
|
//// private Integer type;
|
||||||
|
//}
|
|
@ -0,0 +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;
|
||||||
|
//
|
||||||
|
//// /**
|
||||||
|
//// * 评论类型
|
||||||
|
//// */
|
||||||
|
//// private Integer type;
|
||||||
|
//}
|
|
@ -0,0 +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<String> betweenTime;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 创建开始时间
|
||||||
|
// */
|
||||||
|
// private String createBeginTime;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 创建结束时间
|
||||||
|
// */
|
||||||
|
// private String createEndTime;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 自定义excel表头列表
|
||||||
|
// */
|
||||||
|
// private List<String> customizeColumnNameList;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 查询条件
|
||||||
|
// */
|
||||||
|
// private String blurry;
|
||||||
|
//}
|
|
@ -0,0 +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<String> 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<String> 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();
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +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<ProductCommentEntity, ProductCommentConditionEntity> {
|
||||||
|
//
|
||||||
|
// MallProduct findById(@Param("id") Long id);
|
||||||
|
//
|
||||||
|
// int insert(ProductCommentEntity productCommentEntity);
|
||||||
|
//
|
||||||
|
// int upda(ProductCommentEntity productCommentEntity);
|
||||||
|
//
|
||||||
|
// List<ProductCommentEntity> findByIds(List<Long> ids);
|
||||||
|
//
|
||||||
|
// int deleteByIds(List<Long> ids, ProductCommentEntity productCommentEntity);
|
||||||
|
//}
|
|
@ -0,0 +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<ProductCommentEntity, ProductCommentConditionEntity> {
|
||||||
|
//
|
||||||
|
// @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<Long> ids) {
|
||||||
|
// List<ProductCommentEntity> 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;
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -1,57 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.mcwl.comment.mapper.CommentMapper">
|
|
||||||
<insert id="insert">
|
|
||||||
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})
|
|
||||||
</insert>
|
|
||||||
<update id="upda"></update>
|
|
||||||
|
|
||||||
<delete id="deleteByIds">
|
|
||||||
delete
|
|
||||||
from model
|
|
||||||
where id in
|
|
||||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
<select id="findById" resultType="com.mcwl.resource.domain.ModelProduct">
|
|
||||||
select
|
|
||||||
id,
|
|
||||||
parent_id,
|
|
||||||
product_id,
|
|
||||||
user_id,
|
|
||||||
content,
|
|
||||||
create_by,
|
|
||||||
create_time,
|
|
||||||
update_by,
|
|
||||||
update_time,
|
|
||||||
remark,
|
|
||||||
del_flag
|
|
||||||
from model
|
|
||||||
where id = #{id}
|
|
||||||
</select>
|
|
||||||
<select id="findByIds" resultType="com.mcwl.comment.domain.ProductCommentEntity">
|
|
||||||
select
|
|
||||||
id,
|
|
||||||
parent_id,
|
|
||||||
product_id,
|
|
||||||
user_id,
|
|
||||||
content,
|
|
||||||
create_by,
|
|
||||||
create_time,
|
|
||||||
update_by,
|
|
||||||
update_time,
|
|
||||||
remark,
|
|
||||||
del_flag
|
|
||||||
from mall_product_comment
|
|
||||||
where id in
|
|
||||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
|
@ -341,7 +341,26 @@
|
||||||
<version>3.5.0</version>
|
<version>3.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.alibaba</groupId>-->
|
||||||
|
<!-- <artifactId>fastjson</artifactId>-->
|
||||||
|
<!-- <version>1.2.15</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpcore</artifactId>
|
||||||
|
<version>4.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -47,5 +47,10 @@ public class CacheConstants
|
||||||
*/
|
*/
|
||||||
public static final String WX_OPENID_KEY = "wx_openid:";
|
public static final String WX_OPENID_KEY = "wx_openid:";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型
|
||||||
|
*/
|
||||||
public static final String WE_CHAT = "we_chat";
|
public static final String WE_CHAT = "we_chat";
|
||||||
|
|
||||||
|
public static final String ID_CARD_COUNT = "id_card_count:";
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,6 @@ public class SysUser extends BaseEntity
|
||||||
/** 密码 */
|
/** 密码 */
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/** 钱包 */
|
|
||||||
private Long wallet;
|
|
||||||
|
|
||||||
/** 帐号状态(0正常 1停用) */
|
/** 帐号状态(0正常 1停用) */
|
||||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||||
private String status;
|
private String status;
|
||||||
|
@ -99,14 +96,14 @@ public class SysUser extends BaseEntity
|
||||||
private String brief;
|
private String brief;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邀请人id
|
* 姓名
|
||||||
*/
|
*/
|
||||||
private Long inviterUserId;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 免费用户积分
|
* 身份证
|
||||||
*/
|
*/
|
||||||
private Double freePoints;
|
private String idCard;
|
||||||
|
|
||||||
public SysUser()
|
public SysUser()
|
||||||
{
|
{
|
||||||
|
@ -241,6 +238,22 @@ public class SysUser extends BaseEntity
|
||||||
return delFlag;
|
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)
|
public void setDelFlag(String delFlag)
|
||||||
{
|
{
|
||||||
this.delFlag = delFlag;
|
this.delFlag = delFlag;
|
||||||
|
@ -324,23 +337,6 @@ public class SysUser extends BaseEntity
|
||||||
this.brief = brief;
|
this.brief = brief;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Long getInviterUserId() {
|
|
||||||
return inviterUserId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInviterUserId(Long inviterUserId) {
|
|
||||||
this.inviterUserId = inviterUserId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double getFreePoints() {
|
|
||||||
return freePoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFreePoints(Double freePoints) {
|
|
||||||
this.freePoints = freePoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SysUser{" +
|
return "SysUser{" +
|
||||||
|
@ -363,6 +359,8 @@ public class SysUser extends BaseEntity
|
||||||
", postIds=" + Arrays.toString(postIds) +
|
", postIds=" + Arrays.toString(postIds) +
|
||||||
", roleId=" + roleId +
|
", roleId=" + roleId +
|
||||||
", brief='" + brief + '\'' +
|
", brief='" + brief + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", idCard='" + idCard + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpGet request = new HttpGet(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> 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<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
Map<String, String> bodys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bodys != null) {
|
||||||
|
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
|
||||||
|
|
||||||
|
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<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> 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<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> 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<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> 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<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> 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<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String buildUrl(String host, String path, Map<String, String> 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<String, String> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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<String, String> headers = new HashMap<String, String>();
|
||||||
|
//最后在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<String, String> querys = new HashMap<String, String>();
|
||||||
|
Map<String, String> bodys = new HashMap<String, String>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -71,9 +71,8 @@ public class SysUserAttentionServiceImpl implements SysUserAttentionService {
|
||||||
public SysUserInfo selectUserInfo() {
|
public SysUserInfo selectUserInfo() {
|
||||||
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
return SysUserInfo.builder().bean(sysUserAttentionMapper.selectBean(userId))
|
return SysUserInfo.builder().bean(sysUserAttentionMapper.selectBean(userId))
|
||||||
.download(mallProductMapper.sumNumber(userId))
|
// .download(mallProductMapper.sumNumber(userId))
|
||||||
.likeCount(mallProductLikeMapper.countLike(userId))
|
.likeCount(mallProductLikeMapper.countLike(userId))
|
||||||
.attention(sysUserAttentionMapper.selectAttentionCount(userId)).build();
|
.attention(sysUserAttentionMapper.selectAttentionCount(userId)).build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.mcwl.system.mapper;
|
package com.mcwl.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@ -133,5 +132,8 @@ public interface SysUserMapper
|
||||||
|
|
||||||
SysUser selectUserInfoById(@Param("userId") Long userId);
|
SysUser selectUserInfoById(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
void updateIdCard(SysUser sysUser);
|
||||||
|
|
||||||
|
SysUser selectByIdCard(@Param("idCard") String idCard);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.mcwl.system.service;
|
package com.mcwl.system.service;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -213,4 +214,5 @@ public interface ISysUserService
|
||||||
|
|
||||||
SysUser selectUserInfoById(Long userId);
|
SysUser selectUserInfoById(Long userId);
|
||||||
|
|
||||||
|
AjaxResult updateIdCard(SysUser sysUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package com.mcwl.system.service.impl;
|
package com.mcwl.system.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.mcwl.common.annotation.DataScope;
|
import com.mcwl.common.annotation.DataScope;
|
||||||
|
import com.mcwl.common.constant.CacheConstants;
|
||||||
import com.mcwl.common.constant.UserConstants;
|
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.SysRole;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
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.exception.ServiceException;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.common.utils.VerifyCard;
|
||||||
import com.mcwl.common.utils.bean.BeanValidators;
|
import com.mcwl.common.utils.bean.BeanValidators;
|
||||||
import com.mcwl.common.utils.spring.SpringUtils;
|
import com.mcwl.common.utils.spring.SpringUtils;
|
||||||
import com.mcwl.system.domain.SysPost;
|
import com.mcwl.system.domain.SysPost;
|
||||||
|
@ -30,6 +34,7 @@ import javax.validation.Validator;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +47,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserMapper userMapper;
|
private SysUserMapper userMapper;
|
||||||
|
|
||||||
|
@ -600,6 +608,47 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return userMapper.selectUserInfoById(userId);
|
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
|
* @param length
|
||||||
|
@ -618,5 +667,4 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,10 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUserInfoById" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
<select id="selectUserInfoById" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
||||||
select user_id,avatar,brief,nick_name from sys_user where user_id = #{userId}
|
select user_id,avatar,brief,nick_name,name from sys_user where user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
<select id="selectByIdCard" resultType="com.mcwl.common.core.domain.entity.SysUser">
|
||||||
|
select * from sys_user where id_card = #{idCard}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
|
@ -226,7 +229,13 @@
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteUserById" parameterType="Long">
|
<update id="updateIdCard">
|
||||||
|
update sys_user set name = #{name},
|
||||||
|
id_card = #{idCard}
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteUserById" parameterType="Long">
|
||||||
update sys_user set del_flag = '2' where user_id = #{userId}
|
update sys_user set del_flag = '2' where user_id = #{userId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue