商品品牌,商品分类

master
miaoqingshuai 2026-01-22 14:28:30 +08:00
parent 4dfa2301df
commit b78ad98b8c
23 changed files with 609 additions and 80 deletions

View File

@ -8,10 +8,14 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.Brand;
import com.ruoyi.web.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
*/
@RestController
@RequestMapping("/mall/brand")
public class BrandController extends BaseController {
@ -25,9 +29,9 @@ public class BrandController extends BaseController {
* @return
*/
@Anonymous
@GetMapping("/tree")
public AjaxResult getBrandTree() {
return AjaxResult.success(brandService.getBrandTree());
@GetMapping(value = "/getTree/{storeId}")
public AjaxResult getBrandTree(@PathVariable String storeId) {
return AjaxResult.success(brandService.getBrandTree(storeId));
}
/**
@ -40,6 +44,10 @@ public class BrandController extends BaseController {
@Log(title = "商品品牌管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult addBrand(@RequestBody Brand brand) {
if (!brandService.checkBrandUnique(brand)) {
return error("新增商品品牌'" + brand.getBrandName() + "'失败,商品品牌名称已存在");
}
brand.setCreateBy(getUsername());
return toAjax(brandService.addBrand(brand));
}
@ -54,13 +62,21 @@ public class BrandController extends BaseController {
@Log(title = "商品品牌管理", businessType = BusinessType.UPDATE)
@PostMapping("/update")
public AjaxResult updateBrand(@RequestBody Brand brand) {
if (!brandService.checkBrandUnique(brand)) {
return error("修改商品品牌'" + brand.getBrandName() + "'失败,商品品牌名称已存在");
}
return toAjax(brandService.updateBrand(brand));
}
// 删除品牌
/**
*
*
* @param id
* @return
*/
@DeleteMapping("/delete/{id}")
public String deleteBrand(@PathVariable Long id) {
brandService.deleteBrand(id);
return "success";
@Log(title = "商品品牌管理", businessType = BusinessType.DELETE)
public AjaxResult deleteBrand(@PathVariable Long id) {
return toAjax(brandService.deleteBrand(id));
}
}

View File

@ -0,0 +1,80 @@
package com.ruoyi.web.controller;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.Classification;
import com.ruoyi.web.service.ClassIficationService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
*
*/
@RestController
@RequestMapping("/mall/classification")
public class ClassificationController extends BaseController {
@Resource
private ClassIficationService classIficationService;
/**
*
*
* @return
*/
@Anonymous
@GetMapping(value = "/getTree/{storeId}")
public AjaxResult getClassIficationTree(@PathVariable String storeId) {
return AjaxResult.success(classIficationService.getIficationTree(storeId));
}
/**
*
*
* @param classification
* @return
*/
@Anonymous
@Log(title = "商品分类管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult addClassIfication(@RequestBody Classification classification) {
if (!classIficationService.checkBrandUnique(classification)) {
return error("新增商品分类'" + classification.getClassificationName() + "'失败,商品分类名称已存在");
}
classification.setCreateBy(getUsername());
return toAjax(classIficationService.addClassification(classification));
}
/**
*
*
* @param classification
* @return
*/
@Anonymous
@Log(title = "商品分类管理", businessType = BusinessType.UPDATE)
@PostMapping("/update")
public AjaxResult updateClassIfication(@RequestBody Classification classification) {
if (!classIficationService.checkBrandUnique(classification)) {
return error("修改商品分类'" + classification.getClassificationName()+ "'失败,商品分类名称已存在");
}
return toAjax(classIficationService.updateClassification(classification));
}
/**
*
*
* @param id
* @return
*/
@DeleteMapping("/delete/{id}")
@Log(title = "商品分类管理", businessType = BusinessType.DELETE)
public AjaxResult deleteClassIfication(@PathVariable Long id) {
return toAjax(classIficationService.deleteClassIfication(id));
}
}

View File

@ -67,7 +67,6 @@ public class ProductStoreController extends BaseController {
}
/**
*
*/
@ -75,14 +74,17 @@ public class ProductStoreController extends BaseController {
@Log(title = "商品管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(@Validated Product product,
@RequestParam("file") MultipartFile file) throws IOException, InvalidExtensionException {
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, InvalidExtensionException {
if (!productService.checkProductCodeUnique(product)) {
return error("新增商品条码'" + product.getProductBarCode() + "'失败,商品条码已存在");
}
//todo 这里可以国码有的时候使用国码的图片路径
// TODO: 2026/1/14 这个file 为空的时候 就使用国码里面的图片,不为空代表用户自己选择了图片上传 用自己服务器上的
//国码后续添加
if (!file.isEmpty()) {
if (file != null) {
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION, true);
if (StringUtils.isNotEmpty(avatar)) {
product.setMainImage(avatar);
@ -101,22 +103,22 @@ public class ProductStoreController extends BaseController {
@Log(title = "商品管理", businessType = BusinessType.UPDATE)
@PostMapping("/update")
public AjaxResult edit(@Validated Product product,
@RequestParam("file") MultipartFile file) throws IOException, InvalidExtensionException {
@RequestParam(value = "file", required = false) MultipartFile file) throws IOException, InvalidExtensionException {
if (!productService.checkProductCodeUnique(product)) {
return error("修改商品条码'" + product.getProductBarCode() + "'失败,商品条码已存在");
}
//todo 这里可以国码有的时候使用国码的图片路径
// TODO: 2026/1/14 这个file 为空的时候 就使用国码里面的图片,不为空代表用户自己选择了图片上传 用自己服务器上的
//然后修改的时候 这个file不为空代表用户又修改了图片需要更新为空的话之前图片保持不变
if (!file.isEmpty()) {
if (file != null) {
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION, true);
if (StringUtils.isNotEmpty(avatar)) {
product.setMainImage(avatar);
}
}
//todo 这里可以国码有的时候使用国码的图片路径
product.setUpdateBy(getUsername());
return toAjax(productService.updateProduct(product));
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.web.controller;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@ -35,6 +36,15 @@ public class StoreController extends BaseController {
return getDataTable(list);
}
/**
* id
*/
@Anonymous
// @PreAuthorize("@ss.hasPermi('store:query')")
@GetMapping(value = "/{storeId}")
public AjaxResult getInfo(@PathVariable Long storeId) {
return success(storeService.selectStore(storeId));
}
/**
*
@ -74,6 +84,16 @@ public class StoreController extends BaseController {
return toAjax(storeService.updateStore(store));
}
/**
*
*/
@Anonymous
@Log(title = "门店管理", businessType = BusinessType.UPDATE)
@PutMapping("updateStatus")
public AjaxResult updateStatus(@Validated @RequestBody Store store) {
store.setUpdateBy(getUsername());
return toAjax(storeService.updateStatus(store));
}
/**
*
@ -88,6 +108,7 @@ public class StoreController extends BaseController {
/**
* id
*/
@Anonymous
// @PreAuthorize("@ss.hasPermi('product:query')")
@GetMapping(value = "/getUserStore/{userId}")
public AjaxResult getUserStore(@PathVariable String userId) {

View File

@ -0,0 +1,18 @@
package com.ruoyi.web.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.List;
@Data
public class Classification extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long id;
private Long parentId = 0L; // 0表示一级分类
private String classificationName; // 分类名称
private Integer storeId; //门店id
// 非数据库字段:子商品分类列表
private List<Classification> children;
}

View File

@ -55,6 +55,18 @@ public class Product extends BaseEntity {
@Excel(name = "商品条码")
private String productBarCode;
/**
*
*/
private String productBrand;
/**
*
*/
private String classifcation;
/**
*
*/

View File

@ -3,6 +3,8 @@ package com.ruoyi.web.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import javax.validation.constraints.Size;
/**
* mall_store
@ -49,6 +51,7 @@ public class Store extends BaseEntity {
/**
*
*/
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
private String contactPhone;
/**
@ -56,4 +59,6 @@ public class Store extends BaseEntity {
*/
private String storeManager;
private Integer status;
}

View File

@ -1,56 +1,34 @@
package com.ruoyi.web.mapper;
import com.ruoyi.web.domain.Brand;
import com.ruoyi.web.domain.Store;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface BrandMapper {
/**
*
*/
List<Brand> selectAll();
/**
* parentId=0
*/
List<Brand> selectRootBrands();
List<Brand> selectRootBrands(String storeId);
/**
* ID
*/
List<Brand> selectByParentId(@Param("parentId") Long parentId);
/**
* ID
*/
Brand selectById(@Param("id") Long id);
/**
*
*/
int insert(Brand brand);
/**
*
*/
int update(Brand brand);
/**
*
*/
int delete(@Param("id") Long id);
int batchBrand(Long id);
Store checkBrandUnique(Brand brand);
// /**
// * 检查是否有子品牌
// */
// int countChildren(@Param("parentId") Long parentId);
//
// /**
// * 根据品牌名称查询
// */
// Brand selectByName(@Param("brandName") String brandName);
}

View File

@ -0,0 +1,37 @@
package com.ruoyi.web.mapper;
import com.ruoyi.web.domain.Brand;
import com.ruoyi.web.domain.Classification;
import com.ruoyi.web.domain.Store;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface ClassIficationMapper {
List<Classification> selectRootBrands(String storeId);
List<Classification> selectByParentId(@Param("parentId") Long parentId);
Classification selectById(@Param("id") Long id);
int insert(Classification classification);
int update(Classification classification);
int delete(@Param("id") Long id);
int batchBrand(Long id);
Classification checkBrandUnique(Classification classification);
}

View File

@ -2,6 +2,8 @@ package com.ruoyi.web.mapper;
import com.ruoyi.web.domain.Store;
import com.ruoyi.web.vo.StoreVo;
import com.ruoyi.web.vo.UserStoreVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -29,4 +31,9 @@ public interface StoreMapper
void deleteStoreUser(Long storeId);
Store selectStore(Long storeId);
int updateStatus(Store store);
}

View File

@ -1,12 +1,17 @@
package com.ruoyi.web.mapper;
import com.ruoyi.web.vo.StoreVo;
import com.ruoyi.web.vo.UserStoreVo;
import java.util.List;
/**
*
*/
public interface UserStoreMapper {
UserStoreVo getUserStoreWithStores(String userId);
List<StoreVo> queryStore();
}

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface BrandService {
// 获取品牌树(一级品牌包含子品牌)
List<Brand> getBrandTree();
List<Brand> getBrandTree(String storeId);
// 添加品牌
int addBrand(Brand brand);
@ -15,6 +15,7 @@ public interface BrandService {
int updateBrand(Brand brand);
// 删除品牌
void deleteBrand(Long id);
int deleteBrand(Long id);
boolean checkBrandUnique(Brand brand);
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.web.service;
import com.ruoyi.web.domain.Classification;
import java.util.List;
public interface ClassIficationService {
List<Classification> getIficationTree(String storeId);
int addClassification(Classification classification);
int updateClassification(Classification classification);
int deleteClassIfication(Long id);
boolean checkBrandUnique(Classification classification);
}

View File

@ -56,4 +56,8 @@ public interface StoreService {
int insertUserStores(Long userId, Long[] storeIds);
UserStoreVo getUserStore(String userId);
Store selectStore(Long storeId);
int updateStatus(Store store);
}

View File

@ -1,13 +1,20 @@
package com.ruoyi.web.service.impl;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.domain.Brand;
import com.ruoyi.web.domain.Classification;
import com.ruoyi.web.domain.Store;
import com.ruoyi.web.mapper.BrandMapper;
import com.ruoyi.web.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class BrandServiceImpl implements BrandService {
@ -16,20 +23,43 @@ public class BrandServiceImpl implements BrandService {
private BrandMapper brandMapper;
@Override
public List<Brand> getBrandTree() {
// 1. 获取所有一级品牌
List<Brand> rootBrands = brandMapper.selectRootBrands();
public List<Brand> getBrandTree(String storeId) {
List<Brand> rootBrands = brandMapper.selectRootBrands(storeId);
return buildTree(rootBrands);
// 2. 为每个一级品牌设置子品牌
for (Brand rootBrand : rootBrands) {
List<Brand> children = brandMapper.selectByParentId(rootBrand.getId());
rootBrand.setChildren(children);
}
return rootBrands;
private List<Brand> buildTree(List<Brand> allList) {
List<Brand> rootList = new ArrayList<>();
Map<Long, Brand> nodeMap = new HashMap<>();
for (Brand node : allList) {
node.setChildren(new ArrayList<>());
nodeMap.put(node.getId(), node);
}
for (Brand node : allList) {
Long parentId = node.getParentId();
if (parentId == null || parentId == 0) {
rootList.add(node);
} else {
Brand parent = nodeMap.get(parentId);
if (parent != null) {
parent.getChildren().add(node);
} else {
rootList.add(node);
}
}
}
return rootList;
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public int addBrand(Brand brand) {
// 如果是二级品牌,检查父品牌是否存在
if (brand.getParentId() != null && brand.getParentId() != 0) {
@ -44,14 +74,30 @@ public class BrandServiceImpl implements BrandService {
}
@Override
@Transactional
@Transactional(rollbackFor = Exception.class)
public int updateBrand(Brand brand) {
return brandMapper.update(brand);
}
@Override
public void deleteBrand(Long id) {
@Transactional(rollbackFor = Exception.class)
public int deleteBrand(Long id) {
brandMapper.delete(id);
//如果该品牌是一级品牌,那删除的时候也要把下面的二级品牌一起删掉
brandMapper.batchBrand(id);
return 1;
}
@Override
public boolean checkBrandUnique(Brand brand) {
if (brand == null || StringUtils.isBlank(brand.getBrandName())) {
return UserConstants.UNIQUE;
}
Long id = brand.getId() == null ? -1L : brand.getId();
brand.setId(id);
Store existStore = brandMapper.checkBrandUnique(brand);
return existStore != null ? UserConstants.NOT_UNIQUE : UserConstants.UNIQUE;
}
}

View File

@ -0,0 +1,124 @@
package com.ruoyi.web.service.impl;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.domain.Classification;
import com.ruoyi.web.domain.Store;
import com.ruoyi.web.mapper.ClassIficationMapper;
import com.ruoyi.web.service.ClassIficationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ClassIficationServiceImpl implements ClassIficationService {
@Resource
private ClassIficationMapper classIficationMapper;
@Override
public List<Classification> getIficationTree(String storeId) {
List<Classification> rootBrands = classIficationMapper.selectRootBrands(storeId);
// 构建树形结构
return buildTree(rootBrands);
}
/**
*
*/
private List<Classification> buildTree(List<Classification> allList) {
List<Classification> rootList = new ArrayList<>();
Map<Long, Classification> nodeMap = new HashMap<>();
for (Classification node : allList) {
node.setChildren(new ArrayList<>());
nodeMap.put(node.getId(), node);
}
for (Classification node : allList) {
Long parentId = node.getParentId();
if (parentId == null || parentId == 0) {
rootList.add(node);
} else {
Classification parent = nodeMap.get(parentId);
if (parent != null) {
parent.getChildren().add(node);
} else {
rootList.add(node);
}
}
}
return rootList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int addClassification(Classification classification) {
// 如果是二级品牌,检查父品牌是否存在
if (classification.getParentId() != null && classification.getParentId() != 0) {
Classification classification1 = classIficationMapper.selectById(classification.getParentId());
if (classification1 == null) {
throw new RuntimeException("父分类不存在");
}
}
return classIficationMapper.insert(classification);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int updateClassification(Classification classification) {
return classIficationMapper.update(classification);
}
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteClassIfication(Long id) {
List<Long> allDeleteIds = getAllChildIds(id);
allDeleteIds.add(id); // 包括自身
for (Long allDeleteId : allDeleteIds) {
classIficationMapper.delete(allDeleteId);
}
return 1;
}
/**
* ID
*/
private List<Long> getAllChildIds(Long parentId) {
List<Long> allChildIds = new ArrayList<>();
// 查询直接子节点
List<Classification> children = classIficationMapper.selectByParentId(parentId);
for (Classification child : children) {
allChildIds.add(child.getId());
allChildIds.addAll(getAllChildIds(child.getId()));
}
return allChildIds;
}
@Override
public boolean checkBrandUnique(Classification classification) {
if (classification == null || StringUtils.isBlank(classification.getClassificationName())) {
return UserConstants.UNIQUE;
}
Long id = classification.getId() == null ? -1L : classification.getId();
classification.setId(id);
Classification existStore = classIficationMapper.checkBrandUnique(classification);
return existStore != null ? UserConstants.NOT_UNIQUE : UserConstants.UNIQUE;
}
}

View File

@ -7,6 +7,7 @@ import com.ruoyi.web.domain.Store;
import com.ruoyi.web.mapper.StoreMapper;
import com.ruoyi.web.mapper.UserStoreMapper;
import com.ruoyi.web.service.StoreService;
import com.ruoyi.web.vo.StoreVo;
import com.ruoyi.web.vo.UserStoreVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -84,6 +85,27 @@ public class StoreServiceImpl implements StoreService {
@Override
public UserStoreVo getUserStore(String userId) {
return userStoreMapper.getUserStoreWithStores(userId);
UserStoreVo userStoreWithStores = userStoreMapper.getUserStoreWithStores(userId);
List<StoreVo> storeVos = userStoreMapper.queryStore();
if (userStoreWithStores != null) {
userStoreWithStores.setAllStores(storeVos);
return userStoreWithStores;
} else {
UserStoreVo userStoreVo = new UserStoreVo();
userStoreVo.setAllStores(storeVos);
userStoreVo.setUserId(Long.valueOf(userId));
return userStoreVo;
}
}
@Override
public Store selectStore(Long storeId) {
return storeMapper.selectStore(storeId);
}
@Override
public int updateStatus(Store store) {
return storeMapper.updateStatus(store);
}
}

View File

@ -2,11 +2,12 @@ package com.ruoyi.web.vo;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class UserStoreVo {
private List<StoreVo> allStores = new ArrayList<>(); //所有的门店
private Long userId; //用户id
private List<StoreVo> stores; // 门店对象列表
}

View File

@ -24,7 +24,7 @@
<select id="selectRootBrands" resultMap="BaseResultMap">
SELECT *
FROM mall_brand
WHERE parent_id = 0 and del_flag = '0'
WHERE del_flag = '0' and store_id = #{storeId}
</select>
<!-- 根据父ID查询子品牌 -->
@ -32,6 +32,7 @@
SELECT *
FROM mall_brand
WHERE parent_id = #{parentId}
and del_flag = '0'
</select>
<!-- 根据ID查询品牌 -->
@ -41,6 +42,15 @@
WHERE id = #{id}
</select>
<select id="checkBrandUnique" resultType="com.ruoyi.web.domain.Store">
select * from mall_brand
where brand_name=#{brandName} and del_flag = '0' and store_id = #{storeId}
<if test="id != null">
AND id != #{id}
</if>
limit 1
</select>
<insert id="insert" parameterType="Brand">
insert into mall_brand (
@ -67,11 +77,16 @@
<!-- 删除品牌 -->
<delete id="delete">
DELETE
FROM brand
WHERE id = #{id}
update mall_brand
set del_flag = '2'
where id = #{id}
</delete>
<delete id="batchBrand">
update mall_brand
set del_flag = '2'
where parent_id = #{id}
</delete>
</mapper>

View File

@ -0,0 +1,81 @@
<?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.ruoyi.web.mapper.ClassIficationMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.web.domain.Classification">
<id property="id" column="id"/>
<result column="parent_id" property="parentId"/>
<result column="classification_name" property="classificationName"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="create_by" property="createBy"/>
<result column="update_by" property="updateBy"/>
<result column="store_id" property="storeId"/>
</resultMap>
<select id="selectRootBrands" resultMap="BaseResultMap">
SELECT *
FROM mall_classification
where del_flag = '0' and store_id = #{storeId}
</select>
<select id="selectByParentId" resultMap="BaseResultMap">
SELECT *
FROM mall_classification
WHERE parent_id = #{parentId}
and del_flag = '0'
</select>
<select id="selectById" resultMap="BaseResultMap" parameterType="long">
SELECT id, parent_id, classification_name
FROM mall_classification
WHERE id = #{id}
</select>
<select id="checkBrandUnique" resultType="com.ruoyi.web.domain.Classification">
select * from mall_classification
where classification_name=#{classificationName} and del_flag = '0' and store_id = #{storeId}
<if test="id != null">
AND id != #{id}
</if>
limit 1
</select>
<insert id="insert" parameterType="Brand">
insert into mall_classification (
<if test="parentId != null">parent_id,</if>
<if test="classificationName != null and classificationName != ''">classification_name,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="storeId != null">store_id,</if>
create_time
)values(
<if test="parentId != null">#{parentId},</if>
<if test="classificationName != null and classificationName != ''">#{classificationName},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="storeId != null">#{storeId},</if>
sysdate()
)
</insert>
<update id="update">
UPDATE mall_classification
SET classification_name = #{classificationName}
WHERE id = #{id}
</update>
<delete id="delete">
update mall_classification
set del_flag = '2'
where id = #{id}
</delete>
<delete id="batchBrand">
update mall_classification
set del_flag = '2'
where parent_id = #{id}
</delete>
</mapper>

View File

@ -25,6 +25,8 @@
<result property="shelfLife" column="shelf_life"/>
<result property="approaching" column="approaching"/>
<result property="productionDate" column="production_date"/>
<result property="productBrand" column="product_brand"/>
<result property="classifcation" column="classifcation"/>
</resultMap>
<sql id="selectCommodityVo">
@ -48,7 +50,9 @@
shelf_code,
shelf_life,
production_date,
approaching
approaching,
product_brand,
classifcation
from mall_product_store
</sql>
@ -155,6 +159,8 @@
<if test="shelfLife != null">shelf_life = #{shelfLife},</if>
<if test="productionDate != null and productionDate != ''">production_date = #{productionDate},</if>
<if test="approaching != null">approaching = #{approaching},</if>
<if test="productBrand != null and productBrand != ''">product_brand = #{productBrand},</if>
<if test="classifcation != null and classifcation != ''">classifcation = #{classifcation},</if>
update_time = sysdate()
</set>
where id = #{id}
@ -179,6 +185,8 @@
<if test="shelfLife != null">shelf_life = #{shelfLife},</if>
<if test="productionDate != null and productionDate != ''">production_date = #{productionDate},</if>
<if test="approaching != null">approaching = #{approaching},</if>
<if test="productBrand != null and productBrand != ''">product_brand = #{productBrand},</if>
<if test="classifcation != null and classifcation != ''">classifcation = #{classifcation},</if>
update_time = sysdate()
</set>
where product_bar_code = #{productBarCode}

View File

@ -18,11 +18,10 @@
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="status" column="status"/>
</resultMap>
<sql id="selectStoreVo">
select store_id,
store_name,
@ -37,7 +36,8 @@
create_time,
update_by,
update_time,
remark
remark,
status
from mall_store
</sql>
@ -61,6 +61,13 @@
limit 1
</select>
<select id="selectStore" resultType="com.ruoyi.web.domain.Store">
<include refid="selectStoreVo"/>
where store_id=#{storeId} and del_flag = '0'
</select>
<insert id="insertStore" parameterType="Store">
insert into mall_store (
@ -74,6 +81,7 @@
<if test="storeManager != null and storeManager != '' ">store_manager,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="status != null ">status,</if>
create_time
)values(
<if test="storeName != null and storeName != ''">#{storeName},</if>
@ -86,6 +94,7 @@
<if test="storeManager != null and storeManager != ''">#{storeManager},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="status != null">#{status},</if>
sysdate()
)
</insert>
@ -112,11 +121,18 @@
<if test="storeManager != null and storeManager != ''">store_manager = #{storeManager},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="status != null">status = #{status},</if>
update_time = sysdate()
</set>
where store_id = #{storeId}
</update>
<update id="updateStatus">
update mall_store
set status = #{status}
where store_id = #{storeId}
</update>
<delete id="deleteStoreById">
update mall_store
set del_flag = '2'

View File

@ -13,6 +13,12 @@
</collection>
</resultMap>
<resultMap id="userStoresMap" type="com.ruoyi.web.vo.StoreVo">
<result property="storeName" column="store_name"/>
<result property="storeId" column="store_id"/>
<result property="storeCode" column="store_code"/>
</resultMap>
<select id="getUserStoreWithStores" resultMap="userStoreWithStoresMap">
SELECT mus.user_id,
s.store_id,
@ -23,5 +29,11 @@
WHERE mus.user_id = #{userId}
</select>
<select id="queryStore" resultMap="userStoresMap">
select *
from mall_store
where del_flag = '0'
</select>
</mapper>