查询套餐商品接口
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
package com.sczx.car.controller;
|
||||
|
||||
|
||||
import com.sczx.car.common.Result;
|
||||
import com.sczx.car.dto.RentBatteyRuleDTO;
|
||||
import com.sczx.car.service.RentBatteyRuleService;
|
||||
import com.sczx.car.service.RuleItemService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
@Api(value = "套餐商品接口", tags = "套餐商品接口")
|
||||
@RestController
|
||||
@RequestMapping("/ruleitem")
|
||||
public class RuleItemController {
|
||||
|
||||
@Autowired
|
||||
private RuleItemService ruleItemService;
|
||||
|
||||
|
||||
@ApiOperation(value = "根据租电套餐id查询租电套餐")
|
||||
@GetMapping("/queryiteminfo")
|
||||
public Result<RentBatteyRuleDTO> getItemInfoByIds(@RequestParam(required = true) Long brandId,@RequestParam(required = true) Long carModelId,
|
||||
@RequestParam(required = true) Long carRuleId,@RequestParam(required = true) Long batteryRuleId){
|
||||
return Result.ok(ruleItemService.getRentRuleItemByIds(brandId, carModelId, carRuleId, batteryRuleId));
|
||||
}
|
||||
}
|
||||
147
src/main/java/com/sczx/car/dto/RuleItemDto.java
Normal file
147
src/main/java/com/sczx/car/dto/RuleItemDto.java
Normal file
@ -0,0 +1,147 @@
|
||||
package com.sczx.car.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@ApiModel(value = "车型租赁规则项对象")
|
||||
@Data
|
||||
public class RuleItemDto{
|
||||
/**
|
||||
* 车型ID
|
||||
*/
|
||||
@ApiModelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 外部商品ID
|
||||
*/
|
||||
@ApiModelProperty("外部商品ID")
|
||||
private String outItemId;
|
||||
|
||||
/**
|
||||
* 阿里商品ID
|
||||
*/
|
||||
@ApiModelProperty("阿里商品ID")
|
||||
private String aliItemId;
|
||||
|
||||
/**
|
||||
* 外部SKU ID
|
||||
*/
|
||||
@ApiModelProperty("外部SKU ID")
|
||||
private String outSkuId;
|
||||
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
@ApiModelProperty("商品描述")
|
||||
private String itemDesc;
|
||||
|
||||
/**
|
||||
* 品牌名称
|
||||
*/
|
||||
@ApiModelProperty("品牌名称")
|
||||
private String brandName;
|
||||
|
||||
/**
|
||||
* 车型名称
|
||||
*/
|
||||
@ApiModelProperty("车型名称")
|
||||
private String modelName;
|
||||
|
||||
/**
|
||||
* 电池类别名称
|
||||
*/
|
||||
@ApiModelProperty("电池类别名称")
|
||||
private String categoryName;
|
||||
|
||||
/**
|
||||
* 租赁天数(当类型为"按天数"时使用)
|
||||
*/
|
||||
@ApiModelProperty("租赁天数")
|
||||
private Integer rentalDays;
|
||||
|
||||
/**
|
||||
* 套餐类型
|
||||
*/
|
||||
@ApiModelProperty("套餐类型")
|
||||
private String rentType;
|
||||
|
||||
/**
|
||||
* 套餐名称
|
||||
*/
|
||||
@ApiModelProperty("套餐名称")
|
||||
private String ruleName;
|
||||
|
||||
@ApiModelProperty("支付宝页面路径")
|
||||
private String pagePath;
|
||||
/**
|
||||
* 车型照片
|
||||
*/
|
||||
@ApiModelProperty("车型照片")
|
||||
private String image;
|
||||
|
||||
/**
|
||||
* 车型照片列表1
|
||||
*/
|
||||
@ApiModelProperty("车型照片列表1")
|
||||
private String imageList1;
|
||||
|
||||
/**
|
||||
* 车型照片列表2
|
||||
*/
|
||||
@ApiModelProperty("车型照片列表2")
|
||||
private String imageList2;
|
||||
|
||||
/**
|
||||
* 车型照片列表3
|
||||
*/
|
||||
@ApiModelProperty("车型照片列表3")
|
||||
private String imageList3;
|
||||
|
||||
/**
|
||||
* 是否支持免押(0不支持 1支持)
|
||||
*/
|
||||
@ApiModelProperty("是否支持免押(0不支持 1支持)")
|
||||
private String depositFree;
|
||||
|
||||
/**
|
||||
* 押金价格(元)
|
||||
*/
|
||||
@ApiModelProperty("押金价格(元)")
|
||||
private BigDecimal depositPrice;
|
||||
|
||||
/**
|
||||
* 租车价格(元)
|
||||
*/
|
||||
@ApiModelProperty("租车价格(元)")
|
||||
private BigDecimal rentalPrice;
|
||||
|
||||
/**
|
||||
* 电池套餐ID
|
||||
*/
|
||||
@ApiModelProperty("电池套餐ID")
|
||||
private Long batteryRuleId;
|
||||
|
||||
/**
|
||||
* 车辆套餐ID
|
||||
*/
|
||||
@ApiModelProperty("车辆套餐ID")
|
||||
private Long carRuleId;
|
||||
|
||||
/**
|
||||
* 车型ID
|
||||
*/
|
||||
@ApiModelProperty("车型ID")
|
||||
private Long carModelId;
|
||||
|
||||
/**
|
||||
* 品牌ID
|
||||
*/
|
||||
@ApiModelProperty("品牌ID")
|
||||
private Long brandId;
|
||||
}
|
||||
24
src/main/java/com/sczx/car/mapper/RuleItemMapper.java
Normal file
24
src/main/java/com/sczx/car/mapper/RuleItemMapper.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.sczx.car.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sczx.car.po.RuleItemPo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface RuleItemMapper extends BaseMapper<RuleItemPo> {
|
||||
/**
|
||||
* 根据品牌ID、车型ID、车辆套餐ID和电池套餐ID查询套餐商品
|
||||
*
|
||||
* @param brandId 品牌ID
|
||||
* @param carModelId 车型ID
|
||||
* @param carRuleId 车辆套餐ID
|
||||
* @param batteryRuleId 电池套餐ID
|
||||
* @return 套餐商品信息
|
||||
*/
|
||||
RuleItemPo selectByRuleIds(@Param("brandId") Long brandId,
|
||||
@Param("carModelId") Long carModelId,
|
||||
@Param("carRuleId") Long carRuleId,
|
||||
@Param("batteryRuleId") Long batteryRuleId);
|
||||
}
|
||||
92
src/main/java/com/sczx/car/po/RuleItemPo.java
Normal file
92
src/main/java/com/sczx/car/po/RuleItemPo.java
Normal file
@ -0,0 +1,92 @@
|
||||
package com.sczx.car.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("zc_rent_rule_item")
|
||||
@ApiModel(value = "RuleItemPo对象", description = "套餐商品对象")
|
||||
public class RuleItemPo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("外部商品ID")
|
||||
private String outItemId;
|
||||
|
||||
@ApiModelProperty("阿里商品ID")
|
||||
private String aliItemId;
|
||||
|
||||
@ApiModelProperty("外部SKU ID")
|
||||
private String outSkuId;
|
||||
|
||||
@ApiModelProperty("商品描述")
|
||||
private String itemDesc;
|
||||
|
||||
@ApiModelProperty("品牌名称")
|
||||
private String brandName;
|
||||
|
||||
@ApiModelProperty("车型名称")
|
||||
private String modelName;
|
||||
|
||||
@ApiModelProperty("电池类别名称")
|
||||
private String categoryName;
|
||||
|
||||
@ApiModelProperty("租赁天数(当类型为\"按天数\"时使用)")
|
||||
private Integer rentalDays;
|
||||
|
||||
@ApiModelProperty("套餐类型")
|
||||
private String rentType;
|
||||
|
||||
@ApiModelProperty("套餐名称")
|
||||
private String ruleName;
|
||||
|
||||
@ApiModelProperty("支付宝页面路径")
|
||||
private String pagePath;
|
||||
|
||||
@ApiModelProperty("车型照片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty("车型照片列表1")
|
||||
private String imageList1;
|
||||
|
||||
@ApiModelProperty("车型照片列表2")
|
||||
private String imageList2;
|
||||
|
||||
@ApiModelProperty("车型照片列表3")
|
||||
private String imageList3;
|
||||
|
||||
@ApiModelProperty("是否支持免押(0不支持 1支持)")
|
||||
private String depositFree;
|
||||
|
||||
@ApiModelProperty("押金价格(元)")
|
||||
private BigDecimal depositPrice;
|
||||
|
||||
@ApiModelProperty("租车价格(元)")
|
||||
private BigDecimal rentalPrice;
|
||||
|
||||
@ApiModelProperty("电池套餐ID")
|
||||
private Long batteryRuleId;
|
||||
|
||||
@ApiModelProperty("车辆套餐ID")
|
||||
private Long carRuleId;
|
||||
|
||||
@ApiModelProperty("车型ID")
|
||||
private Long carModelId;
|
||||
|
||||
@ApiModelProperty("品牌ID")
|
||||
private Long brandId;
|
||||
}
|
||||
10
src/main/java/com/sczx/car/service/RuleItemService.java
Normal file
10
src/main/java/com/sczx/car/service/RuleItemService.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.sczx.car.service;
|
||||
|
||||
import com.sczx.car.dto.RuleItemDto;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
public interface RuleItemService {
|
||||
|
||||
RuleItemDto getRentRuleItemByIds(Long brandId,Long carModelId, Long carRuleId, Long batteryRuleId);
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package com.sczx.car.service.impl;
|
||||
|
||||
|
||||
import com.sczx.car.dto.RuleItemDto;
|
||||
import com.sczx.car.mapper.RuleItemMapper;
|
||||
import com.sczx.car.po.RuleItemPo;
|
||||
import com.sczx.car.service.RuleItemService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RuleItemServiceImpl implements RuleItemService {
|
||||
|
||||
@Autowired
|
||||
private RuleItemMapper ruleItemMapper;
|
||||
|
||||
@Override
|
||||
public RuleItemDto getRentRuleItemByIds(Long brandId, Long carModelId, Long carRuleId, Long batteryRuleId) {
|
||||
log.info("根据套餐商品id查询套餐商品: brandId={}, carModelId={}, carRuleId={}, batteryRuleId={}",
|
||||
brandId, carModelId, carRuleId, batteryRuleId);
|
||||
|
||||
RuleItemPo ruleItemPo = ruleItemMapper.selectByRuleIds(brandId, carModelId, carRuleId, batteryRuleId);
|
||||
|
||||
if (ruleItemPo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RuleItemDto ruleItemDto = new RuleItemDto();
|
||||
BeanUtils.copyProperties(ruleItemPo, ruleItemDto);
|
||||
return ruleItemDto;
|
||||
}
|
||||
}
|
||||
50
src/main/resources/mapper/RuleItemMapper.xml
Normal file
50
src/main/resources/mapper/RuleItemMapper.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sczx.car.mapper.RuleItemMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.sczx.car.po.RuleItemPo">
|
||||
<id column="id" property="id" />
|
||||
<result column="out_item_id" property="outItemId" />
|
||||
<result column="ali_item_id" property="aliItemId" />
|
||||
<result column="out_sku_id" property="outSkuId" />
|
||||
<result column="item_desc" property="itemDesc" />
|
||||
<result column="brand_name" property="brandName" />
|
||||
<result column="model_name" property="modelName" />
|
||||
<result column="category_name" property="categoryName" />
|
||||
<result column="rental_days" property="rentalDays" />
|
||||
<result column="rent_type" property="rentType" />
|
||||
<result column="rule_name" property="ruleName" />
|
||||
<result column="page_path" property="pagePath" />
|
||||
<result column="image" property="image" />
|
||||
<result column="image_list1" property="imageList1" />
|
||||
<result column="image_list2" property="imageList2" />
|
||||
<result column="image_list3" property="imageList3" />
|
||||
<result column="deposit_free" property="depositFree" />
|
||||
<result column="deposit_price" property="depositPrice" />
|
||||
<result column="rental_price" property="rentalPrice" />
|
||||
<result column="battery_rule_id" property="batteryRuleId" />
|
||||
<result column="car_rule_id" property="carRuleId" />
|
||||
<result column="car_model_id" property="carModelId" />
|
||||
<result column="brand_id" property="brandId" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, out_item_id, ali_item_id, out_sku_id, item_desc, brand_name, model_name, category_name,
|
||||
rental_days, rent_type, rule_name, page_path, image, image_list1, image_list2, image_list3,
|
||||
deposit_free, deposit_price, rental_price, battery_rule_id, car_rule_id, car_model_id, brand_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据品牌ID、车型ID、车辆套餐ID和电池套餐ID查询套餐商品 -->
|
||||
<select id="selectByRuleIds" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM zc_rent_rule_item
|
||||
WHERE brand_id = #{brandId}
|
||||
AND car_model_id = #{carModelId}
|
||||
AND car_rule_id = #{carRuleId}
|
||||
AND battery_rule_id = #{batteryRuleId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user