From 1be24d92987d070ce1fddd2fdcb9626d31b09fb5 Mon Sep 17 00:00:00 2001 From: walker Date: Tue, 6 Jun 2023 11:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BA=BF=E8=B7=AF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E3=80=81=E7=BB=98=E5=9B=BE=E8=8D=89=E7=A8=BF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8F=8A=E4=B8=80=E4=BA=9B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DraftingController.java | 73 +++++++++++++++++++ .../controller/LineInfoController.java | 18 +++++ .../xiannccda/controller/UserController.java | 6 +- .../joylink/xiannccda/dto/DraftingDto.java | 5 ++ .../xiannccda/dto/DraftingQueryDto.java | 15 ++++ .../joylink/xiannccda/dto/LoginInfoDto.java | 4 +- .../joylink/xiannccda/entity/Drafting.java | 56 ++++++++++++++ .../joylink/xiannccda/entity/LineInfo.java | 57 +++++++++++++++ .../xiannccda/mapper/DraftingMapper.java | 18 +++++ .../xiannccda/mapper/LineInfoMapper.java | 18 +++++ .../xiannccda/mapper/xml/DraftingMapper.xml | 19 +++++ .../xiannccda/mapper/xml/LineInfoMapper.xml | 20 +++++ .../repository/IDraftingRepository.java | 27 +++++++ .../repository/ILineInfoRepository.java | 16 ++++ .../repository/impl/DraftingRepository.java | 48 ++++++++++++ .../repository/impl/LineInfoRepository.java | 20 +++++ .../joylink/xiannccda/occmock/OccServer.java | 5 ++ 17 files changed, 418 insertions(+), 7 deletions(-) create mode 100644 src/main/java/club/joylink/xiannccda/controller/DraftingController.java create mode 100644 src/main/java/club/joylink/xiannccda/controller/LineInfoController.java create mode 100644 src/main/java/club/joylink/xiannccda/dto/DraftingDto.java create mode 100644 src/main/java/club/joylink/xiannccda/dto/DraftingQueryDto.java create mode 100644 src/main/java/club/joylink/xiannccda/entity/Drafting.java create mode 100644 src/main/java/club/joylink/xiannccda/entity/LineInfo.java create mode 100644 src/main/java/club/joylink/xiannccda/mapper/DraftingMapper.java create mode 100644 src/main/java/club/joylink/xiannccda/mapper/LineInfoMapper.java create mode 100644 src/main/java/club/joylink/xiannccda/mapper/xml/DraftingMapper.xml create mode 100644 src/main/java/club/joylink/xiannccda/mapper/xml/LineInfoMapper.xml create mode 100644 src/main/java/club/joylink/xiannccda/repository/IDraftingRepository.java create mode 100644 src/main/java/club/joylink/xiannccda/repository/ILineInfoRepository.java create mode 100644 src/main/java/club/joylink/xiannccda/repository/impl/DraftingRepository.java create mode 100644 src/main/java/club/joylink/xiannccda/repository/impl/LineInfoRepository.java create mode 100644 src/test/java/club/joylink/xiannccda/occmock/OccServer.java diff --git a/src/main/java/club/joylink/xiannccda/controller/DraftingController.java b/src/main/java/club/joylink/xiannccda/controller/DraftingController.java new file mode 100644 index 0000000..a6e74ef --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/controller/DraftingController.java @@ -0,0 +1,73 @@ +package club.joylink.xiannccda.controller; + +import club.joylink.xiannccda.dto.DraftingQueryDto; +import club.joylink.xiannccda.entity.Drafting; +import club.joylink.xiannccda.entity.Drafting.Creation; +import club.joylink.xiannccda.repository.IDraftingRepository; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 绘图草稿 前端控制器 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@RestController +@RequestMapping("/api/drafting") +@Tag(name = "绘图草稿管理接口") +public class DraftingController { + + final IDraftingRepository draftingRepository; + + public DraftingController(IDraftingRepository draftingRepository) { + this.draftingRepository = draftingRepository; + } + + @GetMapping("/paging") + @SecurityRequirement(name = "jwt") + @Operation(summary = "分页查询绘图草稿信息") + @ApiResponse(description = "绘图草稿信息") + public Page paging(DraftingQueryDto query) { + return this.draftingRepository.pageQuery(query); + } + + @PostMapping("") + @SecurityRequirement(name = "jwt") + @Operation(summary = "创建绘图草稿") + @ApiResponse(description = "绘图草稿信息") + public Drafting create(@RequestBody @Validated(Creation.class) Drafting drafting) { + return this.draftingRepository.create(drafting); + } + + @GetMapping("/{id}") + @SecurityRequirement(name = "jwt") + @Operation(summary = "获取绘图草稿数据") + @ApiResponse(description = "绘图草稿数据") + public Drafting getById(@PathVariable Long id) { + return this.draftingRepository.getById(id); + } + + @DeleteMapping("/{id}") + @SecurityRequirement(name = "jwt") + @Operation(summary = "删除绘图草稿数据") + @ApiResponse(description = "绘图草稿数据") + public boolean deleteById(@PathVariable Long id) { + return this.draftingRepository.removeById(id); + } +} diff --git a/src/main/java/club/joylink/xiannccda/controller/LineInfoController.java b/src/main/java/club/joylink/xiannccda/controller/LineInfoController.java new file mode 100644 index 0000000..980d6ff --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/controller/LineInfoController.java @@ -0,0 +1,18 @@ +package club.joylink.xiannccda.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 前端控制器 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@RestController +@RequestMapping("/lineInfo") +public class LineInfoController { + +} diff --git a/src/main/java/club/joylink/xiannccda/controller/UserController.java b/src/main/java/club/joylink/xiannccda/controller/UserController.java index dda5414..f108353 100644 --- a/src/main/java/club/joylink/xiannccda/controller/UserController.java +++ b/src/main/java/club/joylink/xiannccda/controller/UserController.java @@ -5,14 +5,10 @@ import club.joylink.xiannccda.entity.User; import club.joylink.xiannccda.entity.User.Register; import club.joylink.xiannccda.service.UserService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; -import java.util.List; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -28,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController; */ @RestController @RequestMapping("/api/user") -@Tag(name = "用户管理接口", description = "用户管理接口描述") +@Tag(name = "用户管理接口") public class UserController { private UserService userService; diff --git a/src/main/java/club/joylink/xiannccda/dto/DraftingDto.java b/src/main/java/club/joylink/xiannccda/dto/DraftingDto.java new file mode 100644 index 0000000..fb6013e --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/dto/DraftingDto.java @@ -0,0 +1,5 @@ +package club.joylink.xiannccda.dto; + +public class DraftingDto { + +} diff --git a/src/main/java/club/joylink/xiannccda/dto/DraftingQueryDto.java b/src/main/java/club/joylink/xiannccda/dto/DraftingQueryDto.java new file mode 100644 index 0000000..318b66b --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/dto/DraftingQueryDto.java @@ -0,0 +1,15 @@ +package club.joylink.xiannccda.dto; + +import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class DraftingQueryDto extends PageDTO { + + @Schema(description = "草稿图名称") + String name; + +} diff --git a/src/main/java/club/joylink/xiannccda/dto/LoginInfoDto.java b/src/main/java/club/joylink/xiannccda/dto/LoginInfoDto.java index ad2da8e..7502f81 100644 --- a/src/main/java/club/joylink/xiannccda/dto/LoginInfoDto.java +++ b/src/main/java/club/joylink/xiannccda/dto/LoginInfoDto.java @@ -12,8 +12,8 @@ import lombok.Setter; @Schema(name = "登录信息") public class LoginInfoDto { - @Schema(description = "账号", defaultValue = "19999999999") + @Schema(description = "账号", defaultValue = "17791995809") String account; - @Schema(description = "密码", defaultValue = "123456") + @Schema(description = "密码", defaultValue = "95129dbaace576e46f41a629e6f35d5c") String password; } diff --git a/src/main/java/club/joylink/xiannccda/entity/Drafting.java b/src/main/java/club/joylink/xiannccda/entity/Drafting.java new file mode 100644 index 0000000..acd1668 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/entity/Drafting.java @@ -0,0 +1,56 @@ +package club.joylink.xiannccda.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import jakarta.validation.constraints.NotBlank; +import java.time.LocalDateTime; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +/** + *

+ * 绘图草稿 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@Getter +@Setter +@Accessors(chain = true) +@Schema(name = "Drafting", description = "$!{table.comment}") +public class Drafting { + + @Schema(description = "id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @Schema(description = "草稿图名称") + @NotBlank(message = "草稿图名称不能为空", groups = {Creation.class}) + private String name; + + @Schema(description = "绘图数据") + private byte[] proto; + + @Schema(description = "创建时间") + private LocalDateTime createdAt; + + @Schema(description = "修改时间") + private LocalDateTime updateAt; + + public static final String ID = "id"; + + public static final String NAME = "name"; + + public static final String PROTO = "proto"; + + public static final String CREATED_AT = "created_at"; + + public static final String UPDATE_AT = "update_at"; + + public interface Creation { + + } +} diff --git a/src/main/java/club/joylink/xiannccda/entity/LineInfo.java b/src/main/java/club/joylink/xiannccda/entity/LineInfo.java new file mode 100644 index 0000000..ae8cbf3 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/entity/LineInfo.java @@ -0,0 +1,57 @@ +package club.joylink.xiannccda.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.time.LocalDateTime; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@Getter +@Setter +@Accessors(chain = true) +@TableName("line_info") +@Schema(name = "LineInfo", description = "$!{table.comment}") +public class LineInfo { + + @Schema(description = "id") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @Schema(description = "线路名") + private String name; + + @Schema(description = "线路号") + private Integer lineId; + + @Schema(description = "线路配置") + private String config; + + @Schema(description = "创建时间") + private LocalDateTime createdAt; + + @Schema(description = "修改时间") + private LocalDateTime updateAt; + + public static final String ID = "id"; + + public static final String NAME = "name"; + + public static final String LINE_ID = "line_id"; + + public static final String CONFIG = "config"; + + public static final String CREATED_AT = "created_at"; + + public static final String UPDATE_AT = "update_at"; +} diff --git a/src/main/java/club/joylink/xiannccda/mapper/DraftingMapper.java b/src/main/java/club/joylink/xiannccda/mapper/DraftingMapper.java new file mode 100644 index 0000000..f632d7e --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/mapper/DraftingMapper.java @@ -0,0 +1,18 @@ +package club.joylink.xiannccda.mapper; + +import club.joylink.xiannccda.entity.Drafting; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 绘图草稿 Mapper 接口 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@Mapper +public interface DraftingMapper extends BaseMapper { + +} diff --git a/src/main/java/club/joylink/xiannccda/mapper/LineInfoMapper.java b/src/main/java/club/joylink/xiannccda/mapper/LineInfoMapper.java new file mode 100644 index 0000000..d5490a4 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/mapper/LineInfoMapper.java @@ -0,0 +1,18 @@ +package club.joylink.xiannccda.mapper; + +import club.joylink.xiannccda.entity.LineInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@Mapper +public interface LineInfoMapper extends BaseMapper { + +} diff --git a/src/main/java/club/joylink/xiannccda/mapper/xml/DraftingMapper.xml b/src/main/java/club/joylink/xiannccda/mapper/xml/DraftingMapper.xml new file mode 100644 index 0000000..3552ad2 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/mapper/xml/DraftingMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + id, name, proto, created_at, update_at + + + diff --git a/src/main/java/club/joylink/xiannccda/mapper/xml/LineInfoMapper.xml b/src/main/java/club/joylink/xiannccda/mapper/xml/LineInfoMapper.xml new file mode 100644 index 0000000..44106ae --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/mapper/xml/LineInfoMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + id, name, line_id, config, created_at, update_at + + + diff --git a/src/main/java/club/joylink/xiannccda/repository/IDraftingRepository.java b/src/main/java/club/joylink/xiannccda/repository/IDraftingRepository.java new file mode 100644 index 0000000..3f45f6c --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/repository/IDraftingRepository.java @@ -0,0 +1,27 @@ +package club.joylink.xiannccda.repository; + +import club.joylink.xiannccda.dto.DraftingQueryDto; +import club.joylink.xiannccda.entity.Drafting; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 绘图草稿 服务类 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +public interface IDraftingRepository extends IService { + + /** + * 分页查询绘图数据 + * + * @param query + * @return + */ + Page pageQuery(DraftingQueryDto query); + + Drafting create(Drafting drafting); +} diff --git a/src/main/java/club/joylink/xiannccda/repository/ILineInfoRepository.java b/src/main/java/club/joylink/xiannccda/repository/ILineInfoRepository.java new file mode 100644 index 0000000..167e0cd --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/repository/ILineInfoRepository.java @@ -0,0 +1,16 @@ +package club.joylink.xiannccda.repository; + +import club.joylink.xiannccda.entity.LineInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +public interface ILineInfoRepository extends IService { + +} diff --git a/src/main/java/club/joylink/xiannccda/repository/impl/DraftingRepository.java b/src/main/java/club/joylink/xiannccda/repository/impl/DraftingRepository.java new file mode 100644 index 0000000..1af49cf --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/repository/impl/DraftingRepository.java @@ -0,0 +1,48 @@ +package club.joylink.xiannccda.repository.impl; + +import club.joylink.xiannccda.dto.DraftingQueryDto; +import club.joylink.xiannccda.entity.Drafting; +import club.joylink.xiannccda.mapper.DraftingMapper; +import club.joylink.xiannccda.repository.IDraftingRepository; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.time.LocalDateTime; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +/** + *

+ * 绘图草稿 服务实现类 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@Service +@Slf4j +public class DraftingRepository extends ServiceImpl implements + IDraftingRepository { + + @Override + public Page pageQuery(DraftingQueryDto query) { + log.info("分页查询参数: {},{},{}", query.getCurrent(), query.getSize(), query.getName()); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + // 分页不查询具体proto数据 + wrapper.select(info -> !info.getColumn().equals("proto")); + if (StringUtils.hasText(query.getName())) { + wrapper.like(Drafting::getName, query.getName()); + } + DraftingQueryDto page = this.page(query, wrapper); + return page; + } + + @Override + public Drafting create(Drafting drafting) { + drafting.setCreatedAt(LocalDateTime.now()); + this.save(drafting); + return drafting; + } +} diff --git a/src/main/java/club/joylink/xiannccda/repository/impl/LineInfoRepository.java b/src/main/java/club/joylink/xiannccda/repository/impl/LineInfoRepository.java new file mode 100644 index 0000000..f162e91 --- /dev/null +++ b/src/main/java/club/joylink/xiannccda/repository/impl/LineInfoRepository.java @@ -0,0 +1,20 @@ +package club.joylink.xiannccda.repository.impl; + +import club.joylink.xiannccda.entity.LineInfo; +import club.joylink.xiannccda.mapper.LineInfoMapper; +import club.joylink.xiannccda.repository.ILineInfoRepository; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author walker-sheng + * @since 2023-06-06 + */ +@Service +public class LineInfoRepository extends ServiceImpl implements ILineInfoRepository { + +} diff --git a/src/test/java/club/joylink/xiannccda/occmock/OccServer.java b/src/test/java/club/joylink/xiannccda/occmock/OccServer.java new file mode 100644 index 0000000..68eae8a --- /dev/null +++ b/src/test/java/club/joylink/xiannccda/occmock/OccServer.java @@ -0,0 +1,5 @@ +package club.joylink.xiannccda.occmock; + +public class OccServer { + +}