补全后端基础相关模块
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.member;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 项目的启动类
|
||||
*
|
||||
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
* 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class MemberServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
|
||||
SpringApplication.run(MemberServerApplication.class, args);
|
||||
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
// 如果你碰到启动的问题,请认真阅读 https://cloud.iocoder.cn/quick-start/ 文章
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.member.api.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.api.address.dto.MemberAddressRespDTO;
|
||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||
import cn.iocoder.yudao.module.member.service.address.AddressService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 用户收件地址 API 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class MemberAddressApiImpl implements MemberAddressApi {
|
||||
|
||||
@Resource
|
||||
private AddressService addressService;
|
||||
|
||||
@Override
|
||||
public CommonResult<MemberAddressRespDTO> getAddress(Long id, Long userId) {
|
||||
return success(AddressConvert.INSTANCE.convert02(addressService.getAddress(userId, id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<MemberAddressRespDTO> getDefaultAddress(Long userId) {
|
||||
return success(AddressConvert.INSTANCE.convert02(addressService.getDefaultUserAddress(userId)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.member.api.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.api.config.dto.MemberConfigRespDTO;
|
||||
import cn.iocoder.yudao.module.member.convert.config.MemberConfigConvert;
|
||||
import cn.iocoder.yudao.module.member.service.config.MemberConfigService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 用户配置 API 实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class MemberConfigApiImpl implements MemberConfigApi {
|
||||
|
||||
@Resource
|
||||
private MemberConfigService memberConfigService;
|
||||
|
||||
@Override
|
||||
public CommonResult<MemberConfigRespDTO> getConfig() {
|
||||
return success(MemberConfigConvert.INSTANCE.convert01(memberConfigService.getConfig()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.iocoder.yudao.module.member.api.level;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||
import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.service.level.MemberLevelService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT;
|
||||
|
||||
/**
|
||||
* 会员等级 API 实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class MemberLevelApiImpl implements MemberLevelApi {
|
||||
|
||||
@Resource
|
||||
private MemberLevelService memberLevelService;
|
||||
|
||||
@Override
|
||||
public CommonResult<MemberLevelRespDTO> getMemberLevel(Long id) {
|
||||
return success(MemberLevelConvert.INSTANCE.convert02(memberLevelService.getLevel(id)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addExperience(Long userId, Integer experience, Integer bizType, String bizId) {
|
||||
MemberExperienceBizTypeEnum bizTypeEnum = MemberExperienceBizTypeEnum.getByType(bizType);
|
||||
if (bizTypeEnum == null) {
|
||||
throw exception(EXPERIENCE_BIZ_NOT_SUPPORT);
|
||||
}
|
||||
memberLevelService.addExperience(userId, experience, bizTypeEnum, bizId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> reduceExperience(Long userId, Integer experience, Integer bizType, String bizId) {
|
||||
return addExperience(userId, -experience, bizType, bizId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.member.api;
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.member.api.point;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.member.service.point.MemberPointRecordService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.POINT_RECORD_BIZ_NOT_SUPPORT;
|
||||
|
||||
/**
|
||||
* 用户积分的 API 实现类
|
||||
*
|
||||
* @author owen
|
||||
*/
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class MemberPointApiImpl implements MemberPointApi {
|
||||
|
||||
@Resource
|
||||
private MemberPointRecordService memberPointRecordService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addPoint(Long userId, Integer point, Integer bizType, String bizId) {
|
||||
Assert.isTrue(point > 0);
|
||||
MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType);
|
||||
if (bizTypeEnum == null) {
|
||||
throw exception(POINT_RECORD_BIZ_NOT_SUPPORT);
|
||||
}
|
||||
memberPointRecordService.createPointRecord(userId, point, bizTypeEnum, bizId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> reducePoint(Long userId, Integer point, Integer bizType, String bizId) {
|
||||
Assert.isTrue(point > 0);
|
||||
MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType);
|
||||
if (bizTypeEnum == null) {
|
||||
throw exception(POINT_RECORD_BIZ_NOT_SUPPORT);
|
||||
}
|
||||
memberPointRecordService.createPointRecord(userId, -point, bizTypeEnum, bizId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.iocoder.yudao.module.member.api.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.USER_MOBILE_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 会员用户的 API 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class MemberUserApiImpl implements MemberUserApi {
|
||||
|
||||
@Resource
|
||||
private MemberUserService userService;
|
||||
|
||||
@Override
|
||||
public CommonResult<MemberUserRespDTO> getUser(Long id) {
|
||||
MemberUserDO user = userService.getUser(id);
|
||||
return success(MemberUserConvert.INSTANCE.convert2(user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<MemberUserRespDTO>> getUserList(Collection<Long> ids) {
|
||||
return success(MemberUserConvert.INSTANCE.convertList2(userService.getUserList(ids)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<MemberUserRespDTO>> getUserListByNickname(String nickname) {
|
||||
return success(MemberUserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<MemberUserRespDTO> getUserByMobile(String mobile) {
|
||||
return success(MemberUserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> validateUser(Long id) {
|
||||
MemberUserDO user = userService.getUser(id);
|
||||
if (user == null) {
|
||||
throw exception(USER_MOBILE_NOT_EXISTS);
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.address.vo.AddressRespVO;
|
||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.address.MemberAddressDO;
|
||||
import cn.iocoder.yudao.module.member.service.address.AddressService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 用户收件地址")
|
||||
@RestController
|
||||
@RequestMapping("/member/address")
|
||||
@Validated
|
||||
public class AddressController {
|
||||
|
||||
@Resource
|
||||
private AddressService addressService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得用户收件地址列表")
|
||||
@Parameter(name = "userId", description = "用户编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('member:user:query')")
|
||||
public CommonResult<List<AddressRespVO>> getAddressList(@RequestParam("userId") Long userId) {
|
||||
List<MemberAddressDO> list = addressService.getAddressList(userId);
|
||||
return success(AddressConvert.INSTANCE.convertList2(list));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address;
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.address.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 用户收件地址 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class AddressBaseVO {
|
||||
|
||||
@Schema(description = "收件人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotNull(message = "收件人名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "手机号不能为空")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地区编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "15716")
|
||||
@NotNull(message = "地区编码不能为空")
|
||||
private Long areaId;
|
||||
|
||||
@Schema(description = "收件详细地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "收件详细地址不能为空")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "是否默认", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "是否默认不能为空")
|
||||
private Boolean defaultStatus;
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user