开始迁移用户收件地址,清理部分代码~

This commit is contained in:
YunaiV 2020-07-23 08:12:42 +08:00
parent 25047e081c
commit 6ae48b6543
37 changed files with 171 additions and 12654 deletions

View File

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
package cn.iocoder.mall.userservice.enums.address;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* 用户收件地址的类型枚举
*/
public enum UserAddressType implements IntArrayValuable {
DEFAULT(1, "默认收件地址"),
NORMAL(2, "普通收件地址"), // 即非默认收件笛之爱
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(UserAddressType::getType).toArray();
private final Integer type;
private final String desc;
UserAddressType(Integer type, String desc) {
this.type = type;
this.desc = desc;
}
public Integer getType() {
return type;
}
public String getDesc() {
return desc;
}
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -0,0 +1,59 @@
package cn.iocoder.mall.userservice.dal.mysql.dataobject.address;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import cn.iocoder.mall.userservice.enums.address.UserAddressType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 用户收件地址
*
* @author Sin
* @time 2019-04-06 13:22
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class UsersUserAddressDO extends DeletableDO {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 省份编号
*/
private Integer provinceCode;
/**
* 城市编号
*/
private Integer cityCode;
/**
* 区域编号
*/
private Integer countyCode;
/**
* 收件详细地址
*/
private String detailAddress;
/**
* 地址类型主要分为默认地址和普通地址
*
* 外键 {@link UserAddressType}
*/
private Integer type;
}

View File

@ -0,0 +1,73 @@
package cn.iocoder.mall.userservice.dal.mysql.dataobject.user;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 用户三方开放平台授权例如QQ / 微博 / 微信等等
*
* TODO 优化点需要在改改
*/
@Data
@Accessors(chain = true)
public class UserThirdAuthDO {
/**
* 用户编号
*
* 外键 {@link UserDO#uid}
*/
private Long uid;
// ========== 授权相关字段
/**
* 用户的唯一标识
*/
private String openid;
/**
* 开放平台
*
* @see cn.iocoder.mall.user.api.constant.ThirdPlatformConstant
*/
private Integer platform;
/**
* 访问令牌
*/
private Date accessToken;
/**
* 过期时间
*/
private Date expireTime;
/**
* 刷新令牌
*/
private Date refreshToken;
/**
* 授权范围一般情况下使用逗号分隔
*/
private String scopes;
// ========== 基础信息
/**
* 用户昵称
*/
private String nickname;
/**
* 性别
*
* TODO 芋艿找地方统一枚举0-未知1-2-
*/
private Integer gender;
// TODO https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842
// TODO 芋艿其他字段国家/省份/城市/地区等
// TODO 芋艿头像
// TODO 芋艿微信独有 unionid
/**
* 统一存储基础信息使用 JSON 格式化避免未有效解析的情况
*/
private String extras;
}

View File

@ -1,18 +0,0 @@
package cn.iocoder.mall.user.rest.controller;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.web.core.constant.CommonMallConstants;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(CommonMallConstants.ROOT_PATH_USER + "/test")
public class TestController {
@GetMapping("/echo")
public CommonResult<Boolean> echo() {
return CommonResult.success(true);
}
}

View File

@ -1 +0,0 @@
package cn.iocoder.mall.user.rest.controller;

View File

@ -1,37 +0,0 @@
package cn.iocoder.mall.user.rest.convert;
import cn.iocoder.mall.user.biz.bo.user.UserAddressBO;
import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO;
import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO;
import cn.iocoder.mall.user.rest.request.user.UserAddressAddRequest;
import cn.iocoder.mall.user.rest.request.user.UserAddressUpdateRequest;
import cn.iocoder.mall.user.rest.response.user.UserAddressResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 用户地址 convert
*
* author: sin
* time: 2020/5/8 10:01
*/
@Mapper
public interface UserAddressConvert {
UserAddressConvert INSTANCE = Mappers.getMapper(UserAddressConvert.class);
@Mappings({})
List<UserAddressResponse> convert(List<UserAddressBO> userAddressBOList);
@Mappings({})
UserAddressResponse convert(UserAddressBO userAddressBO);
@Mappings({})
UserAddressAddDTO convert(UserAddressAddRequest userAddressAddRequest);
@Mappings({})
UserAddressUpdateDTO convert(UserAddressUpdateRequest userAddressUpdateRequest);
}

View File

@ -1 +0,0 @@
package cn.iocoder.mall.user.rest;

View File

@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/8 9:57
*/
package cn.iocoder.mall.user.rest.request;

View File

@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/8 9:57
*/
package cn.iocoder.mall.user.rest.response;

View File

@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/3 8:39 下午
*/
package cn.iocoder.mall.user.rpc;

View File

@ -1,45 +0,0 @@
package cn.iocoder.mall.user.rpc.request.user;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 用户地址 add
*
* @author Sin
* @time 2019-04-06 13:25
*/
@Data
@Accessors(chain = true)
public class UserAddressAddRequest implements Serializable {
/**
* 收件区域编号
*/
private Integer userId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 收件详细地址
*/
private String address;
/**
* 是否默认
*
* - 1 不是
* - 2
*/
private Integer hasDefault;
}

View File

@ -1,46 +0,0 @@
package cn.iocoder.mall.user.rpc.request.user;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 用户地址 更新
*
* @author Sin
* @time 2019-04-06 13:28
*/
@Data
@Accessors(chain = true)
public class UserAddressUpdateRequest implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 收件详细地址
*/
private String address;
/**
* 是否默认地址
*/
private Integer hasDefault;
}

View File

@ -1,5 +0,0 @@
/**
* author: sin
* time: 2020/5/3 8:42 下午
*/
package cn.iocoder.mall.user.rpc.response;

View File

@ -1,46 +0,0 @@
package cn.iocoder.mall.user.rpc.response.user;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 用户地址
*
* @author Sin
* @time 2019-04-06 13:28
*/
@Data
@Accessors(chain = true)
public class UserAddressResponse implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 收件详细地址
*/
private String address;
/**
* 是否默认
*/
private Integer hasDefault;
}

View File

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>user</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>user-service-api</artifactId>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>system-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,31 +0,0 @@
package cn.iocoder.mall.user.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.user.api.bo.UserAddressBO;
import cn.iocoder.mall.user.api.dto.UserAddressAddDTO;
import cn.iocoder.mall.user.api.dto.UserAddressUpdateDTO;
import java.util.List;
/**
* 用户地址
*
* @author Sin
* @time 2019-04-06 13:24
*/
public interface UserAddressService {
// TODO FROM 芋艿 to 小范泛型哈另外Service 不用 CommonResult 返回
CommonResult addAddress(UserAddressAddDTO userAddressAddDTO);
CommonResult updateAddress(UserAddressUpdateDTO userAddressAddDTO);
CommonResult removeAddress(Integer userId, Integer addressId);
CommonResult<List<UserAddressBO>> addressList(Integer userId);
CommonResult<UserAddressBO> getAddress(Integer userId, Integer id);
CommonResult<UserAddressBO> getDefaultAddress(Integer userId);
}

View File

@ -1,43 +0,0 @@
package cn.iocoder.mall.user.api;
import cn.iocoder.common.framework.constant.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.user.api.bo.UserBO;
import cn.iocoder.mall.user.api.bo.UserPageBO;
import cn.iocoder.mall.user.api.dto.UserPageDTO;
import cn.iocoder.mall.user.api.dto.UserUpdateDTO;
public interface UserService {
UserPageBO getUserPage(UserPageDTO userPageDTO);
UserBO getUser(Integer userId);
/**
* 更新用户基本信息
*
* @param userUpdateDTO 更新 DTO
* @return 更新结果
*/
Boolean updateUser(UserUpdateDTO userUpdateDTO);
/**
* 更新用户状态
*
* @param userId 用户编号
* @param status 状态
* @return 更新结果
*/
Boolean updateUserStatus(Integer userId,
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") Integer status);
/**
* 更新用户手机号
*
* @param userId 用户编号
* @param mobile 手机号
* @return 更新结果
*/
Boolean updateUserMobile(Integer userId, String mobile);
}

View File

@ -1,44 +0,0 @@
package cn.iocoder.mall.user.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author Sin
* @time 2019-04-06 13:28
*/
@Data
@Accessors(chain = true)
public class UserAddressBO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 收件详细地址
*/
private String address;
/**
* 是否默认
*/
private Integer hasDefault;
}

View File

@ -1,41 +0,0 @@
package cn.iocoder.mall.user.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
@Data
@Accessors(chain = true)
public class UserBO implements Serializable {
/**
* 用户编号
*/
private Integer id;
/**
* 手机号
*/
private String mobile;
/**
* 昵称
*/
private String nickname;
/**
* 头像
*/
private String avatar;
/**
* 账号状态
*
* 1 - 开启
* 2 - 禁用
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -1,22 +0,0 @@
package cn.iocoder.mall.user.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
@Data
@Accessors(chain = true)
public class UserPageBO implements Serializable {
/**
* 用户数组
*/
private List<UserBO> list;
/**
* 总量
*/
private Integer total;
}

View File

@ -1,13 +0,0 @@
package cn.iocoder.mall.user.api.constant;
public class ThirdPlatformConstant {
public static final int QQ = 1;
public static final int WEIBO = 2;
// WECHAT 可能分成好几个
// ....
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.mall.user.api.constant;
/**
* 用户地址 - 用户默认地址
*
* @author Sin
* @time 2019-04-10 22:02
*/
public enum UserAddressHasDefaultEnum {
DEFAULT_ADDRESS_NO (1, "不是默认地址"),
DEFAULT_ADDRESS_YES (2, "不是默认地址")
;
private final int value;
private final String name;
UserAddressHasDefaultEnum(int value, String name) {
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@ -1,14 +0,0 @@
package cn.iocoder.mall.user.api.constant;
public class UserConstants {
/**
* 状态 - 开启
*/
public static final Integer STATUS_ENABLE = 1;
/**
* 状态 - 关闭
*/
public static final Integer STATUS_DISABLE = 2;
}

View File

@ -1,54 +0,0 @@
package cn.iocoder.mall.user.api.constant;
/**
* 错误码枚举类
*
* 用户系统使用 1-001-000-000
*/
public enum UserErrorCodeEnum {
// ========== OAUTH2 模块 ==========
OAUTH2_UNKNOWN(1001001000, "未知错误"), // 预留
OAUTH2_INVALID_GRANT_BAD_CREDENTIALS(1001001001, "密码不正确"), // 暂时没用到
OAUTH2_INVALID_GRANT_USERNAME_NOT_FOUND(1001001002, "账号不存在"), // 暂时没用到
OAUTH2_INVALID_GRANT(1001001010, ""), // 预留
OAUTH_INVALID_ACCESS_TOKEN_NOT_FOUND(1001001011, "访问令牌不存在"),
OAUTH_INVALID_ACCESS_TOKEN_EXPIRED(1001001012, "访问令牌已过期"),
OAUTH_INVALID_ACCESS_TOKEN_INVALID(1001001013, "访问令牌已失效"),
OAUTH_INVALID_REFRESH_TOKEN(1001001020, ""), // 预留
OAUTH_INVALID_REFRESH_TOKEN_NOT_FOUND(1001001021, "刷新令牌不存在"),
OAUTH_INVALID_REFRESH_TOKEN_EXPIRED(1001001022, "访问令牌已过期"),
OAUTH_INVALID_REFRESH_TOKEN_INVALID(1001001023, "刷新令牌已失效"),
// ========== 用户模块 ==========
USER_MOBILE_NOT_REGISTERED(1001002000, "手机号未注册用户"),
USER_MOBILE_ALREADY_REGISTERED(1001002001, "手机号已经注册用户"),
USER_NOT_EXISTS(1001002002, "用户不存在"),
USER_STATUS_EQUALS(1001002003, "账号已经是该状态"),
USER_MOBILE_EQUALS(1001002004, "账号已经是该手机号"),
// ========== 用户地址 ==========
USER_ADDRESS_NOT_EXISTENT(1001004000, "用户地址不存在!"),
USER_ADDRESS_IS_DELETED(1001004001, "用户地址已被删除!"),
USER_GET_ADDRESS_NOT_EXISTS(1001004002, "获取的地址不存在!"),
;
private final int code;
private final String message;
UserErrorCodeEnum(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}

View File

@ -1,45 +0,0 @@
package cn.iocoder.mall.user.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 用户地址 add
*
* @author Sin
* @time 2019-04-06 13:25
*/
@Data
@Accessors(chain = true)
public class UserAddressAddDTO implements Serializable {
/**
* 收件区域编号
*/
private Integer userId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 收件详细地址
*/
private String address;
/**
* 是否默认
*
* - 1 不是
* - 2
*/
private Integer hasDefault;
}

View File

@ -1,46 +0,0 @@
package cn.iocoder.mall.user.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 用户地址 更新
*
* @author Sin
* @time 2019-04-06 13:28
*/
@Data
@Accessors(chain = true)
public class UserAddressUpdateDTO implements Serializable {
/**
* 编号
*/
private Integer id;
/**
* 用户编号
*/
private Integer userId;
/**
* 收件区域编号
*/
private String areaNo;
/**
* 收件人名称
*/
private String name;
/**
* 收件手机号
*/
private String mobile;
/**
* 收件详细地址
*/
private String address;
/**
* 是否默认地址
*/
private Integer hasDefault;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.mall.user.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
@Data
@Accessors(chain = true)
public class UserPageDTO {
/**
* 查询的昵称
*
* 模糊查询
*/
private String nickname;
/**
* 状态
*/
private Integer status;
@NotNull(message = "页码不能为空")
private Integer pageNo;
@NotNull(message = "每页条数不能为空")
private Integer pageSize;
}

View File

@ -1,26 +0,0 @@
package cn.iocoder.mall.user.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 用户更新 DTO
*/
@Data
@Accessors(chain = true)
public class UserUpdateDTO {
/**
* 用户编号
*/
private Integer id;
/**
* 昵称
*/
private String nickname;
/**
* 头像
*/
private String avatar;
}

View File

@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>user</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>user-application</artifactId>
<properties>
</properties>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>user-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>user-service-impl</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>system-sdk</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>user-sdk</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
<!-- 服务保障相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 提供给 mapstruct 使用 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- 打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,15 +0,0 @@
package cn.iocoder.mall.user.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.user"})
@EnableAsync(proxyTargetClass = true)
public class UserApplication {
public static void main(String[] args) {
SpringApplication.run(UserApplication.class, args);
}
}

View File

@ -1,79 +0,0 @@
package cn.iocoder.mall.user.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.user.api.UserAddressService;
import cn.iocoder.mall.user.api.bo.UserAddressBO;
import cn.iocoder.mall.user.api.dto.UserAddressAddDTO;
import cn.iocoder.mall.user.api.dto.UserAddressUpdateDTO;
import cn.iocoder.mall.user.application.convert.UserAddressConvert;
import cn.iocoder.mall.user.application.po.UserAddressAddPO;
import cn.iocoder.mall.user.application.po.UserAddressUpdatePO;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 用户地址
*
* @author Sin
* @time 2019-04-06 14:11
*/
@RestController
@RequestMapping("users/address")
@Api(value = "用户地址API")
public class UserAddressController {
@Reference(validation = "true", version = "${dubbo.provider.UserAddressService.version}")
private UserAddressService userAddressService;
@PostMapping("add")
@ApiOperation(value = "用户地址-添加")
public CommonResult addAddress(@Validated UserAddressAddPO userAddressAddPO) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
UserAddressAddDTO userAddressAddDTO = UserAddressConvert.INSTANCE.convert(userAddressAddPO);
userAddressAddDTO.setUserId(userId);
return userAddressService.addAddress(userAddressAddDTO);
}
@PutMapping("update")
@ApiOperation(value = "用户地址-更新")
public CommonResult updateAddress(@Validated UserAddressUpdatePO userAddressUpdatePO) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
UserAddressUpdateDTO userAddressUpdateDTO = UserAddressConvert.INSTANCE.convert(userAddressUpdatePO);
userAddressUpdateDTO.setUserId(userId);
return userAddressService.updateAddress(userAddressUpdateDTO);
}
@DeleteMapping("remove")
@ApiOperation(value = "用户地址-删除")
public CommonResult removeAddress(@RequestParam("id") Integer id) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
return userAddressService.removeAddress(userId, id);
}
@GetMapping("list")
@ApiOperation(value = "用户地址列表")
public CommonResult<List<UserAddressBO>> addressList() {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
return userAddressService.addressList(userId);
}
@GetMapping("address")
@ApiOperation(value = "获取地址")
public CommonResult<UserAddressBO> getAddress(@RequestParam("id") Integer id) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
return userAddressService.getAddress(userId, id);
}
@GetMapping("default_address")
@ApiOperation(value = "获取默认地址")
public CommonResult<UserAddressBO> getDefaultAddress() {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
return userAddressService.getDefaultAddress(userId);
}
}

View File

@ -1,59 +0,0 @@
package cn.iocoder.mall.user.application.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* 用户地址 add
*
* @author Sin
* @time 2019-04-06 14:13
*/
@ApiModel("用户地址")
@Data
@Accessors(chain = true)
public class UserAddressAddPO implements Serializable {
/**
* 收件区域编号
*/
@ApiModelProperty("区域编号")
@NotNull(message = "区域编号不能为空!")
private String areaNo;
/**
* 收件人名称
*/
@ApiModelProperty("收件人名称")
@NotNull(message = "请填写收人信息!")
private String name;
/**
* 收件手机号
*/
@ApiModelProperty("收件手机号")
@NotNull(message = "手机号为不能为空!")
@Size(min = 11, max = 11, message = "手机号为 11 位!")
private String mobile;
/**
* 收件详细地址
*/
@ApiModelProperty("收件详细地址")
@NotEmpty(message = "详细地址不能为空")
@Length(min = 10, max = 100, message = "地址在 10 ~ 100 字之间!")
private String address;
/**
* 收件详细地址
*/
@ApiModelProperty("默认地址")
@NotNull(message = "默认地址不能为空")
private Integer hasDefault;
}

View File

@ -1,61 +0,0 @@
package cn.iocoder.mall.user.application.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* 用户地址 add
*
* @author Sin
* @time 2019-04-06 14:13
*/
@ApiModel("用户地址-更新")
@Data
@Accessors(chain = true)
public class UserAddressUpdatePO implements Serializable {
/**
* 收件区域编号
*/
@ApiModelProperty("地址编号")
@NotNull(message = "地址编号为空!")
private Integer id;
/**
* 收件区域编号
*/
@ApiModelProperty("区域编号")
@NotNull(message = "区域编号不能为空!")
private String areaNo;
/**
* 收件人名称
*/
@ApiModelProperty("收件人名称")
@NotNull(message = "请填写收人信息!")
private String name;
/**
* 收件手机号
*/
@ApiModelProperty("收件手机号")
@NotNull(message = "手机号为不能为空!")
@Size(min = 11, max = 11, message = "手机号为 11 位!")
private String mobile;
/**
* 收件详细地址
*/
@ApiModelProperty("收件详细地址")
@NotNull(message = "详细地址不能为空")
@Size(min = 10, max = 100, message = "地址在 10 ~ 100 字之间!")
private String address;
/**
* 是否设置默认
*/
@ApiModelProperty("是否设置默认")
@NotNull(message = "是否设置默认不能为空")
private Integer hasDefault;
}

View File

@ -1,6 +0,0 @@
swagger:
enable: true
title: 用户子系统
description: 用户子系统
version: 1.0.0
base-package: cn.iocoder.mall.user.application.controller

View File

@ -1,32 +0,0 @@
spring:
application:
name: user-application
# Spring Cloud 配置项
cloud:
# Spring Cloud Sentinel 配置项
sentinel:
transport:
dashboard: s1.iocoder.cn:12088 # Sentinel Dashboard 服务地址
eager: true # 项目启动时,直接连接到 Sentinel
# server
server:
port: 18082
servlet:
context-path: /user-api/
swagger:
enable: true # 暂时不去掉
title: 用户子系统
description: 用户子系统
version: 1.0.0
base-package: cn.iocoder.mall.user.application.controller
management:
endpoints:
web:
exposure:
include: health,info,env,metrics,prometheus
metrics:
enabled: true