提交 413f75f4 authored 作者: benpaodeyouyusi's avatar benpaodeyouyusi

Merge branch 'master' of gitee.com:zhijiantianya/onemall

root=true root=true
[*.java] [*.{adoc,bat,groovy,html,java,js,jsp,kt,kts,md,properties,py,rb,sh,sql,svg,txt,xml,xsd}]
indent_style = space charset = utf-8
indent_size = 4
continuation_indent_size = 8
[*.xml] [*.{groovy,java,kt,kts,xml,xsd}]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
continuation_indent_size = 4 continuation_indent_size = 8
end_of_line = lf
...@@ -15,89 +15,16 @@ ...@@ -15,89 +15,16 @@
<!-- Mall 相关 --> <!-- Mall 相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId> <artifactId>order-rest</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot</artifactId> <artifactId>order-rpc</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-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> <version>1.0-SNAPSHOT</version>
</dependency> </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>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</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> </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> </project>
...@@ -3,24 +3,35 @@ package cn.iocoder.mall.order.application; ...@@ -3,24 +3,35 @@ package cn.iocoder.mall.order.application;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer; import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
/**
* @author xiaofeng
*/
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.order"}) @SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.order"})
public class OrderApplication { public class OrderApplication {
public static void main(String[] args) { /**
SpringApplication.run(OrderApplication.class, args); * 设置需要读取的配置文件的名字。 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY}
} * 实现。
*/
private static final String CONFIG_NAME_VALUE = "biz,rest,rpc,application";
public static void main(String[] args) {
// 设置环境变量
System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE);
SpringApplication.run(OrderApplication.class, args);
}
/** /**
* 解决异常信息: * 解决异常信息: java.lang.IllegalArgumentException: Invalid character found in the request target.
* java.lang.IllegalArgumentException: * The valid characters are defined in RFC 7230 and RFC 3986
* Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 *
* @return * @return
*/ */
@Bean @Bean
...@@ -36,5 +47,4 @@ public class OrderApplication { ...@@ -36,5 +47,4 @@ public class OrderApplication {
} }
}
}
\ No newline at end of file
package cn.iocoder.mall.order.application.controller.admins;
import cn.iocoder.common.framework.util.HttpUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderReturnService;
import cn.iocoder.mall.order.api.bo.OrderReturnListBO;
import cn.iocoder.mall.order.api.dto.OrderReturnQueryDTO;
import cn.iocoder.mall.order.application.convert.OrderReturnConvert;
import cn.iocoder.mall.order.application.po.admin.OrderReturnQueryPO;
import io.swagger.annotations.Api;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* 订单退货
*
* @author Sin
* @time 2019-05-06 21:31
*/
@RestController
@RequestMapping("admins/order_return")
@Api("订单退货(admins api)")
public class AdminOrderReturnController {
@Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
private OrderReturnService orderReturnService;
@GetMapping("list")
public CommonResult<OrderReturnListBO> list(@Validated OrderReturnQueryPO queryPO) {
OrderReturnQueryDTO queryDTO = OrderReturnConvert.INSTANCE.convert(queryPO);
return orderReturnService.orderReturnList(queryDTO);
}
@PostMapping("agree")
public CommonResult agree(@RequestParam("id") Integer id) {
return orderReturnService.orderReturnAgree(id);
}
@PostMapping("refuse")
public CommonResult refuse(@RequestParam("id") Integer id) {
return orderReturnService.orderReturnRefuse(id);
}
@PostMapping("confirm_receipt")
public CommonResult confirmReceipt(@RequestParam("id") Integer id) {
return orderReturnService.confirmReceipt(id);
}
@PostMapping("confirm_refund")
public CommonResult confirmRefund(HttpServletRequest request, @RequestParam("id") Integer id) {
String ip = HttpUtil.getIp(request);
return orderReturnService.refund(id, ip);
}
}
package cn.iocoder.mall.order.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.bo.OrderItemBO;
import cn.iocoder.mall.order.api.bo.OrderPageBO;
import cn.iocoder.mall.order.api.bo.OrderRecipientBO;
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO;
import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
import cn.iocoder.mall.order.application.convert.OrderConvertAPP;
import cn.iocoder.mall.order.application.convert.OrderDeliveryConvert;
import cn.iocoder.mall.order.application.po.admin.OrderDeliverPO;
import cn.iocoder.mall.order.application.po.admin.OrderItemUpdatePO;
import cn.iocoder.mall.order.application.po.admin.OrderLogisticsPO;
import cn.iocoder.mall.order.application.po.admin.OrderPageQueryPO;
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;
/**
* 订单API(admins)
*
* @author Sin
* @time 2019-03-24 10:22
*/
@RestController
@RequestMapping("admins/order")
@Api(value = "订单 API(admins)")
public class AdminsOrderController {
@Reference(validation = "true", version = "${dubbo.provider.OrderService.version}")
private OrderService orderService;
@GetMapping("page")
@ApiOperation("订单列表")
public CommonResult<OrderPageBO> getOrderPage(@Validated OrderPageQueryPO orderPageQueryVO) {
OrderQueryDTO orderQueryDTO = OrderConvertAPP.INSTANCE.convert(orderPageQueryVO);
return orderService.getOrderPage(orderQueryDTO);
}
@GetMapping("order_items")
@ApiOperation("订单列表")
public CommonResult<List<OrderItemBO>> getOrderItems(@RequestParam("orderId") Integer orderId) {
return orderService.getOrderItems(orderId);
}
@GetMapping("order_recipient_info")
@ApiOperation("订单收件人信息")
public CommonResult<OrderRecipientBO> getOrderRecipientBO(@RequestParam("orderId") Integer orderId) {
return orderService.getOrderRecipientBO(orderId);
}
@PostMapping("order_deliver")
@ApiOperation("订单发货")
public CommonResult<OrderRecipientBO> orderDeliver(@RequestBody @Validated OrderDeliverPO orderDeliverPO) {
return orderService.orderDelivery(OrderDeliveryConvert.INSTANCE.convert(orderDeliverPO));
}
@PutMapping("update_remark")
@ApiOperation("更新-更新订单备注")
public CommonResult updateRemark(@RequestParam("orderId") Integer orderId,
@RequestParam("remark") String remark) {
return orderService.updateOrderRemake(orderId, remark);
}
@PutMapping("cancel_order")
@ApiOperation("取消订单")
public CommonResult cancelOrder(
@RequestParam("orderId") Integer orderId,
@RequestParam("reasons") Integer reasons,
@RequestParam(value = "otherReasons", required = false) String otherReasons) {
return orderService.cancelOrder(orderId, reasons, otherReasons);
}
@PutMapping("order_item/update_pay_amount")
@ApiOperation("更新-订单item实付金额")
public CommonResult updateOrderItemPayAmount(@RequestParam("orderId") Integer orderId,
@RequestParam("orderItemId") Integer orderItemId,
@RequestParam("payAmount") Integer payAmount) {
return orderService.updateOrderItemPayAmount(orderId, orderItemId, payAmount);
}
@PutMapping("order_item/update")
@ApiOperation("更新-订单item")
public CommonResult updateOrderItem(@RequestBody @Validated OrderItemUpdatePO orderItemUpdateVO) {
OrderItemUpdateDTO dto = OrderConvertAPP.INSTANCE.convert(orderItemUpdateVO);
return orderService.updateOrderItem(dto);
}
@PutMapping("logistics/update")
@ApiOperation("更新-订单物流")
public CommonResult updateLogistics(@RequestBody @Validated OrderLogisticsPO orderLogisticsVO) {
OrderLogisticsUpdateDTO dto = OrderConvertAPP.INSTANCE.convert(orderLogisticsVO);
return orderService.updateLogistics(dto);
}
}
package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderCommentReplyService;
import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
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 static cn.iocoder.common.framework.vo.CommonResult.success;
/**
*
* 订单评论 Api(user)
*
* @author wtz
* @time 2019-05-27 20:46
*/
@RestController
@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment")
@Api("用户评论模块")
public class OrderCommentController {
@Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
private OrderCommentService orderCommentService;
@Reference(validation = "true", version = "${dubbo.provider.OrderCommentReplyService.version}")
private OrderCommentReplyService orderCommentReplyService;
@PostMapping("create_order_comment")
//@RequiresLogin
@ApiOperation(value = "创建订单评论")
public CommonResult<OrderCommentCreateBO> createOrderComment(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
orderCommentCreateDTO.setUserId(userId);
return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
}
@GetMapping("order_comment_page")
@ApiOperation(value = "获取评论分页")
public CommonResult<OrderCommentPageBO> getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){
return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO));
}
@GetMapping("order_comment_info_merchant_reply")
@ApiOperation(value = "获取评论和商家回复")
public CommonResult<OrderCommentInfoAndMerchantReplyBO> geOrderCommentInfoAndMerchantReply(@RequestParam("commentId") Integer commentId){
OrderCommentInfoAndMerchantReplyBO orderCommentInfoAndMerchantReplyBO=new OrderCommentInfoAndMerchantReplyBO();
orderCommentInfoAndMerchantReplyBO.setOrderCommentInfoBO(orderCommentService.getOrderCommentInfo(commentId));
orderCommentInfoAndMerchantReplyBO.setOrderCommentMerchantReplyBOS(orderCommentReplyService.getOrderCommentMerchantReply(commentId));
return success(orderCommentInfoAndMerchantReplyBO);
}
@GetMapping
//@RequiresLogin
@ApiOperation(value = "获取订单评论状态分页")
public CommonResult<OrderCommentStateInfoPageBO> getOrderCommentStateInfoPage(@Validated OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO){
//Integer userId = UserSecurityContextHolder.getContext().getUserId();
//orderCommentStateInfoPageDTO.setUserId(userId);
return success(orderCommentService.getOrderCommentStateInfoPage(orderCommentStateInfoPageDTO));
}
}
package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderCommentReplyService;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
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 static cn.iocoder.common.framework.vo.CommonResult.success;
/**
*
* 评论回复模块 Api(user)
*
* @author wtz
* @time 2019-05-31 18:00
*/
@RestController
@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment_reply")
@Api("用户评论回复模块 ")
public class OrderCommentReplyController {
@Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
private OrderCommentReplyService orderCommentReplyService;
@PostMapping("create_order_comment_reply")
//@RequiresLogin
@ApiOperation(value = "创建订单回复")
public CommonResult<OrderCommentReplyCreateBO> createOrderCommentReply(@RequestBody @Validated OrderCommentReplyCreateDTO orderCommentReplyCreateDTO){
return success(orderCommentReplyService.createOrderCommentReply(orderCommentReplyCreateDTO));
}
@GetMapping("order_comment_reply_page")
//@RequiresLogin
@ApiOperation(value = "分页获取评论回复")
public CommonResult<OrderCommentReplyPageBO> getOrderCommentReplyPage(@Validated OrderCommentReplyPageDTO orderCommentReplyCreateDTO){
return success(orderCommentReplyService.getOrderCommentReplyPage(orderCommentReplyCreateDTO));
}
}
package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.util.HttpUtil;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.api.DataDictService;
import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.CartService;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.bo.*;
import cn.iocoder.mall.order.api.constant.DictKeyConstants;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
import cn.iocoder.mall.order.application.convert.CartConvert;
import cn.iocoder.mall.order.application.convert.OrderConvertAPP;
import cn.iocoder.mall.order.application.po.user.OrderCreatePO;
import cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO;
import cn.iocoder.mall.promotion.api.CouponService;
import cn.iocoder.mall.promotion.api.bo.CouponCardAvailableBO;
import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
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 javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* 订单API(users)
*
* @author Sin
* @time 2019-03-24 11:24
*/
@RestController
@RequestMapping("users/order")
@Api(description = "用户订单") // TODO FROM 芋艿 to 小范,description 已经废弃啦
public class OrderController {
@Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
private OrderService orderService;
@Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
private CartService cartService;
@Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
private DataDictService dataDictService;
@Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
private CouponService couponService;
@GetMapping("order_page")
@RequiresLogin
@ApiOperation("订单分页")
public CommonResult<OrderPageBO> getOrderPage(@Validated OrderQueryDTO orderQueryDTO) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
orderQueryDTO.setUserId(userId);
return orderService.getOrderPage(orderQueryDTO);
}
@PostMapping("create_order")
@RequiresLogin
@ApiOperation("创建订单")
public CommonResult<OrderCreateBO> createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO,
HttpServletRequest request) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.convert(orderCreatePO);
orderCreateDTO.setUserId(userId).setIp(HttpUtil.getIp(request));
return orderService.createOrder(orderCreateDTO);
}
@PostMapping("create_order_from_cart")
@RequiresLogin
@ApiOperation("创建订单购物车")
public CommonResult<OrderCreateBO> createOrderFromCart(@RequestParam("userAddressId") Integer userAddressId,
@RequestParam(value = "couponCardId", required = false) Integer couponCardId,
@RequestParam(value = "remark", required = false) String remark,
HttpServletRequest request) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
// 获得购物车中选中的商品
List<CartItemBO> cartItems = cartService.list(userId, true);
if (cartItems.isEmpty()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_CREATE_CART_IS_EMPTY.getCode());
}
// 创建 OrderCreateDTO 对象
OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.createOrderCreateDTO(userId, userAddressId,
remark, HttpUtil.getIp(request),
cartItems, couponCardId);
// 创建订单
CommonResult<OrderCreateBO> createResult = orderService.createOrder(orderCreateDTO);
if (createResult.isError()) {
return CommonResult.error(createResult);
}
// 清空购物车 // TODO 芋艿,需要标记删除的原因,即结果为创建为某个订单。
cartService.deleteList(userId, cartItems.stream().map(CartItemBO::getSkuId).collect(Collectors.toList()));
// 返回结果
return createResult;
}
@GetMapping("confirm_create_order")
@RequiresLogin
@ApiOperation("确认创建订单")
public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam("skuId") Integer skuId,
@RequestParam("quantity") Integer quantity,
@RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
// 创建 CalcOrderPriceDTO 对象,并执行价格计算
CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
.setUserId(userId)
.setItems(Collections.singletonList(new CalcOrderPriceDTO.Item(skuId, quantity, true)))
.setCouponCardId(couponCardId);
CalcOrderPriceBO calcOrderPrice = cartService.calcOrderPrice(calcOrderPriceDTO);
// 获得优惠劵
List<CouponCardAvailableBO> couponCards = couponService.getCouponCardList(userId,
CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
// 执行数据拼装
return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
}
@PostMapping("confirm_receiving")
@RequiresLogin
@ApiOperation("确认收货")
public CommonResult confirmReceiving(@RequestParam("orderId") Integer orderId) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
return orderService.confirmReceiving(userId, orderId);
}
@GetMapping("info")
@RequiresLogin
@ApiOperation("订单详情")
public CommonResult<OrderInfoBO> orderInfo(@RequestParam("orderId") Integer orderId) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
CommonResult<OrderInfoBO> commonResult = orderService.info(userId, orderId);
OrderInfoBO orderInfoBO = commonResult.getData();
if (orderInfoBO != null) {
CommonResult<DataDictBO> dictResult = dataDictService
.getDataDict(DictKeyConstants.ORDER_STATUS, orderInfoBO.getStatus());
orderInfoBO.setStatusText(dictResult.getData().getDisplayName());
}
return commonResult;
}
}
package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.api.DataDictService;
import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.api.constant.DictKeyConstants;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import org.apache.dubbo.config.annotation.Reference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.CollectionUtils;
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 java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 订单物流 controller
*
* @author Sin
* @time 2019-04-12 22:24
*/
@RestController
@RequestMapping("users/order_logistics")
@Api(description = "订单物流信息")
public class OrderLogisticsController {
@Reference(validation = "true", version = "${dubbo.provider.OrderLogisticsService.version}")
private OrderLogisticsService orderLogisticsService;
@Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
private DataDictService dataDictService;
@GetMapping("info")
@ApiOperation("物流详细 - 物流通用")
public CommonResult<OrderLogisticsInfoBO> logistics(@RequestParam("logisticsId") Integer logisticsId) {
return orderLogisticsService.getLogisticsInfo(logisticsId);
}
@GetMapping("info_order")
@ApiOperation("物流详细 - 返回订单所关联的所有物流信息(订单用的)")
public CommonResult<OrderLogisticsInfoWithOrderBO> logisticsInfoWithOrder(@RequestParam("orderId") Integer orderId) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
CommonResult<OrderLogisticsInfoWithOrderBO> commonResult = orderLogisticsService.getOrderLogisticsInfo(userId, orderId);
if (commonResult.isSuccess()) {
OrderLogisticsInfoWithOrderBO orderLogisticsInfoBO = commonResult.getData();
List<OrderLogisticsInfoWithOrderBO.Logistics> logisticsList = orderLogisticsInfoBO.getLogistics();
// 获取字典值
Set<Integer> dictValues = logisticsList.stream().map(o -> o.getLogistics()).collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(dictValues)) {
CommonResult<List<DataDictBO>> dictResult = dataDictService
.getDataDictList(DictKeyConstants.ORDER_LOGISTICS_COMPANY, dictValues);
if (dictResult.isError()) {
// 错误情况
return ServiceExceptionUtil.error(OrderErrorCodeEnum.DICT_SERVER_INVOKING_FAIL.getCode());
}
// 转换结果字典值
Map<String, DataDictBO> dataDictBOMap = dictResult.getData()
.stream().collect(Collectors.toMap(o -> o.getValue(), o -> o));
logisticsList.stream().map(o -> {
String dicValue = o.getLogistics().toString();
if (dataDictBOMap.containsKey(dicValue)) {
o.setLogisticsText(dataDictBOMap.get(dicValue).getDisplayName());
}
return o;
}).collect(Collectors.toList());
}
}
return commonResult;
}
}
package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.api.DataDictService;
import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.OrderReturnService;
import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
import cn.iocoder.mall.order.api.constant.DictKeyConstants;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.application.convert.OrderReturnConvert;
import cn.iocoder.mall.order.application.po.user.OrderReturnApplyPO;
import org.apache.dubbo.config.annotation.Reference;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 订单退款/售后流程
*
* @author Sin
* @time 2019-04-25 22:04
*/
@RestController
@RequestMapping("users/order_return")
public class OrderReturnController {
@Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
private OrderReturnService orderReturnService;
@Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
private DataDictService dataDictService;
@GetMapping("reason")
@ApiOperation("原因")
public CommonResult<List<DataDictBO>> orderReturnReason() {
return dataDictService.getDataDict(DictKeyConstants.ORDER_RETURN_REASON);
}
@PostMapping("apply")
@ApiOperation("订单售后")
public CommonResult orderReturnApply(@RequestBody OrderReturnApplyPO orderReturnApplyPO) {
OrderReturnApplyDTO applyDTO = OrderReturnConvert.INSTANCE.convert(orderReturnApplyPO);
return orderReturnService.orderReturnApply(applyDTO);
}
@GetMapping("info")
@ApiOperation("订单售后详细")
public CommonResult<OrderReturnInfoBO> orderApplyInfo(@RequestParam("orderId") Integer orderId) {
CommonResult<OrderReturnInfoBO> commonResult = orderReturnService.orderApplyInfo(orderId);
// 转换 字典值
if (commonResult.isSuccess()) {
CommonResult<DataDictBO> dataDictResult = dataDictService.getDataDict(
DictKeyConstants.ORDER_RETURN_SERVICE_TYPE,
commonResult.getData().getReturnInfo().getServiceType());
if (dataDictResult.isSuccess()) {
commonResult.getData().getReturnInfo().setServiceTypeText(dataDictResult.getData().getDisplayName());
}
}
return commonResult;
}
}
package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.CartService;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO;
import cn.iocoder.mall.order.api.bo.CalcSkuPriceBO;
import cn.iocoder.mall.order.api.bo.CartItemBO;
import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
import cn.iocoder.mall.order.application.convert.CartConvert;
import cn.iocoder.mall.order.application.vo.UsersCalcSkuPriceVO;
import cn.iocoder.mall.order.application.vo.UsersCartDetailVO;
import cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO;
import cn.iocoder.mall.promotion.api.CouponService;
import cn.iocoder.mall.promotion.api.bo.CouponCardAvailableBO;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("users/cart")
public class UsersCartController {
@Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
private CartService cartService;
@Reference(validation = "true", version = "${dubbo.provider.OrderService.version}")
private OrderService orderService;
@Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
private CouponService couponService;
@PostMapping("add")
public CommonResult<Integer> add(@RequestParam("skuId") Integer skuId,
@RequestParam("quantity") Integer quantity) {
// 添加到购物车
cartService.add(UserSecurityContextHolder.getContext().getUserId(), skuId, quantity);
// 获得目前购物车商品总数量
return success(cartService.count(UserSecurityContextHolder.getContext().getUserId()));
}
@PostMapping("update_quantity")
public CommonResult<UsersCartDetailVO> updateQuantity(@RequestParam("skuId") Integer skuId, // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
@RequestParam("quantity") Integer quantity) {
// 添加到购物车
cartService.updateQuantity(UserSecurityContextHolder.getContext().getUserId(),
skuId, quantity);
// 获得目前购物车明细
return getCartDetail();
}
@PostMapping("update_selected")
public CommonResult<UsersCartDetailVO> updateSelected(@RequestParam("skuIds") Set<Integer> skuIds, // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
@RequestParam("selected") Boolean selected) {
// 添加到购物车
cartService.updateSelected(UserSecurityContextHolder.getContext().getUserId(), skuIds, selected);
// 获得目前购物车明细
return getCartDetail();
}
@GetMapping("count")
public CommonResult<Integer> count() {
return success(cartService.count(UserSecurityContextHolder.getContext().getUserId()));
}
@GetMapping("/list")
public CommonResult<UsersCartDetailVO> list() { // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
return getCartDetail();
}
private CommonResult<UsersCartDetailVO> getCartDetail() {
// 获得购物车中选中的
List<CartItemBO> cartItems = cartService.list(UserSecurityContextHolder.getContext().getUserId(), null);
// 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回
if (cartItems.isEmpty()) {
UsersCartDetailVO result = new UsersCartDetailVO();
result.setItemGroups(Collections.emptyList());
result.setFee(new UsersCartDetailVO.Fee(0, 0, 0, 0));
return success(result);
}
// 计算商品价格
CalcOrderPriceBO calcOrder = list0(cartItems, null);
// 执行数据拼装
return success(CartConvert.INSTANCE.convert2(calcOrder));
}
@GetMapping("/confirm_create_order")
public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
// 获得购物车中选中的
List<CartItemBO> cartItems = cartService.list(userId, true);
// 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回
if (cartItems.isEmpty()) {
UsersOrderConfirmCreateVO result = new UsersOrderConfirmCreateVO();
result.setItemGroups(Collections.emptyList());
result.setFee(new UsersOrderConfirmCreateVO.Fee(0, 0, 0, 0));
return success(result);
}
// 计算商品价格
CalcOrderPriceBO calcOrderPrice = list0(cartItems, couponCardId);
// 获得优惠劵
List<CouponCardAvailableBO> couponCards = couponService.getCouponCardList(userId,
CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
// 执行数据拼装
return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
}
private CalcOrderPriceBO list0(List<CartItemBO> cartItems, Integer couponCardId) {
// 创建计算的 DTO
CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
.setUserId(UserSecurityContextHolder.getContext().getUserId())
.setItems(new ArrayList<>(cartItems.size()))
.setCouponCardId(couponCardId);
for (CartItemBO item : cartItems) {
calcOrderPriceDTO.getItems().add(new CalcOrderPriceDTO.Item(item.getSkuId(), item.getQuantity(), item.getSelected()));
}
// 执行计算
return cartService.calcOrderPrice(calcOrderPriceDTO);
}
@GetMapping("/calc_sku_price")
public CommonResult<UsersCalcSkuPriceVO> calcSkuPrice(@RequestParam("skuId") Integer skuId) {
// 计算 sku 的价格
CalcSkuPriceBO calcSkuPrice = cartService.calcSkuPrice(skuId);
return success(CartConvert.INSTANCE.convert2(calcSkuPrice));
}
public CommonResult<Object> confirmOrder() {
// 查询购物车列表(选中的)
// cartService.list(userId, true);
// 查询确认订单信息的明细
return null;
}
}
package cn.iocoder.mall.order.application.convert;
import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO;
import cn.iocoder.mall.order.api.bo.CalcSkuPriceBO;
import cn.iocoder.mall.order.application.vo.UsersCalcSkuPriceVO;
import cn.iocoder.mall.order.application.vo.UsersCartDetailVO;
import cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO;
import cn.iocoder.mall.promotion.api.dto.CouponCardSpuDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Mapper
public interface CartConvert {
CartConvert INSTANCE = Mappers.getMapper(CartConvert.class);
UsersOrderConfirmCreateVO convert(CalcOrderPriceBO calcOrderPriceBO);
UsersCartDetailVO convert2(CalcOrderPriceBO calcOrderPriceBO);
UsersCalcSkuPriceVO convert2(CalcSkuPriceBO calcSkuPriceBO);
default List<CouponCardSpuDTO> convertList(List<CalcOrderPriceBO.ItemGroup> itemGroups) {
List<CouponCardSpuDTO> items = new ArrayList<>();
itemGroups.forEach(itemGroup -> items.addAll(itemGroup.getItems().stream().map(
item -> new CouponCardSpuDTO()
.setSpuId(item.getSpu().getId())
.setSkuId(item.getId())
.setCategoryId(item.getSpu().getCid())
.setPrice(item.getBuyPrice())
.setQuantity(item.getBuyQuantity()))
.collect(Collectors.toList())));
return items;
}
}
package cn.iocoder.mall.order.application.convert;
import cn.iocoder.mall.order.api.bo.CartItemBO;
import cn.iocoder.mall.order.api.dto.*;
import cn.iocoder.mall.order.application.po.admin.OrderItemUpdatePO;
import cn.iocoder.mall.order.application.po.admin.OrderLogisticsPO;
import cn.iocoder.mall.order.application.po.admin.OrderPageQueryPO;
import cn.iocoder.mall.order.application.po.user.OrderCreatePO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* application 订单 convert
*
* TODO 这种方式 文件名不能一样哈!
*
* @author Sin
* @time 2019-03-24 10:45
*/
@Mapper
public interface OrderConvertAPP {
OrderConvertAPP INSTANCE = Mappers.getMapper(OrderConvertAPP.class);
@Mappings({})
OrderQueryDTO convert(OrderPageQueryPO orderPageQueryVO);
@Mappings({})
OrderLogisticsUpdateDTO convert(OrderLogisticsPO orderLogisticsVO);
@Mappings({})
OrderItemUpdateDTO convert(OrderItemUpdatePO orderItemUpdateVO);
@Mappings({})
OrderCreateDTO convert(OrderCreatePO orderCreatePO);
@Mappings({})
List<OrderCreateDTO.OrderItem> convert(List<CartItemBO> cartItems);
default OrderCreateDTO createOrderCreateDTO(Integer userId, Integer userAddressId, String remark, String ip,
List<CartItemBO> cartItems, Integer couponCardId) {
return new OrderCreateDTO()
.setUserId(userId)
.setUserAddressId(userAddressId)
.setRemark(remark)
.setIp(ip)
.setOrderItems(this.convert(cartItems))
.setCouponCardId(couponCardId);
}
}
spring: spring:
# Application 的配置项
application: application:
name: order-application name: order-application
# Profile 的配置项
# Spring Cloud 配置项 profiles:
cloud: active: local
# Spring Cloud Sentinel 配置项
sentinel:
transport:
dashboard: s1.iocoder.cn:12088 # Sentinel Dashboard 服务地址
eager: true # 项目启动时,直接连接到 Sentinel
# server
server:
port: 18088
servlet:
context-path: /order-api/
swagger:
enable: true # 暂时不去掉
title: 订单子系统
description: 订单子系统
version: 1.0.0
base-package: cn.iocoder.mall.order.application.controller
management:
endpoints:
web:
exposure:
include: health,info,env,metrics,prometheus
metrics:
enabled: true
<?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>onemall</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>order-biz-api</artifactId>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
/**
* 该项目,主要用于暴露一些共享的枚举类等。
*
* 例如说,RPC 接口提供错误码给调用方
*/
package cn.iocoder.mall.order.biz;
<?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>onemall</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>order-biz</artifactId>
<dependencies>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-biz-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- Spring 核心 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</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>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>
</project>
spring:
# 数据源配置项
datasource:
url: jdbc:mysql://s1.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 3WLiVUBEwTbvAfsh
# MyBatis Plus 配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: auto
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.system.biz.dataobject
<?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>order</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>order-rest</artifactId>
<description>提供 order 服务的 Rest 接口的实现,提供对外调用</description>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-biz</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-web</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-security</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-swagger</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
package cn.iocoder.mall.order.rest.controller.admins;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 订单退货
*
* @author Sin
* @time 2019-05-06 21:31
*/
@RestController
@RequestMapping("admins/order_return")
@Api("订单退货(admins api)")
public class AdminOrderReturnController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
// private OrderReturnService orderReturnService;
//
// @GetMapping("list")
// public CommonResult<OrderReturnListBO> list(@Validated OrderReturnQueryPO queryPO) {
// OrderReturnQueryDTO queryDTO = OrderReturnConvert.INSTANCE.convert(queryPO);
// return orderReturnService.orderReturnList(queryDTO);
// }
//
// @PostMapping("agree")
// public CommonResult agree(@RequestParam("id") Integer id) {
// return orderReturnService.orderReturnAgree(id);
// }
//
// @PostMapping("refuse")
// public CommonResult refuse(@RequestParam("id") Integer id) {
// return orderReturnService.orderReturnRefuse(id);
// }
//
// @PostMapping("confirm_receipt")
// public CommonResult confirmReceipt(@RequestParam("id") Integer id) {
// return orderReturnService.confirmReceipt(id);
// }
//
// @PostMapping("confirm_refund")
// public CommonResult confirmRefund(HttpServletRequest request, @RequestParam("id") Integer id) {
// String ip = HttpUtil.getIp(request);
// return orderReturnService.refund(id, ip);
// }
}
package cn.iocoder.mall.order.rest.controller.admins;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 订单API(admins)
*
* @author Sin
* @time 2019-03-24 10:22
*/
@RestController
@RequestMapping("admins/order")
@Api(value = "订单 API(admins)")
public class AdminsOrderController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderService.version}")
// private OrderService orderService;
//
// @GetMapping("page")
// @ApiOperation("订单列表")
// public CommonResult<OrderPageBO> getOrderPage(@Validated OrderPageQueryPO orderPageQueryVO) {
// OrderQueryDTO orderQueryDTO = OrderConvertAPP.INSTANCE.convert(orderPageQueryVO);
// return orderService.getOrderPage(orderQueryDTO);
// }
//
// @GetMapping("order_items")
// @ApiOperation("订单列表")
// public CommonResult<List<OrderItemBO>> getOrderItems(@RequestParam("orderId") Integer orderId) {
// return orderService.getOrderItems(orderId);
// }
//
// @GetMapping("order_recipient_info")
// @ApiOperation("订单收件人信息")
// public CommonResult<OrderRecipientBO> getOrderRecipientBO(@RequestParam("orderId") Integer orderId) {
// return orderService.getOrderRecipientBO(orderId);
// }
//
// @PostMapping("order_deliver")
// @ApiOperation("订单发货")
// public CommonResult<OrderRecipientBO> orderDeliver(@RequestBody @Validated OrderDeliverPO orderDeliverPO) {
// return orderService.orderDelivery(OrderDeliveryConvert.INSTANCE.convert(orderDeliverPO));
// }
//
// @PutMapping("update_remark")
// @ApiOperation("更新-更新订单备注")
// public CommonResult updateRemark(@RequestParam("orderId") Integer orderId,
// @RequestParam("remark") String remark) {
// return orderService.updateOrderRemake(orderId, remark);
// }
//
// @PutMapping("cancel_order")
// @ApiOperation("取消订单")
// public CommonResult cancelOrder(
// @RequestParam("orderId") Integer orderId,
// @RequestParam("reasons") Integer reasons,
// @RequestParam(value = "otherReasons", required = false) String otherReasons) {
// return orderService.cancelOrder(orderId, reasons, otherReasons);
// }
//
// @PutMapping("order_item/update_pay_amount")
// @ApiOperation("更新-订单item实付金额")
// public CommonResult updateOrderItemPayAmount(@RequestParam("orderId") Integer orderId,
// @RequestParam("orderItemId") Integer orderItemId,
// @RequestParam("payAmount") Integer payAmount) {
// return orderService.updateOrderItemPayAmount(orderId, orderItemId, payAmount);
// }
//
// @PutMapping("order_item/update")
// @ApiOperation("更新-订单item")
// public CommonResult updateOrderItem(@RequestBody @Validated OrderItemUpdatePO orderItemUpdateVO) {
// OrderItemUpdateDTO dto = OrderConvertAPP.INSTANCE.convert(orderItemUpdateVO);
// return orderService.updateOrderItem(dto);
// }
//
// @PutMapping("logistics/update")
// @ApiOperation("更新-订单物流")
// public CommonResult updateLogistics(@RequestBody @Validated OrderLogisticsPO orderLogisticsVO) {
// OrderLogisticsUpdateDTO dto = OrderConvertAPP.INSTANCE.convert(orderLogisticsVO);
// return orderService.updateLogistics(dto);
// }
}
package cn.iocoder.mall.order.rest.controller.users;
import cn.iocoder.common.framework.constant.MallConstants;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* 订单评论 Api(user)
*
* @author wtz
* @time 2019-05-27 20:46
*/
@RestController
@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment")
@Api("用户评论模块")
public class OrderCommentController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
// private OrderCommentService orderCommentService;
//
// @Reference(validation = "true", version = "${dubbo.provider.OrderCommentReplyService.version}")
// private OrderCommentReplyService orderCommentReplyService;
//
//
// @PostMapping("create_order_comment")
// //@RequiresLogin
// @ApiOperation(value = "创建订单评论")
// public CommonResult<OrderCommentCreateBO> createOrderComment(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// orderCommentCreateDTO.setUserId(userId);
// return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
// }
//
// @GetMapping("order_comment_page")
// @ApiOperation(value = "获取评论分页")
// public CommonResult<OrderCommentPageBO> getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){
// return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO));
// }
//
// @GetMapping("order_comment_info_merchant_reply")
// @ApiOperation(value = "获取评论和商家回复")
// public CommonResult<OrderCommentInfoAndMerchantReplyBO> geOrderCommentInfoAndMerchantReply(@RequestParam("commentId") Integer commentId){
// OrderCommentInfoAndMerchantReplyBO orderCommentInfoAndMerchantReplyBO=new OrderCommentInfoAndMerchantReplyBO();
// orderCommentInfoAndMerchantReplyBO.setOrderCommentInfoBO(orderCommentService.getOrderCommentInfo(commentId));
// orderCommentInfoAndMerchantReplyBO.setOrderCommentMerchantReplyBOS(orderCommentReplyService.getOrderCommentMerchantReply(commentId));
// return success(orderCommentInfoAndMerchantReplyBO);
// }
//
// @GetMapping
// //@RequiresLogin
// @ApiOperation(value = "获取订单评论状态分页")
// public CommonResult<OrderCommentStateInfoPageBO> getOrderCommentStateInfoPage(@Validated OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO){
// //Integer userId = UserSecurityContextHolder.getContext().getUserId();
// //orderCommentStateInfoPageDTO.setUserId(userId);
// return success(orderCommentService.getOrderCommentStateInfoPage(orderCommentStateInfoPageDTO));
// }
}
package cn.iocoder.mall.order.rest.controller.users;
import cn.iocoder.common.framework.constant.MallConstants;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* 评论回复模块 Api(user)
*
* @author wtz
* @time 2019-05-31 18:00
*/
@RestController
@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment_reply")
@Api("用户评论回复模块 ")
public class OrderCommentReplyController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
// private OrderCommentReplyService orderCommentReplyService;
//
// @PostMapping("create_order_comment_reply")
// //@RequiresLogin
// @ApiOperation(value = "创建订单回复")
// public CommonResult<OrderCommentReplyCreateBO> createOrderCommentReply(@RequestBody @Validated OrderCommentReplyCreateDTO orderCommentReplyCreateDTO){
// return success(orderCommentReplyService.createOrderCommentReply(orderCommentReplyCreateDTO));
// }
//
// @GetMapping("order_comment_reply_page")
// //@RequiresLogin
// @ApiOperation(value = "分页获取评论回复")
// public CommonResult<OrderCommentReplyPageBO> getOrderCommentReplyPage(@Validated OrderCommentReplyPageDTO orderCommentReplyCreateDTO){
// return success(orderCommentReplyService.getOrderCommentReplyPage(orderCommentReplyCreateDTO));
// }
}
package cn.iocoder.mall.order.rest.controller.users;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 订单API(users)
*
* @author Sin
* @time 2019-03-24 11:24
*/
@RestController
@RequestMapping("users/order")
@Api(description = "用户订单") // TODO FROM 芋艿 to 小范,description 已经废弃啦
public class OrderController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
// private OrderService orderService;
//
// @Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
// private CartService cartService;
//
// @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
// private DataDictService dataDictService;
//
// @Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
// private CouponService couponService;
//
// @GetMapping("order_page")
// @RequiresLogin
// @ApiOperation("订单分页")
// public CommonResult<OrderPageBO> getOrderPage(@Validated OrderQueryDTO orderQueryDTO) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// orderQueryDTO.setUserId(userId);
// return orderService.getOrderPage(orderQueryDTO);
// }
//
// @PostMapping("create_order")
// @RequiresLogin
// @ApiOperation("创建订单")
// public CommonResult<OrderCreateBO> createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO,
// HttpServletRequest request) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.convert(orderCreatePO);
// orderCreateDTO.setUserId(userId).setIp(HttpUtil.getIp(request));
// return orderService.createOrder(orderCreateDTO);
// }
//
// @PostMapping("create_order_from_cart")
// @RequiresLogin
// @ApiOperation("创建订单购物车")
// public CommonResult<OrderCreateBO> createOrderFromCart(@RequestParam("userAddressId") Integer userAddressId,
// @RequestParam(value = "couponCardId", required = false) Integer couponCardId,
// @RequestParam(value = "remark", required = false) String remark,
// HttpServletRequest request) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// // 获得购物车中选中的商品
// List<CartItemBO> cartItems = cartService.list(userId, true);
// if (cartItems.isEmpty()) {
// return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_CREATE_CART_IS_EMPTY.getCode());
// }
// // 创建 OrderCreateDTO 对象
// OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.createOrderCreateDTO(userId, userAddressId,
// remark, HttpUtil.getIp(request),
// cartItems, couponCardId);
// // 创建订单
// CommonResult<OrderCreateBO> createResult = orderService.createOrder(orderCreateDTO);
// if (createResult.isError()) {
// return CommonResult.error(createResult);
// }
// // 清空购物车 // TODO 芋艿,需要标记删除的原因,即结果为创建为某个订单。
// cartService.deleteList(userId, cartItems.stream().map(CartItemBO::getSkuId).collect(Collectors.toList()));
// // 返回结果
// return createResult;
// }
//
// @GetMapping("confirm_create_order")
// @RequiresLogin
// @ApiOperation("确认创建订单")
// public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam("skuId") Integer skuId,
// @RequestParam("quantity") Integer quantity,
// @RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// // 创建 CalcOrderPriceDTO 对象,并执行价格计算
// CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
// .setUserId(userId)
// .setItems(Collections.singletonList(new CalcOrderPriceDTO.Item(skuId, quantity, true)))
// .setCouponCardId(couponCardId);
// CalcOrderPriceBO calcOrderPrice = cartService.calcOrderPrice(calcOrderPriceDTO);
// // 获得优惠劵
// List<CouponCardAvailableBO> couponCards = couponService.getCouponCardList(userId,
// CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
// // 执行数据拼装
// return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
// }
//
// @PostMapping("confirm_receiving")
// @RequiresLogin
// @ApiOperation("确认收货")
// public CommonResult confirmReceiving(@RequestParam("orderId") Integer orderId) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// return orderService.confirmReceiving(userId, orderId);
// }
//
// @GetMapping("info")
// @RequiresLogin
// @ApiOperation("订单详情")
// public CommonResult<OrderInfoBO> orderInfo(@RequestParam("orderId") Integer orderId) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// CommonResult<OrderInfoBO> commonResult = orderService.info(userId, orderId);
//
// OrderInfoBO orderInfoBO = commonResult.getData();
// if (orderInfoBO != null) {
// CommonResult<DataDictBO> dictResult = dataDictService
// .getDataDict(DictKeyConstants.ORDER_STATUS, orderInfoBO.getStatus());
// orderInfoBO.setStatusText(dictResult.getData().getDisplayName());
// }
// return commonResult;
// }
}
package cn.iocoder.mall.order.rest.controller.users;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 订单物流 controller
*
* @author Sin
* @time 2019-04-12 22:24
*/
@RestController
@RequestMapping("users/order_logistics")
@Api(description = "订单物流信息")
public class OrderLogisticsController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderLogisticsService.version}")
// private OrderLogisticsService orderLogisticsService;
//
// @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
// private DataDictService dataDictService;
//
// @GetMapping("info")
// @ApiOperation("物流详细 - 物流通用")
// public CommonResult<OrderLogisticsInfoBO> logistics(@RequestParam("logisticsId") Integer logisticsId) {
// return orderLogisticsService.getLogisticsInfo(logisticsId);
// }
//
// @GetMapping("info_order")
// @ApiOperation("物流详细 - 返回订单所关联的所有物流信息(订单用的)")
// public CommonResult<OrderLogisticsInfoWithOrderBO> logisticsInfoWithOrder(@RequestParam("orderId") Integer orderId) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// CommonResult<OrderLogisticsInfoWithOrderBO> commonResult = orderLogisticsService.getOrderLogisticsInfo(userId, orderId);
// if (commonResult.isSuccess()) {
// OrderLogisticsInfoWithOrderBO orderLogisticsInfoBO = commonResult.getData();
// List<OrderLogisticsInfoWithOrderBO.Logistics> logisticsList = orderLogisticsInfoBO.getLogistics();
//
// // 获取字典值
// Set<Integer> dictValues = logisticsList.stream().map(o -> o.getLogistics()).collect(Collectors.toSet());
// if (!CollectionUtils.isEmpty(dictValues)) {
// CommonResult<List<DataDictBO>> dictResult = dataDictService
// .getDataDictList(DictKeyConstants.ORDER_LOGISTICS_COMPANY, dictValues);
//
// if (dictResult.isError()) {
// // 错误情况
// return ServiceExceptionUtil.error(OrderErrorCodeEnum.DICT_SERVER_INVOKING_FAIL.getCode());
// }
//
// // 转换结果字典值
// Map<String, DataDictBO> dataDictBOMap = dictResult.getData()
// .stream().collect(Collectors.toMap(o -> o.getValue(), o -> o));
//
// logisticsList.stream().map(o -> {
// String dicValue = o.getLogistics().toString();
// if (dataDictBOMap.containsKey(dicValue)) {
// o.setLogisticsText(dataDictBOMap.get(dicValue).getDisplayName());
// }
// return o;
// }).collect(Collectors.toList());
// }
// }
// return commonResult;
// }
}
package cn.iocoder.mall.order.rest.controller.users;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 订单退款/售后流程
*
* @author Sin
* @time 2019-04-25 22:04
*/
@RestController
@RequestMapping("users/order_return")
public class OrderReturnController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
// private OrderReturnService orderReturnService;
//
// @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
// private DataDictService dataDictService;
//
// @GetMapping("reason")
// @ApiOperation("原因")
// public CommonResult<List<DataDictBO>> orderReturnReason() {
// return dataDictService.getDataDict(DictKeyConstants.ORDER_RETURN_REASON);
// }
//
// @PostMapping("apply")
// @ApiOperation("订单售后")
// public CommonResult orderReturnApply(@RequestBody OrderReturnApplyPO orderReturnApplyPO) {
// OrderReturnApplyDTO applyDTO = OrderReturnConvert.INSTANCE.convert(orderReturnApplyPO);
// return orderReturnService.orderReturnApply(applyDTO);
// }
//
// @GetMapping("info")
// @ApiOperation("订单售后详细")
// public CommonResult<OrderReturnInfoBO> orderApplyInfo(@RequestParam("orderId") Integer orderId) {
// CommonResult<OrderReturnInfoBO> commonResult = orderReturnService.orderApplyInfo(orderId);
//
// // 转换 字典值
// if (commonResult.isSuccess()) {
// CommonResult<DataDictBO> dataDictResult = dataDictService.getDataDict(
// DictKeyConstants.ORDER_RETURN_SERVICE_TYPE,
// commonResult.getData().getReturnInfo().getServiceType());
//
// if (dataDictResult.isSuccess()) {
// commonResult.getData().getReturnInfo().setServiceTypeText(dataDictResult.getData().getDisplayName());
// }
// }
//
// return commonResult;
// }
}
package cn.iocoder.mall.order.rest.controller.users;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("users/cart")
public class UsersCartController {
// @Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
// private CartService cartService;
//
// @Reference(validation = "true", version = "${dubbo.provider.OrderService.version}")
// private OrderService orderService;
//
// @Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
// private CouponService couponService;
//
// @PostMapping("add")
// public CommonResult<Integer> add(@RequestParam("skuId") Integer skuId,
// @RequestParam("quantity") Integer quantity) {
// // 添加到购物车
// cartService.add(UserSecurityContextHolder.getContext().getUserId(), skuId, quantity);
// // 获得目前购物车商品总数量
// return success(cartService.count(UserSecurityContextHolder.getContext().getUserId()));
// }
//
// @PostMapping("update_quantity")
// public CommonResult<UsersCartDetailVO> updateQuantity(@RequestParam("skuId") Integer skuId, // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
// @RequestParam("quantity") Integer quantity) {
// // 添加到购物车
// cartService.updateQuantity(UserSecurityContextHolder.getContext().getUserId(),
// skuId, quantity);
// // 获得目前购物车明细
// return getCartDetail();
// }
//
// @PostMapping("update_selected")
// public CommonResult<UsersCartDetailVO> updateSelected(@RequestParam("skuIds") Set<Integer> skuIds, // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
// @RequestParam("selected") Boolean selected) {
// // 添加到购物车
// cartService.updateSelected(UserSecurityContextHolder.getContext().getUserId(), skuIds, selected);
// // 获得目前购物车明细
// return getCartDetail();
// }
//
// @GetMapping("count")
// public CommonResult<Integer> count() {
// return success(cartService.count(UserSecurityContextHolder.getContext().getUserId()));
// }
//
// @GetMapping("/list")
// public CommonResult<UsersCartDetailVO> list() { // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
// return getCartDetail();
// }
//
// private CommonResult<UsersCartDetailVO> getCartDetail() {
// // 获得购物车中选中的
// List<CartItemBO> cartItems = cartService.list(UserSecurityContextHolder.getContext().getUserId(), null);
// // 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回
// if (cartItems.isEmpty()) {
// UsersCartDetailVO result = new UsersCartDetailVO();
// result.setItemGroups(Collections.emptyList());
// result.setFee(new UsersCartDetailVO.Fee(0, 0, 0, 0));
// return success(result);
// }
// // 计算商品价格
// CalcOrderPriceBO calcOrder = list0(cartItems, null);
// // 执行数据拼装
// return success(CartConvert.INSTANCE.convert2(calcOrder));
// }
//
// @GetMapping("/confirm_create_order")
// public CommonResult<UsersOrderConfirmCreateVO> getConfirmCreateOrder(@RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// // 获得购物车中选中的
// List<CartItemBO> cartItems = cartService.list(userId, true);
// // 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回
// if (cartItems.isEmpty()) {
// UsersOrderConfirmCreateVO result = new UsersOrderConfirmCreateVO();
// result.setItemGroups(Collections.emptyList());
// result.setFee(new UsersOrderConfirmCreateVO.Fee(0, 0, 0, 0));
// return success(result);
// }
// // 计算商品价格
// CalcOrderPriceBO calcOrderPrice = list0(cartItems, couponCardId);
// // 获得优惠劵
// List<CouponCardAvailableBO> couponCards = couponService.getCouponCardList(userId,
// CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
// // 执行数据拼装
// return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
// }
//
// private CalcOrderPriceBO list0(List<CartItemBO> cartItems, Integer couponCardId) {
// // 创建计算的 DTO
// CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
// .setUserId(UserSecurityContextHolder.getContext().getUserId())
// .setItems(new ArrayList<>(cartItems.size()))
// .setCouponCardId(couponCardId);
// for (CartItemBO item : cartItems) {
// calcOrderPriceDTO.getItems().add(new CalcOrderPriceDTO.Item(item.getSkuId(), item.getQuantity(), item.getSelected()));
// }
// // 执行计算
// return cartService.calcOrderPrice(calcOrderPriceDTO);
// }
//
// @GetMapping("/calc_sku_price")
// public CommonResult<UsersCalcSkuPriceVO> calcSkuPrice(@RequestParam("skuId") Integer skuId) {
// // 计算 sku 的价格
// CalcSkuPriceBO calcSkuPrice = cartService.calcSkuPrice(skuId);
// return success(CartConvert.INSTANCE.convert2(calcSkuPrice));
// }
//
// public CommonResult<Object> confirmOrder() {
// // 查询购物车列表(选中的)
//// cartService.list(userId, true);
// // 查询确认订单信息的明细
//
// return null;
// }
}
package cn.iocoder.mall.order.rest.convert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface CartConvert {
CartConvert INSTANCE = Mappers.getMapper(CartConvert.class);
// UsersOrderConfirmCreateVO convert(CalcOrderPriceBO calcOrderPriceBO);
//
// UsersCartDetailVO convert2(CalcOrderPriceBO calcOrderPriceBO);
//
// UsersCalcSkuPriceVO convert2(CalcSkuPriceBO calcSkuPriceBO);
//
// default List<CouponCardSpuDTO> convertList(List<CalcOrderPriceBO.ItemGroup> itemGroups) {
// List<CouponCardSpuDTO> items = new ArrayList<>();
// itemGroups.forEach(itemGroup -> items.addAll(itemGroup.getItems().stream().map(
// item -> new CouponCardSpuDTO()
// .setSpuId(item.getSpu().getId())
// .setSkuId(item.getId())
// .setCategoryId(item.getSpu().getCid())
// .setPrice(item.getBuyPrice())
// .setQuantity(item.getBuyQuantity()))
// .collect(Collectors.toList())));
// return items;
// }
}
package cn.iocoder.mall.order.rest.convert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* application 订单 convert
*
* TODO 这种方式 文件名不能一样哈!
*
* @author Sin
* @time 2019-03-24 10:45
*/
@Mapper
public interface OrderConvertAPP {
OrderConvertAPP INSTANCE = Mappers.getMapper(OrderConvertAPP.class);
// @Mappings({})
// OrderQueryDTO convert(OrderPageQueryPO orderPageQueryVO);
//
// @Mappings({})
// OrderLogisticsUpdateDTO convert(OrderLogisticsPO orderLogisticsVO);
//
// @Mappings({})
// OrderItemUpdateDTO convert(OrderItemUpdatePO orderItemUpdateVO);
//
// @Mappings({})
// OrderCreateDTO convert(OrderCreatePO orderCreatePO);
//
// @Mappings({})
// List<OrderCreateDTO.OrderItem> convert(List<CartItemBO> cartItems);
//
// default OrderCreateDTO createOrderCreateDTO(Integer userId, Integer userAddressId,
// String remark, String ip,
// List<CartItemBO> cartItems, Integer couponCardId) {
// return new OrderCreateDTO()
// .setUserId(userId)
// .setUserAddressId(userAddressId)
// .setRemark(remark)
// .setIp(ip)
// .setOrderItems(this.convert(cartItems))
// .setCouponCardId(couponCardId);
// }
}
package cn.iocoder.mall.order.application.convert; package cn.iocoder.mall.order.rest.convert;
import cn.iocoder.mall.order.api.dto.OrderDeliveryDTO;
import cn.iocoder.mall.order.application.po.admin.OrderDeliverPO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**
...@@ -15,6 +12,6 @@ public interface OrderDeliveryConvert { ...@@ -15,6 +12,6 @@ public interface OrderDeliveryConvert {
OrderDeliveryConvert INSTANCE = Mappers.getMapper(OrderDeliveryConvert.class); OrderDeliveryConvert INSTANCE = Mappers.getMapper(OrderDeliveryConvert.class);
@Mappings({}) // @Mappings({})
OrderDeliveryDTO convert(OrderDeliverPO orderDeliverPO); // OrderDeliveryDTO convert(OrderDeliverPO orderDeliverPO);
} }
package cn.iocoder.mall.order.application.convert; package cn.iocoder.mall.order.rest.convert;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.api.dto.OrderReturnQueryDTO;
import cn.iocoder.mall.order.application.po.admin.OrderReturnQueryPO;
import cn.iocoder.mall.order.application.po.user.OrderReturnApplyPO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**
...@@ -19,9 +14,9 @@ public interface OrderReturnConvert { ...@@ -19,9 +14,9 @@ public interface OrderReturnConvert {
OrderReturnConvert INSTANCE = Mappers.getMapper(OrderReturnConvert.class); OrderReturnConvert INSTANCE = Mappers.getMapper(OrderReturnConvert.class);
@Mappings({}) // @Mappings({})
OrderReturnApplyDTO convert(OrderReturnApplyPO orderReturnApplyPO); // OrderReturnApplyDTO convert(OrderReturnApplyPO orderReturnApplyPO);
//
@Mappings({}) // @Mappings({})
OrderReturnQueryDTO convert(OrderReturnQueryPO orderReturnQueryPO); // OrderReturnQueryDTO convert(OrderReturnQueryPO orderReturnQueryPO);
} }
package cn.iocoder.mall.order.application.po.admin; package cn.iocoder.mall.order.rest.request.admin;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;
/** /**
* 订单发货 * 订单发货
...@@ -18,7 +17,7 @@ import java.util.List; ...@@ -18,7 +17,7 @@ import java.util.List;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(description = "订单发货PO") @ApiModel(description = "订单发货PO")
public class OrderDeliverPO implements Serializable { public class OrderDeliverRequest implements Serializable {
/** /**
* 订单编号 * 订单编号
......
package cn.iocoder.mall.order.application.po.admin; package cn.iocoder.mall.order.rest.request.admin;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import java.io.Serializable;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import lombok.Data;
import lombok.experimental.Accessors;
/** /**
* 订单 item 更新 * 订单 item 更新
...@@ -18,7 +17,7 @@ import java.io.Serializable; ...@@ -18,7 +17,7 @@ import java.io.Serializable;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel("订单item更新") @ApiModel("订单item更新")
public class OrderItemUpdatePO implements Serializable { public class OrderItemUpdateRequest implements Serializable {
/** /**
* 编号 * 编号
......
package cn.iocoder.mall.order.application.po.admin; package cn.iocoder.mall.order.rest.request.admin;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import java.io.Serializable;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import lombok.Data;
import lombok.experimental.Accessors;
/** /**
* 订单物流 * 订单物流
...@@ -18,7 +17,7 @@ import java.io.Serializable; ...@@ -18,7 +17,7 @@ import java.io.Serializable;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel("订单物流信息") @ApiModel("订单物流信息")
public class OrderLogisticsPO implements Serializable { public class OrderLogisticsRequest implements Serializable {
/** /**
* 订单 id * 订单 id
......
package cn.iocoder.mall.order.application.po.admin; package cn.iocoder.mall.order.rest.request.admin;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/** /**
* 订单 page 查询 vo * 订单 page 查询 vo
* *
...@@ -18,7 +17,7 @@ import java.util.Date; ...@@ -18,7 +17,7 @@ import java.util.Date;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel("订单查询") @ApiModel("订单查询")
public class OrderPageQueryPO implements Serializable { public class OrderPageQueryRequest implements Serializable {
/** /**
* id * id
......
package cn.iocoder.mall.order.application.po.admin; package cn.iocoder.mall.order.rest.request.admin;
import cn.iocoder.mall.order.api.bo.OrderBO; import cn.iocoder.mall.order.api.bo.OrderBO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import lombok.Data;
import lombok.experimental.Accessors;
/** /**
* 订单分页 vo * 订单分页 vo
...@@ -18,7 +17,7 @@ import java.util.List; ...@@ -18,7 +17,7 @@ import java.util.List;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel("订单VO") @ApiModel("订单VO")
public class OrderPagePO implements Serializable { public class OrderPageRequest implements Serializable {
/** /**
* 分页 * 分页
......
package cn.iocoder.mall.order.application.po.admin; package cn.iocoder.mall.order.rest.request.admin;
import java.io.Serializable;
import java.util.Date;
import javax.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/** /**
* 订单退货 查询 po * 订单退货 查询 po
* *
...@@ -16,7 +15,7 @@ import java.util.Date; ...@@ -16,7 +15,7 @@ import java.util.Date;
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class OrderReturnQueryPO implements Serializable { public class OrderReturnQueryRequest implements Serializable {
/** /**
* *
......
package cn.iocoder.mall.order.application.po.user; package cn.iocoder.mall.order.rest.request.users;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.Max; import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import lombok.Data;
import java.util.List; import lombok.experimental.Accessors;
/** /**
* 订单创建 * 订单创建
...@@ -17,7 +16,7 @@ import java.util.List; ...@@ -17,7 +16,7 @@ import java.util.List;
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class OrderCreatePO implements Serializable { public class OrderCreateRequest implements Serializable {
/** /**
* 收件手机号 * 收件手机号
......
package cn.iocoder.mall.order.application.po.user; package cn.iocoder.mall.order.rest.request.users;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import lombok.Data;
import lombok.experimental.Accessors;
/** /**
* 订单售后 * 订单售后
...@@ -15,7 +14,7 @@ import java.io.Serializable; ...@@ -15,7 +14,7 @@ import java.io.Serializable;
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class OrderReturnApplyPO implements Serializable { public class OrderReturnApplyRequest implements Serializable {
/** /**
* 订单编号 * 订单编号
......
package cn.iocoder.mall.order.application.vo; package cn.iocoder.mall.order.rest.response;
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
...@@ -8,20 +7,20 @@ import lombok.experimental.Accessors; ...@@ -8,20 +7,20 @@ import lombok.experimental.Accessors;
@ApiModel("计算商品 SKU 价格结果 VO") @ApiModel("计算商品 SKU 价格结果 VO")
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class UsersCalcSkuPriceVO { public class UsersCalcSkuPriceResponse {
/** /**
* 满减送促销活动 * 满减送促销活动
* *
* TODO 芋艿,后续改成 VO * TODO 芋艿,后续改成 VO
*/ */
private PromotionActivityBO fullPrivilege; // private PromotionActivityBO fullPrivilege;
/** /**
* 电视和折扣促销活动 * 电视和折扣促销活动
* *
* TODO 芋艿,后续改成 VO * TODO 芋艿,后续改成 VO
*/ */
private PromotionActivityBO timeLimitedDiscount; // private PromotionActivityBO timeLimitedDiscount;
/** /**
* 原价格,单位:分。 * 原价格,单位:分。
*/ */
......
package cn.iocoder.mall.order.application.vo; package cn.iocoder.mall.order.rest.response;
import cn.iocoder.mall.product.api.bo.ProductAttrAndValuePairBO;
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import java.util.List;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.List;
@ApiModel(value = "购物车明细 VO") @ApiModel(value = "购物车明细 VO")
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class UsersCartDetailVO { public class UsersCartDetailResponse {
/** /**
* 商品分组数组 * 商品分组数组
...@@ -34,7 +31,7 @@ public class UsersCartDetailVO { ...@@ -34,7 +31,7 @@ public class UsersCartDetailVO {
/** /**
* 优惠活动 * 优惠活动
*/ */
private PromotionActivityBO activity; // TODO 芋艿,偷懒 // private PromotionActivityBO activity; // TODO 芋艿,偷懒
/** /**
* 促销减少的金额 * 促销减少的金额
* *
...@@ -69,7 +66,7 @@ public class UsersCartDetailVO { ...@@ -69,7 +66,7 @@ public class UsersCartDetailVO {
/** /**
* 规格值数组 * 规格值数组
*/ */
private List<ProductAttrAndValuePairBO> attrs; // TODO 后面改下 // private List<ProductAttrAndValuePairBO> attrs; // TODO 后面改下
/** /**
* 价格,单位:分 * 价格,单位:分
*/ */
...@@ -92,7 +89,7 @@ public class UsersCartDetailVO { ...@@ -92,7 +89,7 @@ public class UsersCartDetailVO {
/** /**
* 优惠活动 * 优惠活动
*/ */
private PromotionActivityBO activity; // private PromotionActivityBO activity;
/** /**
* 原始单价,单位:分。 * 原始单价,单位:分。
*/ */
......
package cn.iocoder.mall.order.application.vo; package cn.iocoder.mall.order.rest.response;
import cn.iocoder.mall.product.api.bo.ProductAttrAndValuePairBO; import java.util.List;
import cn.iocoder.mall.promotion.api.bo.CouponCardAvailableBO;
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.List;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class UsersOrderConfirmCreateVO { public class UsersOrderConfirmCreateResponse {
/** /**
* 商品分组数组 * 商品分组数组
...@@ -23,7 +19,7 @@ public class UsersOrderConfirmCreateVO { ...@@ -23,7 +19,7 @@ public class UsersOrderConfirmCreateVO {
/** /**
* 优惠劵列表 TODO 芋艿,后续改改 * 优惠劵列表 TODO 芋艿,后续改改
*/ */
private List<CouponCardAvailableBO> couponCards; // private List<CouponCardAvailableBO> couponCards;
/** /**
* 优惠劵优惠金额 * 优惠劵优惠金额
*/ */
...@@ -42,7 +38,7 @@ public class UsersOrderConfirmCreateVO { ...@@ -42,7 +38,7 @@ public class UsersOrderConfirmCreateVO {
*/ */
// TODO 芋艿,目前只会有【满减送】的情况,未来有新的促销方式,可能需要改成数组 // TODO 芋艿,目前只会有【满减送】的情况,未来有新的促销方式,可能需要改成数组
// TODO 芋艿,后面改成 VO // TODO 芋艿,后面改成 VO
private PromotionActivityBO activity; // private PromotionActivityBO activity;
/** /**
* 商品数组 * 商品数组
*/ */
...@@ -70,7 +66,7 @@ public class UsersOrderConfirmCreateVO { ...@@ -70,7 +66,7 @@ public class UsersOrderConfirmCreateVO {
/** /**
* 规格值数组 * 规格值数组
*/ */
private List<ProductAttrAndValuePairBO> attrs; // TODO 后面改下 // private List<ProductAttrAndValuePairBO> attrs; // TODO 后面改下
/** /**
* 价格,单位:分 * 价格,单位:分
*/ */
......
# 服务器的配置项
server:
port: 18088
servlet:
context-path: /order-api/
# Swagger 配置项
swagger:
title: 订单子系统
description: 订单子系统
version: 1.0.0
base-package: cn.iocoder.mall.order.rest.controller
<?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>order</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>order-rpc-api</artifactId>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-biz-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>
/**
* 提供 order 服务的 RPC 接口的定义,提供内部调用
*/
package cn.iocoder.mall.order.rpc;
<?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>order</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>order-rpc</artifactId>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-rpc-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>order-biz</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- RPC 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-dubbo</artifactId>
</dependency>
<!-- Registry 和 Config 相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>
</project>
/**
* 提供 order 服务的 RPC 接口的实现,提供内部调用
*/
package cn.iocoder.mall.order.rpc;
spring:
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
namespace: local # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
spring:
# Spring Cloud 配置项
cloud:
nacos:
# Spring Cloud Nacos Discovery 配置项
discovery:
server-addr: s1.iocoder.cn:8848 # Nacos 服务器地址
namespace: test # Nacos 命名空间
# Dubbo 配置项
dubbo:
# Dubbo 注册中心
registry:
address: spring-cloud://s1.iocoder.cn:8848 # 指定 Dubbo 服务注册中心的地址
# Dubbo 配置项
dubbo:
# Spring Cloud Alibaba Dubbo 专属配置
cloud:
subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 提供者的协议
protocol:
name: dubbo
port: -1
# Dubbo 提供服务的扫描基础包
scan:
base-packages: cn.iocoder.mall.order.rpc.rpc
# Dubbo 服务提供者的配置
provider:
filter: -exception
SystemLogRPC:
version: 1.0.0
OAuth2RPC:
version: 1.0.0
AuthorizationRPC:
version: 1.0.0
AdminRPC:
version: 1.0.0
UserRPC:
version: 1.0.0
UserAddressRPC:
version: 1.0.0
# Dubbo 服务消费者的配置
consumer:
SystemLogRPC: # 用于 AccessLogInterceptor 等拦截器,记录 HTTP API 请求的访问日志
version: 1.0.0
OAuth2RPC: # 用于 AccountAuthInterceptor 拦截器,执行认证
version: 1.0.0
AuthorizationRPC: # 用于 AccountAuthInterceptor 拦截器,执行鉴权(权限验证)
version: 1.0.0
AdminRPC:
version: 1.0.0
UserRPC:
version: 1.0.0
...@@ -13,8 +13,12 @@ ...@@ -13,8 +13,12 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>order-application</module> <module>order-application</module>
<module>order-service-api</module> <module>order-biz</module>
<module>order-service-impl</module> <module>order-biz-api</module>
<module>order-rest</module>
<module>order-rpc</module>
<module>order-rpc-api</module>
</modules> </modules>
<dependencyManagement> <dependencyManagement>
......
...@@ -15,16 +15,22 @@ ...@@ -15,16 +15,22 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<modules> <modules>
<module>product</module> <module>product</module>
<!-- <module>order</module>--> <module>order</module>
<!-- <module>user</module>--> <module>user</module>
<module>common</module> <module>common</module>
<module>system</module> <module>system</module>
<!-- <module>ops</module>--> <!-- <module>ops</module>-->
<!-- <module>pay</module>--> <!-- <module>pay</module>-->
<!-- <module>promotion</module>--> <module>promotion</module>
<!-- <module>search</module>--> <!-- <module>search</module>-->
<!-- <module>demo</module>--> <!-- <module>demo</module>-->
<module>mall-dependencies</module> <module>mall-dependencies</module>
<module>order-biz</module>
<module>order/order-biz</module>
<module>order/order-biz-api</module>
<module>order/order-rpc</module>
<module>order/order-rpc-api</module>
<module>order-rest</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>
......
package cn.iocoder.mall.product.biz.enums; package cn.iocoder.mall.product.biz.enums;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
/** /**
* 错误码枚举类 * 错误码枚举类
* *
* 商品系统,使用 1-003-000-000 段 * 商品系统,使用 1-003-000-000 段
*/ */
public enum ProductErrorCodeEnum { public enum ProductErrorCodeEnum implements ServiceExceptionUtil.Enumerable {
// ========== PRODUCT CATEGORY 模块 ========== // ========== PRODUCT CATEGORY 模块 ==========
PRODUCT_CATEGORY_PARENT_NOT_EXISTS(1003001000, "父分类不存在"), PRODUCT_CATEGORY_PARENT_NOT_EXISTS(1003001000, "父分类不存在"),
...@@ -45,12 +47,12 @@ public enum ProductErrorCodeEnum { ...@@ -45,12 +47,12 @@ public enum ProductErrorCodeEnum {
this.message = message; this.message = message;
} }
public int getCode() {
return code;
}
public String getMessage() { public String getMessage() {
return message; return message;
} }
@Override
public int getCode() {
return code;
}
} }
package cn.iocoder.mall.product.biz.bo.category;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @Author: jiangweifan
* @Date: 2020/5/6
* @Description: 商品分类 - 商品分类列表BO
*/
@Data
@Accessors(chain = true)
public class ProductCategoryAllListBO implements Serializable {
/**
* 分类编号
*/
private Integer id;
/**
* 父分类编号
*
* 如果不存在父级,则 pid = 0 。
*/
private Integer pid;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 分类图片
*/
private String picUrl;
/**
* 排序值
*/
private Integer sort;
/**
* 状态
*
* 1-开启
* 2-关闭
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
}
...@@ -8,11 +8,12 @@ import java.util.Date; ...@@ -8,11 +8,12 @@ import java.util.Date;
/** /**
* @Author: jiangweifan * @Author: jiangweifan
* @Date: 2020/5/6 * @Date: 2020/5/6
* @Description: 商品分类 - 创建商品分类BO * @Description: 商品分类 - 商品分类统一BO
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class ProductCategoryAddBO implements Serializable { // TODO FROM 芋艿 to 伟帆,BO 可以不加 Serializable 接口,因为没序列化的诉求哈。一般 BO 可以创建一个统一的 ProductCategory,可以把 ProductCategoryAllListBO 合并过来 [DONE]
public class ProductCategoryBO {
/** /**
* 分类编号 * 分类编号
......
package cn.iocoder.mall.product.biz.convert.category; package cn.iocoder.mall.product.biz.convert.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO; import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO; import cn.iocoder.mall.product.biz.dataobject.product.ProductCategoryDO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.List; import java.util.List;
...@@ -21,19 +19,19 @@ public interface ProductCategoryConvert { ...@@ -21,19 +19,19 @@ public interface ProductCategoryConvert {
ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class); ProductCategoryConvert INSTANCE = Mappers.getMapper(ProductCategoryConvert.class);
/** /**
* 商品分类列表 - DO转换BO 单实体 * 商品分类统一DO转BO
* @param category * @param category
* @return * @return
*/ */
ProductCategoryAllListBO convertToAllListBO(ProductCategoryDO category); ProductCategoryBO convertToBO(ProductCategoryDO category);
/** /**
* 商品分类列表 - DO转换BO {@link #convertToAllListBO(ProductCategoryDO)} * 商品分类列表 - DO转换BO {@link #convertToBO(ProductCategoryDO)}
* @param category * @param category
* @return * @return
*/ */
List<ProductCategoryAllListBO> convertToAllListBO(List<ProductCategoryDO> category); List<ProductCategoryBO> convertToAllListBO(List<ProductCategoryDO> category);
/** /**
* 新增商品分类 - DTO转换DO * 新增商品分类 - DTO转换DO
...@@ -42,13 +40,6 @@ public interface ProductCategoryConvert { ...@@ -42,13 +40,6 @@ public interface ProductCategoryConvert {
*/ */
ProductCategoryDO convertToDO(ProductCategoryAddDTO productCategoryAddDTO); ProductCategoryDO convertToDO(ProductCategoryAddDTO productCategoryAddDTO);
/**
* 新增商品分类 - DO转换BO
* @param category
* @return
*/
ProductCategoryAddBO convertToAddBO(ProductCategoryDO category);
/** /**
* 更新商品分类 - DTO转换DO * 更新商品分类 - DTO转换DO
* @param productCategoryUpdateDTO * @param productCategoryUpdateDTO
......
...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category; ...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/** /**
* @Author: jiangweifan * @Author: jiangweifan
* @Date: 2020/5/6 * @Date: 2020/5/6
...@@ -15,19 +17,24 @@ public class ProductCategoryAddDTO { ...@@ -15,19 +17,24 @@ public class ProductCategoryAddDTO {
/** /**
* 管理员id * 管理员id
*/ */
// TODO FROM 芋艿 to 伟帆:传入 Service 的,要加下 Validation 的注解,虽然 Controller 那也添加了 Validation,但是相比来说,Service 更应该被保护,嘿嘿。因为一些时候,Service 也会被别人所调用,所以要保护好自己。[DONE]
@NotNull(message = "管理员id不能为空")
private Integer adminId; private Integer adminId;
/** /**
* 父分类编号 * 父分类编号
*/ */
@NotNull(message = "父分类编号不能为空")
private Integer pid; private Integer pid;
/** /**
* 名称 * 名称
*/ */
@NotNull(message = "名称不能为空")
private String name; private String name;
/** /**
* 描述 * 描述
*/ */
@NotNull(message = "描述不能为空")
private String description; private String description;
/** /**
* 分类图片 * 分类图片
...@@ -36,6 +43,7 @@ public class ProductCategoryAddDTO { ...@@ -36,6 +43,7 @@ public class ProductCategoryAddDTO {
/** /**
* 排序值 * 排序值
*/ */
@NotNull(message = "排序值不能为空")
private Integer sort; private Integer sort;
} }
...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category; ...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/** /**
* @Author: jiangweifan * @Author: jiangweifan
* @Date: 2020/5/6 * @Date: 2020/5/6
...@@ -15,10 +17,12 @@ public class ProductCategoryDeleteDTO { ...@@ -15,10 +17,12 @@ public class ProductCategoryDeleteDTO {
/** /**
* 管理员id * 管理员id
*/ */
@NotNull(message = "管理员id不能为空")
private Integer adminId; private Integer adminId;
/** /**
* 商品分类编号 * 商品分类编号
*/ */
@NotNull(message = "编号不能为空")
private Integer id; private Integer id;
} }
...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category; ...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/** /**
* @Author: jiangweifan * @Author: jiangweifan
* @Date: 2020/5/6 * @Date: 2020/5/6
...@@ -15,22 +17,27 @@ public class ProductCategoryUpdateDTO { ...@@ -15,22 +17,27 @@ public class ProductCategoryUpdateDTO {
/** /**
* 管理员id * 管理员id
*/ */
@NotNull(message = "管理员id不能为空")
private Integer adminId; private Integer adminId;
/** /**
* 编号 * 编号
*/ */
@NotNull(message = "编号不能为空")
private Integer id; private Integer id;
/** /**
* 父分类编号 * 父分类编号
*/ */
@NotNull(message = "父分类编号不能为空")
private Integer pid; private Integer pid;
/** /**
* 名称 * 名称
*/ */
@NotNull(message = "名称不能为空")
private String name; private String name;
/** /**
* 描述 * 描述
*/ */
@NotNull(message = "描述不能为空")
private String description; private String description;
/** /**
* 分类图片 * 分类图片
...@@ -39,6 +46,7 @@ public class ProductCategoryUpdateDTO { ...@@ -39,6 +46,7 @@ public class ProductCategoryUpdateDTO {
/** /**
* 排序值 * 排序值
*/ */
@NotNull(message = "描述不能为空")
private Integer sort; private Integer sort;
} }
...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category; ...@@ -3,6 +3,8 @@ package cn.iocoder.mall.product.biz.dto.category;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/** /**
* @Author: jiangweifan * @Author: jiangweifan
* @Date: 2020/5/6 * @Date: 2020/5/6
...@@ -15,14 +17,17 @@ public class ProductCategoryUpdateStatusDTO { ...@@ -15,14 +17,17 @@ public class ProductCategoryUpdateStatusDTO {
/** /**
* 管理员id * 管理员id
*/ */
@NotNull(message = "管理员id不能为空")
private Integer adminId; private Integer adminId;
/** /**
* 商品分类编号 * 商品分类编号
*/ */
@NotNull(message = "编号不能为空")
private Integer id; private Integer id;
/** /**
* 状态 * 状态
*/ */
@NotNull(message = "状态不能为空")
private Integer status; private Integer status;
} }
package cn.iocoder.mall.product.biz.service.product; package cn.iocoder.mall.product.biz.service.product;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO; import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateStatusDTO;
import java.util.List; import java.util.List;
...@@ -21,14 +19,14 @@ public interface ProductCategoryService { ...@@ -21,14 +19,14 @@ public interface ProductCategoryService {
* 获取所有商品分类 * 获取所有商品分类
* @return * @return
*/ */
List<ProductCategoryAllListBO> getAllProductCategory(); List<ProductCategoryBO> getAllProductCategory();
/** /**
* 新增商品分类 * 新增商品分类
* @param productCategoryAddDTO * @param productCategoryAddDTO
* @return * @return
*/ */
ProductCategoryAddBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO); ProductCategoryBO addProductCategory(ProductCategoryAddDTO productCategoryAddDTO);
/** /**
* 更新商品分类 * 更新商品分类
......
...@@ -2,8 +2,7 @@ package cn.iocoder.mall.product.rest.controller.admins; ...@@ -2,8 +2,7 @@ package cn.iocoder.mall.product.rest.controller.admins;
import cn.iocoder.common.framework.constant.MallConstants; import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO; import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
...@@ -45,9 +44,9 @@ public class AdminsProductCategoryController { ...@@ -45,9 +44,9 @@ public class AdminsProductCategoryController {
@GetMapping("/tree") @GetMapping("/tree")
@ApiOperation("获取分类树结构") @ApiOperation("获取分类树结构")
public CommonResult<List<AdminsProductCategoryTreeNodeResponse>> tree() { public CommonResult<List<AdminsProductCategoryTreeNodeResponse>> tree() {
List<ProductCategoryAllListBO> productCategories = productCategoryService.getAllProductCategory(); List<ProductCategoryBO> productCategories = productCategoryService.getAllProductCategory();
// 创建 ProductCategoryTreeNodeVO Map // 创建 ProductCategoryTreeNodeVO Map
Map<Integer, AdminsProductCategoryTreeNodeResponse> treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryAllListBO::getId, ProductCategoryConvert.INSTANCE::convertToTreeNodeResponse)); Map<Integer, AdminsProductCategoryTreeNodeResponse> treeNodeMap = productCategories.stream().collect(Collectors.toMap(ProductCategoryBO::getId, ProductCategoryConvert.INSTANCE::convertToTreeNodeResponse));
// 处理父子关系 // 处理父子关系
treeNodeMap.values().stream() treeNodeMap.values().stream()
.filter(node -> !node.getPid().equals(ProductCategoryConstants.PID_ROOT)) .filter(node -> !node.getPid().equals(ProductCategoryConstants.PID_ROOT))
...@@ -74,7 +73,7 @@ public class AdminsProductCategoryController { ...@@ -74,7 +73,7 @@ public class AdminsProductCategoryController {
// 转换 ProductCategoryAddDTO 对象 // 转换 ProductCategoryAddDTO 对象
ProductCategoryAddDTO productCategoryAddDTO = ProductCategoryConvert.INSTANCE.convertToAddDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryAddRequest); ProductCategoryAddDTO productCategoryAddDTO = ProductCategoryConvert.INSTANCE.convertToAddDTO(AdminSecurityContextHolder.getContext().getAdminId(), adminsProductCategoryAddRequest);
// 创建商品分类 // 创建商品分类
ProductCategoryAddBO addProductCategoryBO = productCategoryService.addProductCategory(productCategoryAddDTO); ProductCategoryBO addProductCategoryBO = productCategoryService.addProductCategory(productCategoryAddDTO);
// 返回结果 // 返回结果
return success(ProductCategoryConvert.INSTANCE.convertToAddResponse(addProductCategoryBO)); return success(ProductCategoryConvert.INSTANCE.convertToAddResponse(addProductCategoryBO));
} }
......
package cn.iocoder.mall.product.rest.convert.category; package cn.iocoder.mall.product.rest.convert.category;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAddBO; import cn.iocoder.mall.product.biz.bo.category.ProductCategoryBO;
import cn.iocoder.mall.product.biz.bo.category.ProductCategoryAllListBO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryAddDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryDeleteDTO;
import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO; import cn.iocoder.mall.product.biz.dto.category.ProductCategoryUpdateDTO;
...@@ -12,7 +11,6 @@ import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdate ...@@ -12,7 +11,6 @@ import cn.iocoder.mall.product.rest.request.category.AdminsProductCategoryUpdate
import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryAddResponse; import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryAddResponse;
import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryTreeNodeResponse; import cn.iocoder.mall.product.rest.response.category.AdminsProductCategoryTreeNodeResponse;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**
...@@ -30,7 +28,7 @@ public interface ProductCategoryConvert { ...@@ -30,7 +28,7 @@ public interface ProductCategoryConvert {
* @param productCategoryAllListBO * @param productCategoryAllListBO
* @return * @return
*/ */
AdminsProductCategoryTreeNodeResponse convertToTreeNodeResponse(ProductCategoryAllListBO productCategoryAllListBO); AdminsProductCategoryTreeNodeResponse convertToTreeNodeResponse(ProductCategoryBO productCategoryAllListBO);
/** /**
...@@ -45,7 +43,7 @@ public interface ProductCategoryConvert { ...@@ -45,7 +43,7 @@ public interface ProductCategoryConvert {
* @param productCategoryAddBO * @param productCategoryAddBO
* @return * @return
*/ */
AdminsProductCategoryAddResponse convertToAddResponse(ProductCategoryAddBO productCategoryAddBO); AdminsProductCategoryAddResponse convertToAddResponse(ProductCategoryBO productCategoryAddBO);
/** /**
* 更新商品分类 - Request转DTO * 更新商品分类 - Request转DTO
......
...@@ -16,32 +16,23 @@ import javax.validation.constraints.NotNull; ...@@ -16,32 +16,23 @@ import javax.validation.constraints.NotNull;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class AdminsProductCategoryAddRequest { public class AdminsProductCategoryAddRequest {
/**
* 父分类编号 // TODO FROM 芋艿 to 伟帆:写了 swagger 注解,我们可以少写一份 Java 注释。[DONE]
*/
@ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1") @ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空") @NotNull(message = "父分类编号不能为空")
private Integer pid; private Integer pid;
/**
* 名称
*/
@ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info") @ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info")
@NotNull(message = "名称不能为空") @NotNull(message = "名称不能为空")
private String name; private String name;
/**
* 描述
*/
@ApiModelProperty(name = "description", value = "描述", required = true, example = "1") @ApiModelProperty(name = "description", value = "描述", required = true, example = "1")
@NotNull(message = "描述不能为空") @NotNull(message = "描述不能为空")
private String description; private String description;
/**
* 分类图片
*/
@ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/") @ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/")
private String picUrl; private String picUrl;
/**
* 排序值
*/
@ApiModelProperty(name = "sort", value = "排序", required = true, example = "1") @ApiModelProperty(name = "sort", value = "排序", required = true, example = "1")
@NotNull(message = "排序值不能为空") @NotNull(message = "排序值不能为空")
private Integer sort; private Integer sort;
......
...@@ -16,38 +16,26 @@ import javax.validation.constraints.NotNull; ...@@ -16,38 +16,26 @@ import javax.validation.constraints.NotNull;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class AdminsProductCategoryUpdateRequest { public class AdminsProductCategoryUpdateRequest {
/**
* 编号
*/
@ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1") @ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1")
@NotNull(message = "编号不能为空") @NotNull(message = "编号不能为空")
private Integer id; private Integer id;
/**
* 父分类编号
*/
@ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1") @ApiModelProperty(name = "pid", value = "父级分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空") @NotNull(message = "父分类编号不能为空")
private Integer pid; private Integer pid;
/**
* 名称
*/
@ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info") @ApiModelProperty(name = "name", value = "分类名字(标识)", required = true, example = "admin/info")
@NotNull(message = "名称不能为空") @NotNull(message = "名称不能为空")
private String name; private String name;
/**
* 描述
*/
@ApiModelProperty(name = "description", value = "描述", required = true, example = "1") @ApiModelProperty(name = "description", value = "描述", required = true, example = "1")
@NotNull(message = "描述不能为空") @NotNull(message = "描述不能为空")
private String description; private String description;
/**
* 分类图片
*/
@ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/") @ApiModelProperty(name = "picUrl", value = "分类图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg/")
private String picUrl; private String picUrl;
/**
* 排序值
*/
@ApiModelProperty(name = "sort", value = "排序", required = true, example = "1") @ApiModelProperty(name = "sort", value = "排序", required = true, example = "1")
@NotNull(message = "排序值不能为空") @NotNull(message = "排序值不能为空")
private Integer sort; private Integer sort;
......
...@@ -16,15 +16,11 @@ import javax.validation.constraints.NotNull; ...@@ -16,15 +16,11 @@ import javax.validation.constraints.NotNull;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class AdminsProductCategoryUpdateStatusRequest { public class AdminsProductCategoryUpdateStatusRequest {
/**
* 商品分类编号
*/
@ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1") @ApiModelProperty(name = "id", value = "分类编号", required = true, example = "1")
@NotNull(message = "编号不能为空") @NotNull(message = "编号不能为空")
private Integer id; private Integer id;
/**
* 更新状态
*/
@ApiModelProperty(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1") @ApiModelProperty(name = "status", value = "状态。1 - 开启;2 - 禁用", required = true, example = "1")
@NotNull(message = "状态不能为空") @NotNull(message = "状态不能为空")
private Integer status; private Integer status;
......
...@@ -18,18 +18,25 @@ public class AdminsProductCategoryAddResponse { ...@@ -18,18 +18,25 @@ public class AdminsProductCategoryAddResponse {
@ApiModelProperty(value = "分类编号", required = true, example = "1") @ApiModelProperty(value = "分类编号", required = true, example = "1")
private Integer id; private Integer id;
@ApiModelProperty(value = "父分类编号", required = true, example = "0") @ApiModelProperty(value = "父分类编号", required = true, example = "0")
private Integer pid; private Integer pid;
@ApiModelProperty(value = "分类名", required = true, example = "手机") @ApiModelProperty(value = "分类名", required = true, example = "手机")
private String name; private String name;
@ApiModelProperty(value = "描述", required = true, example = "这个商品很吊") @ApiModelProperty(value = "描述", required = true, example = "这个商品很吊")
private String description; private String description;
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg") @ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
private String picUrl; private String picUrl;
@ApiModelProperty(value = "排序值", required = true, example = "10") @ApiModelProperty(value = "排序值", required = true, example = "10")
private Integer sort; private Integer sort;
@ApiModelProperty(value = "状态", required = true, notes = "1-开启;2-关闭", example = "1") @ApiModelProperty(value = "状态", required = true, notes = "1-开启;2-关闭", example = "1")
private Integer status; private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳") @ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime; private Date createTime;
......
...@@ -20,20 +20,28 @@ public class AdminsProductCategoryTreeNodeResponse { ...@@ -20,20 +20,28 @@ public class AdminsProductCategoryTreeNodeResponse {
@ApiModelProperty(value = "分类编号", required = true, example = "1") @ApiModelProperty(value = "分类编号", required = true, example = "1")
private Integer id; private Integer id;
@ApiModelProperty(value = "父分类编号", required = true, example = "0") @ApiModelProperty(value = "父分类编号", required = true, example = "0")
private Integer pid; private Integer pid;
@ApiModelProperty(value = "分类名", required = true, example = "手机") @ApiModelProperty(value = "分类名", required = true, example = "手机")
private String name; private String name;
@ApiModelProperty(value = "描述", required = true, example = "这个商品很吊") @ApiModelProperty(value = "描述", required = true, example = "这个商品很吊")
private String description; private String description;
@ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg") @ApiModelProperty(value = "分类图片", notes = "一般情况下,只有根分类才有图片", example = "http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
private String picUrl; private String picUrl;
@ApiModelProperty(value = "排序值", required = true, example = "10") @ApiModelProperty(value = "排序值", required = true, example = "10")
private Integer sort; private Integer sort;
@ApiModelProperty(value = "状态", required = true, notes = "1-开启;2-关闭", example = "1") @ApiModelProperty(value = "状态", required = true, notes = "1-开启;2-关闭", example = "1")
private Integer status; private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳") @ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
private Date createTime; private Date createTime;
@ApiModelProperty(value = "子节点数组") @ApiModelProperty(value = "子节点数组")
private List<AdminsProductCategoryTreeNodeResponse> children; private List<AdminsProductCategoryTreeNodeResponse> children;
......
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
<artifactId>system-sdk</artifactId> <artifactId>system-sdk</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- Web 相关 --> <!-- Web 相关 -->
<dependency> <dependency>
...@@ -93,6 +97,18 @@ ...@@ -93,6 +97,18 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-security</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-security</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
......
package cn.iocoder.mall.promotion.application.controller.admins; package cn.iocoder.mall.promotion.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
import cn.iocoder.mall.promotion.api.BannerService; import cn.iocoder.mall.promotion.api.BannerService;
import cn.iocoder.mall.promotion.api.bo.BannerPageBO; import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
import cn.iocoder.mall.promotion.api.dto.BannerAddDTO; import cn.iocoder.mall.promotion.api.dto.BannerAddDTO;
...@@ -10,6 +9,7 @@ import cn.iocoder.mall.promotion.api.dto.BannerUpdateDTO; ...@@ -10,6 +9,7 @@ import cn.iocoder.mall.promotion.api.dto.BannerUpdateDTO;
import cn.iocoder.mall.promotion.application.convert.BannerConvert; import cn.iocoder.mall.promotion.application.convert.BannerConvert;
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerPageVO;
import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsBannerVO;
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
......
...@@ -2,7 +2,6 @@ package cn.iocoder.mall.promotion.application.controller.admins; ...@@ -2,7 +2,6 @@ package cn.iocoder.mall.promotion.application.controller.admins;
import cn.iocoder.common.framework.util.DateUtil; import cn.iocoder.common.framework.util.DateUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
import cn.iocoder.mall.promotion.api.CouponService; import cn.iocoder.mall.promotion.api.CouponService;
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO; import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO;
...@@ -12,6 +11,7 @@ import cn.iocoder.mall.promotion.api.dto.CouponTemplatePageDTO; ...@@ -12,6 +11,7 @@ import cn.iocoder.mall.promotion.api.dto.CouponTemplatePageDTO;
import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert; import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert;
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplatePageVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplatePageVO;
import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsCouponTemplateVO;
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
......
package cn.iocoder.mall.promotion.application.controller.admins; package cn.iocoder.mall.promotion.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder;
import cn.iocoder.mall.product.api.ProductSpuService; import cn.iocoder.mall.product.api.ProductSpuService;
import cn.iocoder.mall.product.api.bo.ProductSpuBO; import cn.iocoder.mall.product.api.bo.ProductSpuBO;
import cn.iocoder.mall.promotion.api.ProductRecommendService; import cn.iocoder.mall.promotion.api.ProductRecommendService;
...@@ -13,6 +12,7 @@ import cn.iocoder.mall.promotion.api.dto.ProductRecommendUpdateDTO; ...@@ -13,6 +12,7 @@ import cn.iocoder.mall.promotion.api.dto.ProductRecommendUpdateDTO;
import cn.iocoder.mall.promotion.application.convert.ProductRecommendConvert; import cn.iocoder.mall.promotion.application.convert.ProductRecommendConvert;
import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendPageVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendPageVO;
import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendVO; import cn.iocoder.mall.promotion.application.vo.admins.AdminsProductRecommendVO;
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
......
...@@ -11,7 +11,7 @@ import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert; ...@@ -11,7 +11,7 @@ import cn.iocoder.mall.promotion.application.convert.CouponTemplateConvert;
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardPageVO; import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardPageVO;
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardVO; import cn.iocoder.mall.promotion.application.vo.users.UsersCouponCardVO;
import cn.iocoder.mall.promotion.application.vo.users.UsersCouponTemplateVO; import cn.iocoder.mall.promotion.application.vo.users.UsersCouponTemplateVO;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder; import cn.iocoder.mall.security.core.context.UserSecurityContextHolder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
......
...@@ -90,6 +90,18 @@ ...@@ -90,6 +90,18 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
......
package cn.iocoder.mall.promotion.biz.dataobject; package cn.iocoder.mall.promotion.biz.dataobject;
import cn.iocoder.common.framework.dataobject.DeletableDO; import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
......
package cn.iocoder.mall.promotion.biz.dataobject; package cn.iocoder.mall.promotion.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.mall.mybatis.dataobject.BaseDO;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
......
package cn.iocoder.mall.promotion.biz.dataobject; package cn.iocoder.mall.promotion.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.mall.mybatis.dataobject.BaseDO;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
......
package cn.iocoder.mall.promotion.biz.dataobject; package cn.iocoder.mall.promotion.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.mall.mybatis.dataobject.BaseDO;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
......
package cn.iocoder.mall.promotion.biz.dataobject; package cn.iocoder.mall.promotion.biz.dataobject;
import cn.iocoder.common.framework.dataobject.DeletableDO;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.promotion.api.constant.ProductRecommendTypeEnum; import cn.iocoder.mall.promotion.api.constant.ProductRecommendTypeEnum;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
......
package cn.iocoder.mall.promotion.biz.dataobject; package cn.iocoder.mall.promotion.biz.dataobject;
import cn.iocoder.common.framework.dataobject.BaseDO; import cn.iocoder.mall.mybatis.dataobject.BaseDO;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
......
package cn.iocoder.mall.promotion.biz.mybatis; package cn.iocoder.mall.promotion.biz.mybatis;
import cn.iocoder.common.framework.mybatis.JSONTypeHandler; import cn.iocoder.mall.mybatis.type.JSONTypeHandler;
import cn.iocoder.mall.promotion.biz.dataobject.PromotionActivityDO; import cn.iocoder.mall.promotion.biz.dataobject.PromotionActivityDO;
public class TestHandler extends JSONTypeHandler<PromotionActivityDO.TimeLimitedDiscount> { public class TestHandler extends JSONTypeHandler<PromotionActivityDO.TimeLimitedDiscount> {
......
package cn.iocoder.mall.promotion.biz.service; package cn.iocoder.mall.promotion.biz.service;
import cn.iocoder.common.framework.constant.CommonStatusEnum; import cn.iocoder.common.framework.constant.CommonStatusEnum;
import cn.iocoder.common.framework.constant.DeletedStatusEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum;
import cn.iocoder.mall.promotion.api.BannerService; import cn.iocoder.mall.promotion.api.BannerService;
import cn.iocoder.mall.promotion.api.bo.BannerBO; import cn.iocoder.mall.promotion.api.bo.BannerBO;
import cn.iocoder.mall.promotion.api.bo.BannerPageBO; import cn.iocoder.mall.promotion.api.bo.BannerPageBO;
......
package cn.iocoder.mall.promotion.biz.service; package cn.iocoder.mall.promotion.biz.service;
import cn.iocoder.common.framework.constant.CommonStatusEnum; import cn.iocoder.common.framework.constant.CommonStatusEnum;
import cn.iocoder.common.framework.constant.DeletedStatusEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum;
import cn.iocoder.mall.product.api.ProductSpuService; import cn.iocoder.mall.product.api.ProductSpuService;
import cn.iocoder.mall.promotion.api.ProductRecommendService; import cn.iocoder.mall.promotion.api.ProductRecommendService;
import cn.iocoder.mall.promotion.api.bo.ProductRecommendBO; import cn.iocoder.mall.promotion.api.bo.ProductRecommendBO;
......
...@@ -11,5 +11,12 @@ ...@@ -11,5 +11,12 @@
<artifactId>user-biz-api</artifactId> <artifactId>user-biz-api</artifactId>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project> </project>
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<!-- Mall 相关 --> <!-- Mall 相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>system-biz-api</artifactId> <artifactId>user-biz-api</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
......
package cn.iocoder.mall.user.biz.convert.user; package cn.iocoder.mall.user.biz.convert.user;
import cn.iocoder.mall.user.biz.bo.user.UserAddressBO; import cn.iocoder.mall.user.biz.bo.user.UserAddressBO;
import cn.iocoder.mall.user.biz.dataobject.user.UserAddressDO; import cn.iocoder.mall.user.biz.dataobject.user.UsersUserAddressDO;
import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO; import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO;
import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO; import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
...@@ -22,14 +22,14 @@ public interface UserAddressConvert { ...@@ -22,14 +22,14 @@ public interface UserAddressConvert {
UserAddressConvert INSTANCE = Mappers.getMapper(UserAddressConvert.class); UserAddressConvert INSTANCE = Mappers.getMapper(UserAddressConvert.class);
@Mappings({}) @Mappings({})
UserAddressDO convert(UserAddressAddDTO userAddressAddDTO); UsersUserAddressDO convert(UserAddressAddDTO userAddressAddDTO);
@Mappings({}) @Mappings({})
UserAddressDO convert(UserAddressUpdateDTO userAddressUpdateDTO); UsersUserAddressDO convert(UserAddressUpdateDTO userAddressUpdateDTO);
@Mappings({}) @Mappings({})
UserAddressBO convert(UserAddressDO userAddressDO); UserAddressBO convert(UsersUserAddressDO userAddressDO);
@Mappings({}) @Mappings({})
List<UserAddressBO> convertUserAddressBOList(List<UserAddressDO> userAddressDOList); List<UserAddressBO> convertUserAddressBOList(List<UsersUserAddressDO> userAddressDOList);
} }
package cn.iocoder.mall.user.biz.dao.user; package cn.iocoder.mall.user.biz.dao.user;
import cn.iocoder.mall.user.biz.dataobject.user.UserAddressDO; import cn.iocoder.mall.user.biz.dataobject.user.UsersUserAddressDO;
import cn.iocoder.mall.user.biz.enums.user.UserAddressHasDefaultEnum; import cn.iocoder.mall.user.biz.enums.user.UserAddressHasDefaultEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...@@ -15,19 +15,19 @@ import java.util.List; ...@@ -15,19 +15,19 @@ import java.util.List;
* @time 2019-04-06 13:29 * @time 2019-04-06 13:29
*/ */
@Repository @Repository
// TODO FROM 芋艿 to 小范:替换成 Mybatis Plus // TODO done FROM 芋艿 to 小范:替换成 Mybatis Plus
public interface UserAddressMapper extends BaseMapper<UserAddressDO> { public interface UserAddressMapper extends BaseMapper<UsersUserAddressDO> {
default List<UserAddressDO> selectByUserId(Integer userId) { default List<UsersUserAddressDO> selectByUserId(Integer userId) {
LambdaQueryWrapper<UserAddressDO> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<UsersUserAddressDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(UserAddressDO::getUserId, userId); wrapper.eq(UsersUserAddressDO::getUserId, userId);
return selectList(wrapper); return selectList(wrapper);
} }
default UserAddressDO selectHasDefault(Integer userId) { default UsersUserAddressDO selectHasDefault(Integer userId) {
LambdaQueryWrapper<UserAddressDO> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<UsersUserAddressDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(UserAddressDO::getUserId, userId); wrapper.eq(UsersUserAddressDO::getUserId, userId);
wrapper.eq(UserAddressDO::getHasDefault, UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue()); wrapper.eq(UsersUserAddressDO::getHasDefault, UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue());
return selectOne(wrapper); return selectOne(wrapper);
} }
} }
...@@ -12,7 +12,7 @@ import lombok.experimental.Accessors; ...@@ -12,7 +12,7 @@ import lombok.experimental.Accessors;
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class UserAddressDO extends DeletableDO { public class UsersUserAddressDO extends DeletableDO {
/** /**
* 编号 * 编号
......
package cn.iocoder.mall.user.biz.enums;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
/**
* 错误码枚举类
*
* 用户系统,使用 1-001-000-000 段
*/
public enum UserErrorCodeEnum implements ServiceExceptionUtil.Enumerable {
// ========== 用户地址 ==========
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;
}
}
/**
* author: sin
* time: 2020/5/3 8:29 下午
*/
package cn.iocoder.mall.user.biz.enums;
\ No newline at end of file
...@@ -14,15 +14,49 @@ import java.util.List; ...@@ -14,15 +14,49 @@ import java.util.List;
*/ */
public interface UserAddressService { public interface UserAddressService {
/**
* 添加地址
*
* @param userAddressAddDTO
*/
void addAddress(UserAddressAddDTO userAddressAddDTO); void addAddress(UserAddressAddDTO userAddressAddDTO);
/**
* 更新 - 根据id 更新
*
* @param userAddressAddDTO
*/
void updateAddress(UserAddressUpdateDTO userAddressAddDTO); void updateAddress(UserAddressUpdateDTO userAddressAddDTO);
/**
* 删除 - 更新id 删除
*
* @param userId
* @param addressId
*/
void removeAddress(Integer userId, Integer addressId); void removeAddress(Integer userId, Integer addressId);
List<UserAddressBO> addressList(Integer userId); /**
* 获取 - 用户所有地址
UserAddressBO getAddress(Integer userId, Integer id); *
* @param userId
* @return
*/
List<UserAddressBO> listAddress(Integer userId);
/**
* 获取 - 根据id 获取地址
*
* @param id
* @return
*/
UserAddressBO getAddress(Integer id);
/**
* 获取 - 获取用户 default 地址
*
* @param userId
* @return
*/
UserAddressBO getDefaultAddress(Integer userId); UserAddressBO getDefaultAddress(Integer userId);
} }
...@@ -2,13 +2,13 @@ package cn.iocoder.mall.user.biz.service.user; ...@@ -2,13 +2,13 @@ package cn.iocoder.mall.user.biz.service.user;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum; import cn.iocoder.mall.mybatis.enums.DeletedStatusEnum;
import cn.iocoder.mall.system.biz.enums.SystemErrorCodeEnum;
import cn.iocoder.mall.user.biz.bo.user.UserAddressBO; import cn.iocoder.mall.user.biz.bo.user.UserAddressBO;
import cn.iocoder.mall.user.biz.convert.user.UserAddressConvert; import cn.iocoder.mall.user.biz.convert.user.UserAddressConvert;
import cn.iocoder.mall.user.biz.dao.user.UserAddressMapper; import cn.iocoder.mall.user.biz.dao.user.UserAddressMapper;
import cn.iocoder.mall.user.biz.dataobject.user.UserAddressDO; import cn.iocoder.mall.user.biz.dataobject.user.UsersUserAddressDO;
import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO; import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO;
import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO; import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO;
import cn.iocoder.mall.user.biz.enums.UserErrorCodeEnum;
import cn.iocoder.mall.user.biz.enums.user.UserAddressHasDefaultEnum; import cn.iocoder.mall.user.biz.enums.user.UserAddressHasDefaultEnum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -32,112 +32,101 @@ public class UserAddressServiceImpl implements UserAddressService { ...@@ -32,112 +32,101 @@ public class UserAddressServiceImpl implements UserAddressService {
@Override @Override
@Transactional @Transactional
public void addAddress(UserAddressAddDTO userAddressAddDTO) { public void addAddress(UserAddressAddDTO userAddressAddDTO) {
UserAddressDO userAddressDO = UserAddressConvert.INSTANCE.convert(userAddressAddDTO);
// 转换do,设置默认数据
UsersUserAddressDO userAddressDO = UserAddressConvert.INSTANCE.convert(userAddressAddDTO);
userAddressDO.setCreateTime(new Date()); userAddressDO.setCreateTime(new Date());
userAddressDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue()); userAddressDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
// 检查是否设置为默认地址 // 检查是否设置为默认地址
if (UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue() == userAddressAddDTO.getHasDefault()) { if (UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue() == userAddressAddDTO.getHasDefault()) {
UserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(userAddressAddDTO.getUserId()); UsersUserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(userAddressAddDTO.getUserId());
if (defaultUserAddress != null) { if (defaultUserAddress != null) {
userAddressMapper.updateById( userAddressMapper.updateById(
new UserAddressDO() new UsersUserAddressDO()
.setId(defaultUserAddress.getId()) .setId(defaultUserAddress.getId())
.setHasDefault(UserAddressHasDefaultEnum.DEFAULT_ADDRESS_NO.getValue()) .setHasDefault(UserAddressHasDefaultEnum.DEFAULT_ADDRESS_NO.getValue())
); );
} }
} }
// 保存地址
userAddressMapper.insert(userAddressDO); userAddressMapper.insert(userAddressDO);
} }
@Override @Override
@Transactional
public void updateAddress(UserAddressUpdateDTO userAddressAddDTO) { public void updateAddress(UserAddressUpdateDTO userAddressAddDTO) {
UserAddressDO userAddress = userAddressMapper.selectById(userAddressAddDTO.getId());
if (DeletedStatusEnum.DELETED_YES.getValue().equals(userAddress.getDeleted())) { // 检查地址
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.USER_ADDRESS_IS_DELETED.getCode()); UsersUserAddressDO userAddress = userAddressMapper.selectById(userAddressAddDTO.getId());
}
if (userAddress == null) { if (userAddress == null) {
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.USER_ADDRESS_NOT_EXISTENT.getCode()); throw ServiceExceptionUtil.exception(UserErrorCodeEnum.USER_ADDRESS_NOT_EXISTENT.getCode());
}
// 删除的地址不能更新
if (DeletedStatusEnum.DELETED_YES.getValue().equals(userAddress.getDeleted())) {
throw ServiceExceptionUtil.exception(UserErrorCodeEnum.USER_ADDRESS_IS_DELETED.getCode());
} }
// 检查是否设置为默认地址 // 检查是否设置为默认地址
// 是:将数据库 default address 设置为 no
if (UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue() == userAddressAddDTO.getHasDefault()) { if (UserAddressHasDefaultEnum.DEFAULT_ADDRESS_YES.getValue() == userAddressAddDTO.getHasDefault()) {
UserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(userAddressAddDTO.getUserId()); UsersUserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(userAddressAddDTO.getUserId());
if (defaultUserAddress != null && !userAddressAddDTO.getId().equals(defaultUserAddress.getId())) { if (defaultUserAddress != null && !userAddressAddDTO.getId().equals(defaultUserAddress.getId())) {
userAddressMapper.updateById( userAddressMapper.updateById(
new UserAddressDO() new UsersUserAddressDO()
.setId(defaultUserAddress.getId()) .setId(defaultUserAddress.getId())
.setHasDefault(UserAddressHasDefaultEnum.DEFAULT_ADDRESS_NO.getValue()) .setHasDefault(UserAddressHasDefaultEnum.DEFAULT_ADDRESS_NO.getValue())
); );
} }
} }
UserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(userAddressAddDTO.getUserId()); // 转换 vo, 并保存数据
if (defaultUserAddress != null && !userAddressAddDTO.getId().equals(defaultUserAddress.getId())) { UsersUserAddressDO userAddressDO = UserAddressConvert.INSTANCE.convert(userAddressAddDTO);
userAddressMapper.updateById(
new UserAddressDO()
.setId(defaultUserAddress.getId())
.setHasDefault(UserAddressHasDefaultEnum.DEFAULT_ADDRESS_NO.getValue())
);
}
UserAddressDO userAddressDO = UserAddressConvert.INSTANCE.convert(userAddressAddDTO);
userAddressDO.setUpdateTime(new Date()); userAddressDO.setUpdateTime(new Date());
userAddressMapper.updateById(userAddressDO); userAddressMapper.updateById(userAddressDO);
} }
@Override @Override
public void removeAddress(Integer userId, Integer addressId) { public void removeAddress(Integer userId, Integer addressId) {
UserAddressDO userAddress = userAddressMapper.selectById(addressId); // checked address is exists.
UsersUserAddressDO userAddress = userAddressMapper.selectById(addressId);
if (userAddress == null) {
throw ServiceExceptionUtil.exception(UserErrorCodeEnum.USER_ADDRESS_NOT_EXISTENT.getCode());
}
if (DeletedStatusEnum.DELETED_YES.getValue().equals(userAddress.getDeleted())) { if (DeletedStatusEnum.DELETED_YES.getValue().equals(userAddress.getDeleted())) {
// skip // skip
return; return;
} }
if (userAddress == null) { // 更新状态为 remove
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.USER_ADDRESS_NOT_EXISTENT.getCode());
}
userAddressMapper.updateById( userAddressMapper.updateById(
(UserAddressDO) new UserAddressDO() (UsersUserAddressDO) new UsersUserAddressDO()
.setId(addressId) .setId(addressId)
.setDeleted(DeletedStatusEnum.DELETED_YES.getValue()) .setDeleted(DeletedStatusEnum.DELETED_YES.getValue())
); );
} }
@Override @Override
public List<UserAddressBO> addressList(Integer userId) { public List<UserAddressBO> listAddress(Integer userId) {
List<UserAddressDO> userAddressDOList = userAddressMapper.selectByUserId(userId); List<UsersUserAddressDO> userAddressDOList = userAddressMapper.selectByUserId(userId);
List<UserAddressBO> userAddressBOList = UserAddressConvert.INSTANCE.convertUserAddressBOList(userAddressDOList);
List<UserAddressBO> userAddressBOList = UserAddressConvert
.INSTANCE.convertUserAddressBOList(userAddressDOList);
return userAddressBOList; return userAddressBOList;
} }
@Override @Override
public UserAddressBO getAddress(Integer userId, Integer id) { public UserAddressBO getAddress(Integer id) {
UserAddressDO userAddress = userAddressMapper.selectById(id); UsersUserAddressDO userAddress = userAddressMapper.selectById(id);
if (userAddress == null) { return UserAddressConvert.INSTANCE.convert(userAddress);
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.USER_GET_ADDRESS_NOT_EXISTS.getCode());
}
if (DeletedStatusEnum.DELETED_YES.getValue().equals(userAddress.getDeleted())) {
throw ServiceExceptionUtil.exception(SystemErrorCodeEnum.USER_ADDRESS_IS_DELETED.getCode());
}
UserAddressBO userAddressBO = UserAddressConvert.INSTANCE.convert(userAddress);
return userAddressBO;
} }
@Override @Override
public UserAddressBO getDefaultAddress(Integer userId) { public UserAddressBO getDefaultAddress(Integer userId) {
UserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(userId); UsersUserAddressDO defaultUserAddress = userAddressMapper.selectHasDefault(userId);
return UserAddressConvert.INSTANCE.convert(defaultUserAddress); return UserAddressConvert.INSTANCE.convert(defaultUserAddress);
} }
} }
...@@ -13,17 +13,11 @@ ...@@ -13,17 +13,11 @@
<dependencies> <dependencies>
<!-- Mall 相关 --> <!-- Mall 相关 -->
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.mall</groupId>-->
<!-- <artifactId>user-biz</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- Mall 相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId> <artifactId>user-biz</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
<!-- Web 相关 --> <!-- Web 相关 -->
...@@ -32,8 +26,16 @@ ...@@ -32,8 +26,16 @@
<artifactId>mall-spring-boot-starter-web</artifactId> <artifactId>mall-spring-boot-starter-web</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<!-- TODO 云服务 --> <groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-security</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-swagger</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
package cn.iocoder.mall.user.rest.controller.user;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.security.core.context.UserSecurityContextHolder;
import cn.iocoder.mall.user.biz.dto.user.UserAddressAddDTO;
import cn.iocoder.mall.user.biz.dto.user.UserAddressUpdateDTO;
import cn.iocoder.mall.user.biz.service.user.UserAddressService;
import cn.iocoder.mall.user.rest.convert.UserAddressConvert;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* 用户地址(user API)
*
* author: sin
* time: 2020/5/8 9:50
*/
@RestController
@Api(tags = "用户地址(user API)")
@RequestMapping("/users/user-address")
public class UsersUserAddressController {
@Autowired
private UserAddressService userAddressService;
@GetMapping("list-address")
@ApiOperation("获取 - 地址列表(all)")
public CommonResult<List<UserAddressResponse>> listAddress() {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
return CommonResult.success(UserAddressConvert.INSTANCE.convert(userAddressService.listAddress(userId)));
}
@GetMapping("{addressId}")
@ApiOperation("获取 - 根据id获取")
public CommonResult<UserAddressResponse> getAddress(@PathVariable("addressId") Integer addressId) {
return CommonResult.success(UserAddressConvert.INSTANCE.convert(userAddressService.getAddress(addressId)));
}
@GetMapping("default")
@ApiOperation("获取 - 获取默认地址")
public CommonResult<UserAddressResponse> getDefaultAddress() {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
return CommonResult.success(UserAddressConvert.INSTANCE.convert(userAddressService.getDefaultAddress(userId)));
}
@DeleteMapping("/{addressId}/remove")
@ApiOperation("删除 - 根据id删除")
public CommonResult getDefaultAddress(@PathVariable("addressId") Integer addressId) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
userAddressService.removeAddress(userId, addressId);
return CommonResult.success(null);
}
@PostMapping("/add-address")
@ApiOperation("添加地址")
public CommonResult addAddress(@RequestBody @Valid UserAddressAddRequest userAddressAddRequest) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
UserAddressAddDTO userAddressAddDTO = UserAddressConvert.INSTANCE.convert(userAddressAddRequest);
userAddressAddDTO.setUserId(userId);
userAddressService.addAddress(userAddressAddDTO);
return CommonResult.success(null);
}
@PutMapping("/update-address")
@ApiOperation("更新地址")
public CommonResult updateAddress(@RequestBody @Valid UserAddressUpdateRequest userAddressAddRequest) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
UserAddressUpdateDTO userAddressAddDTO = UserAddressConvert.INSTANCE.convert(userAddressAddRequest);
userAddressAddDTO.setUserId(userId);
userAddressService.updateAddress(userAddressAddDTO);
return CommonResult.success(null);
}
}
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);
}
/**
* author: sin
* time: 2020/5/8 9:57
*/
package cn.iocoder.mall.user.rest.request;
\ No newline at end of file
package cn.iocoder.mall.user.rest.request.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 用户地址 add
*
* @author Sin
* @time 2019-04-06 13:25
*/
@Data
@Accessors(chain = true)
@ApiModel("用户地址(添加)")
public class UserAddressAddRequest implements Serializable {
@NotNull
@ApiModelProperty("收件区域编号")
private String areaNo;
@NotNull
@ApiModelProperty("收件人名称")
private String name;
@NotNull
@ApiModelProperty("收件手机号")
private String mobile;
@NotNull
@ApiModelProperty("收件详细地址")
private String address;
@NotNull
@ApiModelProperty("是否默认 1 不是 2 是")
private Integer hasDefault;
}
package cn.iocoder.mall.user.rest.request.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 用户地址 更新
*
* @author Sin
* @time 2019-04-06 13:28
*/
@Data
@Accessors(chain = true)
@ApiModel("用户地址(更新)")
public class UserAddressUpdateRequest implements Serializable {
@NotNull
@ApiModelProperty("编号")
private Integer id;
@NotNull
@ApiModelProperty("收件区域编号")
private String areaNo;
@NotNull
@ApiModelProperty("收件人名称")
private String name;
@NotNull
@ApiModelProperty("收件手机号")
private String mobile;
@NotNull
@ApiModelProperty("收件详细地址")
private String address;
@NotNull
@ApiModelProperty("是否默认地址")
private Integer hasDefault;
}
/**
* author: sin
* time: 2020/5/8 9:57
*/
package cn.iocoder.mall.user.rest.response;
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论