展示商品设备表

pull/3/head
ASUS 2023-12-18 21:28:27 +08:00
parent b1cc202f06
commit b7e8563b10
10 changed files with 292 additions and 4 deletions

View File

@ -0,0 +1,49 @@
package com.bwie.common.pojo.DTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class DTOGoods {
//商品设备中间id
private Integer goodsId;
//商品id
private Integer shopId;
//商品名称
private String shopName;
//商品价格
private double shopPrice;
//商品类型id
private Integer typeId;
//商品类型名称
private String typeName;
//图片
private List<String> pictureUrl;
//设备id
private Integer facilityId;
//设备类型
private String facilityType;
//设备地址
private String facilitySite;
//库存
private Integer goodsNum;
//上下架(逻辑字段: 0上架, 1下架)
private Integer goodsIsDelete;
}

View File

@ -0,0 +1,33 @@
package com.bwie.common.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Facility {
//设备编号
private Integer facilityId;
//设备类型
private String facilityType;
//设备地址
private String facilitySite;
//补货员工
private Integer replenishmentUserId;
//维修员工
private Integer maintainUserId;
//设备状态
private Integer facilityStatic;
//删除状态
private Integer delId;
}

View File

@ -0,0 +1,28 @@
package com.bwie.common.pojo.VO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class VOGoods {
//商品id
private Integer shopId;
//设备id
private Integer facilityId;
//库存
private Integer goodsNum;
//上下架(逻辑字段: 0上架, 1下架)
private Integer goodsIsDelete;
//分页
private Integer pageNum=1;
private Integer pageSize=3;
}

View File

@ -0,0 +1,39 @@
package com.bwie.list.controller;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.pojo.VO.VOGoods;
import com.bwie.common.result.Result;
import com.bwie.list.service.GoodsService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@Log4j2
public class GoodsController {
@Autowired
private GoodsService goodsService;
@Autowired
private HttpServletRequest request;
@PostMapping("/goodsList")
public Result goodsList(@RequestBody VOGoods voGoods){
log.info("功能名称:[查询商品设备表],请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),voGoods);
Result result = goodsService.goodsList(voGoods);
log.info("功能名称:[查询商品设备表],请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -1,5 +1,6 @@
package com.bwie.list.controller;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.pojo.VO.VOShop;
import com.bwie.common.result.Result;
import com.bwie.list.service.ShopService;
@ -8,27 +9,56 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
@RestController
@Log4j2
public class ShopController {
@Autowired
private ShopService shopService;
@Autowired
private HttpServletRequest request;
//展示商品列表
@PostMapping("/shopList")
public Result shopList(@RequestBody VOShop voShop){
return shopService.shopList(voShop);
log.info("功能名称:[展示商品列表],请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),voShop);
Result result = shopService.shopList(voShop);
log.info("功能名称:[展示商品列表],请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
//上传图片
@PostMapping("/upImg")
public Result upImg(@RequestParam("file")MultipartFile myFile){
return shopService.upImg(myFile);
log.info("功能名称:[上传图片],请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),myFile);
Result result = shopService.upImg(myFile);
log.info("功能名称:[上传图片],请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
//添加商品
@PostMapping("/addShop")
public Result addShop(@RequestBody VOShop shop){
return shopService.addShop(shop);
log.info("功能名称:[新增商品],请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),shop);
Result result = shopService.addShop(shop);
log.info("功能名称:[新增商品],请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -1,20 +1,36 @@
package com.bwie.list.controller;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.result.Result;
import com.bwie.list.service.TypeService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@Log4j2
public class TypeController {
@Autowired
private TypeService typeService;
@Autowired
private HttpServletRequest request;
// 根据商品类型查询商品的商品类型菜单栏
@GetMapping("/findType")
public Result findType(){
return typeService.findType();
log.info("功能名称:[类型菜单栏],请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),"");
Result result = typeService.findType();
log.info("功能名称:[类型菜单栏],请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -0,0 +1,12 @@
package com.bwie.list.mapper;
import com.bwie.common.pojo.DTO.DTOGoods;
import com.bwie.common.pojo.VO.VOGoods;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface GoodsMapper {
List<DTOGoods> goodsList(VOGoods voGoods);
}

View File

@ -0,0 +1,8 @@
package com.bwie.list.service;
import com.bwie.common.pojo.VO.VOGoods;
import com.bwie.common.result.Result;
public interface GoodsService {
Result goodsList(VOGoods voGoods);
}

View File

@ -0,0 +1,31 @@
package com.bwie.list.service.impl;
import com.bwie.common.pojo.DTO.DTOGoods;
import com.bwie.common.pojo.VO.VOGoods;
import com.bwie.common.result.Result;
import com.bwie.list.mapper.GoodsMapper;
import com.bwie.list.service.GoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GoodsServiceImpl implements GoodsService {
@Autowired
private GoodsMapper goodsMapper;
@Override
public Result goodsList(VOGoods voGoods) {
PageHelper.startPage(voGoods.getPageNum(), voGoods.getPageSize());
List<DTOGoods> dtoGoodsList = goodsMapper.goodsList(voGoods);
PageInfo<DTOGoods> info = new PageInfo<>(dtoGoodsList);
return Result.success(info,"商品设备中间表");
}
}

View File

@ -0,0 +1,42 @@
<?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">
<!--
1.在mybats的开发中namespace有特殊的意思一定要是对应接口的全限定名
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
-->
<mapper namespace="com.bwie.list.mapper.GoodsMapper">
<!-- 添加 -->
<resultMap id="map" type="com.bwie.common.pojo.DTO.DTOGoods">
<id property="goodsId" column="goods_id"></id>
<result property="goodsNum" column="goods_num"></result>
<result property="goodsIsDelete" column="goods_isdelete"></result>
<result property="shopId" column="shop_id"></result>
<result property="shopPrice" column="shop_price"></result>
<result property="shopName" column="shop_name"></result>
<result property="typeId" column="type_id"></result>
<result property="typeName" column="type_name"></result>
<result property="facilityId" column="facility_id"></result>
<result property="facilityType" column="facility_type"></result>
<result property="facilitySite" column="facility_site"></result>
<collection property="pictureUrl" ofType="java.lang.String">
<result column="picture_url"></result>
</collection>
</resultMap>
<select id="goodsList" resultMap="map">
SELECT g.goods_id,g.shop_id,s.shop_name,s.shop_price,s.type_id,t.type_name,p.picture_url,
g.facility_id,f.facility_type,f.facility_site,g.goods_num,g.goods_isdelete
FROM t_goods g
LEFT JOIN t_shop s on g.shop_id = s.shop_id
LEFT JOIN t_type t on s.type_id=t.type_id
LEFT JOIN t_picture p on s.shop_id = p.shop_id
LEFT JOIN t_facility f on g.facility_id = f.facility_id
<where>
<if test="facilityId != null">
and facility_id = #{facilityId}
</if>
</where>
ORDER BY g.goods_id
</select>
</mapper>