- demo 项目,增加 redis 库
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package cn.iocoder.mall.demo.application.controller;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.demo.application.convert.DemOrderConvert;
|
||||
import cn.iocoder.mall.demo.application.convert.DemoOrderConvert;
|
||||
import cn.iocoder.mall.demo.application.dto.DemoOrderAddDTO;
|
||||
import cn.iocoder.mall.demo.business.api.DemoOrderService;
|
||||
import cn.iocoder.mall.demo.business.bo.order.DemoOrderAddBO;
|
||||
@@ -19,7 +19,7 @@ public class DemoOrderController {
|
||||
|
||||
@PostMapping("/add")
|
||||
public CommonResult<Integer> add(DemoOrderAddDTO addDTO) {
|
||||
DemoOrderAddBO addBO = DemOrderConvert.INSTANCE.convert(addDTO);
|
||||
DemoOrderAddBO addBO = DemoOrderConvert.INSTANCE.convert(addDTO);
|
||||
addBO.setUserId(10); // TODO 10 用户编号。
|
||||
Integer orderId = demoOrderService.add(addBO);
|
||||
return CommonResult.success(orderId);
|
||||
|
||||
@@ -5,8 +5,6 @@ import cn.iocoder.mall.demo.application.convert.DemoProductConvert;
|
||||
import cn.iocoder.mall.demo.application.vo.DemoProductVO;
|
||||
import cn.iocoder.mall.demo.business.api.DemoProductService;
|
||||
import cn.iocoder.mall.demo.business.bo.product.DemoProductBO;
|
||||
import cn.iocoder.mall.demo.rpc.api.DemoProductRpcService;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -20,20 +18,10 @@ public class DemoProductController {
|
||||
@Autowired
|
||||
private DemoProductService productService;
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.DemoProductRpcService.version}")
|
||||
private DemoProductRpcService productRpcService;
|
||||
|
||||
@GetMapping("/get")
|
||||
public CommonResult<DemoProductVO> get(@RequestParam("id") Integer id) {
|
||||
DemoProductBO product = productService.get(id);
|
||||
return CommonResult.success(DemoProductConvert.INSTANCE.convert(product));
|
||||
}
|
||||
|
||||
// TODO 芋艿,这里只是做一个 demo 。实际一般不会这么玩,更多是内嵌的,像 {@link #get(Integer id)} 的情况。
|
||||
@GetMapping("/get2")
|
||||
public CommonResult<DemoProductVO> get2(@RequestParam("id") Integer id) {
|
||||
cn.iocoder.mall.demo.rpc.vo.DemoProductVO product = productRpcService.get(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.iocoder.mall.demo.application.controller;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.demo.application.convert.DemoUserConvert;
|
||||
import cn.iocoder.mall.demo.application.vo.DemoUserVO;
|
||||
import cn.iocoder.mall.demo.rpc.api.DemoUserRpcService;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class DemoUserController {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.consumer.DemoUserRpcService.version}")
|
||||
private DemoUserRpcService userRpcService;
|
||||
|
||||
// TODO 芋艿,这里只是做一个 demo 。实际一般不会这么玩,更多是内嵌的,像 {@link #get(Integer id)} 的情况。
|
||||
@GetMapping("/get")
|
||||
public CommonResult<DemoUserVO> get(@RequestParam("id") Integer id) {
|
||||
cn.iocoder.mall.demo.rpc.vo.DemoUserVO user = userRpcService.get(id);
|
||||
return CommonResult.success(DemoUserConvert.INSTANCE.convert(user));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,9 +7,9 @@ import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface DemOrderConvert {
|
||||
public interface DemoOrderConvert {
|
||||
|
||||
DemOrderConvert INSTANCE = Mappers.getMapper(DemOrderConvert.class);
|
||||
DemoOrderConvert INSTANCE = Mappers.getMapper(DemoOrderConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
DemoOrderAddBO convert(DemoOrderAddDTO addDTO);
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.iocoder.mall.demo.application.convert;
|
||||
|
||||
import cn.iocoder.mall.demo.application.vo.DemoUserVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface DemoUserConvert {
|
||||
|
||||
DemoUserConvert INSTANCE = Mappers.getMapper(DemoUserConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
DemoUserVO convert(cn.iocoder.mall.demo.rpc.vo.DemoUserVO vo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.mall.demo.application.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DemoUserVO {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
}
|
||||
@@ -11,3 +11,5 @@ dubbo:
|
||||
consumer:
|
||||
DemoProductRpcService:
|
||||
version: 1.0.0
|
||||
DemoUserRpcService:
|
||||
version: 1.0.0
|
||||
|
||||
Reference in New Issue
Block a user