商品上架管理

This commit is contained in:
sxu 2025-06-03 09:29:51 +08:00
parent b1cd6849e9
commit 70aa1c50fa
6 changed files with 530 additions and 0 deletions

View File

@ -0,0 +1,119 @@
package com.bonus.canteen.core.supermarket.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
//import com.bonus.canteen.core.supermarket.common.annotation.PreventRepeatSubmit;
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.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
import com.bonus.canteen.core.supermarket.service.ISupermarketProductService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;
/**
* 超市商城商品Controller
*
* @author xsheng
* @date 2025-06-03
*/
@Api(tags = "超市商城商品接口")
@RestController
@RequestMapping("/supermarket_product")
public class SupermarketProductController extends BaseController {
@Autowired
private ISupermarketProductService supermarketProductService;
/**
* 查询超市商城商品列表
*/
@ApiOperation(value = "查询超市商城商品列表")
//@RequiresPermissions("supermarket:product:list")
@GetMapping("/list")
public TableDataInfo list(SupermarketProduct supermarketProduct) {
startPage();
List<SupermarketProduct> list = supermarketProductService.selectSupermarketProductList(supermarketProduct);
return getDataTable(list);
}
/**
* 导出超市商城商品列表
*/
@ApiOperation(value = "导出超市商城商品列表")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:export")
@SysLog(title = "超市商城商品", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出超市商城商品")
@PostMapping("/export")
public void export(HttpServletResponse response, SupermarketProduct supermarketProduct) {
List<SupermarketProduct> list = supermarketProductService.selectSupermarketProductList(supermarketProduct);
ExcelUtil<SupermarketProduct> util = new ExcelUtil<SupermarketProduct>(SupermarketProduct.class);
util.exportExcel(response, list, "超市商城商品数据");
}
/**
* 获取超市商城商品详细信息
*/
@ApiOperation(value = "获取超市商城商品详细信息")
//@RequiresPermissions("supermarket:product:query")
@GetMapping(value = "/{productId}")
public AjaxResult getInfo(@PathVariable("productId") Long productId) {
return success(supermarketProductService.selectSupermarketProductByProductId(productId));
}
/**
* 新增超市商城商品
*/
@ApiOperation(value = "新增超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:add")
@SysLog(title = "超市商城商品", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增超市商城商品")
@PostMapping
public AjaxResult add(@RequestBody SupermarketProduct supermarketProduct) {
try {
return toAjax(supermarketProductService.insertSupermarketProduct(supermarketProduct));
} catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 修改超市商城商品
*/
@ApiOperation(value = "修改超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:edit")
@SysLog(title = "超市商城商品", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改超市商城商品")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody SupermarketProduct supermarketProduct) {
try {
return toAjax(supermarketProductService.updateSupermarketProduct(supermarketProduct));
} catch (Exception e) {
return error(e.getMessage());
}
}
/**
* 删除超市商城商品
*/
@ApiOperation(value = "删除超市商城商品")
//@PreventRepeatSubmit
//@RequiresPermissions("supermarket:product:remove")
@SysLog(title = "超市商城商品", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除超市商城商品")
@PostMapping("/del/{productIds}")
public AjaxResult remove(@PathVariable Long[] productIds) {
return toAjax(supermarketProductService.deleteSupermarketProductByProductIds(productIds));
}
}

View File

@ -0,0 +1,77 @@
package com.bonus.canteen.core.supermarket.domain;
import java.math.BigDecimal;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
/**
* 超市商城商品对象 supermarket_product
*
* @author xsheng
* @date 2025-06-03
*/
@Data
@ToString
public class SupermarketProduct extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 商城商品明细id */
private Long productId;
/** 超市id */
@Excel(name = "超市id")
@ApiModelProperty(value = "超市id")
private Long supermarketId;
/** 商品id */
@Excel(name = "商品id")
@ApiModelProperty(value = "商品id")
private Long materialId;
/** 上架状态(1-上架,2-下架) */
@Excel(name = "上架状态(1-上架,2-下架)")
@ApiModelProperty(value = "上架状态(1-上架,2-下架)")
private Long putawayState;
/** 是否线上销售(1是2否) */
@Excel(name = "是否线上销售(1是2否)")
@ApiModelProperty(value = "是否线上销售(1是2否)")
private Long ifOnline;
/** 销售价 */
@Excel(name = "销售价")
@ApiModelProperty(value = "销售价")
private Long salePrice;
/** 优惠价 */
@Excel(name = "优惠价")
@ApiModelProperty(value = "优惠价")
private Long prefPrice;
/** 个人限购数量 */
@Excel(name = "个人限购数量")
@ApiModelProperty(value = "个人限购数量")
private Long personLimit;
/** 每日限购数量 */
@Excel(name = "每日限购数量")
@ApiModelProperty(value = "每日限购数量")
private Long oneDayLimit;
/** 图片 */
@Excel(name = "图片")
@ApiModelProperty(value = "图片")
private String imgUrl;
/** 库存数 */
@Excel(name = "库存数")
@ApiModelProperty(value = "库存数")
private BigDecimal inventoryNum;
}

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.supermarket.mapper;
import java.util.List;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
/**
* 超市商城商品Mapper接口
*
* @author xsheng
* @date 2025-06-03
*/
public interface SupermarketProductMapper {
/**
* 查询超市商城商品
*
* @param productId 超市商城商品主键
* @return 超市商城商品
*/
public SupermarketProduct selectSupermarketProductByProductId(Long productId);
/**
* 查询超市商城商品列表
*
* @param supermarketProduct 超市商城商品
* @return 超市商城商品集合
*/
public List<SupermarketProduct> selectSupermarketProductList(SupermarketProduct supermarketProduct);
/**
* 新增超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int insertSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 修改超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int updateSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 删除超市商城商品
*
* @param productId 超市商城商品主键
* @return 结果
*/
public int deleteSupermarketProductByProductId(Long productId);
/**
* 批量删除超市商城商品
*
* @param productIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteSupermarketProductByProductIds(Long[] productIds);
}

View File

@ -0,0 +1,60 @@
package com.bonus.canteen.core.supermarket.service;
import java.util.List;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
/**
* 超市商城商品Service接口
*
* @author xsheng
* @date 2025-06-03
*/
public interface ISupermarketProductService {
/**
* 查询超市商城商品
*
* @param productId 超市商城商品主键
* @return 超市商城商品
*/
public SupermarketProduct selectSupermarketProductByProductId(Long productId);
/**
* 查询超市商城商品列表
*
* @param supermarketProduct 超市商城商品
* @return 超市商城商品集合
*/
public List<SupermarketProduct> selectSupermarketProductList(SupermarketProduct supermarketProduct);
/**
* 新增超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int insertSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 修改超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
public int updateSupermarketProduct(SupermarketProduct supermarketProduct);
/**
* 批量删除超市商城商品
*
* @param productIds 需要删除的超市商城商品主键集合
* @return 结果
*/
public int deleteSupermarketProductByProductIds(Long[] productIds);
/**
* 删除超市商城商品信息
*
* @param productId 超市商城商品主键
* @return 结果
*/
public int deleteSupermarketProductByProductId(Long productId);
}

View File

@ -0,0 +1,98 @@
package com.bonus.canteen.core.supermarket.service.impl;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
import com.bonus.canteen.core.supermarket.service.ISupermarketProductService;
/**
* 超市商城商品Service业务层处理
*
* @author xsheng
* @date 2025-06-03
*/
@Service
public class SupermarketProductServiceImpl implements ISupermarketProductService {
@Autowired
private SupermarketProductMapper supermarketProductMapper;
/**
* 查询超市商城商品
*
* @param productId 超市商城商品主键
* @return 超市商城商品
*/
@Override
public SupermarketProduct selectSupermarketProductByProductId(Long productId) {
return supermarketProductMapper.selectSupermarketProductByProductId(productId);
}
/**
* 查询超市商城商品列表
*
* @param supermarketProduct 超市商城商品
* @return 超市商城商品
*/
@Override
public List<SupermarketProduct> selectSupermarketProductList(SupermarketProduct supermarketProduct) {
return supermarketProductMapper.selectSupermarketProductList(supermarketProduct);
}
/**
* 新增超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
@Override
public int insertSupermarketProduct(SupermarketProduct supermarketProduct) {
supermarketProduct.setCreateTime(DateUtils.getNowDate());
try {
return supermarketProductMapper.insertSupermarketProduct(supermarketProduct);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* 修改超市商城商品
*
* @param supermarketProduct 超市商城商品
* @return 结果
*/
@Override
public int updateSupermarketProduct(SupermarketProduct supermarketProduct) {
supermarketProduct.setUpdateTime(DateUtils.getNowDate());
try {
return supermarketProductMapper.updateSupermarketProduct(supermarketProduct);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* 批量删除超市商城商品
*
* @param productIds 需要删除的超市商城商品主键
* @return 结果
*/
@Override
public int deleteSupermarketProductByProductIds(Long[] productIds) {
return supermarketProductMapper.deleteSupermarketProductByProductIds(productIds);
}
/**
* 删除超市商城商品信息
*
* @param productId 超市商城商品主键
* @return 结果
*/
@Override
public int deleteSupermarketProductByProductId(Long productId) {
return supermarketProductMapper.deleteSupermarketProductByProductId(productId);
}
}

View File

@ -0,0 +1,116 @@
<?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.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper">
<resultMap type="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" id="SupermarketProductResult">
<result property="productId" column="product_id" />
<result property="supermarketId" column="supermarket_id" />
<result property="materialId" column="material_id" />
<result property="putawayState" column="putaway_state" />
<result property="ifOnline" column="if_online" />
<result property="salePrice" column="sale_price" />
<result property="prefPrice" column="pref_price" />
<result property="personLimit" column="person_limit" />
<result property="oneDayLimit" column="one_day_limit" />
<result property="imgUrl" column="img_url" />
<result property="inventoryNum" column="inventory_num" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectSupermarketProductVo">
select product_id, supermarket_id, material_id, putaway_state, if_online, sale_price, pref_price, person_limit, one_day_limit, img_url, inventory_num, create_by, create_time, update_by, update_time from supermarket_product
</sql>
<select id="selectSupermarketProductList" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
<where>
<if test="supermarketId != null "> and supermarket_id = #{supermarketId}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="putawayState != null "> and putaway_state = #{putawayState}</if>
<if test="ifOnline != null "> and if_online = #{ifOnline}</if>
<if test="salePrice != null "> and sale_price = #{salePrice}</if>
<if test="prefPrice != null "> and pref_price = #{prefPrice}</if>
<if test="personLimit != null "> and person_limit = #{personLimit}</if>
<if test="oneDayLimit != null "> and one_day_limit = #{oneDayLimit}</if>
<if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
<if test="inventoryNum != null "> and inventory_num = #{inventoryNum}</if>
</where>
</select>
<select id="selectSupermarketProductByProductId" parameterType="Long" resultMap="SupermarketProductResult">
<include refid="selectSupermarketProductVo"/>
where product_id = #{productId}
</select>
<insert id="insertSupermarketProduct" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" useGeneratedKeys="true" keyProperty="productId">
insert into supermarket_product
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="supermarketId != null">supermarket_id,</if>
<if test="materialId != null">material_id,</if>
<if test="putawayState != null">putaway_state,</if>
<if test="ifOnline != null">if_online,</if>
<if test="salePrice != null">sale_price,</if>
<if test="prefPrice != null">pref_price,</if>
<if test="personLimit != null">person_limit,</if>
<if test="oneDayLimit != null">one_day_limit,</if>
<if test="imgUrl != null">img_url,</if>
<if test="inventoryNum != null">inventory_num,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="supermarketId != null">#{supermarketId},</if>
<if test="materialId != null">#{materialId},</if>
<if test="putawayState != null">#{putawayState},</if>
<if test="ifOnline != null">#{ifOnline},</if>
<if test="salePrice != null">#{salePrice},</if>
<if test="prefPrice != null">#{prefPrice},</if>
<if test="personLimit != null">#{personLimit},</if>
<if test="oneDayLimit != null">#{oneDayLimit},</if>
<if test="imgUrl != null">#{imgUrl},</if>
<if test="inventoryNum != null">#{inventoryNum},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateSupermarketProduct" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct">
update supermarket_product
<trim prefix="SET" suffixOverrides=",">
<if test="supermarketId != null">supermarket_id = #{supermarketId},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="putawayState != null">putaway_state = #{putawayState},</if>
<if test="ifOnline != null">if_online = #{ifOnline},</if>
<if test="salePrice != null">sale_price = #{salePrice},</if>
<if test="prefPrice != null">pref_price = #{prefPrice},</if>
<if test="personLimit != null">person_limit = #{personLimit},</if>
<if test="oneDayLimit != null">one_day_limit = #{oneDayLimit},</if>
<if test="imgUrl != null">img_url = #{imgUrl},</if>
<if test="inventoryNum != null">inventory_num = #{inventoryNum},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where product_id = #{productId}
</update>
<delete id="deleteSupermarketProductByProductId" parameterType="Long">
delete from supermarket_product where product_id = #{productId}
</delete>
<delete id="deleteSupermarketProductByProductIds" parameterType="String">
delete from supermarket_product where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
</mapper>