新增实名认证

feature/comment
Diyu0904 2025-01-09 11:14:22 +08:00
parent 1941c2617c
commit aae00a4bb9
23 changed files with 1050 additions and 575 deletions

View File

@ -1,77 +1,77 @@
package com.mcwl.web.controller.comment; //package com.mcwl.web.controller.comment;
//
//
import com.mcwl.comment.domain.ProductCommentConditionEntity; //import com.mcwl.comment.domain.ProductCommentConditionEntity;
import com.mcwl.comment.domain.ProductCommentEntity; //import com.mcwl.comment.domain.ProductCommentEntity;
import com.mcwl.comment.service.impl.CommentServiceImpl; //import com.mcwl.comment.service.impl.CommentServiceImpl;
import com.mcwl.common.utils.ResponsePageEntity; //import com.mcwl.common.utils.ResponsePageEntity;
import com.mcwl.resource.domain.MallProduct; //import com.mcwl.resource.domain.MallProduct;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; //import org.springframework.web.bind.annotation.*;
//
import javax.validation.constraints.NotNull; //import javax.validation.constraints.NotNull;
import java.util.List; //import java.util.List;
//
/** ///**
* @AuthorChenYan // * @AuthorChenYan
* @ProjectMcWl // * @ProjectMcWl
* @Packagecom.mcwl.web.controller.comment // * @Packagecom.mcwl.web.controller.comment
* @FilenameCommentController // * @FilenameCommentController
* @Description TODO // * @Description TODO
* @Date2025/1/4 18:56 // * @Date2025/1/4 18:56
*/ // */
@RestController //@RestController
@RequestMapping("/comment") //@RequestMapping("/comment")
public class CommentController { //public class CommentController {
//
@Autowired // @Autowired
private CommentServiceImpl commentService; // private CommentServiceImpl commentService;
//
/** // /**
* id // * 通过id查询商品评论信息
* // *
* @param id ID // * @param id 系统ID
* @return // * @return 商品评论信息
*/ // */
@GetMapping("/findById") // @GetMapping("/findById")
public MallProduct findById(Long id) { // public MallProduct findById(Long id) {
return commentService.findById(id); // return commentService.findById(id);
} // }
//
//
//
/** // /**
* // * 添加商品评论
* // *
* @param productCommentEntity // * @param productCommentEntity 商品评论实体
* @return // * @return 影响行数
*/ // */
@PostMapping("/insert") // @PostMapping("/insert")
public int insert(@RequestBody ProductCommentEntity productCommentEntity) { // public int insert(@RequestBody ProductCommentEntity productCommentEntity) {
return commentService.insert(productCommentEntity); // return commentService.insert(productCommentEntity);
} // }
//
/** // /**
* // * 修改商品评论
* // *
* @param productCommentEntity // * @param productCommentEntity 商品评论实体
* @return // * @return 影响行数
*/ // */
@PostMapping("/update") // @PostMapping("/update")
public int update(@RequestBody ProductCommentEntity productCommentEntity) { // public int update(@RequestBody ProductCommentEntity productCommentEntity) {
return commentService.update(productCommentEntity); // return commentService.update(productCommentEntity);
} // }
//
/** // /**
* // * 批量删除商品评论
* // *
* @param ids ID // * @param ids 商品评论ID集合
* @return // * @return 影响行数
*/ // */
@PostMapping("/deleteByIds") // @PostMapping("/deleteByIds")
public int deleteByIds(@RequestBody @NotNull List<Long> ids) { // public int deleteByIds(@RequestBody @NotNull List<Long> ids) {
return commentService.deleteByIds(ids); // return commentService.deleteByIds(ids);
} // }
//
//
} //}

View File

@ -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;
}
}

View File

@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
* @apiNote * @apiNote
*/ */
@RequestMapping("like") @RequestMapping("/like")
@RestController @RestController
public class MallProductLikeController { public class MallProductLikeController {

View File

@ -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);
}
} }

View File

@ -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

View File

@ -1,53 +1,53 @@
package com.mcwl.comment.domain; //package com.mcwl.comment.domain;
//
import com.baomidou.mybatisplus.annotation.TableId; //import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; //import com.baomidou.mybatisplus.annotation.TableName;
import com.mcwl.common.core.domain.BaseEntity; //import com.mcwl.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; //import lombok.AllArgsConstructor;
import lombok.Data; //import lombok.Data;
import lombok.NoArgsConstructor; //import lombok.NoArgsConstructor;
//
/** ///**
* @AuthorChenYan // * @AuthorChenYan
* @ProjectMcWl // * @ProjectMcWl
* @Packagecom.mcwl.comment.domain // * @Packagecom.mcwl.comment.domain
* @FilenameComment // * @FilenameComment
* @Description // * @Description 评论表
* @Date2025/1/4 18:47 // * @Date2025/1/4 18:47
*/ // */
@AllArgsConstructor //@AllArgsConstructor
@NoArgsConstructor //@NoArgsConstructor
@Data //@Data
@TableName("mall_product_comment") //@TableName("mall_product_comment")
public class Comment extends BaseEntity { //public class Comment extends BaseEntity {
//
/** // /**
* ID // * ID
*/ // */
@TableId // @TableId
private Long id; // private Long id;
/** // /**
* ID // * 父评论ID
*/ // */
private String parentId; // private String parentId;
/** // /**
* ID // * 商品ID
*/ // */
private String productId; // private String productId;
/** // /**
* ID // * 用户ID
*/ // */
private String userId; // private String userId;
/** // /**
* // * 评论内容
*/ // */
private String content; // private String content;
/** // /**
* // * 评分
*/ // */
private String rating; // private String rating;
/** // /**
* 0 2 // * 删除标志0代表存在 2代表删除
*/ // */
private String delFlag; // private String delFlag;
} //}

View File

@ -1,56 +1,56 @@
package com.mcwl.comment.domain; //package com.mcwl.comment.domain;
//
//
import lombok.Data; //import lombok.Data;
//
import java.util.List; //import java.util.List;
//
/** ///**
* // * 商品评论查询条件实体
*/ // */
@Data //@Data
public class ProductCommentConditionEntity extends RequestConditionEntity { //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;
// /** // /**
// * 评论类型 // * ID集合
// */ // */
// private Integer type; // 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;
//}

View File

@ -1,50 +1,50 @@
package com.mcwl.comment.domain; //package com.mcwl.comment.domain;
//
import com.mcwl.common.core.domain.BaseEntity; //import com.mcwl.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor; //import lombok.AllArgsConstructor;
import lombok.Data; //import lombok.Data;
import lombok.NoArgsConstructor; //import lombok.NoArgsConstructor;
//
/** ///**
* @AuthorChenYan // * @AuthorChenYan
* @ProjectMcWl // * @ProjectMcWl
* @Packagecom.mcwl.comment.domain // * @Packagecom.mcwl.comment.domain
* @FilenameProductCommentEntity // * @FilenameProductCommentEntity
* @Description // * @Description 评论实体
* @Date2025/1/6 13:21 // * @Date2025/1/6 13:21
*/ // */
@AllArgsConstructor //@AllArgsConstructor
@NoArgsConstructor //@NoArgsConstructor
@Data //@Data
public class ProductCommentEntity extends BaseEntity { //public class ProductCommentEntity extends BaseEntity {
//
/**
* ID
*/
private Long parentId;
/**
* ID
*/
private Long productId;
/**
* ID
*/
private Long userId;
/**
*
*/
private String content;
/**
*
*/
private Integer rating;
// /** // /**
// * 评论类型 // * 父评论ID
// */ // */
// private Integer type; // private Long parentId;
} //
// /**
// * 商品ID
// */
// private Long productId;
//
// /**
// * 用户ID
// */
// private Long userId;
//
// /**
// * 评论内容
// */
// private String content;
//
// /**
// * 评分
// */
// private Integer rating;
//
//// /**
//// * 评论类型
//// */
//// private Integer type;
//}

View File

@ -1,41 +1,41 @@
package com.mcwl.comment.domain; //package com.mcwl.comment.domain;
//
import com.mcwl.common.utils.RequestPageEntity; //import com.mcwl.common.utils.RequestPageEntity;
import io.swagger.annotations.ApiModelProperty; //import io.swagger.annotations.ApiModelProperty;
import lombok.Data; //import lombok.Data;
//
import java.util.List; //import java.util.List;
//
/** ///**
* // * 请求条件实体
*/ // */
@Data //@Data
public class RequestConditionEntity extends RequestPageEntity { //public class RequestConditionEntity extends RequestPageEntity {
//
//
/** // /**
* // * 创建日期范围
*/ // */
@ApiModelProperty("创建日期范围") // @ApiModelProperty("创建日期范围")
private List<String> betweenTime; // private List<String> betweenTime;
//
/** // /**
* // * 创建开始时间
*/ // */
private String createBeginTime; // private String createBeginTime;
//
/** // /**
* // * 创建结束时间
*/ // */
private String createEndTime; // private String createEndTime;
//
/** // /**
* excel // * 自定义excel表头列表
*/ // */
private List<String> customizeColumnNameList; // private List<String> customizeColumnNameList;
//
/** // /**
* // * 查询条件
*/ // */
private String blurry; // private String blurry;
} //}

View File

@ -1,72 +1,72 @@
package com.mcwl.comment.domain; //package com.mcwl.comment.domain;
//
import cn.hutool.core.collection.CollectionUtil; //import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor; //import lombok.AllArgsConstructor;
import lombok.Data; //import lombok.Data;
import lombok.NoArgsConstructor; //import lombok.NoArgsConstructor;
//
import java.io.Serializable; //import java.io.Serializable;
import java.util.List; //import java.util.List;
import java.util.Objects; //import java.util.Objects;
//
/** ///**
* // * 分页请求实体
*/ // */
@AllArgsConstructor //@AllArgsConstructor
@NoArgsConstructor //@NoArgsConstructor
@Data //@Data
public class RequestPageEntity implements Serializable { //public class RequestPageEntity implements Serializable {
//
private static final int DEFAULT_PAGE_SIZE = 10; // private static final int DEFAULT_PAGE_SIZE = 10;
//
/** // /**
* // * 页码,默认从一页开始
*/ // */
private Integer pageNo = 1; // private Integer pageNo = 1;
//
/** // /**
* 10 // * 每页大小默认一页查询10条数据
*/ // */
private Integer pageSize = DEFAULT_PAGE_SIZE; // private Integer pageSize = DEFAULT_PAGE_SIZE;
//
/** // /**
* // * 排序字段
*/ // */
private List<String> sortField; // private List<String> sortField;
//
//
/** // /**
* // * 获取分页开始位置
* // *
* @return // * @return 分页开始位置
*/ // */
public Integer getPageBegin() { // public Integer getPageBegin() {
if (Objects.isNull(this.pageNo) || this.pageNo <= 0) { // if (Objects.isNull(this.pageNo) || this.pageNo <= 0) {
this.pageNo = 1; // this.pageNo = 1;
} // }
//
if (Objects.isNull(this.pageSize)) { // if (Objects.isNull(this.pageSize)) {
this.pageSize = DEFAULT_PAGE_SIZE; // this.pageSize = DEFAULT_PAGE_SIZE;
} // }
//
return (this.pageNo - 1) * this.pageSize; // return (this.pageNo - 1) * this.pageSize;
} // }
//
/** // /**
* // * 获取用户自定义排序集合
* // *
* @return // * @return 排序集合实体
*/ // */
public String getSortString() { // public String getSortString() {
List<String> sortField = this.getSortField(); // List<String> sortField = this.getSortField();
if (CollectionUtil.isEmpty(sortField)) { // if (CollectionUtil.isEmpty(sortField)) {
return null; // return null;
} // }
StringBuilder sortBuilder = new StringBuilder(); // StringBuilder sortBuilder = new StringBuilder();
for (String field : sortField) { // for (String field : sortField) {
String[] values = field.split(","); // String[] values = field.split(",");
sortBuilder.append(String.format("%s %s", values[0], values[1])).append(","); // sortBuilder.append(String.format("%s %s", values[0], values[1])).append(",");
} // }
return sortBuilder.deleteCharAt(sortBuilder.length() - 1).toString(); // return sortBuilder.deleteCharAt(sortBuilder.length() - 1).toString();
} // }
} //}

View File

@ -1,31 +1,31 @@
package com.mcwl.comment.mapper; //package com.mcwl.comment.mapper;
//
//
import com.mcwl.comment.domain.ProductCommentConditionEntity; //import com.mcwl.comment.domain.ProductCommentConditionEntity;
import com.mcwl.comment.domain.ProductCommentEntity; //import com.mcwl.comment.domain.ProductCommentEntity;
import com.mcwl.common.web.BaseMapper; //import com.mcwl.common.web.BaseMapper;
import com.mcwl.resource.domain.MallProduct; //import com.mcwl.resource.domain.MallProduct;
import org.apache.ibatis.annotations.Param; //import org.apache.ibatis.annotations.Param;
//
import java.util.List; //import java.util.List;
//
/** ///**
* @AuthorChenYan // * @AuthorChenYan
* @ProjectMcWl // * @ProjectMcWl
* @Packagecom.mcwl.comment.mapper // * @Packagecom.mcwl.comment.mapper
* @FilenameCommentMapper // * @FilenameCommentMapper
* @Description TODO // * @Description TODO
* @Date2025/1/4 19:04 // * @Date2025/1/4 19:04
*/ // */
public interface CommentMapper extends BaseMapper<ProductCommentEntity, ProductCommentConditionEntity> { //public interface CommentMapper extends BaseMapper<ProductCommentEntity, ProductCommentConditionEntity> {
//
MallProduct findById(@Param("id") Long id); // MallProduct findById(@Param("id") Long id);
//
int insert(ProductCommentEntity productCommentEntity); // int insert(ProductCommentEntity productCommentEntity);
//
int upda(ProductCommentEntity productCommentEntity); // int upda(ProductCommentEntity productCommentEntity);
//
List<ProductCommentEntity> findByIds(List<Long> ids); // List<ProductCommentEntity> findByIds(List<Long> ids);
//
int deleteByIds(List<Long> ids, ProductCommentEntity productCommentEntity); // int deleteByIds(List<Long> ids, ProductCommentEntity productCommentEntity);
} //}

View File

@ -1,88 +1,88 @@
package com.mcwl.comment.service.impl; //package com.mcwl.comment.service.impl;
//
//
import com.mcwl.comment.domain.ProductCommentConditionEntity; //import com.mcwl.comment.domain.ProductCommentConditionEntity;
import com.mcwl.comment.domain.ProductCommentEntity; //import com.mcwl.comment.domain.ProductCommentEntity;
import com.mcwl.comment.mapper.CommentMapper; //import com.mcwl.comment.mapper.CommentMapper;
import com.mcwl.common.core.domain.AjaxResult; //import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.utils.AssertUtil; //import com.mcwl.common.utils.AssertUtil;
import com.mcwl.common.utils.FillUserUtil; //import com.mcwl.common.utils.FillUserUtil;
import com.mcwl.common.utils.ResponsePageEntity; //import com.mcwl.common.utils.ResponsePageEntity;
import com.mcwl.common.utils.SecurityUtils; //import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.bean.BaseService; //import com.mcwl.common.utils.bean.BaseService;
//
import com.mcwl.common.web.BaseMapper; //import com.mcwl.common.web.BaseMapper;
import com.mcwl.resource.domain.MallProduct; //import com.mcwl.resource.domain.MallProduct;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; //import org.springframework.stereotype.Service;
import java.util.List; //import java.util.List;
import java.util.Objects; //import java.util.Objects;
//
import static com.mcwl.common.utils.SecurityUtils.getUsername; //import static com.mcwl.common.utils.SecurityUtils.getUsername;
//
/** ///**
* @AuthorChenYan // * @AuthorChenYan
* @ProjectMcWl // * @ProjectMcWl
* @Packagecom.mcwl.comment.service.impl // * @Packagecom.mcwl.comment.service.impl
* @FilenameCommentServiceImpl // * @FilenameCommentServiceImpl
* @Description TODO // * @Description TODO
* @Date2025/1/4 19:04 // * @Date2025/1/4 19:04
*/ // */
@Service //@Service
public class CommentServiceImpl extends BaseService<ProductCommentEntity, ProductCommentConditionEntity> { //public class CommentServiceImpl extends BaseService<ProductCommentEntity, ProductCommentConditionEntity> {
//
@Autowired // @Autowired
private CommentMapper commentMapper; // private CommentMapper commentMapper;
//
//
public MallProduct findById(Long id) { // public MallProduct findById(Long id) {
return commentMapper.findById(id); // return commentMapper.findById(id);
} // }
//
//
public int insert(ProductCommentEntity productCommentEntity) { // public int insert(ProductCommentEntity productCommentEntity) {
// 获取当前用户 // // 获取当前用户
Long userId = SecurityUtils.getUserId(); // Long userId = SecurityUtils.getUserId();
productCommentEntity.setUserId(userId); // productCommentEntity.setUserId(userId);
productCommentEntity.setCreateBy(getUsername()); // productCommentEntity.setCreateBy(getUsername());
checkParam(productCommentEntity); // checkParam(productCommentEntity);
return commentMapper.insert(productCommentEntity); // return commentMapper.insert(productCommentEntity);
} // }
//
//
public int update(ProductCommentEntity productCommentEntity) { // public int update(ProductCommentEntity productCommentEntity) {
// 获取当前用户 // // 获取当前用户
Long userId = SecurityUtils.getUserId(); // Long userId = SecurityUtils.getUserId();
productCommentEntity.setUserId(userId); // productCommentEntity.setUserId(userId);
productCommentEntity.setUpdateBy(getUsername()); // productCommentEntity.setUpdateBy(getUsername());
checkParam(productCommentEntity); // checkParam(productCommentEntity);
return commentMapper.upda(productCommentEntity); // return commentMapper.upda(productCommentEntity);
} // }
//
//
public int deleteByIds(List<Long> ids) { // public int deleteByIds(List<Long> ids) {
List<ProductCommentEntity> entities = commentMapper.findByIds(ids); // List<ProductCommentEntity> entities = commentMapper.findByIds(ids);
AssertUtil.notEmpty(entities, "商品评论已被删除"); // AssertUtil.notEmpty(entities, "商品评论已被删除");
//
ProductCommentEntity entity = new ProductCommentEntity(); // ProductCommentEntity entity = new ProductCommentEntity();
FillUserUtil.fillUpdateUserInfo(entity); // FillUserUtil.fillUpdateUserInfo(entity);
return commentMapper.deleteByIds(ids, entity); // return commentMapper.deleteByIds(ids, entity);
} // }
private void checkParam(ProductCommentEntity productCommentEntity) { // private void checkParam(ProductCommentEntity productCommentEntity) {
if (Objects.nonNull(productCommentEntity.getParentId()) && productCommentEntity.getParentId() > 0) { // if (Objects.nonNull(productCommentEntity.getParentId()) && productCommentEntity.getParentId() > 0) {
MallProduct productEntity = commentMapper.findById(productCommentEntity.getParentId()); // MallProduct productEntity = commentMapper.findById(productCommentEntity.getParentId());
AssertUtil.notNull(productEntity, "该父评论在系统中不存在"); // AssertUtil.notNull(productEntity, "该父评论在系统中不存在");
} // }
//
MallProduct userEntity = commentMapper.findById(productCommentEntity.getUserId()); // MallProduct userEntity = commentMapper.findById(productCommentEntity.getUserId());
AssertUtil.notNull(userEntity, "该用户在系统中不存在"); // AssertUtil.notNull(userEntity, "该用户在系统中不存在");
//
MallProduct productEntity = commentMapper.findById(productCommentEntity.getProductId()); // MallProduct productEntity = commentMapper.findById(productCommentEntity.getProductId());
AssertUtil.notNull(productEntity, "该商品在系统中不存在"); // AssertUtil.notNull(productEntity, "该商品在系统中不存在");
} // }
//
@Override // @Override
protected BaseMapper getBaseMapper() { // protected BaseMapper getBaseMapper() {
return commentMapper; // return commentMapper;
} // }
} //}

View File

@ -1,95 +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 mall_product_comment
<set>
<if test="parentId != null">
parent_id = #{parentId},
</if>
<if test="productId != null">
product_id = #{productId},
</if>
<if test="userId != null">
user_id = #{userId},
</if>
<if test="content != null">
content = #{content},
</if>
<if test="rating !=null">
rating = #{rating},
</if>
<if test="createBy != null">
create_by = #{createBy},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateBy != null">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
</set>
where id = #{id}
</update>
<delete id="deleteByIds">
delete
from mall_product_comment
where id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="findById" resultType="com.mcwl.resource.domain.MallProduct">
select productId,
userId,
productName,
detail,
model,
amount,
status,
name,
url,
zipUrl,
delFlag
from mall_product
where id = #{id}
</select>
<select id="findByIds" resultType="com.mcwl.comment.domain.ProductCommentEntity">
select
id,
parent_id,
product_id,
user_id,
content,
rating,
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>

View File

@ -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>

View File

@ -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:";
} }

View File

@ -95,6 +95,16 @@ public class SysUser extends BaseEntity
/** 简介 */ /** 简介 */
private String brief; private String brief;
/**
*
*/
private String name;
/**
*
*/
private String idCard;
public SysUser() public SysUser()
{ {
@ -228,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;
@ -333,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 + '\'' +
'}'; '}';
} }
} }

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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();
} }

View File

@ -132,4 +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);
} }

View File

@ -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);
} }

View File

@ -1,12 +1,17 @@
package com.mcwl.system.service.impl; package com.mcwl.system.service.impl;
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;
@ -29,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;
/** /**
@ -41,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;
@ -599,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

View File

@ -148,7 +148,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</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">
@ -223,7 +226,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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>