提交 94d4d153 作者: 张小凤

WebProduct

上级 c9dc5daa
package com.mmc.pms.controller;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.vo.LeaseVo;
import com.mmc.pms.service.WebDeviceService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Author small
* @Date 2023/5/15 13:24
* @Version 1.0
* @Author small @Date 2023/5/15 13:24 @Version 1.0
*/
@Api(tags = {"小程序设备租赁-接口"})
@RestController
@RequestMapping("/appDevice")
public class MiniProgramDeviceController {
@Autowired private WebDeviceService webDeviceService;
@ApiOperation(value = "地域")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/getSecondDistrictInfo")
public ResultBody getSecondDistrictInfo() {
return webDeviceService.listSecondDistrict();
}
@ApiOperation("设备类目")
@GetMapping("/category")
public ResultBody category() {
return webDeviceService.category();
}
@ApiOperation("品牌")
@GetMapping("/brand")
public ResultBody brand() {
return webDeviceService.brand();
}
@ApiOperation("型号")
@GetMapping("/model")
public ResultBody model() {
return webDeviceService.model();
}
@ApiOperation(value = "设备列表筛选")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/deviceList")
public ResultBody deviceList(
@RequestParam(value = "districtId", required = false) Integer districtId,
@RequestParam(value = "categoryId", required = false) Integer categoryId,
@RequestParam(value = "brandId", required = false) Integer brandId,
@RequestParam(value = "modelId", required = false) Integer modelId) {
return webDeviceService.deviceList(districtId, categoryId, brandId, modelId);
}
@ApiOperation(value = "设备详情")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/detail")
public ResultBody detail(@RequestParam(value = "id", required = true) Integer id) {
return webDeviceService.detail(id);
}
@ApiOperation(value = "立即租赁")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/update")
public ResultBody update(@RequestBody LeaseVo param) {
return webDeviceService.update(param);
}
}
......@@ -15,12 +15,12 @@ import org.springframework.web.bind.annotation.*;
*/
@Api(tags = {"web设备租赁-接口"})
@RestController
@RequestMapping("/webProductMall")
@RequestMapping("/webDevice")
public class WebDeviceController {
@Autowired private WebDeviceService webDeviceService;
@ApiOperation(value = "获取到二级地区信息——设备租赁/产品商城接口共用")
@ApiOperation(value = "地域")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/getSecondDistrictInfo")
public ResultBody getSecondDistrictInfo() {
......@@ -56,6 +56,13 @@ public class WebDeviceController {
return webDeviceService.deviceList(districtId, categoryId, brandId, modelId);
}
@ApiOperation(value = "设备详情")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/detail")
public ResultBody detail(@RequestParam(value = "id", required = true) Integer id) {
return webDeviceService.detail(id);
}
@ApiOperation(value = "立即租赁")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/update")
......
package com.mmc.pms.controller;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.service.WebProductMallService;
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.RestController;
/**
* @Author small
* @Date 2023/5/15 13:24
* @Version 1.0
* @Author small @Date 2023/5/15 13:24 @Version 1.0
*/
@Api(tags = {"web产品商城-接口"})
@RestController
@RequestMapping("/userwechat/")
@RequestMapping("/webProductMall")
public class WebProductMallController {
@Autowired private WebProductMallService webProductMallService;
@ApiOperation("产品类目")
@GetMapping("/category")
public ResultBody productCategory() {
return webProductMallService.productCategory();
}
@ApiOperation("产品部件")
@GetMapping("/parts")
public ResultBody productParts() {
return webProductMallService.productParts();
}
@ApiOperation("产品成色")
@GetMapping("/quality")
public ResultBody productQuality() {
return webProductMallService.productQuality();
}
}
......@@ -25,4 +25,6 @@ public interface WebDeviceDao {
int update(LeaseVo param);
InventoryDO findInventory(Integer inventoryId);
DeviceListDO detail(Integer id);
}
package com.mmc.pms.dao;
import com.mmc.pms.entity.ProductCategory;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author small @Date 2023/5/15 20:11 @Version 1.0
*/
@Mapper
public interface WebProductMallDao {
List<ProductCategory> productCategory();
List<ProductCategory> productParts();
List<ProductCategory> productQuality();
}
package com.mmc.pms.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mmc.pms.model.dto.DeviceCategoryDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -10,7 +9,6 @@ import lombok.Data;
* @Author small @Date 2023/5/15 15:03 @Version 1.0
*/
@Data
@TableName("device_category")
@ApiModel("设备类目")
public class DeviceCategory extends BaseEntity {
@ApiModelProperty("1")
......
......@@ -20,6 +20,7 @@ public class DeviceListDO {
private String deviceCategoryName;
private Integer residueCount;
private Integer inventoryId;
private String appraise;
public DeviceListDTO deviceListDTO() {
return DeviceListDTO.builder()
......@@ -33,6 +34,7 @@ public class DeviceListDO {
.deviceCategoryName(this.deviceCategoryName)
.residueCount(this.residueCount)
.inventoryId(this.inventoryId)
.appraise(this.appraise)
.build();
}
}
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.ProductCategoryDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author small @Date 2023/5/15 20:26 @Version 1.0
*/
@Data
@ApiModel("产品类目")
public class ProductCategory {
@ApiModelProperty("1")
private Integer id;
@ApiModelProperty("产品名称")
private String name;
public ProductCategoryDTO productCategoryDTO() {
return ProductCategoryDTO.builder().id(this.id).name(this.name).build();
}
}
......@@ -14,33 +14,36 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
public class DeviceListDTO {
@ApiModelProperty(name = "设备id")
@ApiModelProperty(value = "设备id")
private Integer id;
@ApiModelProperty(name = "设备名称")
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(name = "设备图片地址")
@ApiModelProperty(value = "设备图片地址")
private String imageUrl;
@ApiModelProperty("价格")
@ApiModelProperty(value = "价格")
private String price;
@ApiModelProperty("品牌名称")
@ApiModelProperty(value = "品牌名称")
private String brandName;
@ApiModelProperty("地域名称")
@ApiModelProperty(value = "地域名称")
private String sysDistrictName;
@ApiModelProperty("型号名称")
@ApiModelProperty(value = "型号名称")
private String modelName;
@ApiModelProperty("类目名称")
@ApiModelProperty(value = "类目名称")
private String deviceCategoryName;
@ApiModelProperty("剩余库存数量")
@ApiModelProperty(value = "剩余库存数量")
private Integer residueCount;
@ApiModelProperty("库存id")
@ApiModelProperty(value = "库存id")
private Integer inventoryId;
@ApiModelProperty(value = "评价")
private String appraise;
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author small @Date 2023/5/15 20:27 @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProductCategoryDTO {
@ApiModelProperty("1")
private Integer id;
@ApiModelProperty("产品名称")
private String name;
}
......@@ -96,4 +96,11 @@ public class WebDeviceServiceImpl implements WebDeviceService {
int update = webDeviceDao.update(param);
return ResultBody.success(update);
}
@Override
public ResultBody detail(Integer id) {
DeviceListDO detail = webDeviceDao.detail(id);
DeviceListDTO deviceListDTO = detail.deviceListDTO();
return ResultBody.success(deviceListDTO);
}
}
package com.mmc.pms.service.Impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.dao.WebProductMallDao;
import com.mmc.pms.entity.ProductCategory;
import com.mmc.pms.model.dto.ProductCategoryDTO;
import com.mmc.pms.service.WebProductMallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author small @Date 2023/5/15 20:08 @Version 1.0
*/
@Service
public class WebProductMallServiceImpl implements WebProductMallService {
@Autowired private WebProductMallDao webProductMallDao;
@Override
public ResultBody productCategory() {
List<ProductCategory> category = webProductMallDao.productCategory();
List<ProductCategoryDTO> collect =
category.stream()
.map(
t -> {
return t.productCategoryDTO();
})
.collect(Collectors.toList());
return ResultBody.success(collect);
}
@Override
public ResultBody productParts() {
List<ProductCategory> category = webProductMallDao.productParts();
List<ProductCategoryDTO> collect =
category.stream()
.map(
t -> {
return t.productCategoryDTO();
})
.collect(Collectors.toList());
return ResultBody.success(collect);
}
@Override
public ResultBody productQuality() {
List<ProductCategory> category = webProductMallDao.productQuality();
List<ProductCategoryDTO> collect =
category.stream()
.map(
t -> {
return t.productCategoryDTO();
})
.collect(Collectors.toList());
return ResultBody.success(collect);
}
}
......@@ -18,4 +18,6 @@ public interface WebDeviceService {
ResultBody deviceList(Integer districtId, Integer categoryId, Integer brandId, Integer modelId);
ResultBody update(LeaseVo param);
ResultBody detail(Integer id);
}
package com.mmc.pms.service;
import com.mmc.pms.common.ResultBody;
/**
* @Author small @Date 2023/5/15 20:08 @Version 1.0
*/
public interface WebProductMallService {
ResultBody productCategory();
ResultBody productParts();
ResultBody productQuality();
}
......@@ -57,7 +57,8 @@
m.`name` AS modelName,
dc.`name` AS deviceCategoryName,
i.residue_count AS residueCount,
i.id as inventoryId
i.id as inventoryId,
d.appraise
FROM device d
LEFT JOIN brand b ON d.brand_id = b.id
LEFT JOIN sys_district sd ON d.sys_district_id = sd.id
......@@ -88,4 +89,25 @@
select id, all_count AS allCount, residue_count AS residueCount
from inventory
</select>
<select id="detail" resultType="com.mmc.pms.entity.DeviceListDO">
SELECT d.id,
d.`name` AS deviceName,
d.image_url AS imageUrl,
d.price,
b.`name` AS brandName,
sd.`name` AS sysDistrictName,
m.`name` AS modelName,
dc.`name` AS deviceCategoryName,
i.residue_count AS residueCount,
i.id as inventoryId,
d.appraise
FROM device d
LEFT JOIN brand b ON d.brand_id = b.id
LEFT JOIN sys_district sd ON d.sys_district_id = sd.id
LEFT JOIN model m ON m.id = d.model_id
LEFT JOIN device_category dc ON dc.id = d.device_category_id
LEFT JOIN inventory i ON i.id = d.inventory_id
WHERE d.id = #{id}
</select>
</mapper>
<?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.mmc.pms.dao.WebProductMallDao">
<select id="productCategory" resultType="com.mmc.pms.entity.ProductCategory">
select id, `name`
from product_category;
</select>
<select id="productParts" resultType="com.mmc.pms.entity.ProductCategory">
select id, `name`
from product_parts;
</select>
<select id="productQuality" resultType="com.mmc.pms.entity.ProductCategory">
select id, `name`
from product_quality;
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论