Переглянути джерело

商品信息-上传修改代码

1021934019@qq.com 4 роки тому
батько
коміт
54c2a93a7b

+ 3 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/GoodsDesc.java

@@ -156,5 +156,8 @@ public class GoodsDesc implements Serializable {
 	@TableField(exist = false)
 	private List<GoodsPrice>  bugGoodsPrice;
 
+	@TableField(exist = false)
+	private List<GoodsFiles> filesList;
+
 
 }

+ 83 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/GoodsFiles.java

@@ -0,0 +1,83 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 商品详情表实体类
+ *
+ * @author BladeX
+ * @since 2021-09-18
+ */
+@Data
+@TableName("basic_goods_files")
+@ApiModel(value = "GoodsFiles对象", description = "商品上传表")
+public class GoodsFiles implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+	//主键
+	@TableId
+	private Long id;
+	//主表id
+	private Long pid;
+    //排序
+	private int sort;
+	//文件名
+	private String fileName;
+	//文件地址
+	private String url;
+    //备注
+	private String remarks;
+    //版本
+	private String version;
+    //租户
+	private String tenantId;
+
+	private Long updateUser;
+	//创建人
+	private Long createUser;
+	//创建部门
+	private Long createDept;
+	//创建时间
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	private Date createTime;
+	//修改时间
+	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	private Date updateTime;
+	//状态(0 正常 1停用)
+	private Integer status;
+	//是否已删除(0 否 1是)
+	@TableLogic
+	private Integer isDeleted;
+
+
+
+
+}

+ 9 - 1
blade-service/blade-client/src/main/java/org/springblade/client/goods/controller/GoodsDescController.java

@@ -28,9 +28,11 @@ import lombok.AllArgsConstructor;
 import javax.validation.Valid;
 
 import org.springblade.client.entity.GoodsDesc;
+import org.springblade.client.entity.GoodsFiles;
 import org.springblade.client.entity.GoodsPrice;
 import org.springblade.client.entity.GoodsType;
 import org.springblade.client.goods.enums.GoodsTypeEnum;
+import org.springblade.client.goods.service.IGoodsFilesService;
 import org.springblade.client.goods.service.IGoodsPriceService;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
@@ -63,7 +65,8 @@ public class GoodsDescController extends BladeController {
 	private final IGoodsDescService goodsDescService;
 	@Autowired
 	private IGoodsPriceService goodsPriceService;
-
+    @Autowired
+	private IGoodsFilesService goodsFilesService;
 	/**
 	 * 详情
 	 */
@@ -122,12 +125,17 @@ public class GoodsDescController extends BladeController {
 		LambdaQueryWrapper<GoodsPrice> lambdaQueryWrapper=new LambdaQueryWrapper<>();
 		lambdaQueryWrapper.eq(GoodsPrice::getPid,id);
 		List<GoodsPrice> priceList = goodsPriceService.list(lambdaQueryWrapper);
+
+		LambdaQueryWrapper<GoodsFiles> filesLambdaQueryWrapper=new LambdaQueryWrapper<>();
+		filesLambdaQueryWrapper.eq(GoodsFiles::getPid,id);
+		List<GoodsFiles> filesList = goodsFilesService.list(filesLambdaQueryWrapper);
 		if(!CollectionUtils.isEmpty(priceList))
 		{
 			List<GoodsPrice> sale = priceList.stream().filter(e -> e.getBillType().equals("0")).collect(Collectors.toList());
 			List<GoodsPrice> buy = priceList.stream().filter(e -> e.getBillType().equals("1")).collect(Collectors.toList());
 			goodsDesc.setSaleGoodsPrice(sale);
 			goodsDesc.setBugGoodsPrice(buy);
+			goodsDesc.setFilesList(filesList);
 		}
 		return R.data(goodsDesc);
 	}

+ 76 - 0
blade-service/blade-client/src/main/java/org/springblade/client/goods/controller/GoodsFilesController.java

@@ -0,0 +1,76 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.goods.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.client.entity.GoodsFiles;
+import org.springblade.client.entity.GoodsType;
+import org.springblade.client.goods.enums.GoodsTypeEnum;
+import org.springblade.client.goods.service.IGoodsFilesService;
+import org.springblade.client.goods.service.IGoodsTypeService;
+import org.springblade.client.vo.GoodsTypeVO;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * 商品类别表 控制器
+ *
+ * @author BladeX
+ * @since 2021-09-18
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/goodsfiles")
+@Api(value = "商品文件表", tags = "商品文件表接口")
+public class GoodsFilesController extends BladeController
+{
+     @Autowired
+	private IGoodsFilesService goodsFilesService;
+
+    @PostMapping("add")
+    public  R add(@RequestBody GoodsFiles goodsFiles)
+	{
+		goodsFilesService.save(goodsFiles);
+		return R.success("操作成功");
+	}
+
+	@DeleteMapping("delete")
+	public R delete(@RequestParam(name = "id", required = true) String id)
+	{
+		goodsFilesService.removeById(id);
+		return R.success("操作成功");
+	}
+
+
+}

+ 23 - 0
blade-service/blade-client/src/main/java/org/springblade/client/goods/mapper/GoodsFilesMapper.java

@@ -0,0 +1,23 @@
+package org.springblade.client.goods.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.client.entity.GoodsDesc;
+import org.springblade.client.entity.GoodsFiles;
+import org.springblade.client.vo.GoodsDescVO;
+
+import java.util.List;
+
+/**
+ * 商品详情表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2021-09-18
+ */
+public interface GoodsFilesMapper extends BaseMapper<GoodsFiles>
+{
+
+
+
+}

+ 7 - 0
blade-service/blade-client/src/main/java/org/springblade/client/goods/mapper/GoodsFilesMapper.xml

@@ -0,0 +1,7 @@
+<?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="org.springblade.client.goods.mapper.GoodsFilesMapper">
+
+
+
+</mapper>

+ 35 - 0
blade-service/blade-client/src/main/java/org/springblade/client/goods/service/IGoodsFilesService.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.goods.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.client.entity.GoodsDesc;
+import org.springblade.client.entity.GoodsFiles;
+import org.springblade.client.vo.GoodsDescVO;
+
+/**
+ * 商品详情表 服务类
+ *
+ * @author BladeX
+ * @since 2021-09-18
+ */
+public interface IGoodsFilesService extends IService<GoodsFiles>
+{
+
+
+}

+ 75 - 29
blade-service/blade-client/src/main/java/org/springblade/client/goods/service/impl/GoodsDescServiceImpl.java

@@ -24,12 +24,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.AllArgsConstructor;
 import org.springblade.client.entity.GoodsDesc;
+import org.springblade.client.entity.GoodsFiles;
 import org.springblade.client.entity.GoodsPrice;
 import org.springblade.client.entity.GoodsTypeDesc;
-import org.springblade.client.goods.mapper.GoodsDescMapper;
-import org.springblade.client.goods.mapper.GoodsPriceMapper;
-import org.springblade.client.goods.mapper.GoodsTypeDescMapper;
-import org.springblade.client.goods.mapper.GoodsTypeMapper;
+import org.springblade.client.goods.mapper.*;
 import org.springblade.client.goods.service.IGoodsDescService;
 import org.springblade.client.vo.GoodsDescVO;
 import org.springblade.core.log.exception.ServiceException;
@@ -60,6 +58,8 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
 	private GoodsPriceMapper goodsPriceMapper;
 	@Autowired
 	private GoodsTypeDescMapper goodsTypeDescMapper;
+	@Autowired
+	private GoodsFilesMapper goodsFilesMapper;
 
 
 	@Override
@@ -177,6 +177,7 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
 	@Transactional
 	public void modify(GoodsDesc goodsDesc)
 	{
+		List<GoodsFiles> filesList = goodsDesc.getFilesList();
 		List<GoodsPrice> chilList=new ArrayList<>();
 		chilList.addAll(goodsDesc.getBugGoodsPrice());
 		chilList.addAll(goodsDesc.getSaleGoodsPrice());
@@ -188,36 +189,81 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
 			goodsDesc.setCreateTime(new Date());
 			goodsDesc.setCreateUser(SecureUtil.getUserId());
 			 goodsDescMapper.insert(goodsDesc);
-			 chilList.forEach(e->{
-				 e.setTenantId(AuthUtil.getTenantId());
-				 e.setPid(goodsDesc.getId());
-				 e.setCreateTime(new Date());
-				 e.setCreateUser(SecureUtil.getUserId());
-				 goodsPriceMapper.insert(e);
-			 });
+			 if(!CollectionUtils.isEmpty(chilList))
+			 {
+				 chilList.forEach(e->{
+					 e.setTenantId(AuthUtil.getTenantId());
+					 e.setPid(goodsDesc.getId());
+					 e.setCreateTime(new Date());
+					 e.setCreateUser(SecureUtil.getUserId());
+					 goodsPriceMapper.insert(e);
+				 });
+			 }
+			//文件上传
+			 if(!CollectionUtils.isEmpty(filesList))
+			 {
+				 filesList.forEach(k->{
+					 k.setTenantId(AuthUtil.getTenantId());
+					 k.setPid(goodsDesc.getId());
+					 k.setCreateTime(new Date());
+					 k.setCreateUser(SecureUtil.getUserId());
+					 goodsFilesMapper.insert(k);
+				 });
+			 }
+
+
+
 		}
 		//主表修改,子表看情况
 		else
 		{
 			goodsDescMapper.updateById(goodsDesc);
-			chilList.forEach(e->{
-				//新增
-				if(e.getId()==null)
-				{
-					e.setTenantId(AuthUtil.getTenantId());
-					e.setPid(goodsDesc.getId());
-					e.setCreateTime(new Date());
-					e.setCreateUser(SecureUtil.getUserId());
-					goodsPriceMapper.insert(e);
-				}
-				//修改
-				else
-				{
-					e.setUpdateTime(new Date());
-					e.setUpdateUser(SecureUtil.getUserId());
-					goodsPriceMapper.updateById(e);
-				}
-			});
+			//价格列表
+			if(CollectionUtils.isNotEmpty(chilList))
+			{
+				chilList.forEach(e->{
+					//新增
+					if(e.getId()==null)
+					{
+						e.setTenantId(AuthUtil.getTenantId());
+						e.setPid(goodsDesc.getId());
+						e.setCreateTime(new Date());
+						e.setCreateUser(SecureUtil.getUserId());
+						goodsPriceMapper.insert(e);
+					}
+					//修改
+					else
+					{
+						e.setUpdateTime(new Date());
+						e.setUpdateUser(SecureUtil.getUserId());
+						goodsPriceMapper.updateById(e);
+					}
+				});
+			}
+
+			//文件列表
+			if(CollectionUtils.isNotEmpty(filesList))
+			{
+				filesList.forEach(k->{
+					//新增
+					if(k.getId()==null)
+					{
+						k.setTenantId(AuthUtil.getTenantId());
+						k.setPid(goodsDesc.getId());
+						k.setCreateTime(new Date());
+						k.setCreateUser(SecureUtil.getUserId());
+						goodsFilesMapper.insert(k);
+					}
+					//修改
+					else
+					{
+						k.setUpdateTime(new Date());
+						k.setUpdateUser(SecureUtil.getUserId());
+						goodsFilesMapper.updateById(k);
+					}
+				});
+			}
+
 		}
 	}
 

+ 54 - 0
blade-service/blade-client/src/main/java/org/springblade/client/goods/service/impl/GoodsFilesServiceImpl.java

@@ -0,0 +1,54 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.goods.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.AllArgsConstructor;
+import org.springblade.client.entity.GoodsDesc;
+import org.springblade.client.entity.GoodsFiles;
+import org.springblade.client.entity.GoodsPrice;
+import org.springblade.client.entity.GoodsTypeDesc;
+import org.springblade.client.goods.mapper.*;
+import org.springblade.client.goods.service.IGoodsDescService;
+import org.springblade.client.goods.service.IGoodsFilesService;
+import org.springblade.client.vo.GoodsDescVO;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.secure.utils.SecureUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+
+/**
+ * 商品详情表 服务实现类
+ *
+ * @author BladeX
+ * @since 2021-09-18
+ */
+@Service
+@AllArgsConstructor
+public class GoodsFilesServiceImpl extends ServiceImpl<GoodsFilesMapper, GoodsFiles> implements IGoodsFilesService {
+
+
+}