用户地址完成及其导出新的sql
This commit is contained in:
1 parent
1f726f5c1d
commit
30a0a1c962
14 files changed
+4170
-8
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.app.common.persistence.dao;
|
||||
|
||||
import com.ruoyi.app.common.persistence.model.StoreComment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品评论表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-15
|
||||
*/
|
||||
public interface StoreCommentMapper extends BaseMapper<StoreComment> {
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.app.common.persistence.dao;
|
||||
|
||||
import com.ruoyi.app.common.persistence.model.StorePointsMoneyLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 积分/余额日志(流水)表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-15
|
||||
*/
|
||||
public interface StorePointsMoneyLogMapper extends BaseMapper<StorePointsMoneyLog> {
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?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.ruoyi.app.common.persistence.dao.StoreCommentMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.app.common.persistence.model.StoreComment">
|
||||
<id column="comment_id" property="commentId" />
|
||||
<result column="goods_id" property="goodsId" />
|
||||
<result column="email" property="email" />
|
||||
<result column="username" property="username" />
|
||||
<result column="content" property="content" />
|
||||
<result column="add_time" property="addTime" />
|
||||
<result column="ip_address" property="ipAddress" />
|
||||
<result column="is_show" property="isShow" />
|
||||
<result column="parent_id" property="parentId" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="img" property="img" />
|
||||
<result column="order_id" property="orderId" />
|
||||
<result column="deliver_rank" property="deliverRank" />
|
||||
<result column="goods_rank" property="goodsRank" />
|
||||
<result column="service_rank" property="serviceRank" />
|
||||
<result column="zan_num" property="zanNum" />
|
||||
<result column="zan_userid" property="zanUserid" />
|
||||
<result column="is_anonymous" property="isAnonymous" />
|
||||
<result column="rec_id" property="recId" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?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.ruoyi.app.common.persistence.dao.StorePointsMoneyLogMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.ruoyi.app.common.persistence.model.StorePointsMoneyLog">
|
||||
<id column="id" property="id" />
|
||||
<result column="order_id" property="orderId" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="title" property="title" />
|
||||
<result column="points_number" property="pointsNumber" />
|
||||
<result column="money_number" property="moneyNumber" />
|
||||
<result column="type" property="type" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,297 @@
|
||||
package com.ruoyi.app.common.persistence.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品评论表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-15
|
||||
*/
|
||||
@TableName("store_comment")
|
||||
public class StoreComment extends Model<StoreComment> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 评论id
|
||||
*/
|
||||
@TableId(value = "comment_id", type = IdType.AUTO)
|
||||
private Integer commentId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
@TableField("goods_id")
|
||||
private Integer goodsId;
|
||||
/**
|
||||
* email邮箱
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 评论内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
@TableField("add_time")
|
||||
private Integer addTime;
|
||||
/**
|
||||
* ip地址
|
||||
*/
|
||||
@TableField("ip_address")
|
||||
private String ipAddress;
|
||||
/**
|
||||
* 是否显示
|
||||
*/
|
||||
@TableField("is_show")
|
||||
private Integer isShow;
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
@TableField("parent_id")
|
||||
private Integer parentId;
|
||||
/**
|
||||
* 评论用户
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Integer userId;
|
||||
/**
|
||||
* 晒单图片
|
||||
*/
|
||||
private String img;
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
@TableField("order_id")
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 物流评价等级
|
||||
*/
|
||||
@TableField("deliver_rank")
|
||||
private Integer deliverRank;
|
||||
/**
|
||||
* 商品评价等级
|
||||
*/
|
||||
@TableField("goods_rank")
|
||||
private Integer goodsRank;
|
||||
/**
|
||||
* 商家服务态度评价等级
|
||||
*/
|
||||
@TableField("service_rank")
|
||||
private Integer serviceRank;
|
||||
/**
|
||||
* 被赞数
|
||||
*/
|
||||
@TableField("zan_num")
|
||||
private Integer zanNum;
|
||||
/**
|
||||
* 点赞用户id
|
||||
*/
|
||||
@TableField("zan_userid")
|
||||
private String zanUserid;
|
||||
/**
|
||||
* 是否匿名评价:0不是,1是
|
||||
*/
|
||||
@TableField("is_anonymous")
|
||||
private Integer isAnonymous;
|
||||
/**
|
||||
* 订单商品表ID
|
||||
*/
|
||||
@TableField("rec_id")
|
||||
private Integer recId;
|
||||
|
||||
|
||||
public Integer getCommentId() {
|
||||
return commentId;
|
||||
}
|
||||
|
||||
public void setCommentId(Integer commentId) {
|
||||
this.commentId = commentId;
|
||||
}
|
||||
|
||||
public Integer getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(Integer goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Integer getAddTime() {
|
||||
return addTime;
|
||||
}
|
||||
|
||||
public void setAddTime(Integer addTime) {
|
||||
this.addTime = addTime;
|
||||
}
|
||||
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public void setIpAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public Integer getIsShow() {
|
||||
return isShow;
|
||||
}
|
||||
|
||||
public void setIsShow(Integer isShow) {
|
||||
this.isShow = isShow;
|
||||
}
|
||||
|
||||
public Integer getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Integer parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getImg() {
|
||||
return img;
|
||||
}
|
||||
|
||||
public void setImg(String img) {
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
public Integer getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(Integer orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public Integer getDeliverRank() {
|
||||
return deliverRank;
|
||||
}
|
||||
|
||||
public void setDeliverRank(Integer deliverRank) {
|
||||
this.deliverRank = deliverRank;
|
||||
}
|
||||
|
||||
public Integer getGoodsRank() {
|
||||
return goodsRank;
|
||||
}
|
||||
|
||||
public void setGoodsRank(Integer goodsRank) {
|
||||
this.goodsRank = goodsRank;
|
||||
}
|
||||
|
||||
public Integer getServiceRank() {
|
||||
return serviceRank;
|
||||
}
|
||||
|
||||
public void setServiceRank(Integer serviceRank) {
|
||||
this.serviceRank = serviceRank;
|
||||
}
|
||||
|
||||
public Integer getZanNum() {
|
||||
return zanNum;
|
||||
}
|
||||
|
||||
public void setZanNum(Integer zanNum) {
|
||||
this.zanNum = zanNum;
|
||||
}
|
||||
|
||||
public String getZanUserid() {
|
||||
return zanUserid;
|
||||
}
|
||||
|
||||
public void setZanUserid(String zanUserid) {
|
||||
this.zanUserid = zanUserid;
|
||||
}
|
||||
|
||||
public Integer getIsAnonymous() {
|
||||
return isAnonymous;
|
||||
}
|
||||
|
||||
public void setIsAnonymous(Integer isAnonymous) {
|
||||
this.isAnonymous = isAnonymous;
|
||||
}
|
||||
|
||||
public Integer getRecId() {
|
||||
return recId;
|
||||
}
|
||||
|
||||
public void setRecId(Integer recId) {
|
||||
this.recId = recId;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.commentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StoreComment{" +
|
||||
", commentId=" + commentId +
|
||||
", goodsId=" + goodsId +
|
||||
", email=" + email +
|
||||
", username=" + username +
|
||||
", content=" + content +
|
||||
", addTime=" + addTime +
|
||||
", ipAddress=" + ipAddress +
|
||||
", isShow=" + isShow +
|
||||
", parentId=" + parentId +
|
||||
", userId=" + userId +
|
||||
", img=" + img +
|
||||
", orderId=" + orderId +
|
||||
", deliverRank=" + deliverRank +
|
||||
", goodsRank=" + goodsRank +
|
||||
", serviceRank=" + serviceRank +
|
||||
", zanNum=" + zanNum +
|
||||
", zanUserid=" + zanUserid +
|
||||
", isAnonymous=" + isAnonymous +
|
||||
", recId=" + recId +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
package com.ruoyi.app.common.persistence.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 积分/余额日志(流水)表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-15
|
||||
*/
|
||||
@TableName("store_points_money_log")
|
||||
public class StorePointsMoneyLog extends Model<StorePointsMoneyLog> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 日志id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 关联的订单id 充值d订单或者消费订单
|
||||
*/
|
||||
@TableField("order_id")
|
||||
private Integer orderId;
|
||||
/**
|
||||
* 所有者的用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Integer userId;
|
||||
/**
|
||||
* 积分或者红包日志标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 积分变动数量,亿级
|
||||
*/
|
||||
@TableField("points_number")
|
||||
private Integer pointsNumber;
|
||||
/**
|
||||
* 红包变动数量,亿级
|
||||
*/
|
||||
@TableField("money_number")
|
||||
private BigDecimal moneyNumber;
|
||||
/**
|
||||
* 会员红包或者积分变动类型:1支入,2-支出
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Integer createTime;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(Integer orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Integer getPointsNumber() {
|
||||
return pointsNumber;
|
||||
}
|
||||
|
||||
public void setPointsNumber(Integer pointsNumber) {
|
||||
this.pointsNumber = pointsNumber;
|
||||
}
|
||||
|
||||
public BigDecimal getMoneyNumber() {
|
||||
return moneyNumber;
|
||||
}
|
||||
|
||||
public void setMoneyNumber(BigDecimal moneyNumber) {
|
||||
this.moneyNumber = moneyNumber;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Integer createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StorePointsMoneyLog{" +
|
||||
", id=" + id +
|
||||
", orderId=" + orderId +
|
||||
", userId=" + userId +
|
||||
", title=" + title +
|
||||
", pointsNumber=" + pointsNumber +
|
||||
", moneyNumber=" + moneyNumber +
|
||||
", type=" + type +
|
||||
", createTime=" + createTime +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
+33
-7
@@ -8,16 +8,18 @@ import com.ruoyi.app.common.R;
|
||||
import com.ruoyi.app.common.persistence.model.StoreMember;
|
||||
import com.ruoyi.app.modular.member.service.IMemberService;
|
||||
import com.ruoyi.app.modular.member.service.dto.MemberDTO;
|
||||
import com.ruoyi.app.modular.member.service.impl.AddressServiceImpl;
|
||||
import com.ruoyi.app.modular.member.service.mapper.MemberMapper;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
import com.ruoyi.app.modular.member.service.vo.AddressVO;
|
||||
import com.ruoyi.app.modular.shop.service.vo.PageVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
//import wiki.xsx.core.handler.StringHandler;
|
||||
//import wiki.xsx.core.util.RedisUtil;
|
||||
|
||||
@@ -28,17 +30,16 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
**/
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/user")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@Api(value = "个人中心", tags = "个人中心模块", description = "个人中心")
|
||||
public class UserController {
|
||||
private final UserOperator userOperator;
|
||||
private final IMemberService memberService;
|
||||
private final MemberMapper memberMapper;
|
||||
private final AddressServiceImpl addressService;
|
||||
|
||||
@GetMapping(value = "/info")
|
||||
//@PreAuthorize("hasAllRoles('user')")
|
||||
@ApiOperation(value = "获取个人信息",notes = "获取个人信息")
|
||||
@GetMapping(value = "/shop/user-my-info")
|
||||
@ApiOperation(value = "我的个人信息",notes = "我的个人信息")
|
||||
public R userInfo(){
|
||||
//redis测试
|
||||
//StringHandler stringHandler = RedisUtil.getStringHandler();
|
||||
@@ -49,10 +50,35 @@ public class UserController {
|
||||
return R.success(memberDTO);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/shop/user-my-address")
|
||||
@ApiOperation(value = "我的地址列表",notes = "我的地址列表")
|
||||
public R addressList(@Validated @RequestBody PageVO pageVO){
|
||||
int userId = userOperator.getUser().getId();
|
||||
return R.success(addressService.getList(pageVO,userId));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/shop/user-address-add-edit")
|
||||
@ApiOperation(value = "添加或修改地址",notes = "添加或修改地址")
|
||||
public R addAndEditAdress(@Validated @RequestBody AddressVO addressVO){
|
||||
int userId = userOperator.getUser().getId();
|
||||
boolean result = addressService.addAndEdit(addressVO,userId);
|
||||
if(result){
|
||||
return R.success("操作成功");
|
||||
}else{
|
||||
return R.error(4000,"操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@GetMapping(value = "/super")
|
||||
@PreAuthorize("hasAllRoles('user','admin')")
|
||||
@ApiOperation(value = "超管测试信息",notes = "超管测试信息")
|
||||
public R superInfo(){
|
||||
return R.success("超级管理员才可以访问的权限");
|
||||
}
|
||||
**/
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.app.modular.member.service;
|
||||
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.app.common.persistence.model.StoreMemberAddress;
|
||||
import com.ruoyi.app.modular.member.service.dto.AddressDTO;
|
||||
import com.ruoyi.app.modular.member.service.vo.AddressVO;
|
||||
import com.ruoyi.app.modular.shop.service.vo.PageVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IAddressService extends IService<StoreMemberAddress> {
|
||||
|
||||
List<AddressDTO> getList(PageVO pageVO,int userId);
|
||||
|
||||
boolean addAndEdit(AddressVO addressVO,int userId);
|
||||
|
||||
AddressDTO findDefault(int userId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.app.modular.member.service.dto;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商城会员收货地址
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-13
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AddressDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 收货人姓名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 收货手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
private String cityInfo;
|
||||
|
||||
private String address;
|
||||
|
||||
private Integer isDefault;
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.ruoyi.app.modular.member.service.impl;
|
||||
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.app.common.persistence.dao.StoreMemberAddressMapper;
|
||||
import com.ruoyi.app.common.persistence.model.StoreMemberAddress;
|
||||
import com.ruoyi.app.modular.member.service.IAddressService;
|
||||
import com.ruoyi.app.modular.member.service.dto.AddressDTO;
|
||||
import com.ruoyi.app.modular.member.service.mapper.AddressMapper;
|
||||
import com.ruoyi.app.modular.member.service.vo.AddressVO;
|
||||
import com.ruoyi.app.modular.shop.service.vo.PageVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class AddressServiceImpl extends ServiceImpl<StoreMemberAddressMapper, StoreMemberAddress> implements IAddressService {
|
||||
|
||||
private final AddressMapper addressMapper;
|
||||
|
||||
/**
|
||||
* 地址列表
|
||||
* @param pageVO
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<AddressDTO> getList(PageVO pageVO, int userId) {
|
||||
|
||||
QueryWrapper<StoreMemberAddress> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("mid",userId);
|
||||
Page<StoreMemberAddress> pageModel = new Page<>(pageVO.getPage(), pageVO.getLimit());
|
||||
|
||||
IPage<StoreMemberAddress> pageList = baseMapper.selectPage(pageModel,wrapper);
|
||||
|
||||
return addressMapper.toDto(pageList.getRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加或者修改
|
||||
* @param addressVO
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean addAndEdit(AddressVO addressVO,int userId) {
|
||||
StoreMemberAddress storeMemberAddress = new StoreMemberAddress();
|
||||
storeMemberAddress.setCityInfo(addressVO.getCityInfo());
|
||||
storeMemberAddress.setPhone(addressVO.getPhone());
|
||||
storeMemberAddress.setAddress(addressVO.getAddress());
|
||||
storeMemberAddress.setUsername(addressVO.getUsername());
|
||||
int count = 0;
|
||||
if(StrUtil.isEmpty(addressVO.getId())){
|
||||
if(findDefault(userId) != null){
|
||||
storeMemberAddress.setIsDefault(0);
|
||||
}else{
|
||||
storeMemberAddress.setIsDefault(1);
|
||||
}
|
||||
storeMemberAddress.setMid(Integer.valueOf(userId).longValue());
|
||||
count = baseMapper.insert(storeMemberAddress);
|
||||
if(count > 0) return true;
|
||||
}else{
|
||||
storeMemberAddress.setId(Long.valueOf(addressVO.getId()));
|
||||
count = baseMapper.updateById(storeMemberAddress);
|
||||
if(count > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddressDTO findDefault(int userId) {
|
||||
QueryWrapper<StoreMemberAddress> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("mid",userId).eq("is_default",1);
|
||||
|
||||
return addressMapper.toDto(baseMapper.selectOne(wrapper));
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.app.modular.member.service.mapper;
|
||||
|
||||
|
||||
|
||||
import com.ruoyi.app.common.persistence.model.StoreMemberAddress;
|
||||
import com.ruoyi.app.modular.mapper.EntityMapper;
|
||||
import com.ruoyi.app.modular.member.service.dto.AddressDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-06-05
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface AddressMapper extends EntityMapper<AddressDTO, StoreMemberAddress> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ruoyi.app.modular.member.service.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商城会员收货地址
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-13
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AddressVO {
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
@NotBlank(message="收货人姓名不能为空")
|
||||
private String username;
|
||||
|
||||
@NotBlank(message="收货手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
@NotBlank(message="所在地址不能为空")
|
||||
private String cityInfo;
|
||||
|
||||
@NotBlank(message="详细地址不能为空")
|
||||
private String address;
|
||||
|
||||
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class EntityGenerator {
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
//strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
|
||||
strategy.setInclude(new String[]{"store_coupon","store_coupon_list"});
|
||||
strategy.setInclude(new String[]{"store_points_money_log","store_comment"});
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 包配置
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user