Commit bf1f627d0682a4757cf75cd270fe49f6909a11ad

Authored by yangfan
1 parent f6940f45

店铺

src/main/java/com/diligrp/xtrade/product/controllor/ShopController.java 0 → 100644
  1 +package com.diligrp.xtrade.product.controllor;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.PathVariable;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +
  10 +import com.diligrp.xtrade.product.domain.dto.ShopDto;
  11 +import com.diligrp.xtrade.product.domain.entity.ShopDo;
  12 +import com.diligrp.xtrade.product.service.ShopService;
  13 +import com.diligrp.xtrade.shared.domain.Message;
  14 +
  15 +/**
  16 + * @ClassName: ShopControler
  17 + * @Description TODO(用一句话描述该文件做什么)
  18 + * @author yangfan
  19 + * @date 2020年4月21日
  20 + */
  21 +@RestController
  22 +@RequestMapping("/sapi/shop")
  23 +public class ShopController {
  24 +
  25 + @Autowired
  26 + private ShopService shopService;
  27 +
  28 + /**
  29 + *
  30 + * @Title save
  31 + * @Description 店铺保存
  32 + * @param shop
  33 + * @return
  34 + * @throws
  35 + */
  36 + @RequestMapping("save")
  37 + public Message<?> save(ShopDto shop){
  38 + shopService.insert(shop);
  39 + return Message.builder().success();
  40 + }
  41 +
  42 + /**
  43 + *
  44 + * @Title get
  45 + * @Description 获取商铺
  46 + * @param shopId
  47 + * @return
  48 + * @throws
  49 + */
  50 + @RequestMapping("get/{shopId}")
  51 + public Message<ShopDo> get(@PathVariable Long shopId){
  52 + return Message.builder().success(shopService.selectByShopId(shopId));
  53 + }
  54 +
  55 + /**
  56 + *
  57 + * @Title selectShopByMerId
  58 + * @Description 根据商户id获取商户全部店铺信息
  59 + * @param merId
  60 + * @return
  61 + * @throws
  62 + */
  63 + @RequestMapping("selectShopByMerId/{merId}")
  64 + public Message<?> selectShopByMerId(@PathVariable Long merId){
  65 + List<ShopDo> shopDos = shopService.selectShopByMerId(merId);
  66 + return Message.builder().success(shopDos);
  67 + }
  68 +}
src/main/java/com/diligrp/xtrade/product/domain/dto/ShopDto.java 0 → 100644
  1 +package com.diligrp.xtrade.product.domain.dto;
  2 +
  3 +import javax.validation.constraints.NotBlank;
  4 +
  5 +/**
  6 + * @ClassName: ShopDTO
  7 + * @Description TODO(用一句话描述该文件做什么)
  8 + * @author yangfan
  9 + * @date 2020年4月21日
  10 + */
  11 +public class ShopDto {
  12 +
  13 + /**
  14 + * 商户id
  15 + */
  16 + private Long merId;
  17 +
  18 + /**
  19 + * 店铺id
  20 + */
  21 + private Long shopId;
  22 +
  23 + /**
  24 + * 店铺名称
  25 + */
  26 + @NotBlank(message = "商铺名称不能为空")
  27 + private String shopName;
  28 +
  29 + /**
  30 + * 店铺类型
  31 + */
  32 + private Integer type;
  33 +
  34 + /**
  35 + * 店铺状态
  36 + */
  37 + private Integer status;
  38 +
  39 + /**
  40 + * 是否自营
  41 + */
  42 + private Integer isSelfShop;
  43 +
  44 + /**
  45 + * 主营业务
  46 + */
  47 + private String mainBusiness;
  48 +
  49 + /**
  50 + * 地址
  51 + */
  52 + private String address;
  53 +
  54 + /**
  55 + * 描述
  56 + */
  57 + private String description;
  58 +
  59 + public Long getMerId() {
  60 + return merId;
  61 + }
  62 +
  63 + public void setMerId(Long merId) {
  64 + this.merId = merId;
  65 + }
  66 +
  67 + public Long getShopId() {
  68 + return shopId;
  69 + }
  70 +
  71 + public void setShopId(Long shopId) {
  72 + this.shopId = shopId;
  73 + }
  74 +
  75 + public String getShopName() {
  76 + return shopName;
  77 + }
  78 +
  79 + public void setShopName(String shopName) {
  80 + this.shopName = shopName;
  81 + }
  82 +
  83 + public Integer getType() {
  84 + return type;
  85 + }
  86 +
  87 + public void setType(Integer type) {
  88 + this.type = type;
  89 + }
  90 +
  91 + public Integer getStatus() {
  92 + return status;
  93 + }
  94 +
  95 + public void setStatus(Integer status) {
  96 + this.status = status;
  97 + }
  98 +
  99 + public Integer getIsSelfShop() {
  100 + return isSelfShop;
  101 + }
  102 +
  103 + public void setIsSelfShop(Integer isSelfShop) {
  104 + this.isSelfShop = isSelfShop;
  105 + }
  106 +
  107 + public String getMainBusiness() {
  108 + return mainBusiness;
  109 + }
  110 +
  111 + public void setMainBusiness(String mainBusiness) {
  112 + this.mainBusiness = mainBusiness;
  113 + }
  114 +
  115 + public String getAddress() {
  116 + return address;
  117 + }
  118 +
  119 + public void setAddress(String address) {
  120 + this.address = address;
  121 + }
  122 +
  123 + public String getDescription() {
  124 + return description;
  125 + }
  126 +
  127 + public void setDescription(String description) {
  128 + this.description = description;
  129 + }
  130 +
  131 +}
src/main/java/com/diligrp/xtrade/product/domain/emuns/IKeyGeneratorKeys.java 0 → 100644
  1 +package com.diligrp.xtrade.product.domain.emuns;
  2 +
  3 +/**
  4 + * @ClassName: IKeyGeneratorKeys
  5 + * @Description id生成key配置
  6 + * @author yangfan
  7 + * @date 2020年4月21日
  8 + */
  9 +public enum IKeyGeneratorKeys {
  10 + SHOP_SEQUENCE
  11 +}
src/main/java/com/diligrp/xtrade/product/service/impl/ShopServiceImpl.java
@@ -8,19 +8,25 @@ import org.springframework.stereotype.Service; @@ -8,19 +8,25 @@ import org.springframework.stereotype.Service;
8 8
9 import com.diligrp.xtrade.product.dao.ShopDao; 9 import com.diligrp.xtrade.product.dao.ShopDao;
10 import com.diligrp.xtrade.product.domain.dto.ShopDto; 10 import com.diligrp.xtrade.product.domain.dto.ShopDto;
  11 +import com.diligrp.xtrade.product.domain.emuns.IKeyGeneratorKeys;
11 import com.diligrp.xtrade.product.domain.entity.ShopDo; 12 import com.diligrp.xtrade.product.domain.entity.ShopDo;
12 import com.diligrp.xtrade.product.service.ShopService; 13 import com.diligrp.xtrade.product.service.ShopService;
  14 +import com.diligrp.xtrade.shared.sequence.KeyGeneratorManager;
13 15
14 @Service("shopService") 16 @Service("shopService")
15 public class ShopServiceImpl implements ShopService { 17 public class ShopServiceImpl implements ShopService {
16 18
17 @Autowired 19 @Autowired
18 private ShopDao shopDao; 20 private ShopDao shopDao;
  21 + @Autowired
  22 + private KeyGeneratorManager KeyGeneratorManager;
19 23
20 @Override 24 @Override
21 public void insert(ShopDto shop) { 25 public void insert(ShopDto shop) {
22 ShopDo shopDo = new ShopDo(); 26 ShopDo shopDo = new ShopDo();
  27 + Long shopId = KeyGeneratorManager.getKeyGenerator(IKeyGeneratorKeys.SHOP_SEQUENCE).nextId();
23 BeanUtils.copyProperties(shop, shopDo); 28 BeanUtils.copyProperties(shop, shopDo);
  29 + shopDo.setShopId(shopId);
24 shopDao.insert(shopDo); 30 shopDao.insert(shopDo);
25 } 31 }
26 32