上下架+进货
parent
6894770e6f
commit
7757177af6
|
@ -1,8 +1,17 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliEqualsAvoidNull" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliMissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliWrapperTypeEquality" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,com.github.pagehelper.page.PageMethod,startPage" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
|
@ -11,6 +11,8 @@ import lombok.ToString;
|
|||
@ToString
|
||||
public class VOGoods {
|
||||
|
||||
//商品设备中间id
|
||||
private Integer goodsId;
|
||||
//商品id
|
||||
private Integer shopId;
|
||||
//设备id
|
||||
|
|
|
@ -33,7 +33,30 @@ public class GoodsController {
|
|||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/topShop")
|
||||
public Result topShop(@RequestBody VOGoods voGoods){
|
||||
log.info("功能名称:[上架],请求URI:{},请求方式:{},请求参数:{}",
|
||||
request.getRequestURI(),request.getMethod(),voGoods);
|
||||
Result result = goodsService.topShop(voGoods);
|
||||
log.info("功能名称:[上架],请求URI:{},请求方式:{},响应结果:{}",
|
||||
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/bottomShop")
|
||||
public Result bottomShop(@RequestBody VOGoods voGoods){
|
||||
log.info("功能名称:[下架],请求URI:{},请求方式:{},请求参数:{}",
|
||||
request.getRequestURI(),request.getMethod(),voGoods);
|
||||
Result result = goodsService.bottomShop(voGoods);
|
||||
log.info("功能名称:[下架],请求URI:{},请求方式:{},响应结果:{}",
|
||||
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/addGoodsNum")
|
||||
public Result addGoodsNum(@RequestBody VOGoods voGoods){
|
||||
return goodsService.addGoodsNum(voGoods);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,26 @@
|
|||
package com.bwie.list.mapper;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOGoods;
|
||||
import com.bwie.common.pojo.Goods;
|
||||
import com.bwie.common.pojo.VO.VOGoods;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface GoodsMapper {
|
||||
List<DTOGoods> goodsList(VOGoods voGoods);
|
||||
|
||||
Goods findShopId(Integer shopId, Integer facilityId);
|
||||
|
||||
Integer addGoods(VOGoods voGoods);
|
||||
|
||||
Integer changeGoodsState(@Param("goodsId") Integer goodsId);
|
||||
|
||||
Integer updateGoodsState(@Param("goodsId") Integer goodsId);
|
||||
|
||||
|
||||
Integer changeGoodsNum(VOGoods voGoods);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,4 +5,10 @@ import com.bwie.common.result.Result;
|
|||
|
||||
public interface GoodsService {
|
||||
Result goodsList(VOGoods voGoods);
|
||||
|
||||
Result topShop(VOGoods voGoods);
|
||||
|
||||
Result bottomShop(VOGoods voGoods);
|
||||
|
||||
Result addGoodsNum(VOGoods voGoods);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.bwie.list.service.impl;
|
||||
|
||||
import com.bwie.common.pojo.DTO.DTOGoods;
|
||||
import com.bwie.common.pojo.Goods;
|
||||
import com.bwie.common.pojo.VO.VOGoods;
|
||||
import com.bwie.common.result.Result;
|
||||
import com.bwie.list.mapper.GoodsMapper;
|
||||
|
@ -28,4 +29,57 @@ public class GoodsServiceImpl implements GoodsService {
|
|||
|
||||
return Result.success(info,"商品设备中间表");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result topShop(VOGoods voGoods) {
|
||||
|
||||
Goods goods = goodsMapper.findShopId(voGoods.getShopId(),voGoods.getFacilityId());
|
||||
if (goods==null){
|
||||
Integer i = goodsMapper.addGoods(voGoods);
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"上架成功");
|
||||
}
|
||||
} else {
|
||||
if (goods.getGoodsIsDelete() == 0){
|
||||
Integer i = goodsMapper.changeGoodsState(goods.getGoodsId());
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"上架成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result.error("商品已上架不能重复上架哦~~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result bottomShop(VOGoods voGoods) {
|
||||
Goods goods = goodsMapper.findShopId(voGoods.getShopId(),voGoods.getFacilityId());
|
||||
if (goods==null){
|
||||
|
||||
return Result.error("商品还未上架");
|
||||
|
||||
}else {
|
||||
|
||||
if (goods.getGoodsIsDelete()==1){
|
||||
Integer i = goodsMapper.updateGoodsState(goods.getGoodsId());
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"下架成功");
|
||||
}else {
|
||||
return Result.error("下架失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Result.error("商品已经下架");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addGoodsNum(VOGoods voGoods) {
|
||||
Integer i = goodsMapper.changeGoodsNum(voGoods);
|
||||
if (i>0){
|
||||
return Result.success(voGoods,"进货成功");
|
||||
}
|
||||
return Result.error("进货失败");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
通过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>
|
||||
|
@ -23,6 +23,23 @@
|
|||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<!-- 添加中间表 -->
|
||||
<insert id="addGoods">
|
||||
INSERT INTO `shop_manage`.`t_goods` (`shop_id`, `facility_id`, `goods_num`, `goods_isdelete`)
|
||||
VALUES (#{shopId}, #{facilityId}, NULL, 1)
|
||||
</insert>
|
||||
<!-- 上架修改状态 -->
|
||||
<update id="changeGoodsState">
|
||||
UPDATE `shop_manage`.`t_goods` SET `goods_isdelete` = 1 WHERE `goods_id` = #{goodsId}
|
||||
</update>
|
||||
<!-- 下架修改状态 -->
|
||||
<update id="updateGoodsState">
|
||||
UPDATE `shop_manage`.`t_goods` SET `goods_isdelete` = 0 WHERE `goods_id` = #{goodsId}
|
||||
</update>
|
||||
<!-- 修改库存数 -->
|
||||
<update id="changeGoodsNum">
|
||||
UPDATE `shop_manage`.`t_goods` SET `goods_num` = (`goods_num` + #{goodsNum}) WHERE `goods_id` = #{goodsId}
|
||||
</update>
|
||||
|
||||
<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,
|
||||
|
@ -33,10 +50,15 @@
|
|||
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>
|
||||
and g.goods_isdelete = 1
|
||||
<if test="facilityId != null">
|
||||
and facility_id = #{facilityId}
|
||||
and g.facility_id = #{facilityId}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY g.goods_id
|
||||
</select>
|
||||
<select id="findShopId" resultType="com.bwie.common.pojo.Goods">
|
||||
SELECT * FROM t_goods WHERE shop_id=#{shopId} and facility_id=#{facilityId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue