diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/controller/SupermarketProductController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/controller/SupermarketProductController.java new file mode 100644 index 0000000..f703fd2 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/controller/SupermarketProductController.java @@ -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 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 list = supermarketProductService.selectSupermarketProductList(supermarketProduct); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/domain/SupermarketProduct.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/domain/SupermarketProduct.java new file mode 100644 index 0000000..29dc834 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/domain/SupermarketProduct.java @@ -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; + + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java new file mode 100644 index 0000000..a7f4edb --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java @@ -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 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); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/ISupermarketProductService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/ISupermarketProductService.java new file mode 100644 index 0000000..8dd3a6f --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/ISupermarketProductService.java @@ -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 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); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketProductServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketProductServiceImpl.java new file mode 100644 index 0000000..ce92ecd --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketProductServiceImpl.java @@ -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 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); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml new file mode 100644 index 0000000..c202325 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/supermarket/SupermarketProductMapper.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into supermarket_product + + 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, + + + #{supermarketId}, + #{materialId}, + #{putawayState}, + #{ifOnline}, + #{salePrice}, + #{prefPrice}, + #{personLimit}, + #{oneDayLimit}, + #{imgUrl}, + #{inventoryNum}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update supermarket_product + + supermarket_id = #{supermarketId}, + material_id = #{materialId}, + putaway_state = #{putawayState}, + if_online = #{ifOnline}, + sale_price = #{salePrice}, + pref_price = #{prefPrice}, + person_limit = #{personLimit}, + one_day_limit = #{oneDayLimit}, + img_url = #{imgUrl}, + inventory_num = #{inventoryNum}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where product_id = #{productId} + + + + delete from supermarket_product where product_id = #{productId} + + + + delete from supermarket_product where product_id in + + #{productId} + + + \ No newline at end of file