Merge pull request 'yanyang' (#36) from yanyang into master

Reviewed-on: #36
This commit is contained in:
闫阳 2023-12-28 15:34:13 +08:00
джерело 33a90bc2ec 38ca9efa70
коміт ffc28af175
12 змінених файлів з 200 додано та 27 видалено

@ -1,5 +1,6 @@
package com.cnbm.packing.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData;
@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ProductLevelDTO;
import com.cnbm.packing.entity.ProductLevel;
import com.cnbm.packing.excel.ProductLevelExcel;
import com.cnbm.packing.mapper.ProductLevelMapper;
import com.cnbm.packing.service.ProductLevelServiceBiz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -39,6 +43,8 @@ import java.util.Map;
public class ProductLevelController {
@Autowired
private ProductLevelServiceBiz productLevelService;
@Autowired
private ProductLevelMapper productLevelMapper;
@GetMapping("page")
@ApiOperation("分页")
@ -69,26 +75,51 @@ public class ProductLevelController {
@ApiOperation("保存")
@LogOperation("保存")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:save')")
public Result<Long> save(@RequestBody ProductLevelDTO dto){
public Result<IdVo> save(@RequestBody ProductLevelDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
productLevelService.save(dto);
return new Result<Long>().ok(dto.getId());
//验证编码是否重名
QueryWrapper<ProductLevel> wrapper1 = new QueryWrapper<>();
wrapper1.eq(ProductLevel.CODE, dto.getCode());
if(productLevelMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<ProductLevel> wrapper2 = new QueryWrapper<>();
wrapper2.eq(ProductLevel.PRODUCT_LEVEL, dto.getProductLevel());
if(productLevelMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(productLevelService.add(dto));
}
}
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
// @PreAuthorize("@ex.hasAuthority('basic:productLevel:update')")
public Result<Long> update(@RequestBody ProductLevelDTO dto){
public Result<IdVo> update(@RequestBody ProductLevelDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
productLevelService.update(dto);
return new Result<Long>().ok(dto.getId());
//验证编码是否重名
ProductLevelDTO entity = productLevelService.get(dto.getId());
QueryWrapper<ProductLevel> wrapper1 = new QueryWrapper<>();
wrapper1.eq(ProductLevel.CODE, dto.getCode());
if(entity.getCode()!=dto.getCode() && productLevelMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<ProductLevel> wrapper2 = new QueryWrapper<>();
wrapper2.eq(ProductLevel.PRODUCT_LEVEL, dto.getProductLevel());
if(entity.getProductLevel()!=dto.getProductLevel() && productLevelMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(productLevelService.edit(dto));
}
}
@DeleteMapping

@ -1,5 +1,6 @@
package com.cnbm.packing.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData;
@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ScenesDTO;
import com.cnbm.packing.entity.Scenes;
import com.cnbm.packing.excel.ScenesExcel;
import com.cnbm.packing.mapper.ScenesMapper;
import com.cnbm.packing.service.ScenesServiceBiz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -39,6 +43,8 @@ import java.util.Map;
public class ScenesController {
@Autowired
private ScenesServiceBiz scenesService;
@Autowired
private ScenesMapper scenesMapper;
@GetMapping("page")
@ApiOperation("分页")
@ -69,26 +75,53 @@ public class ScenesController {
@ApiOperation("保存")
@LogOperation("保存")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:save')")
public Result<Long> save(@RequestBody ScenesDTO dto){
public Result<IdVo> save(@RequestBody ScenesDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
scenesService.save(dto);
return new Result<Long>().ok(dto.getId());
//验证编码是否重名
QueryWrapper<Scenes> wrapper1 = new QueryWrapper<>();
wrapper1.eq(Scenes.CODE, dto.getCode());
if(scenesMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<Scenes> wrapper2 = new QueryWrapper<>();
wrapper2.eq(Scenes.SCENES_NAME, dto.getScenesName());
System.out.println(scenesMapper.selectCount(wrapper2));
if(scenesMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(scenesService.add(dto));
}
}
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
// @PreAuthorize("@ex.hasAuthority('basic:scenes:update')")
public Result<Long> update(@RequestBody ScenesDTO dto){
public Result<IdVo> update(@RequestBody ScenesDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
scenesService.update(dto);
return new Result<Long>().ok(dto.getId());
//验证编码是否重名
ScenesDTO entity = scenesService.get(dto.getId());
QueryWrapper<Scenes> wrapper1 = new QueryWrapper<>();
wrapper1.eq(Scenes.CODE, dto.getCode());
if(entity.getCode()!=dto.getCode() && scenesMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<Scenes> wrapper2 = new QueryWrapper<>();
wrapper2.eq(Scenes.SCENES_NAME, dto.getScenesName());
System.out.println(scenesMapper.selectCount(wrapper2));
if(entity.getScenesName()!=dto.getScenesName() && scenesMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(scenesService.edit(dto));
}
}
@DeleteMapping

@ -1,5 +1,6 @@
package com.cnbm.packing.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData;
@ -10,8 +11,11 @@ import com.cnbm.common.validator.ValidatorUtils;
import com.cnbm.common.validator.group.AddGroup;
import com.cnbm.common.validator.group.DefaultGroup;
import com.cnbm.common.validator.group.UpdateGroup;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.entity.WorkingTime;
import com.cnbm.packing.excel.WorkingTimeExcel;
import com.cnbm.packing.mapper.WorkingTimeMapper;
import com.cnbm.packing.service.WorkingTimeServiceBiz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -41,6 +45,8 @@ import java.util.Map;
public class WorkingTimeController {
@Autowired
private WorkingTimeServiceBiz workingTimeService;
@Autowired
private WorkingTimeMapper workingTimeMapper;
@GetMapping("page")
@ApiOperation("分页")
@ -68,25 +74,50 @@ public class WorkingTimeController {
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")
public Result<Long> save(@RequestBody WorkingTimeDTO dto){
public Result<IdVo> save(@RequestBody WorkingTimeDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
workingTimeService.save(dto);
return new Result<Long>().ok(dto.getId());
//验证编码是否重名
QueryWrapper<WorkingTime> wrapper1 = new QueryWrapper<>();
wrapper1.eq(WorkingTime.CODE, dto.getCode());
if(workingTimeMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<WorkingTime> wrapper2 = new QueryWrapper<>();
wrapper2.eq(WorkingTime.ORDER_NAME, dto.getOrderName());
if(workingTimeMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(workingTimeService.add(dto));
}
}
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
public Result<Long> update(@RequestBody WorkingTimeDTO dto){
public Result<IdVo> update(@RequestBody WorkingTimeDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
workingTimeService.update(dto);
return new Result<Long>().ok(dto.getId());
//验证编码是否重名
WorkingTimeDTO entity = workingTimeService.get(dto.getId());
QueryWrapper<WorkingTime> wrapper1 = new QueryWrapper<>();
wrapper1.eq(WorkingTime.CODE, dto.getCode());
if(entity.getCode()!=dto.getCode() && workingTimeMapper.selectCount(wrapper1)!= 0){
return new Result().error(1,"编码重复");
}
//验证名称是否重名
QueryWrapper<WorkingTime> wrapper2 = new QueryWrapper<>();
wrapper2.eq( WorkingTime.ORDER_NAME, dto.getOrderName());
if(entity.getOrderName()!=dto.getOrderName() && workingTimeMapper.selectCount(wrapper2)!= 0){
return new Result().error(1,"名称重复");
}
else {
return new Result<IdVo>().ok(workingTimeService.edit(dto));
}
}
@DeleteMapping

@ -2,6 +2,7 @@ package com.cnbm.packing.service;
import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ProductLevelDTO;
import com.cnbm.packing.entity.ProductLevel;
@ -27,5 +28,8 @@ public interface ProductLevelServiceBiz extends CrudService<ProductLevel, Produc
void delete(Long[] ids);
List<ProductLevelDTO> list();
IdVo add(ProductLevelDTO dto);
IdVo edit(ProductLevelDTO dto);
}

@ -2,6 +2,7 @@ package com.cnbm.packing.service;
import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ScenesDTO;
import com.cnbm.packing.entity.Scenes;
@ -22,10 +23,14 @@ public interface ScenesServiceBiz extends CrudService<Scenes, ScenesDTO> {
void save(ScenesDTO dto);
IdVo add(ScenesDTO dto);
void update(ScenesDTO dto);
IdVo edit(ScenesDTO dto);
void delete(Long[] ids);
List<ScenesDTO> list();
}

@ -2,6 +2,7 @@ package com.cnbm.packing.service;
import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.entity.WorkingTime;
@ -31,4 +32,8 @@ public interface WorkingTimeServiceBiz extends CrudService<WorkingTime, WorkingT
List<WorkingTimeDTO> list();
String getOrderName(LocalDateTime time);
IdVo add(WorkingTimeDTO dto);
IdVo edit(WorkingTimeDTO dto);
}

@ -6,6 +6,7 @@ import com.cnbm.admin.utils.BaseSupportUtils;
import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.common.utils.ConvertUtils;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ProductLevelDTO;
import com.cnbm.packing.entity.ProductLevel;
import com.cnbm.packing.mapper.ProductLevelMapper;
@ -64,6 +65,16 @@ public class ProductLevelServiceBizImpl extends CrudServiceImpl<ProductLevelMapp
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo add(ProductLevelDTO dto) {
ProductLevel entity = ConvertUtils.sourceToTarget(dto, ProductLevel.class);
BaseSupportUtils.setCommonField(entity);
insert(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ProductLevelDTO dto) {
@ -72,6 +83,15 @@ public class ProductLevelServiceBizImpl extends CrudServiceImpl<ProductLevelMapp
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo edit(ProductLevelDTO dto) {
ProductLevel entity = ConvertUtils.sourceToTarget(dto, ProductLevel.class);
BaseSupportUtils.setUpdateCommonField(entity);
updateById(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long[] ids) {

@ -6,6 +6,7 @@ import com.cnbm.admin.utils.BaseSupportUtils;
import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.common.utils.ConvertUtils;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.ScenesDTO;
import com.cnbm.packing.entity.Scenes;
import com.cnbm.packing.mapper.ScenesMapper;
@ -86,5 +87,22 @@ public class ScenesServiceBizImpl extends CrudServiceImpl<ScenesMapper, Scenes,
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo add(ScenesDTO dto) {
Scenes entity = ConvertUtils.sourceToTarget(dto, Scenes.class);
BaseSupportUtils.setCommonField(entity);
insert(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo edit(ScenesDTO dto) {
Scenes entity = ConvertUtils.sourceToTarget(dto, Scenes.class);
BaseSupportUtils.setUpdateCommonField(entity);
updateById(entity);
return IdVo.builder().id(entity.getId()).build();
}
}

@ -8,6 +8,7 @@ import com.cnbm.common.page.PageData;
import com.cnbm.common.service.impl.CrudServiceImpl;
import com.cnbm.common.utils.ConvertUtils;
import com.cnbm.packing.dto.IdVo;
import com.cnbm.packing.dto.WorkingTimeDTO;
import com.cnbm.packing.entity.WorkingTime;
import com.cnbm.packing.mapper.WorkingTimeMapper;
@ -72,6 +73,17 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo add(WorkingTimeDTO dto) {
//验证时间段不重合
timeOverlap(dto);
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
BaseSupportUtils.setCommonField(entity);
insert(entity);
return IdVo.builder().id(entity.getId()).build();
}
public void timeOverlap(WorkingTimeDTO newTime){
List<WorkingTimeDTO> dtoList = list();
LocalTime newBeginTime = newTime.getBeginTime().toLocalTime();
@ -115,6 +127,18 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public IdVo edit(WorkingTimeDTO dto) {
//验证时间段不重合
timeOverlap(dto);
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
BaseSupportUtils.setUpdateCommonField(entity);
updateById(entity);
return IdVo.builder().id(entity.getId()).build();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long[] ids) {
@ -154,5 +178,4 @@ public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper
}
}

@ -18,6 +18,7 @@
<select id="list" resultType="com.cnbm.packing.dto.ProductLevelDTO">
select * from t_product_level
where valid = 1
order by id asc
</select>

@ -17,6 +17,7 @@
<select id="list" resultType="com.cnbm.packing.dto.ScenesDTO">
select * from t_scenes
where valid = 1
order by id asc
</select>

@ -19,6 +19,7 @@
<select id="list" resultType="com.cnbm.packing.dto.WorkingTimeDTO">
select * from t_working_time
where valid = 1
order by id asc
</select>