提交 b0ee0edf 作者: 张小凤

new model and bind (update)

上级 ab83d969
......@@ -74,4 +74,11 @@ public class MiniProgramDeviceController {
public ResultBody update(@RequestBody LeaseVo param) {
return webDeviceService.update(param);
}
@ApiOperation(value = "获取设备sku")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = SkuInfoDTO.class) })
@GetMapping("listWareSkuById")
public ResultBody<SkuInfoDTO> listWareSkuById(@RequestParam Integer id) {
return ResultBody.success(webDeviceService.listWareSkuById(id));
}
}
......@@ -44,4 +44,6 @@ public interface WebDeviceDao {
WareDetailDO getWareDetailById(Integer id);
List<AdDO> ad();
List<SkuInfoDO> listSkuInfo(Integer id);
}
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.SkuInfoDTO;
import com.mmc.pms.model.vo.WareSkuInfoVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.CollectionUtils;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author small
* @Date 2023/5/19 19:54
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SkuInfoDO implements Serializable {
private static final long serialVersionUID = 3684543586091477788L;
private Integer id;
private Integer wareInfoId;
private String skuTitle;
private BigDecimal rentPrice;
private BigDecimal rentDeposit;
private Integer stockNum;
private Integer saleNum;
private Integer pid;
private Date createTime;
private Date updateTime;
/**
* 辅助字段-start
*/
private WareInfoDO wareInfo;
private List<SkuPriceDO> skuPriceDOList;
/**
* 辅助字段-end
*
* @param d
*/
public SkuInfoDO(WareSkuInfoVO d) {
this.id = d.getId();
this.skuTitle = d.getSkuTitle();
this.rentDeposit = d.getRentDeposit();
this.stockNum = d.getStockNum();
}
public SkuInfoDTO buildSkuInfoDTO(){
return SkuInfoDTO.builder().id(this.id).wareInfoId(this.wareInfoId).skuTitle(this.skuTitle).rentPrice(this.rentPrice).rentDeposit(this.rentDeposit)
.stockNum(this.stockNum).saleNum(this.saleNum).createTime(this.createTime).updateTime(this.updateTime)
.skuPriceDTOList(CollectionUtils.isEmpty(this.skuPriceDOList) ? null : this.skuPriceDOList.stream().map(d->{
return d.buildSkuPriceDTO();
}).collect(Collectors.toList())).build();
}
}
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.SkuPriceDTO;
import com.mmc.pms.model.vo.WareSkuPriceVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author small
* @Date 2023/5/19 19:55
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SkuPriceDO implements Serializable {
private static final long serialVersionUID = 3807980441008975420L;
private Integer id;
private Integer wareInfoId;
private Integer skuInfoId;
private BigDecimal rentPrice;
private Integer minDay;
private Integer maxDay;
private Date createTime;
public SkuPriceDO(WareSkuPriceVO dd) {
this.id = dd.getId();
this.rentPrice = dd.getRentPrice();
this.minDay = dd.getMinDay();
this.maxDay = dd.getMaxDay();
}
public SkuPriceDTO buildSkuPriceDTO(){
return SkuPriceDTO.builder().id(this.id).wareInfoId(this.wareInfoId).skuInfoId(this.skuInfoId).rentPrice(this.rentPrice).minDay(this.minDay)
.maxDay(this.maxDay).createTime(this.createTime).build();
}
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Author small
* @Date 2023/5/19 19:51
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.dto.SkuInfoDTO", description = "sku信息DTO")
public class SkuInfoDTO implements Serializable {
private static final long serialVersionUID = -4321518089785860606L;
@ApiModelProperty(value = "sku表id")
private Integer id;
@ApiModelProperty(value = "商品id")
private Integer wareInfoId;
@ApiModelProperty(value = "sku标题")
private String skuTitle;
@ApiModelProperty(value = "基础租金(日租金)")
private BigDecimal rentPrice;
@ApiModelProperty(value = "出租押金")
private BigDecimal rentDeposit;
@ApiModelProperty(value = "库存数量")
private Integer stockNum;
@ApiModelProperty(value = "已销数量")
private Integer saleNum;
@ApiModelProperty(value = "生成时间")
private Date createTime;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
@ApiModelProperty(value = "sku对应价格")
private List<SkuPriceDTO> skuPriceDTOList;
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author small
* @Date 2023/5/19 19:55
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
//@ApiModel(value = "com.mmc.csf.model.dto.SkuPriceDTO", description = "sku价格信息DTO")
public class SkuPriceDTO implements Serializable {
private static final long serialVersionUID = 7304698187458849560L;
@ApiModelProperty(value = "sku价格表id")
private Integer id;
@ApiModelProperty(value = "商品id")
private Integer wareInfoId;
@ApiModelProperty(value = "sku表id")
private Integer skuInfoId;
@ApiModelProperty(value = "周期租金")
private BigDecimal rentPrice;
@ApiModelProperty(value = "起租天数")
private Integer minDay;
@ApiModelProperty(value = "截租天数")
private Integer maxDay;
@ApiModelProperty(value = "生成时间")
private Date createTime;
}
......@@ -19,7 +19,7 @@ import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "com.mmc.pms.model.dto.WareInfoItemDTO", description = "设备列表ItemDTO")
//@ApiModel(value = "com.mmc.pms.model.dto.WareInfoItemDTO", description = "设备列表ItemDTO")
public class WareInfoItemDTO implements Serializable {
private static final long serialVersionUID = -4354269497656808831L;
......
......@@ -180,4 +180,12 @@ public class WebDeviceServiceImpl implements WebDeviceService {
.collect(Collectors.toList());
return ResultBody.success(collect);
}
@Override
public List<SkuInfoDTO> listWareSkuById(Integer id) {
List<SkuInfoDO> skuInfoDOS = webDeviceDao.listSkuInfo(id);
return skuInfoDOS.isEmpty() ? null : skuInfoDOS.stream().map(d -> {
return d.buildSkuInfoDTO();
}).collect(Collectors.toList());
}
}
......@@ -3,9 +3,13 @@ package com.mmc.pms.service;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.dto.AdDTO;
import com.mmc.pms.model.dto.ModelDTO;
import com.mmc.pms.model.dto.SkuInfoDTO;
import com.mmc.pms.model.dto.WareInfoDTO;
import com.mmc.pms.model.qo.WareInfoQO;
import com.mmc.pms.model.vo.LeaseVo;
import com.mmc.pms.model.dto.SkuInfoDTO;
import java.util.List;
/**
* @Author small @Date 2023/5/15 14:28 @Version 1.0
......@@ -34,4 +38,6 @@ public interface WebDeviceService {
WareInfoDTO getWareInfoById(Integer id);
ResultBody<AdDTO> ad();
List<SkuInfoDTO> listWareSkuById(Integer id);
}
......@@ -93,7 +93,6 @@
select id, `name`
from device_model;
</select>
<select id="deviceList" resultType="com.mmc.pms.entity.DeviceListDO">
SELECT d.id,
d.`name` AS deviceName,
......@@ -250,5 +249,31 @@
FROM
device_ad
</select>
<resultMap type="com.mmc.pms.entity.SkuInfoDO"
id="skuInfoDoResultMap">
<id property="id" column="sku_info_id" />
<result property="wareInfoId" column="ware_info_id" />
<result property="skuTitle" column="sku_title" />
<result property="rentDeposit" column="rent_deposit" />
<result property="stockNum" column="stock_num" />
<result property="saleNum" column="sale_num" />
<result property="rentDeposit" column="rent_deposit" />
<result property="updateTime" column="update_time" />
<result property="createTime" column="create_time" />
<collection property="skuPriceDOList" javaType="java.util.List"
ofType="com.mmc.pms.entity.SkuPriceDO">
<id property="id" column="sku_price_id" />
<result property="wareInfoId" column="ware_info_id" />
<result property="skuInfoId" column="sku_info_id" />
<result property="rentPrice" column="rent_price" />
<result property="minDay" column="min_day" />
<result property="maxDay" column="max_day" />
</collection>
</resultMap>
<select id="listSkuInfo" resultMap="skuInfoDoResultMap" parameterType="java.lang.Integer">
select si.id as sku_info_id,si.ware_info_id,si.sku_title,si.rent_deposit,si.stock_num,si.sale_num,
si.create_time,si.update_time,sp.id as sku_price_id,sp.rent_price,sp.min_day,sp.max_day
from sku_info si INNER JOIN sku_price sp ON si.id=sp.sku_info_id where si.ware_info_id = #{id} and si.is_deleted = 0
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论