|
|
|
@ -1,42 +1,29 @@ |
|
|
|
|
package org.jeecg.modules.demo.base.controller; |
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
import java.net.URLDecoder; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
|
import org.jeecg.common.util.oConvertUtils; |
|
|
|
|
import org.jeecg.modules.demo.base.entity.ZyClothsType; |
|
|
|
|
import org.jeecg.modules.demo.base.service.IZyClothsTypeService; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil; |
|
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
|
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams; |
|
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams; |
|
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
|
|
|
|
import org.jeecg.common.api.vo.Result; |
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController; |
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
|
import org.jeecg.modules.demo.base.entity.ZyClothsType; |
|
|
|
|
import org.jeecg.modules.demo.base.mapper.ZyClothsTypeMapper; |
|
|
|
|
import org.jeecg.modules.demo.base.service.IZyClothsTypeService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest; |
|
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Description: zy_cloths_type |
|
|
|
@ -51,6 +38,8 @@ import org.jeecg.common.aspect.annotation.AutoLog; |
|
|
|
|
public class ZyClothsTypeController extends JeecgController<ZyClothsType, IZyClothsTypeService> { |
|
|
|
|
@Autowired |
|
|
|
|
private IZyClothsTypeService zyClothsTypeService; |
|
|
|
|
@Resource |
|
|
|
|
private ZyClothsTypeMapper zyClothsTypeMapper; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页列表查询 |
|
|
|
@ -84,15 +73,25 @@ public class ZyClothsTypeController extends JeecgController<ZyClothsType, IZyClo |
|
|
|
|
@ApiOperation(value = "zy_cloths_type-添加", notes = "zy_cloths_type-添加") |
|
|
|
|
@PostMapping(value = "/add") |
|
|
|
|
public Result<?> add(@RequestBody ZyClothsType zyClothsType) { |
|
|
|
|
//类型名称输入时没有最大长度限制,提交时才提示。前端校验、后台校验
|
|
|
|
|
//type_name,类型名称,varchar,50,非空,同类型下不重复
|
|
|
|
|
String typeName = zyClothsType.getTypeName(); |
|
|
|
|
if (!StringUtils.hasText(typeName)) { |
|
|
|
|
return Result.error("类型名称 不能为空"); |
|
|
|
|
} |
|
|
|
|
//类型名称输入时没有最大长度限制,提交时才提示。前端校验、后台校验
|
|
|
|
|
if (typeName.length() > 10) { |
|
|
|
|
return Result.error("类型名称长度不能超过10"); |
|
|
|
|
} |
|
|
|
|
//类型名称 同类型下不重复
|
|
|
|
|
if (!StringUtils.isEmpty(zyClothsType.getTypeId())) { |
|
|
|
|
String typeId = zyClothsType.getTypeId(); |
|
|
|
|
List<String> zyClothsTypeList = zyClothsTypeMapper.listByTypeId(typeId); |
|
|
|
|
zyClothsTypeList.add(zyClothsType.getTypeName()); |
|
|
|
|
HashSet<String> set = new HashSet<>(zyClothsTypeList); |
|
|
|
|
if (set.size() != zyClothsTypeList.size()){ |
|
|
|
|
return Result.error("同类型下 类型名称不能重复"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//生成编号 nums,编号,varchar,10,非空,不重复,企业缩写(4)+顺序号(6)在service层处理
|
|
|
|
|
zyClothsType.setNums(zyClothsTypeService.generateNumber()); |
|
|
|
|
zyClothsTypeService.save(zyClothsType); |
|
|
|
|