2 İşlemeler 4544817de2 ... b64afc7396

Yazar SHA1 Mesaj Tarih
  loovi b64afc7396 增加商品分类树形表格,增加向商品分类添加或删除商品功能 1 yıl önce
  loovi 5cb7265cd8 增加商品分类树形表格,增加向商品分类添加或删除商品功能 1 yıl önce

+ 1 - 1
app.pid

@@ -1 +1 @@
-30260
+5480

+ 9 - 9
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsType.java

@@ -1,11 +1,8 @@
 package com.pj.tb_goods_type;
 package com.pj.tb_goods_type;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
-import java.util.Date;
-
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
 
 
 import lombok.Data;
 import lombok.Data;
@@ -46,10 +43,10 @@ public class TbGoodsType extends Model<TbGoodsType> implements Serializable {
 	 * 主键 
 	 * 主键 
 	 */
 	 */
 	@TableId(type = IdType.AUTO)
 	@TableId(type = IdType.AUTO)
-	private Long id;
+	private String id;	
 
 
 	/**
 	/**
-	 * 名称 
+	 * 类别名称 
 	 */
 	 */
 	private String name;	
 	private String name;	
 
 
@@ -66,8 +63,7 @@ public class TbGoodsType extends Model<TbGoodsType> implements Serializable {
 	/**
 	/**
 	 * 创建时间 
 	 * 创建时间 
 	 */
 	 */
-	@JsonFormat(pattern = "yyyy-MM-dd")
-	private Date createTime;
+	private String createTime;	
 
 
 	/**
 	/**
 	 * 创建人编号 
 	 * 创建人编号 
@@ -82,8 +78,7 @@ public class TbGoodsType extends Model<TbGoodsType> implements Serializable {
 	/**
 	/**
 	 * 更新时间 
 	 * 更新时间 
 	 */
 	 */
-	@JsonFormat(pattern = "yyyy-MM-dd")
-	private Date updateTime;
+	private String updateTime;	
 
 
 	/**
 	/**
 	 * 更新人编号 
 	 * 更新人编号 
@@ -100,6 +95,11 @@ public class TbGoodsType extends Model<TbGoodsType> implements Serializable {
 	 */
 	 */
 	private Integer deleteStatus;	
 	private Integer deleteStatus;	
 
 
+	/**
+	 * 父类型id 
+	 */
+	private Long parentId;	
+
 
 
 
 
 
 

+ 34 - 39
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeController.java

@@ -1,18 +1,14 @@
 package com.pj.tb_goods_type;
 package com.pj.tb_goods_type;
 
 
-import java.io.IOException;
 import java.util.List;
 import java.util.List;
 import com.pj.utils.so.SoMap;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import com.pj.utils.sg.*;
 import com.pj.utils.sg.*;
 import com.pj.project4sp.SP;
 import com.pj.project4sp.SP;
 
 
-import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.annotation.SaCheckPermission;
-import org.springframework.web.multipart.MultipartFile;
 
 
 
 
 /**
 /**
@@ -39,8 +35,8 @@ public class TbGoodsTypeController {
 	/** 删 */  
 	/** 删 */  
 	@RequestMapping("delete")
 	@RequestMapping("delete")
 	@SaCheckPermission(TbGoodsType.PERMISSION_CODE_DEL)
 	@SaCheckPermission(TbGoodsType.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Long id){
-		 tbGoodsTypeService.delete(id);
+	public AjaxJson delete(String id){
+		 tbGoodsTypeService.delete(Long.valueOf(id));
 		return AjaxJson.getSuccess();
 		return AjaxJson.getSuccess();
 	}
 	}
 	
 	
@@ -78,6 +74,17 @@ public class TbGoodsTypeController {
 		return AjaxJson.getPageData(so.getDataCount(), list);
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
 	}
 	
 	
+	/** 查集合 (整个表数据转化为tree结构返回) */  
+	@RequestMapping("getTree")
+	public AjaxJson getTree() { 
+		// 获取记录 
+		SoMap so = SoMap.getRequestSoMap();
+		List<TbGoodsType> list = tbGoodsTypeService.getList(so);
+		// 转为tree结构,并返回 
+		List<SoMap> listMap = SoMap.getSoMapByList(list);
+		List<SoMap> listTree = SoMap.listToTree(listMap, "id", "parentId", "children");
+		return AjaxJson.getPageData(Long.valueOf(listMap.size()), listTree);
+	}
 	
 	
 	
 	
 	/** 改 - 删除状态(0=禁用,1=启用) */  
 	/** 改 - 删除状态(0=禁用,1=启用) */  
@@ -88,46 +95,34 @@ public class TbGoodsTypeController {
 		return AjaxJson.getByLine(line);
 		return AjaxJson.getByLine(line);
 	}
 	}
 
 
-
-
 	/**
 	/**
-	 * 数据导入接口
-	 * @param file
-	 * @return
+	 *
+	 *给商品类型添加商品
+	 * @author loovi
+	 * @date
 	 */
 	 */
-	@RequestMapping("goodsTypeImport")
-	@ResponseBody
-	public AjaxJson dataImport(@RequestParam("file") MultipartFile file){
-		try {
-			String importData = tbGoodsTypeService.importData(file);
-			AjaxJson.getSuccess(importData);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		return AjaxJson.getError();
+	@RequestMapping("addGoodsToGoodsType")
+	@SaCheckPermission(com.pj.tb_goods_type.TbGoodsType.PERMISSION_CODE_EDIT)
+	public AjaxJson AddGoodsToGoodsType(@RequestParam("goodsTypeId") Long goodsTypeId,@RequestParam("goodsIds") Long [] goodsIds){
+		int  line = tbGoodsTypeService.AddGoodsToGoodsType(goodsTypeId,goodsIds);
+		return AjaxJson.getByLine(line);
 	}
 	}
 
 
 	/**
 	/**
-	 * 导出
-	 * @param keyword
-	 * @return
+	 *
+	 *删除商品类型中的商品
+	 * @author loovi
+	 * @date
 	 */
 	 */
-	@RequestMapping("goodsTypeOutport")
-	@ResponseBody
-	public AjaxJson dataOutport(@RequestParam(value = "keyword",required = false) String keyword,@RequestParam(value = "filepathh",required = false)String filepath){
-		try {
-			String importData = tbGoodsTypeService.outportExcel(keyword,filepath);
-			AjaxJson.getSuccess(importData);
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		return AjaxJson.getError();
+	@RequestMapping("delGoodsFromGoodsType")
+	@SaCheckPermission(com.pj.tb_goods_type.TbGoodsType.PERMISSION_CODE_EDIT)
+	public AjaxJson delGoodsFromGoodsType(@RequestParam("goodsTypeId") Long goodsTypeId,@RequestParam("goodsIds") Long [] goodsIds){
+		int  line = tbGoodsTypeService.delGoodsFromGoodsType(goodsTypeId,goodsIds);
+		return AjaxJson.getByLine(line);
 	}
 	}
 
 
-
-
-
-
-
+	
+	
+	
 
 
 }
 }

+ 15 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
 
 
 import com.pj.utils.so.*;
 import com.pj.utils.so.*;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import org.springframework.stereotype.Repository;
 
 
 /**
 /**
@@ -26,5 +27,19 @@ public interface TbGoodsTypeMapper extends BaseMapper <TbGoodsType> {
 	 */
 	 */
 	List<TbGoodsType> getList(SoMap so);
 	List<TbGoodsType> getList(SoMap so);
 
 
+	/**
+	 *写入商品和大河内高频类型关系表
+	 *
+	 * @author loovi
+	 * @date
+	 */
+	int addGoodsToGoodsType(@Param("goodsTypeId") Long goodsTypeId, @Param("goodsId") Long goodsId);
+	/**
+	 *删除商品和大河内高频类型关系表的关系
+	 *
+	 * @author loovi
+	 * @date
+	 */
+	int delGoodsFromGoodsType(@Param("goodsTypeId") Long goodsTypeId, @Param("goodsId") Long goodsId);
 
 
 }
 }

+ 47 - 30
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeMapper.xml

@@ -6,7 +6,7 @@
 
 
 
 
 	<!-- ================================== 查询相关 ================================== -->
 	<!-- ================================== 查询相关 ================================== -->
-	<!-- select id, name, sort, no, create_time, create_by, create_name, update_time, update_by, update_name, delete_status from tb_goods_type  -->
+	<!-- select id, name, sort, no, create_time, create_by, create_name, update_time, update_by, update_name, delete_status, parent_id from tb_goods_type  -->
 	
 	
 	<!-- 通用映射:自动模式 -->
 	<!-- 通用映射:自动模式 -->
 	<resultMap id="model" autoMapping="true" type="com.pj.tb_goods_type.TbGoodsType"></resultMap>
 	<resultMap id="model" autoMapping="true" type="com.pj.tb_goods_type.TbGoodsType"></resultMap>
@@ -17,38 +17,55 @@
 		from tb_goods_type 
 		from tb_goods_type 
 	</sql>
 	</sql>
 
 
-	
+	<insert id="addGoodsToGoodsType">
+		insert into tb_goods_type_goods_relation
+		(goods_id,goods_type_id)
+		values(
+		<if  test="goodsId!=null and goodsId!=''"> #{goodsId},</if>
+		<if  test="goodsTypeId!=null and goodsTypeId!=''">  #{goodsTypeId}</if>
+		)
+	</insert>
+
+	<delete id="delGoodsFromGoodsType">
+		delete from  tb_goods_type_goods_relation
+		<where>
+			<if  test="goodsTypeId!=null and goodsTypeId!=''"> goods_id=#{goodsId}</if>
+			<if  test="goodsTypeId!=null and goodsTypeId!=''"> and goods_type_id=#{goodsTypeId}</if>
+		</where>
+	</delete>
 	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
 	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
 	<select id="getList" resultMap="model">
 	<select id="getList" resultMap="model">
 		<include refid="select_sql"></include>
 		<include refid="select_sql"></include>
-		<where>
-			<if test=' this.has("id") '> and id = #{id} </if>
-			<if test=' this.has("name") '> and name = #{name} </if>
-			<if test=' this.has("sort") '> and sort = #{sort} </if>
-			<if test=' this.has("no") '> and no = #{no} </if>
-			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>
-			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>
-			<if test=' this.has("createName") '> and create_name = #{createName} </if>
-			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>
-			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>
-			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>
-			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>
-		</where>
-		order by
-		<choose>
-			<when test='sortType == 1'> id desc </when>
-			<when test='sortType == 2'> name desc </when>
-			<when test='sortType == 3'> sort desc </when>
-			<when test='sortType == 4'> no desc </when>
-			<when test='sortType == 5'> create_time desc </when>
-			<when test='sortType == 6'> create_by desc </when>
-			<when test='sortType == 7'> create_name desc </when>
-			<when test='sortType == 8'> update_time desc </when>
-			<when test='sortType == 9'> update_by desc </when>
-			<when test='sortType == 10'> update_name desc </when>
-			<when test='sortType == 11'> delete_status desc </when>
-			<otherwise> id desc </otherwise>
-		</choose>
+<!--		<where>-->
+<!--			<if test=' this.has("id") '> and id = #{id} </if>-->
+<!--			<if test=' this.has("name") '> and name = #{name} </if>-->
+<!--			<if test=' this.has("sort") '> and sort = #{sort} </if>-->
+<!--			<if test=' this.has("no") '> and no = #{no} </if>-->
+<!--			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>-->
+<!--			<if test=' this.has("createBy") '> and create_by = #{createBy} </if>-->
+<!--			<if test=' this.has("createName") '> and create_name = #{createName} </if>-->
+<!--			<if test=' this.has("updateTime") '> and update_time = #{updateTime} </if>-->
+<!--			<if test=' this.has("updateBy") '> and update_by = #{updateBy} </if>-->
+<!--			<if test=' this.has("updateName") '> and update_name = #{updateName} </if>-->
+<!--			<if test=' this.has("deleteStatus") '> and delete_status = #{deleteStatus} </if>-->
+<!--			<if test=' this.has("parentId") '> and parent_id = #{parentId} </if>-->
+<!--		</where>-->
+<!--		order by-->
+<!--		<choose>-->
+<!--			<when test='sortType == 1'> id desc </when>-->
+<!--			<when test='sortType == 2'> name desc </when>-->
+<!--			<when test='sortType == 3'> sort desc </when>-->
+<!--			<when test='sortType == 4'> no desc </when>-->
+<!--			<when test='sortType == 5'> create_time desc </when>-->
+<!--			<when test='sortType == 6'> create_by desc </when>-->
+<!--			<when test='sortType == 7'> create_name desc </when>-->
+<!--			<when test='sortType == 8'> update_time desc </when>-->
+<!--			<when test='sortType == 9'> update_by desc </when>-->
+<!--			<when test='sortType == 10'> update_name desc </when>-->
+<!--			<when test='sortType == 11'> delete_status desc </when>-->
+<!--			<when test='sortType == 12'> parent_id desc </when>-->
+<!--			<otherwise> id asc </otherwise>-->
+<!--		</choose>-->
 	</select>
 	</select>
 	
 	
 	
 	

+ 55 - 101
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeService.java

@@ -1,27 +1,17 @@
 package com.pj.tb_goods_type;
 package com.pj.tb_goods_type;
 
 
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
 import java.util.List;
 import java.util.List;
+import java.util.Objects;
 
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.pj.tb_goods.TbGoods;
 import com.pj.tb_goods.TbGoods;
+import com.pj.tb_goods.TbGoodsMapper;
 import com.pj.utils.so.SoMap;
 import com.pj.utils.so.SoMap;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
-import com.pj.utils.sg.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.swing.filechooser.FileSystemView;
 
 
 /**
 /**
  * Service: tb_goods_type -- 商品分类
  * Service: tb_goods_type -- 商品分类
@@ -34,9 +24,8 @@ public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsTy
 	/** 底层 Mapper 对象 */
 	/** 底层 Mapper 对象 */
 	@Autowired
 	@Autowired
 	TbGoodsTypeMapper tbGoodsTypeMapper;
 	TbGoodsTypeMapper tbGoodsTypeMapper;
-
 	@Autowired
 	@Autowired
-	private MethodGoodsTypeService methodGoodsTypeService;
+	TbGoodsMapper tbGoodsMapper;
 
 
 	/** 增 */
 	/** 增 */
 	void add(TbGoodsType t){
 	void add(TbGoodsType t){
@@ -65,97 +54,62 @@ public class TbGoodsTypeService extends ServiceImpl<TbGoodsTypeMapper, TbGoodsTy
 	}
 	}
 
 
 	/**
 	/**
-	 * 导入
-	 * @param file excel文件
-	 * @return
-	 * @throws IOException
-	 */
-	public String importData(MultipartFile file) throws IOException {
-		System.out.println("\n开始执行文件上传....\n");
+	*
+	*向商品分类添加商品
+	* @author loovi
+	* @date
+	*/
+	public int AddGoodsToGoodsType(Long goodsTypeId,Long [] goodsIds){
+		// 获取当前登录用户id
+//		Long loginId = StpUserUtil.getLoginIdAsLong();
+		int line = 0;
+		// 获取商品类型信息
+		com.pj.tb_goods_type.TbGoodsType tbGoodsType = tbGoodsTypeMapper.selectById(goodsTypeId);
+		// 如果商品类型不存在则抛异常
+		if (Objects.isNull(tbGoodsType)){
+			throw new RuntimeException("该商品类型不存在");
+		}
+		List<Long> list = Arrays.asList(goodsIds);
+		// 把商品与类型关联id写入商品类型商品关系表
+		for (Long goodsId : list) {
+			TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
+			if(Objects.isNull(tbGoods)){
+				throw new RuntimeException("该商品不存在");
+			}
+			int i =tbGoodsTypeMapper.addGoodsToGoodsType(goodsTypeId,goodsId);
+			line = i+1;
+		}
+		return line;
 
 
-		//判空
-		if(file.isEmpty()) return "文件为空,无法执行上传...";
-		//获取文件上传数据
-		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
-		//获取第一页sheet
-		HSSFSheet sheet = wb.getSheetAt(0);
-		//定义计数器
-		int count = 0;
-		//定义行对象
-		HSSFRow row = null;
-		//解析数据封装到集合
-		count = methodGoodsTypeService.importMethod(row, sheet, count);
-		wb.close();
-		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
-		return "上传完成,共上传"  + count + "条"  + "数据。";
 	}
 	}
-
 	/**
 	/**
-	 * 导出 excel文件
-	 * @param keyword
-	 * @return
-	 */
-	public String outportExcel(String keyword,String filepath) throws IOException {
-		System.out.println("\n开始执行文件导出....\n");
-		//导出的文件的路径
-		if(filepath == null){
-			// 获取当前用户的桌面路径
-			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
-			filepath = fileSystemView.getHomeDirectory().getPath();
+	*删除商品分类中的商品
+	*
+	* @author loovi
+	* @date
+	*/
+	public int delGoodsFromGoodsType(Long goodsTypeId,Long [] goodsIds){
+
+		// 获取当前登录用户id
+//		Long loginId = StpUserUtil.getLoginIdAsLong();
+		int line = 0;
+		// 获取商品类型信息
+		com.pj.tb_goods_type.TbGoodsType tbGoodsType = tbGoodsTypeMapper.selectById(goodsTypeId);
+		// 如果商品类型不存在则抛异常
+		if (Objects.isNull(tbGoodsType)){
+			throw new RuntimeException("该商品类型不存在");
 		}
 		}
-		filepath = filepath + "\\商品分类数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
-		//根据需求查询数据
-		List<TbGoodsType> selectedList = tbGoodsTypeMapper.selectList
-				(new LambdaQueryWrapper<TbGoodsType>().eq(StringUtils.isNoneBlank(keyword), TbGoodsType::getName, keyword));
-		if(selectedList.size() == 0)return "没有可导出的数据。";
-		//建立excel对象封装数据
-		HSSFWorkbook workbook = new HSSFWorkbook();
-		//创建excel表格右下角的sheet页名称
-		HSSFSheet sheet = workbook.createSheet("1");
-		//创建表头
-		HSSFRow row = sheet.createRow(0);
-		row.createCell(0).setCellValue("序号");
-		row.createCell(1).setCellValue("名称");
-		row.createCell(2).setCellValue("排序");
-		row.createCell(3).setCellValue("编号");
-		row.createCell(12).setCellValue("创建时间");
-		row.createCell(13).setCellValue("创建人编号");
-		row.createCell(14).setCellValue("创建人名称");
-		row.createCell(15).setCellValue("更新时间");
-		row.createCell(16).setCellValue("更新人编号");
-		row.createCell(17).setCellValue("更新人名称");
-		row.createCell(18).setCellValue("删除状态");
-
-		//定义计数器
-		int count = 0;
-		//遍历集合
-		for (int i = 0; i < selectedList.size(); i++) {
-			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
-			sheetRow.createCell(0).setCellValue(i + 1);
-			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
-			sheetRow.createCell(2).setCellValue((selectedList.get(i).getSort() + "").equals("null")? "": selectedList.get(i).getSort() + "");
-			sheetRow.createCell(3).setCellValue((selectedList.get(i).getNo() + "").equals("null")? "": selectedList.get(i).getNo() + "");
-			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
-			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
-			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
-			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
-			sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
-			sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
-			sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
-			count += 1;
+		List<Long> list = Arrays.asList(goodsIds);
+		// 从商品类型商品关系表把商品与类型关联删除
+		for (Long goodsId : list) {
+			TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
+			if(Objects.isNull(tbGoods)){
+				throw new RuntimeException("该商品不存在");
+			}
+			int i =tbGoodsTypeMapper.delGoodsFromGoodsType(goodsTypeId,goodsId);
+			line = i+1;
 		}
 		}
-		//建立输出流,输出文件
-		FileOutputStream fos = new FileOutputStream(filepath);
-
-		workbook.write(fos);
-		fos.flush();
-		//关闭输出流
-		fos.close();
-		workbook.close();
-		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
-		return "数据导出完成!共导出 " + count + " 条数据。";
+		return line;
 	}
 	}
 
 
-
-
 }
 }

+ 27 - 65
sp-service/level-one-server/src/main/java/com/pj/tb_goods_type/TbGoodsTypeUtil.java

@@ -1,65 +1,27 @@
-package com.pj.tb_goods_type;//package com.pj.tb_goods_type;
-//
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Component;
-//
-//import com.pj.utils.sg.*;
-//
-///**
-// * 工具类:tb_goods_type -- 商品分类
-// * @author qzy
-// *
-// */
-//@Component
-//public class TbGoodsTypeUtil {
-//
-//
-//	/** 底层 Mapper 对象 */
-//	public static TbGoodsTypeMapper tbGoodsTypeMapper;
-//	@Autowired
-//	private void setTbGoodsTypeMapper(TbGoodsTypeMapper tbGoodsTypeMapper) {
-//		TbGoodsTypeUtil.tbGoodsTypeMapper = tbGoodsTypeMapper;
-//	}
-//
-//
-//	/**
-//	 * 将一个 TbGoodsType 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G]
-//	 */
-//	static void check(TbGoodsType t) {
-//		AjaxError.throwByIsNull(t.getId(), "[主键] 不能为空");		// 验证: 主键
-//		AjaxError.throwByIsNull(t.getName(), "[名称] 不能为空");		// 验证: 名称
-//		AjaxError.throwByIsNull(t.getSort(), "[排序] 不能为空");		// 验证: 排序
-//		AjaxError.throwByIsNull(t.getNo(), "[编号] 不能为空");		// 验证: 编号
-//		AjaxError.throwByIsNull(t.getCreateTime(), "[创建时间] 不能为空");		// 验证: 创建时间
-//		AjaxError.throwByIsNull(t.getCreateBy(), "[创建人编号] 不能为空");		// 验证: 创建人编号
-//		AjaxError.throwByIsNull(t.getCreateName(), "[创建人名称] 不能为空");		// 验证: 创建人名称
-//		AjaxError.throwByIsNull(t.getUpdateTime(), "[更新时间] 不能为空");		// 验证: 更新时间
-//		AjaxError.throwByIsNull(t.getUpdateBy(), "[更新人编号] 不能为空");		// 验证: 更新人编号
-//		AjaxError.throwByIsNull(t.getUpdateName(), "[更新人名称] 不能为空");		// 验证: 更新人名称
-//		AjaxError.throwByIsNull(t.getDeleteStatus(), "[删除状态] 不能为空");		// 验证: 删除状态(0=禁用,1=启用)
-//	}
-//
-//	/**
-//	 * 获取一个TbGoodsType (方便复制代码用) [G]
-//	 */
-//	static TbGoodsType getTbGoodsType() {
-//		TbGoodsType t = new TbGoodsType();	// 声明对象
-//		t.setId("");		// 主键
-//		t.setName("");		// 名称
-//		t.setSort(0);		// 排序
-//		t.setNo("");		// 编号
-//		t.setCreateTime("");		// 创建时间
-//		t.setCreateBy("");		// 创建人编号
-//		t.setCreateName("");		// 创建人名称
-//		t.setUpdateTime("");		// 更新时间
-//		t.setUpdateBy("");		// 更新人编号
-//		t.setUpdateName("");		// 更新人名称
-//		t.setDeleteStatus(0);		// 删除状态(0=禁用,1=启用)
-//		return t;
-//	}
-//
-//
-//
-//
-//
-//}
+package com.pj.tb_goods_type;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 工具类:tb_goods_type -- 商品分类
+ * @author qzy 
+ *
+ */
+@Component
+public class TbGoodsTypeUtil {
+
+	
+	/** 底层 Mapper 对象 */
+	public static TbGoodsTypeMapper tbGoodsTypeMapper;
+	@Autowired
+	private void setTbGoodsTypeMapper(TbGoodsTypeMapper tbGoodsTypeMapper) {
+		TbGoodsTypeUtil.tbGoodsTypeMapper = tbGoodsTypeMapper;
+	}
+	
+
+
+	
+	
+	
+}