排期接口,价格接口

排期接口,价格接口

准备物料:

1.排期接口,价格接口
2.微服务工程scheduler-provider
3.根据"商品ID查询商品排期接口"业务和根据"商品排期查询商品价格接口"业务的sql语句实现:
SELECT * FROM dm_item WHERE id = 5;
SELECT * FROM dm_scheduler WHERE itemId = 5;
SELECT * FROM dm_scheduler_seat_price WHERE scheduleId = 12700;
SELECT * FROM dm_scheduler_seat WHERE scheduleId = 12700 AND STATUS = 1;
2.参看排期页面

https://piao.damai.cn/178499.html?spm=a2oeg.home.card_1.ditem_1.26c623e1ckkVsa

3.业务实现:

(1)根据商品ID查询商品排期接口
(2)根据商品排期查询商品价格接口

4.具体实现
(1).实现根据商品ID查询商品排期接口

思路1:定位dm-item-consumer微服务工程
思路2:入口为商品itemId,出口为商品排期集合Dto<List> (vo中包含两张表:dm_item,dm_scheduler)
思路3:定位dm_scheduler排期库中的dm_scheduler表
思路4:组装VOList(itemSchedulerVoList)

步骤1:

*********dm-item-consumer/ItemDetailService*********
    /**
     * 根据商品ID查询排期
     * @param itemId
     * @return
     * @throws Exception
     */
    public Dto<List<ItemSchedulerVo>> queryItemScheduler(Long itemId)throws Exception;
步骤2:
*********dm-item-consumer/ItemDetailServiceImpl*********
附注:(dm-item-consumer\src\main\java\cn\dm\exception加入字符串常量ItemErrorCode.java)

public class ItemDetailServiceImpl implements ItemDetailService {
    //引入
    @Autowired
    private RestDmSchedulerClient restDmSchedulerClient;

	@Override
    public Dto<List<ItemSchedulerVo>> queryItemScheduler(Long id) throws Exception {
        //1.根据商品id查询商品对象信息
        DmItem dmItem = dmItemClient.getDmItemById(id);
	//2.商品对象信息判空校验
        if (EmptyUtils.isEmpty(dmItem)) {
            throw new BaseException(ItemErrorCode.ITEM_NO_DATA);
        }
        //3.根据商品id查询排期对象信息集合
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("itemId", dmItem.getId());
        List<DmScheduler> dmSchedulerList = restDmSchedulerClient.getDmSchedulerListByMap(param);
	//4.排期对象信息判空校验
        if (EmptyUtils.isEmpty(dmSchedulerList)) {
            throw new BaseException(ItemErrorCode.ITEM_NO_DATA);
        }
        //5.组装VOList(itemSchedulerVoList)
        List<ItemSchedulerVo> itemSchedulerVoList = new ArrayList<ItemSchedulerVo>();
        for (int i = 0; i < dmSchedulerList.size(); i++) {
            ItemSchedulerVo itemSchedulerVo = new ItemSchedulerVo();
            BeanUtils.copyProperties(dmItem, itemSchedulerVo);
            BeanUtils.copyProperties(dmSchedulerList.get(i), itemSchedulerVo);
         //6.如果出现vo中的字段和javabean中的字段格式不一样,需要转化
            itemSchedulerVo.setStartTime(DateUtil.format(dmSchedulerList.get(i).getStartTime()));
            itemSchedulerVo.setEndTime(DateUtil.format(dmSchedulerList.get(i).getEndTime()));
            itemSchedulerVoList.add(itemSchedulerVo);
        }
        return DtoUtil.returnDataSuccess(itemSchedulerVoList);
    }	
}

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cx49wUy6-1573225130692)(C:\Users\DELL\AppData\Roaming\Typora\typora-user-images\1573128611272.png)]

步骤3:
*********dm-item-consumer/ItemDetailController*********
@ResponseBody
@RequestMapping(value = "/p/queryItemScheduler",method = RequestMethod.POST)
public Dto<List<ItemSchedulerVo>> queryItemScheduler(@RequestBody Map<String, Object> param) throws Exception {
	Integer id = Integer.parseInt(param.get("itemId").toString());
	return itemDetailService.queryItemScheduler((long)id);
}

2.测试:

步骤1:

1.启动eureka微服务成功
2.启动dm-base-provider微服务
2.启动dm-item-provider微服务
3.启动dm-item-consumer微服务
4.启动dm-scheduler-provider微服务

步骤2:

打开postman:http://localhost:7201/api/p/queryItemScheduler
设置:

header
Content-Type    application/json

body
{
"itemId":5
}

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-E7gaJGoi-1573225130693)(C:\Users\DELL\AppData\Roaming\Typora\typora-user-images\1573136097828.png)]

2.根据商品排期查询商品价格接口

思路1:定位商品微服务工程dm-item-consumer
思路2:根据排期ID查询价格
思路3:条件是保证座位可选
思路4:确定排期价格相关信息在dm_scheduler_seat_price表中
思路5:确定座位状态字段status在dm_scheduler_seat表中
思路6:组装itemPriceVoList

步骤一:
**dm-item-consumer/ItemDetailService**
public Dto<List<ItemPriceVo>> queryItemPrice(Long id) throws Exception;
步骤二:
*********dm-item-consumer/ItemDetailServiceImpl*********
//引入:
    @Autowired
    private RestDmSchedulerSeatPriceClient restDmSchedulerSeatPriceClient;

    @Autowired
    private RestDmSchedulerSeatClient restDmSchedulerSeatClient;

 public Dto<List<ItemPriceVo>> queryItemPrice(Long id) throws Exception {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("scheduleId", id);
        //1.根据排期ID查询排期价格信息
        List<DmSchedulerSeatPrice> dmSchedulerSeatPriceList = restDmSchedulerSeatPriceClient.getDmSchedulerSeatPriceListByMap(param);
        //2.判空校验
	if (EmptyUtils.isEmpty(dmSchedulerSeatPriceList)) {
            throw new BaseException(ItemErrorCode.ITEM_NO_DATA);
        }
        //3.组装itemPriceVoListVo
        List<ItemPriceVo> itemPriceVoList = new ArrayList<ItemPriceVo>();
        for (DmSchedulerSeatPrice dmSchedulerSeatPrice : dmSchedulerSeatPriceList) {
            ItemPriceVo itemPriceVo = new ItemPriceVo();
            BeanUtils.copyProperties(dmSchedulerSeatPrice, itemPriceVo);
            //查询所有是有效的并且没有被锁定的座位
            Map<String, Object> lockMap = new HashMap<String, Object>();
            lockMap.put("status", 1);
            lockMap.put("scheduleId", itemPriceVo.getScheduleId());
            int num = restDmSchedulerSeatClient.getDmSchedulerSeatCountByMap(lockMap);
            int isHaveSeat = num > 0 ? 1 : 0;
            itemPriceVo.setIsHaveSeat(isHaveSeat);
            itemPriceVoList.add(itemPriceVo);
        }
        return DtoUtil.returnDataSuccess(itemPriceVoList);
    }
步骤三:
*********dm-item-consumer/ItemDetailController*********
@ResponseBody
@RequestMapping(value = "/p/queryItemPrice",method = RequestMethod.POST)
public Dto<List<ItemPriceVo>> queryItemPrice(@RequestBody Map<String, Object> param) throws Exception {
	Integer id = Integer.parseInt(param.get("scheduleId").toString());
	return itemDetailService.queryItemPrice((long)id);
}
步骤四:

测试:http://localhost:7201/api/p/queryItemPrice
设置:

raw
{
"scheduleId":12700
}

m.get(“scheduleId”).toString());
return itemDetailService.queryItemPrice((long)id);
}


##### 步骤四:

测试:http://localhost:7201/api/p/queryItemPrice
设置:

```java
raw
{
"scheduleId":12700
}

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-onPwHcKc-1573225130694)(C:\Users\DELL\AppData\Roaming\Typora\typora-user-images\1573136384689.png)]

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
IT开发表格排期模板是指一种用于管理IT开发项目时间安排的模板。在IT开发过程中,合理而准确地安排时间是确保项目能够按时交付的关键。表格排期模板可帮助团队成员了解项目所需的工作量和时间,并提前识别潜在的风险和延迟。 一个典型的IT开发表格排期模板包括以下几个重要部分: 1. 项目概况:包括项目名称、项目经理、起止日期等基本信息。 2. 里程碑:列出项目的关键里程碑,这些里程碑是项目成功的关键节点。每个里程碑应包括开始日期、完成日期以及与之相关的任务和工作内容。 3. 任务列表:将项目分解为具体的任务,并为每个任务指定负责人和预计完成日期。这有助于明确每个人的责任,并确保项目按计划进行。 4. 依赖关系:展示项目中各个任务之间的依赖关系。这能够帮助团队成员了解哪些任务必须在其他任务完成后开始,避免出现不必要的延迟。 5. 资源分配:记录项目中可用资源的分配情况,包括人力资源、设备和资金。这有助于确保项目资源的合理利用和调配。 6. 风险评估和管理:对可能导致项目延迟的风险进行评估,并制定相应的风险应对策略。这有助于项目团队及时应对潜在问题,降低项目风险。 通过IT开发表格排期模板,团队成员可以清晰地看到项目的时间安排,知道自己的工作内容和截止日期。同时,项目经理也可以通过模板来跟踪项目进度,及时调整资源分配和解决潜在问题。 总之,IT开发表格排期模板是IT项目管理中非常重要的工具,它能够帮助团队成员明确目标、合理分配资源、减少延迟风险,确保项目按计划顺利进行。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值