diff --git a/fast-boot-system/src/main/java/net/maku/system/controller/SysAttachmentController.java b/fast-boot-system/src/main/java/net/maku/system/controller/SysAttachmentController.java new file mode 100644 index 0000000..67f17a3 --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/controller/SysAttachmentController.java @@ -0,0 +1,55 @@ +package net.maku.system.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import net.maku.framework.common.page.PageResult; +import net.maku.framework.common.utils.Result; +import net.maku.system.query.SysAttachmentQuery; +import net.maku.system.service.SysAttachmentService; +import net.maku.system.vo.SysAttachmentVO; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * 附件管理 + * + * @author 阿沐 babamu@126.com + */ +@RestController +@RequestMapping("sys/attachment") +@Tag(name = "附件管理") +@AllArgsConstructor +public class SysAttachmentController { + private final SysAttachmentService sysAttachmentService; + + @GetMapping("page") + @Operation(summary = "分页") + @PreAuthorize("hasAuthority('sys:attachment:page')") + public Result> page(@Valid SysAttachmentQuery query) { + PageResult page = sysAttachmentService.page(query); + + return Result.ok(page); + } + + @PostMapping + @Operation(summary = "保存") + @PreAuthorize("hasAuthority('sys:attachment:save')") + public Result save(@RequestBody SysAttachmentVO vo) { + sysAttachmentService.save(vo); + + return Result.ok(); + } + + @DeleteMapping + @Operation(summary = "删除") + @PreAuthorize("hasAuthority('sys:attachment:delete')") + public Result delete(@RequestBody List idList) { + sysAttachmentService.delete(idList); + + return Result.ok(); + } +} \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/convert/SysAttachmentConvert.java b/fast-boot-system/src/main/java/net/maku/system/convert/SysAttachmentConvert.java new file mode 100644 index 0000000..894c8ac --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/convert/SysAttachmentConvert.java @@ -0,0 +1,25 @@ +package net.maku.system.convert; + +import net.maku.system.entity.SysAttachmentEntity; +import net.maku.system.vo.SysAttachmentVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 附件管理 + * + * @author 阿沐 babamu@126.com + */ +@Mapper +public interface SysAttachmentConvert { + SysAttachmentConvert INSTANCE = Mappers.getMapper(SysAttachmentConvert.class); + + SysAttachmentEntity convert(SysAttachmentVO vo); + + SysAttachmentVO convert(SysAttachmentEntity entity); + + List convertList(List list); + +} \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/dao/SysAttachmentDao.java b/fast-boot-system/src/main/java/net/maku/system/dao/SysAttachmentDao.java new file mode 100644 index 0000000..a47304f --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/dao/SysAttachmentDao.java @@ -0,0 +1,15 @@ +package net.maku.system.dao; + +import net.maku.framework.common.dao.BaseDao; +import net.maku.system.entity.SysAttachmentEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 附件管理 + * + * @author 阿沐 babamu@126.com + */ +@Mapper +public interface SysAttachmentDao extends BaseDao { + +} \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/entity/SysAttachmentEntity.java b/fast-boot-system/src/main/java/net/maku/system/entity/SysAttachmentEntity.java new file mode 100644 index 0000000..e305614 --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/entity/SysAttachmentEntity.java @@ -0,0 +1,37 @@ +package net.maku.system.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.maku.framework.common.entity.BaseEntity; + +/** + * 附件管理 + * + * @author 阿沐 babamu@126.com + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("sys_attachment") +public class SysAttachmentEntity extends BaseEntity { + /** + * 附件名称 + */ + private String name; + + /** + * 附件地址 + */ + private String url; + + /** + * 附件大小 + */ + private Long size; + + /** + * 存储平台 + */ + private String platform; + +} \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/query/SysAttachmentQuery.java b/fast-boot-system/src/main/java/net/maku/system/query/SysAttachmentQuery.java new file mode 100644 index 0000000..bca93b0 --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/query/SysAttachmentQuery.java @@ -0,0 +1,23 @@ +package net.maku.system.query; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import net.maku.framework.common.query.Query; + +/** + * 附件管理查询 + * + * @author 阿沐 babamu@126.com + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(description = "附件管理查询") +public class SysAttachmentQuery extends Query { + @Schema(description = "附件名称") + private String name; + + @Schema(description = "存储平台") + private String platform; + +} \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/service/SysAttachmentService.java b/fast-boot-system/src/main/java/net/maku/system/service/SysAttachmentService.java new file mode 100644 index 0000000..ee3b9ff --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/service/SysAttachmentService.java @@ -0,0 +1,25 @@ +package net.maku.system.service; + +import net.maku.framework.common.page.PageResult; +import net.maku.framework.common.service.BaseService; +import net.maku.system.entity.SysAttachmentEntity; +import net.maku.system.query.SysAttachmentQuery; +import net.maku.system.vo.SysAttachmentVO; + +import java.util.List; + +/** + * 附件管理 + * + * @author 阿沐 babamu@126.com + */ +public interface SysAttachmentService extends BaseService { + + PageResult page(SysAttachmentQuery query); + + void save(SysAttachmentVO vo); + + void update(SysAttachmentVO vo); + + void delete(List idList); +} \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/service/impl/SysAttachmentServiceImpl.java b/fast-boot-system/src/main/java/net/maku/system/service/impl/SysAttachmentServiceImpl.java new file mode 100644 index 0000000..9e011ba --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/service/impl/SysAttachmentServiceImpl.java @@ -0,0 +1,65 @@ +package net.maku.system.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.AllArgsConstructor; +import net.maku.framework.common.page.PageResult; +import net.maku.framework.common.service.impl.BaseServiceImpl; +import net.maku.system.convert.SysAttachmentConvert; +import net.maku.system.dao.SysAttachmentDao; +import net.maku.system.entity.SysAttachmentEntity; +import net.maku.system.query.SysAttachmentQuery; +import net.maku.system.service.SysAttachmentService; +import net.maku.system.vo.SysAttachmentVO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 附件管理 + * + * @author 阿沐 babamu@126.com + */ +@Service +@AllArgsConstructor +public class SysAttachmentServiceImpl extends BaseServiceImpl implements SysAttachmentService { + + @Override + public PageResult page(SysAttachmentQuery query) { + IPage page = baseMapper.selectPage(getPage(query), getWrapper(query)); + + return new PageResult<>(SysAttachmentConvert.INSTANCE.convertList(page.getRecords()), page.getTotal()); + } + + private LambdaQueryWrapper getWrapper(SysAttachmentQuery query) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + wrapper.eq(StrUtil.isNotBlank(query.getPlatform()), SysAttachmentEntity::getPlatform, query.getPlatform()); + wrapper.like(StrUtil.isNotBlank(query.getName()), SysAttachmentEntity::getName, query.getName()); + wrapper.orderByDesc(SysAttachmentEntity::getId); + return wrapper; + } + + @Override + public void save(SysAttachmentVO vo) { + SysAttachmentEntity entity = SysAttachmentConvert.INSTANCE.convert(vo); + + baseMapper.insert(entity); + } + + @Override + public void update(SysAttachmentVO vo) { + SysAttachmentEntity entity = SysAttachmentConvert.INSTANCE.convert(vo); + + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(List idList) { + removeByIds(idList); + } + +} \ No newline at end of file diff --git a/fast-boot-system/src/main/java/net/maku/system/vo/SysAttachmentVO.java b/fast-boot-system/src/main/java/net/maku/system/vo/SysAttachmentVO.java new file mode 100644 index 0000000..4fbb160 --- /dev/null +++ b/fast-boot-system/src/main/java/net/maku/system/vo/SysAttachmentVO.java @@ -0,0 +1,40 @@ +package net.maku.system.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import net.maku.framework.common.utils.DateUtils; + +import java.io.Serializable; +import java.util.Date; + +/** + * 附件管理 + * + * @author 阿沐 babamu@126.com + */ +@Data +@Schema(description = "附件管理") +public class SysAttachmentVO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "id") + private Long id; + + @Schema(description = "附件名称") + private String name; + + @Schema(description = "附件地址") + private String url; + + @Schema(description = "附件大小") + private Long size; + + @Schema(description = "存储平台") + private String platform; + + @Schema(description = "创建时间") + @JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN) + private Date createTime; + +} \ No newline at end of file diff --git a/fast-boot-system/src/main/resources/mapper/SysAttachmentDao.xml b/fast-boot-system/src/main/resources/mapper/SysAttachmentDao.xml new file mode 100644 index 0000000..6496b57 --- /dev/null +++ b/fast-boot-system/src/main/resources/mapper/SysAttachmentDao.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file