فهرست منبع

:package: 商品分类增加描述、商品分类管理页面二级分类不可以上传资源文件、新增查询

Twelve615 1 سال پیش
والد
کامیت
5496786b7c

+ 8 - 1
jlsb-vue/src/views/aa/modules/AaCommodityFlModal.vue

@@ -22,7 +22,13 @@
 <!--        <a-form-model-item label="分类名称-德语" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
           <a-input v-model="model.nameGerman" placeholder="请输入分类名称" ></a-input>
         </a-form-model-item>-->
-        <a-form-model-item label="顶部背景资源" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="assets">
+        <a-form-model-item label="分类描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="des">
+          <a-input v-model="model.des" placeholder="分类描述" ></a-input>
+        </a-form-model-item>
+        <a-form-model-item label="分类描述-英语" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="des">
+          <a-input v-model="model.desEnglish" placeholder="分类描述" ></a-input>
+        </a-form-model-item>
+        <a-form-model-item v-if="!model.pid || model.pid === '0'" label="顶部背景资源" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="assets">
           <j-upload v-model="model.assets" :reNewFile="true" :multiple="false" :beforeUpload="this.beforeUploadHandler" ></j-upload>
           <template slot="extra">
             <span>推荐比例16:9</span>
@@ -59,6 +65,7 @@
 
         confirmLoading: false,
         validatorRules: {
+          des: { pattern: /^.{0,500}$/, message: '不能超过500个字符' }
         },
         url: {
           add: "/aa/aaCommodityFl/add",

+ 32 - 0
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/controller/APIIndexenterController.java

@@ -187,6 +187,38 @@ public class APIIndexenterController {
         return Result.OK(list);
     }
 
+    @ApiOperationSupport(order = 20)
+    @ApiOperation(value = "根据系列id获取子系列及其商品", notes = "获取系列及其商品")
+    @GetMapping(value = "/queryCommodityFl")
+    public Result<AaCommodityFl> queryCommodityFl(@ApiParam(name="commodityFlId",value="商品分类id")String commodityFlId) {
+        // 判断分类是几级获取分类的顶级父类id
+        AaCommodityFl topNode = aaCommodityFlService.findTopNode(commodityFlId);
+        if (topNode == null){
+            return Result.error("找不到此系列");
+        }
+        List<AaCommodityFl> allChild = aaCommodityFlService.findAllChild(topNode);
+        topNode.setCommodities(aaCommodityService.getCommodityByFl(topNode.getId()));
+        if (allChild !=null && !allChild.isEmpty()) {
+            // 设置系列树中的商品
+            setTreeCommodity(allChild);
+        }
+        return Result.OK(topNode);
+    }
+
+    /**
+     * 根据系列树查询商品
+     * @param allChild
+     */
+    private void setTreeCommodity(List<AaCommodityFl> allChild) {
+        if (allChild==null || allChild.isEmpty()){
+            return;
+        }
+        for (AaCommodityFl aaCommodityFl : allChild) {
+            aaCommodityFl.setCommodities(aaCommodityService.getCommodityByFl(aaCommodityFl.getId()));
+            setTreeCommodity(aaCommodityFl.getChildren());
+        }
+    }
+
     @ApiOperationSupport(order = 21)
     @ApiOperation(value = "获取商品展示", notes = "获取商品展示")
     @PostMapping(value = "/getShowC")

+ 19 - 0
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/entity/AaCommodityFl.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.math.BigDecimal;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -15,6 +16,7 @@ import org.jeecg.common.aspect.annotation.Dict;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import java.io.UnsupportedEncodingException;
+import java.util.List;
 
 /**
  * @Description: 商品分类
@@ -59,6 +61,15 @@ public class AaCommodityFl implements Serializable {
     @Excel(name = "分类名称德语", width = 15)
     @ApiModelProperty(value = "分类名称德语")
     private String nameGerman;
+
+    /**分类描述*/
+    @Excel(name = "分类描述", width = 100)
+    @ApiModelProperty(value = "分类名称")
+    private String des;
+
+    @Excel(name = "分类描述英语", width = 100)
+    @ApiModelProperty(value = "分类名称英语")
+    private String desEnglish;
 	/**是否有子节点列*/
 	@Excel(name = "是否有子节点列", width = 15)
     @ApiModelProperty(value = "是否有子节点列")
@@ -68,4 +79,12 @@ public class AaCommodityFl implements Serializable {
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
+
+    @ApiModelProperty(value = "下级分类")
+    @TableField(exist = false)
+    private List<AaCommodityFl> children;
+
+    @ApiModelProperty(value = "商品列表")
+    @TableField(exist = false)
+    private List<AaCommodity> commodities;
 }

+ 9 - 4
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/service/IAaCommodityFlService.java

@@ -16,23 +16,28 @@ public interface IAaCommodityFlService extends IService<AaCommodityFl> {
 
 	/**根节点父ID的值*/
 	public static final String ROOT_PID_VALUE = "0";
-	
+
 	/**树节点有子节点状态值*/
 	public static final String HASCHILD = "1";
-	
+
 	/**树节点无子节点状态值*/
 	public static final String NOCHILD = "0";
 
 	/**新增节点*/
 	void addAaCommodityFl(AaCommodityFl aaCommodityFl);
-	
+
 	/**修改节点*/
 	void updateAaCommodityFl(AaCommodityFl aaCommodityFl) throws JeecgBootException;
-	
+
 	/**删除节点*/
 	void deleteAaCommodityFl(String id) throws JeecgBootException;
 
 	/**查询所有数据,无分页*/
     List<AaCommodityFl> queryTreeListNoPage(QueryWrapper<AaCommodityFl> queryWrapper);
 
+	/**查询所有子节点*/
+	List<AaCommodityFl> findAllChild(AaCommodityFl parent);
+
+	/**根据分类id查询它的顶级父类,如果自己就是顶级父类则返回自己*/
+	AaCommodityFl findTopNode(String id);
 }

+ 8 - 0
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/service/IAaCommodityService.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.aa.service;
 import org.jeecg.modules.aa.entity.AaCommodity;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * @Description: 商品列表
  * @Author: jeecg-boot
@@ -11,4 +13,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IAaCommodityService extends IService<AaCommodity> {
 
+    /**
+     * 根据分类id查询商品
+     * @param commodityFlId
+     * @return
+     */
+    List<AaCommodity> getCommodityByFl(String commodityFlId);
 }

+ 45 - 5
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/service/impl/AaCommodityFlServiceImpl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.aa.service.impl;
 
+import com.google.common.base.Strings;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.aa.entity.AaCommodityFl;
@@ -39,7 +40,7 @@ public class AaCommodityFlServiceImpl extends ServiceImpl<AaCommodityFlMapper, A
 		}
 		baseMapper.insert(aaCommodityFl);
 	}
-	
+
 	@Override
 	public void updateAaCommodityFl(AaCommodityFl aaCommodityFl) {
 		AaCommodityFl entity = this.getById(aaCommodityFl.getId());
@@ -59,7 +60,7 @@ public class AaCommodityFlServiceImpl extends ServiceImpl<AaCommodityFlMapper, A
 		}
 		baseMapper.updateById(aaCommodityFl);
 	}
-	
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void deleteAaCommodityFl(String id) throws JeecgBootException {
@@ -97,7 +98,7 @@ public class AaCommodityFlServiceImpl extends ServiceImpl<AaCommodityFlMapper, A
             baseMapper.deleteById(id);
         }
 	}
-	
+
 	@Override
     public List<AaCommodityFl> queryTreeListNoPage(QueryWrapper<AaCommodityFl> queryWrapper) {
         List<AaCommodityFl> dataList = baseMapper.selectList(queryWrapper);
@@ -118,8 +119,47 @@ public class AaCommodityFlServiceImpl extends ServiceImpl<AaCommodityFlMapper, A
         }
         return mapList;
     }
-	
-	/**
+
+    /**
+     * 查询父节点下的所有子节点,并设置到 org.jeecg.modules.aa.entity.AaCommodityFl#children 属性上
+     * @param parent 父节点
+     * @return 字节点列表
+     */
+    @Override
+    public List<AaCommodityFl> findAllChild(AaCommodityFl parent) {
+        if (Strings.isNullOrEmpty(parent.getHasChild()) || parent.getHasChild().equals("0")) {
+            return new ArrayList<>();
+        }
+        QueryWrapper<AaCommodityFl> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq( "pid", parent.getId());
+        List<AaCommodityFl> child = this.list( queryWrapper );
+        parent.setChildren(child);
+        if (child !=null && !child.isEmpty()) {
+            child.forEach(this::findAllChild);
+        }
+        return child;
+    }
+
+    /**
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public AaCommodityFl findTopNode(String id) {
+        AaCommodityFl byId = getById(id);
+        if (byId == null) {
+            return null;
+        }
+        if ("0".equals(byId.getPid())) {
+            // 自己就是顶级
+            return byId;
+        } else {
+            return this.findTopNode(byId.getPid());
+        }
+    }
+
+    /**
 	 * 根据所传pid查询旧的父级节点的子节点并修改相应状态值
 	 * @param pid
 	 */

+ 9 - 0
jlsb/jeecg-boot-module-system/src/main/java/org/jeecg/modules/aa/service/impl/AaCommodityServiceImpl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.aa.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.jeecg.modules.aa.entity.AaCommodity;
 import org.jeecg.modules.aa.mapper.AaCommodityMapper;
 import org.jeecg.modules.aa.service.IAaCommodityService;
@@ -7,6 +8,8 @@ import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.util.List;
+
 /**
  * @Description: 商品列表
  * @Author: jeecg-boot
@@ -16,4 +19,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class AaCommodityServiceImpl extends ServiceImpl<AaCommodityMapper, AaCommodity> implements IAaCommodityService {
 
+    @Override
+    public List<AaCommodity> getCommodityByFl(String commodityFlId) {
+        LambdaQueryWrapper<AaCommodity> aaCommodityLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        aaCommodityLambdaQueryWrapper.eq(AaCommodity::getTypeId, commodityFlId);
+        return this.list(aaCommodityLambdaQueryWrapper);
+    }
 }