代码同步-删除单位管理功能,删除商品管理单位相关内容,添加商品规格字段;删除goodsunit
parent
6cffaf7164
commit
3ed71c7133
@ -1,88 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.controller.admin.unit;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import javax.validation.*;
|
|
||||||
import javax.servlet.http.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
|
||||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.basic.controller.admin.unit.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.basic.dal.dataobject.unit.UnitDO;
|
|
||||||
import cn.iocoder.yudao.module.basic.convert.unit.UnitConvert;
|
|
||||||
import cn.iocoder.yudao.module.basic.service.unit.UnitService;
|
|
||||||
|
|
||||||
@Api(tags = "管理后台 - 单位")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/basic/unit")
|
|
||||||
@Validated
|
|
||||||
public class UnitController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UnitService unitService;
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@ApiOperation("创建单位")
|
|
||||||
@PreAuthorize("@ss.hasPermission('basic:unit:create')")
|
|
||||||
public CommonResult<Long> createUnit(@Valid @RequestBody UnitCreateReqVO createReqVO) {
|
|
||||||
return success(unitService.createUnit(createReqVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping("/update")
|
|
||||||
@ApiOperation("更新单位")
|
|
||||||
@PreAuthorize("@ss.hasPermission('basic:unit:update')")
|
|
||||||
public CommonResult<Boolean> updateUnit(@Valid @RequestBody UnitUpdateReqVO updateReqVO) {
|
|
||||||
unitService.updateUnit(updateReqVO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
|
||||||
@ApiOperation("删除单位")
|
|
||||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
|
||||||
@PreAuthorize("@ss.hasPermission('basic:unit:delete')")
|
|
||||||
public CommonResult<Boolean> deleteUnit(@RequestParam("id") Long id) {
|
|
||||||
unitService.deleteUnit(id);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/get")
|
|
||||||
@ApiOperation("获得单位")
|
|
||||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
|
||||||
@PreAuthorize("@ss.hasPermission('basic:unit:query')")
|
|
||||||
public CommonResult<UnitRespVO> getUnit(@RequestParam("id") Long id) {
|
|
||||||
UnitDO unit = unitService.getUnit(id);
|
|
||||||
return success(UnitConvert.INSTANCE.convert(unit));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/list")
|
|
||||||
@ApiOperation("获得单位列表")
|
|
||||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
|
||||||
@PreAuthorize("@ss.hasPermission('basic:unit:query')")
|
|
||||||
public CommonResult<List<UnitRespVO>> getUnitList(@RequestParam("ids") Collection<Long> ids) {
|
|
||||||
List<UnitDO> list = unitService.getUnitList(ids);
|
|
||||||
return success(UnitConvert.INSTANCE.convertList(list));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/page")
|
|
||||||
@ApiOperation("获得单位分页")
|
|
||||||
@PreAuthorize("@ss.hasPermission('basic:unit:query')")
|
|
||||||
public CommonResult<PageResult<UnitRespVO>> getUnitPage(@Valid UnitPageReqVO pageVO) {
|
|
||||||
PageResult<UnitDO> pageResult = unitService.getUnitPage(pageVO);
|
|
||||||
return success(UnitConvert.INSTANCE.convertPage(pageResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.controller.admin.unit.vo;
|
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
@ApiModel("管理后台 - 商品创建 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class UnitCreateReqVO extends UnitBaseVO {
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.controller.admin.unit.vo;
|
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品 Excel VO
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class UnitExcelVO {
|
|
||||||
|
|
||||||
@ExcelProperty(" 编码")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@ExcelProperty("单位名称")
|
|
||||||
private String unitName;
|
|
||||||
|
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.controller.admin.unit.vo;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
@ApiModel(value = "管理后台 - 商品 Excel 导出 Request VO", description = "参数和 UnitPageReqVO 是一致的")
|
|
||||||
@Data
|
|
||||||
public class UnitExportReqVO {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "单位名称")
|
|
||||||
private String unitName;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
@DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private Date[] createTime;
|
|
||||||
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.controller.admin.unit.vo;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
@ApiModel("管理后台 - 商品分页 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class UnitPageReqVO extends PageParam {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "单位名称")
|
|
||||||
private String unitName;
|
|
||||||
|
|
||||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT")
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
private Date[] createTime;
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.controller.admin.unit.vo;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.*;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@ApiModel("管理后台 - 商品 Response VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class UnitRespVO extends UnitBaseVO {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = " 编码", required = true)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT")
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.controller.admin.unit.vo;
|
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
@ApiModel("管理后台 - 商品更新 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class UnitUpdateReqVO extends UnitBaseVO {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = " 编码", required = true)
|
|
||||||
@NotNull(message = " 编码不能为空")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.convert.unit;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
import cn.iocoder.yudao.module.basic.controller.admin.unit.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.basic.dal.dataobject.unit.UnitDO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品 Convert
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface UnitConvert {
|
|
||||||
|
|
||||||
UnitConvert INSTANCE = Mappers.getMapper(UnitConvert.class);
|
|
||||||
|
|
||||||
UnitDO convert(UnitCreateReqVO bean);
|
|
||||||
|
|
||||||
UnitDO convert(UnitUpdateReqVO bean);
|
|
||||||
|
|
||||||
UnitRespVO convert(UnitDO bean);
|
|
||||||
|
|
||||||
List<UnitRespVO> convertList(List<UnitDO> list);
|
|
||||||
|
|
||||||
PageResult<UnitRespVO> convertPage(PageResult<UnitDO> page);
|
|
||||||
|
|
||||||
List<UnitExcelVO> convertList02(List<UnitDO> list);
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.dal.mysql.unit;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import cn.iocoder.yudao.module.basic.dal.dataobject.unit.UnitDO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import cn.iocoder.yudao.module.basic.controller.admin.unit.vo.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商品 Mapper
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface UnitMapper extends BaseMapperX<UnitDO> {
|
|
||||||
|
|
||||||
default PageResult<UnitDO> selectPage(UnitPageReqVO reqVO) {
|
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<UnitDO>()
|
|
||||||
.likeIfPresent(UnitDO::getUnitName, reqVO.getUnitName())
|
|
||||||
.betweenIfPresent(UnitDO::getCreateTime, reqVO.getCreateTime())
|
|
||||||
.orderByDesc(UnitDO::getId));
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<UnitDO> selectList(UnitExportReqVO reqVO) {
|
|
||||||
return selectList(new LambdaQueryWrapperX<UnitDO>()
|
|
||||||
.likeIfPresent(UnitDO::getUnitName, reqVO.getUnitName())
|
|
||||||
.betweenIfPresent(UnitDO::getCreateTime, reqVO.getCreateTime())
|
|
||||||
.orderByDesc(UnitDO::getId));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.service.unit;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.validation.*;
|
|
||||||
import cn.iocoder.yudao.module.basic.controller.admin.unit.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.basic.dal.dataobject.unit.UnitDO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单位 Service 接口
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
public interface UnitService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建单位
|
|
||||||
*
|
|
||||||
* @param createReqVO 创建信息
|
|
||||||
* @return 编号
|
|
||||||
*/
|
|
||||||
Long createUnit(@Valid UnitCreateReqVO createReqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新单位
|
|
||||||
*
|
|
||||||
* @param updateReqVO 更新信息
|
|
||||||
*/
|
|
||||||
void updateUnit(@Valid UnitUpdateReqVO updateReqVO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除单位
|
|
||||||
*
|
|
||||||
* @param id 编号
|
|
||||||
*/
|
|
||||||
void deleteUnit(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得单位
|
|
||||||
*
|
|
||||||
* @param id 编号
|
|
||||||
* @return 商品
|
|
||||||
*/
|
|
||||||
UnitDO getUnit(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得单位列表
|
|
||||||
*
|
|
||||||
* @param ids 编号
|
|
||||||
* @return 商品列表
|
|
||||||
*/
|
|
||||||
List<UnitDO> getUnitList(Collection<Long> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得单位分页
|
|
||||||
*
|
|
||||||
* @param pageReqVO 分页查询
|
|
||||||
* @return 商品分页
|
|
||||||
*/
|
|
||||||
PageResult<UnitDO> getUnitPage(UnitPageReqVO pageReqVO);
|
|
||||||
|
|
||||||
}
|
|
@ -1,96 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.basic.service.unit;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import cn.iocoder.yudao.module.basic.controller.admin.unit.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.basic.dal.dataobject.unit.UnitDO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.basic.convert.unit.UnitConvert;
|
|
||||||
import cn.iocoder.yudao.module.basic.dal.mysql.unit.UnitMapper;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
||||||
import static cn.iocoder.yudao.module.basic.enums.ErrorCodeConstants.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单位 Service 实现类
|
|
||||||
*
|
|
||||||
* @author 芋道源码
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Validated
|
|
||||||
public class UnitServiceImpl implements UnitService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UnitMapper unitMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long createUnit(UnitCreateReqVO createReqVO) {
|
|
||||||
//校验单位昵称是否重复
|
|
||||||
validateUnitNameExists(createReqVO.getUnitName());
|
|
||||||
// 插入
|
|
||||||
UnitDO unit = UnitConvert.INSTANCE.convert(createReqVO);
|
|
||||||
unitMapper.insert(unit);
|
|
||||||
// 返回
|
|
||||||
return unit.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateUnitNameExists(String unitName) {
|
|
||||||
QueryWrapper<UnitDO> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("unit_name",unitName);
|
|
||||||
if (unitMapper.selectOne(queryWrapper) != null){
|
|
||||||
throw exception(UNIT_NAME_ALREADY_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateUnit(UnitUpdateReqVO updateReqVO) {
|
|
||||||
// 校验存在
|
|
||||||
UnitDO unitInfo = unitMapper.selectById(updateReqVO.getId());
|
|
||||||
if (unitInfo == null){
|
|
||||||
throw exception(UNIT_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
// 检查单位名称是否发生变化
|
|
||||||
if (!Objects.equals(unitInfo.getUnitName(),updateReqVO.getUnitName())) {
|
|
||||||
//校验商户昵称的地块类型名称是否重复
|
|
||||||
validateUnitNameExists(updateReqVO.getUnitName());
|
|
||||||
}
|
|
||||||
// 更新
|
|
||||||
UnitDO updateObj = UnitConvert.INSTANCE.convert(updateReqVO);
|
|
||||||
unitMapper.updateById(updateObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteUnit(Long id) {
|
|
||||||
// 校验存在
|
|
||||||
validateUnitExists(id);
|
|
||||||
// 删除
|
|
||||||
unitMapper.deleteById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateUnitExists(Long id) {
|
|
||||||
if (unitMapper.selectById(id) == null) {
|
|
||||||
throw exception(UNIT_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UnitDO getUnit(Long id) {
|
|
||||||
return unitMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<UnitDO> getUnitList(Collection<Long> ids) {
|
|
||||||
return unitMapper.selectBatchIds(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<UnitDO> getUnitPage(UnitPageReqVO pageReqVO) {
|
|
||||||
return unitMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue