图库需求
This commit is contained in:
parent
ee48e3f509
commit
f00e52905c
|
|
@ -0,0 +1,77 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.PictureClassifyDTO;
|
||||
import com.czg.account.service.PictureClassifyService;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/picture/classify")
|
||||
public class PictureClassifyController {
|
||||
private final PictureClassifyService pictureClassifyService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
@OperationLog("图片分类-列表")
|
||||
//@SaAdminCheckPermission("pictureClassify:list")
|
||||
public CzgResult<List<PictureClassifyDTO>> getPictureClassifyList(PictureClassifyDTO param) {
|
||||
List<PictureClassifyDTO> data = pictureClassifyService.getPictureClassifyList(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
@OperationLog("图片分类-新增")
|
||||
//@SaAdminCheckPermission("pictureClassify:add")
|
||||
public CzgResult<Void> addPictureClassify(@RequestBody @Validated({InsertGroup.class, DefaultGroup.class}) PictureClassifyDTO dto) {
|
||||
pictureClassifyService.addPictureClassify(dto);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping
|
||||
@OperationLog("图片分类-修改")
|
||||
//@SaAdminCheckPermission("pictureClassify:update")
|
||||
public CzgResult<Void> updatePictureClassify(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) PictureClassifyDTO dto) {
|
||||
pictureClassifyService.updatePictureClassify(dto);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 图片分类id
|
||||
*/
|
||||
@DeleteMapping("{id}")
|
||||
@OperationLog("图片分类-删除")
|
||||
//@SaAdminCheckPermission("pictureClassify:delete")
|
||||
public CzgResult<Void> deletePictureClassify(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
pictureClassifyService.deletePictureClassify(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.PictureGalleryDTO;
|
||||
import com.czg.account.service.PictureGalleryService;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 图库
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/picture/gallery")
|
||||
public class PictureGalleryController {
|
||||
private final PictureGalleryService pictureGalleryService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@OperationLog("图库-分页")
|
||||
//@SaAdminCheckPermission("pictureGallery:page")
|
||||
public CzgResult<Page<PictureGalleryDTO>> getPictureGalleryPage(PictureGalleryDTO param) {
|
||||
Page<PictureGalleryDTO> data = pictureGalleryService.getPictureGalleryPage(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加图片
|
||||
*/
|
||||
@PostMapping
|
||||
@OperationLog("图库-添加图片")
|
||||
//@SaAdminCheckPermission("pictureGallery:add")
|
||||
public CzgResult<Void> addPictureGallery(@RequestBody @Validated({InsertGroup.class, DefaultGroup.class}) PictureGalleryDTO dto) {
|
||||
pictureGalleryService.addPictureGallery(dto);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 图库id
|
||||
*/
|
||||
@DeleteMapping("{id}")
|
||||
@OperationLog("图库-删除图片")
|
||||
//@SaAdminCheckPermission("pictureGallery:delete")
|
||||
public CzgResult<Void> deletePictureGallery(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
pictureGalleryService.deletePictureGallery(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.czg.account.dto;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Data
|
||||
public class PictureClassifyDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Null(message = "ID必须为空", groups = InsertGroup.class)
|
||||
@NotNull(message = "ID不能为空", groups = UpdateGroup.class)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
@NotBlank(message = "分类名称不能为空", groups = DefaultGroup.class)
|
||||
private String name;
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
@NotNull(message = "排序值不能为空", groups = DefaultGroup.class)
|
||||
private Integer sort;
|
||||
/**
|
||||
* 单位来源 1-系统预设 0-商家创建
|
||||
*/
|
||||
private Integer isSystem;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 逻辑删除 1-是 0-否
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.czg.account.dto;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 图库
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Data
|
||||
public class PictureGalleryDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Null(message = "ID必须为空", groups = DefaultGroup.class)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 图片分类id
|
||||
*/
|
||||
@NotNull(message = "图片分类id不能为空", groups = DefaultGroup.class)
|
||||
private Long pictureClassifyId;
|
||||
/**
|
||||
* 图片URL地址
|
||||
*/
|
||||
@NotBlank(message = "图片URL地址不能为空", groups = DefaultGroup.class)
|
||||
private String url;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 逻辑删除 1-是 0-否
|
||||
*/
|
||||
private Integer isDel;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import com.mybatisflex.core.keygen.KeyGenerators;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Data
|
||||
@Table("tb_picture_classify")
|
||||
public class PictureClassify implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 排序值
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 单位来源 1-系统预设 0-商家创建
|
||||
*/
|
||||
private Integer isSystem;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 逻辑删除 1-是 0-否
|
||||
*/
|
||||
@Column(onInsertValue = "0")
|
||||
private Integer isDel;
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 图库
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Data
|
||||
@Table("tb_picture_gallery")
|
||||
public class PictureGallery implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 图片分类id
|
||||
*/
|
||||
private Long pictureClassifyId;
|
||||
/**
|
||||
* 图片URL地址
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 逻辑删除 1-是 0-否
|
||||
*/
|
||||
@Column(onInsertValue = "0")
|
||||
private Integer isDel;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.PictureClassifyDTO;
|
||||
import com.czg.account.entity.PictureClassify;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
public interface PictureClassifyService extends IService<PictureClassify> {
|
||||
|
||||
/**
|
||||
* 获取图片分类列表
|
||||
*
|
||||
* @param param 查询条件
|
||||
*/
|
||||
List<PictureClassifyDTO> getPictureClassifyList(PictureClassifyDTO param);
|
||||
|
||||
/**
|
||||
* 添加图片分类
|
||||
*
|
||||
* @param dto 图片分类DTO
|
||||
*/
|
||||
void addPictureClassify(PictureClassifyDTO dto);
|
||||
|
||||
/**
|
||||
* 更新图片分类
|
||||
*
|
||||
* @param dto 图片分类DTO
|
||||
*/
|
||||
void updatePictureClassify(PictureClassifyDTO dto);
|
||||
|
||||
/**
|
||||
* 删除图片分类
|
||||
*
|
||||
* @param id 图片分类ID
|
||||
*/
|
||||
void deletePictureClassify(Long id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.PictureGalleryDTO;
|
||||
import com.czg.account.entity.PictureGallery;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
/**
|
||||
* 图库
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
public interface PictureGalleryService extends IService<PictureGallery> {
|
||||
/**
|
||||
* 获取图库分页数据
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
Page<PictureGalleryDTO> getPictureGalleryPage(PictureGalleryDTO param);
|
||||
|
||||
/**
|
||||
* 添加图库图片
|
||||
*
|
||||
* @param dto 图片数据
|
||||
*/
|
||||
void addPictureGallery(PictureGalleryDTO dto);
|
||||
|
||||
/**
|
||||
* 删除图库图片
|
||||
*
|
||||
* @param id 图片ID
|
||||
*/
|
||||
void deletePictureGallery(Long id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.entity.PictureClassify;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Mapper
|
||||
public interface PictureClassifyMapper extends BaseMapper<PictureClassify> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.entity.PictureGallery;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 图库
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Mapper
|
||||
public interface PictureGalleryMapper extends BaseMapper<PictureGallery> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.PictureClassifyDTO;
|
||||
import com.czg.account.entity.PictureClassify;
|
||||
import com.czg.account.service.PictureClassifyService;
|
||||
import com.czg.enums.DeleteEnum;
|
||||
import com.czg.enums.YesNoEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.product.entity.ShopProdUnit;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.PictureClassifyMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 图片分类
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Service
|
||||
public class PictureClassifyServiceImpl extends ServiceImpl<PictureClassifyMapper, PictureClassify> implements PictureClassifyService {
|
||||
|
||||
private QueryWrapper buildQueryWrapper(PictureClassifyDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
if (StrUtil.isNotEmpty(param.getName())) {
|
||||
queryWrapper.like(PictureClassify::getName, param.getName());
|
||||
}
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
queryWrapper.eq(PictureClassify::getShopId, shopId);
|
||||
queryWrapper.eq(PictureClassify::getIsDel, DeleteEnum.DELETED.value());
|
||||
queryWrapper.orderBy(PictureClassify::getSort, true);
|
||||
queryWrapper.orderBy(PictureClassify::getId, false);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PictureClassifyDTO> getPictureClassifyList(PictureClassifyDTO param) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
return super.listAs(queryWrapper, PictureClassifyDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPictureClassify(PictureClassifyDTO dto) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
boolean exists = super.exists(query().eq(PictureClassify::getName, dto.getName())
|
||||
.eq(PictureClassify::getShopId, shopId)
|
||||
.and(q -> {
|
||||
q.eq(PictureClassify::getShopId, shopId).or(q1 -> {
|
||||
q1.eq(PictureClassify::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
|
||||
});
|
||||
})
|
||||
);
|
||||
if (exists) {
|
||||
throw new CzgException("图片分类已存在");
|
||||
}
|
||||
PictureClassify entity = BeanUtil.copyProperties(dto, PictureClassify.class);
|
||||
entity.setIsSystem(YesNoEnum.NO.value());
|
||||
entity.setShopId(shopId);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePictureClassify(PictureClassifyDTO dto) {
|
||||
checkPictureClassify(dto.getId());
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(PictureClassify::getName, dto.getName())
|
||||
.eq(PictureClassify::getShopId, shopId)
|
||||
.ne(PictureClassify::getId, dto.getId())
|
||||
.and(q -> {
|
||||
q.eq(PictureClassify::getShopId, shopId).or(q1 -> {
|
||||
q1.eq(PictureClassify::getShopId, 0).eq(ShopProdUnit::getIsSystem, YesNoEnum.YES.value());
|
||||
});
|
||||
})
|
||||
);
|
||||
if (exists) {
|
||||
throw new CzgException("图片分类已存在");
|
||||
}
|
||||
PictureClassify entity = BeanUtil.copyProperties(dto, PictureClassify.class);
|
||||
entity.setIsSystem(YesNoEnum.NO.value());
|
||||
super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePictureClassify(Long id) {
|
||||
checkPictureClassify(id);
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
UpdateChain.of(PictureClassify.class)
|
||||
.set(PictureClassify::getIsDel, DeleteEnum.DELETED.value())
|
||||
.eq(PictureClassify::getShopId, shopId)
|
||||
.eq(PictureClassify::getId, id)
|
||||
.update();
|
||||
}
|
||||
|
||||
private void checkPictureClassify(Long id) {
|
||||
PictureClassify entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("图片分类不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设分类不可操作");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.PictureGalleryDTO;
|
||||
import com.czg.account.entity.PictureGallery;
|
||||
import com.czg.account.service.PictureGalleryService;
|
||||
import com.czg.enums.DeleteEnum;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.PictureGalleryMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 图库
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-26
|
||||
*/
|
||||
@Service
|
||||
public class PictureGalleryServiceImpl extends ServiceImpl<PictureGalleryMapper, PictureGallery> implements PictureGalleryService {
|
||||
|
||||
private QueryWrapper buildQueryWrapper(PictureGalleryDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
if (StrUtil.isNotEmpty(param.getUrl())) {
|
||||
queryWrapper.eq(PictureGallery::getUrl, param.getUrl());
|
||||
}
|
||||
if (ObjUtil.isNotNull(param.getPictureClassifyId())) {
|
||||
queryWrapper.eq(PictureGallery::getPictureClassifyId, param.getPictureClassifyId());
|
||||
}
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
queryWrapper.eq(PictureGallery::getShopId, shopId);
|
||||
queryWrapper.eq(PictureGallery::getIsDel, DeleteEnum.NORMAL.value());
|
||||
queryWrapper.orderBy(PictureGallery::getId, false);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PictureGalleryDTO> getPictureGalleryPage(PictureGalleryDTO param) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(param);
|
||||
return super.pageAs(PageUtil.buildPage(), queryWrapper, PictureGalleryDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPictureGallery(PictureGalleryDTO dto) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
PictureGallery entity = BeanUtil.copyProperties(dto, PictureGallery.class);
|
||||
entity.setShopId(shopId);
|
||||
super.save(entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deletePictureGallery(Long id) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
UpdateChain.of(PictureGallery.class)
|
||||
.set(PictureGallery::getIsDel, DeleteEnum.DELETED.value())
|
||||
.eq(PictureGallery::getShopId, shopId)
|
||||
.eq(PictureGallery::getId, id)
|
||||
.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?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="com.czg.service.account.mapper.PictureClassifyMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?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="com.czg.service.account.mapper.PictureGalleryMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -88,6 +88,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
|
||||
@Override
|
||||
public void updateShopProdUnit(ShopProdUnitDTO dto) {
|
||||
checkShopProdUnit(dto.getId());
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
boolean exists = super.exists(query().eq(ShopProdUnit::getName, dto.getName())
|
||||
|
|
@ -107,26 +108,14 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
|
||||
@Override
|
||||
public void deleteShopProdUnit(Long id) {
|
||||
ShopProdUnit entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("单位信息不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设单位不可操作");
|
||||
}
|
||||
checkShopProdUnit(id);
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
super.remove(query().eq(ShopProdUnit::getId, id).eq(ShopProdUnit::getShopId, shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableShopProdUnit(Long id) {
|
||||
ShopProdUnit entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("单位信息不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设单位不可操作");
|
||||
}
|
||||
checkShopProdUnit(id);
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
UpdateChain.of(ShopProdUnit.class)
|
||||
.set(ShopProdUnit::getStatus, StatusEnum.DISABLE.value())
|
||||
|
|
@ -137,13 +126,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
|
||||
@Override
|
||||
public void enableShopProdUnit(Long id) {
|
||||
ShopProdUnit entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("单位信息不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设单位不可操作");
|
||||
}
|
||||
checkShopProdUnit(id);
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
UpdateChain.of(ShopProdUnit.class)
|
||||
.set(ShopProdUnit::getStatus, StatusEnum.ENABLED.value())
|
||||
|
|
@ -151,4 +134,14 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
|||
.eq(ShopProdUnit::getShopId, shopId)
|
||||
.update();
|
||||
}
|
||||
|
||||
private void checkShopProdUnit(Long id) {
|
||||
ShopProdUnit entity = super.getById(id);
|
||||
if (entity == null) {
|
||||
throw new CzgException("单位信息不存在");
|
||||
}
|
||||
if (entity.getIsSystem() == YesNoEnum.YES.value()) {
|
||||
throw new CzgException("系统预设单位不可操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue