diff --git a/.gitignore b/.gitignore index 958fe2c60..1406fdff0 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ build/ ### VS Code ### .vscode/ /jars/ +/logs/ diff --git a/cash-api/system-server/src/main/java/com/czg/admin/MiniAppPagesController.java b/cash-api/system-server/src/main/java/com/czg/admin/MiniAppPagesController.java new file mode 100644 index 000000000..ddf51c7b5 --- /dev/null +++ b/cash-api/system-server/src/main/java/com/czg/admin/MiniAppPagesController.java @@ -0,0 +1,66 @@ +package com.czg.admin; + +import com.czg.resp.CzgResult; +import com.czg.system.dto.MiniAppPagesDTO; +import com.czg.system.service.MiniAppPageService; +import com.czg.validator.group.InsertGroup; +import com.czg.validator.group.UpdateGroup; +import com.mybatisflex.core.paginate.Page; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +/** + * 小程序页面 + * + * @author GYJoker + */ +@RestController +@RequestMapping("/admin/miniAppPages") +public class MiniAppPagesController { + + @Resource + private MiniAppPageService miniAppPageService; + + /** + * 新增小程序页面 + * @param pagesDTO 小程序页面 + * @return 结果 + */ + @PostMapping + public CzgResult insertMiniAppPage(@RequestBody @Validated({InsertGroup.class}) MiniAppPagesDTO pagesDTO) { + return miniAppPageService.insertMiniAppPage(pagesDTO); + } + + /** + * 修改小程序页面 + * @param pagesDTO 小程序页面 + * @return 结果 + */ + @PutMapping + public CzgResult updateMiniAppPage(@RequestBody @Validated({UpdateGroup.class}) MiniAppPagesDTO pagesDTO) { + return miniAppPageService.updateMiniAppPage(pagesDTO); + } + + /** + * 删除小程序页面 + * @param id 小程序页面主键 + * @return 结果 + */ + @DeleteMapping("{id}") + public CzgResult deleteMiniAppPage(@PathVariable Long id) { + return miniAppPageService.deleteMiniAppPageById(id); + } + + /** + * 查询小程序页面 分页 + * @param name 小程序页面名称 + * @param path 小程序页面路径 + * @param status 小程序页面状态 -1 查全部 1 启用 0 禁用 + * @return 结果 + */ + @GetMapping("page") + public CzgResult> getMiniAppPage(String name, String path, Integer status) { + return miniAppPageService.getMiniAppPage(name, path, status); + } +} diff --git a/cash-common/cash-common-service/src/main/java/com/czg/system/dto/MiniAppPagesDTO.java b/cash-common/cash-common-service/src/main/java/com/czg/system/dto/MiniAppPagesDTO.java new file mode 100644 index 000000000..860a260a3 --- /dev/null +++ b/cash-common/cash-common-service/src/main/java/com/czg/system/dto/MiniAppPagesDTO.java @@ -0,0 +1,52 @@ +package com.czg.system.dto; + +import com.czg.validator.group.Group; +import com.czg.validator.group.UpdateGroup; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * @author GYJoker + */ +@Data +public class MiniAppPagesDTO { + + /** + * id + */ + @NotNull(message = "id不能为空", groups = {UpdateGroup.class}) + private Long id; + + /** + * 图标 + */ + private String icon; + + /** + * 页面名称 + */ + @NotBlank(message = "页面路径不能为空", groups = {Group.class}) + private String name; + + /** + * 页面路径 + */ + @NotBlank(message = "页面路径不能为空", groups = {Group.class}) + private String path; + + /** + * 页面描述 + */ + private String description; + + /** + * 状态 1:启用 0:禁用 + */ + private Integer status = 1; + + /** + * 排序 + */ + private Integer sort = 1; +} diff --git a/cash-common/cash-common-service/src/main/java/com/czg/system/entity/MiniAppPages.java b/cash-common/cash-common-service/src/main/java/com/czg/system/entity/MiniAppPages.java new file mode 100644 index 000000000..fc16ebb80 --- /dev/null +++ b/cash-common/cash-common-service/src/main/java/com/czg/system/entity/MiniAppPages.java @@ -0,0 +1,81 @@ +package com.czg.system.entity; + +import com.mybatisflex.annotation.Column; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.KeyType; +import com.mybatisflex.annotation.Table; +import java.io.Serializable; +import java.time.LocalDateTime; + +import java.io.Serial; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 小程序页面路径 实体类。 + * + * @author mac + * @since 2025-02-12 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table("tb_mini_app_pages") +public class MiniAppPages implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 自增id + */ + @Id(keyType = KeyType.Auto) + private Long id; + + /** + * icon图片 + */ + private String icon; + + /** + * 页面名称 + */ + private String name; + + /** + * 页面路径 + */ + private String path; + + /** + * 页面描述 + */ + private String description; + + /** + * 页面状态:0未启用,1已启用 + */ + private Integer status; + + /** + * 排序 + */ + private Integer sort; + + /** + * 创建时间 + */ + @Column(onInsertValue = "now()") + private LocalDateTime createTime; + + /** + * 更新时间 + */ + @Column(onInsertValue = "now()", onUpdateValue = "now()") + private LocalDateTime updateTime; + +} diff --git a/cash-common/cash-common-service/src/main/java/com/czg/system/service/MiniAppPageService.java b/cash-common/cash-common-service/src/main/java/com/czg/system/service/MiniAppPageService.java new file mode 100644 index 000000000..e8d016717 --- /dev/null +++ b/cash-common/cash-common-service/src/main/java/com/czg/system/service/MiniAppPageService.java @@ -0,0 +1,43 @@ +package com.czg.system.service; + +import com.czg.resp.CzgResult; +import com.czg.system.dto.MiniAppPagesDTO; +import com.czg.system.entity.MiniAppPages; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.service.IService; + +/** + * 店铺支付类型 服务层。 + * + * @author mac + * @since 2025-02-12 + */ +public interface MiniAppPageService extends IService { + + /** + * 新增小程序页面 + * @param pagesDTO 小程序页面 + * @return 结果 + */ + CzgResult insertMiniAppPage(MiniAppPagesDTO pagesDTO); + + /** + * 修改小程序页面 + * @param pagesDTO 小程序页面 + * @return 结果 + */ + CzgResult updateMiniAppPage(MiniAppPagesDTO pagesDTO); + + /** + * 删除小程序页面 + * @param id 小程序页面主键 + * @return 结果 + */ + CzgResult deleteMiniAppPageById(Long id); + + /** + * 查询小程序页面列表 + * @return 结果 + */ + CzgResult> getMiniAppPage(String name, String path, Integer status); +} diff --git a/cash-service/system-service/src/main/java/com/czg/service/system/mapper/MiniAppPagesMapper.java b/cash-service/system-service/src/main/java/com/czg/service/system/mapper/MiniAppPagesMapper.java new file mode 100644 index 000000000..0be420dee --- /dev/null +++ b/cash-service/system-service/src/main/java/com/czg/service/system/mapper/MiniAppPagesMapper.java @@ -0,0 +1,14 @@ +package com.czg.service.system.mapper; + +import com.czg.system.entity.MiniAppPages; +import com.mybatisflex.core.BaseMapper; + +/** + * 小程序页面路径 映射层。 + * + * @author mac + * @since 2025-02-12 + */ +public interface MiniAppPagesMapper extends BaseMapper { + +} diff --git a/cash-service/system-service/src/main/java/com/czg/service/system/service/impl/MiniAppPagesServiceImpl.java b/cash-service/system-service/src/main/java/com/czg/service/system/service/impl/MiniAppPagesServiceImpl.java new file mode 100644 index 000000000..eaa892387 --- /dev/null +++ b/cash-service/system-service/src/main/java/com/czg/service/system/service/impl/MiniAppPagesServiceImpl.java @@ -0,0 +1,85 @@ +package com.czg.service.system.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.StrUtil; +import com.czg.resp.CzgRespCode; +import com.czg.resp.CzgResult; +import com.czg.system.dto.MiniAppPagesDTO; +import com.czg.system.entity.MiniAppPages; +import com.czg.system.service.MiniAppPageService; +import com.czg.utils.PageUtil; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.spring.service.impl.ServiceImpl; +import com.czg.service.system.mapper.MiniAppPagesMapper; +import org.springframework.stereotype.Service; + +/** + * 小程序页面路径 服务层实现。 + * + * @author mac + * @since 2025-02-12 + */ +@Service +public class MiniAppPagesServiceImpl extends ServiceImpl implements MiniAppPageService { + + @Override + public CzgResult insertMiniAppPage(MiniAppPagesDTO pagesDTO) { + if (exists(new QueryWrapper().eq(MiniAppPages::getName, pagesDTO.getName()))) { + return CzgResult.failure("页面名称已存在"); + } + MiniAppPages pages = BeanUtil.toBean(pagesDTO, MiniAppPages.class); + save(pages); + return CzgResult.success(pages.getId()); + } + + @Override + public CzgResult updateMiniAppPage(MiniAppPagesDTO pagesDTO) { + if (exists(new QueryWrapper().eq(MiniAppPages::getName, pagesDTO.getName()).ne(MiniAppPages::getId, pagesDTO.getId()))) { + return CzgResult.failure("页面名称已存在"); + } + + MiniAppPages pages = getById(pagesDTO.getId()); + if (pages == null) { + return CzgResult.failure(CzgRespCode.RECORD_NOT_EXIST); + } + + pages.setIcon(pagesDTO.getIcon()); + pages.setName(pagesDTO.getName()); + pages.setStatus(pagesDTO.getStatus()); + pages.setDescription(pagesDTO.getDescription()); + pages.setStatus(pagesDTO.getStatus()); + pages.setSort(pagesDTO.getSort()); + updateById(pages); + + return CzgResult.success(true); + } + + @Override + public CzgResult deleteMiniAppPageById(Long id) { + MiniAppPages pages = getById(id); + if (pages == null) { + return CzgResult.failure(CzgRespCode.RECORD_NOT_EXIST); + } + + removeById(id); + return CzgResult.success(true); + } + + @Override + public CzgResult> getMiniAppPage(String name, String path, Integer status) { + QueryWrapper queryWrapper = new QueryWrapper(); + if (StrUtil.isNotEmpty(name)) { + queryWrapper.like(MiniAppPages::getName, name); + } + if (StrUtil.isNotEmpty(path)) { + queryWrapper.like(MiniAppPages::getPath, path); + } + if (status != null && status != -1) { + queryWrapper.eq(MiniAppPages::getStatus, status); + } + queryWrapper.orderBy(MiniAppPages::getSort, true); + Page dtoPage = pageAs(PageUtil.buildPage(), queryWrapper, MiniAppPagesDTO.class); + return CzgResult.success(dtoPage); + } +} diff --git a/cash-service/system-service/src/main/resources/mapper/MiniAppPagesMapper.xml b/cash-service/system-service/src/main/resources/mapper/MiniAppPagesMapper.xml new file mode 100644 index 000000000..9cb4dafa1 --- /dev/null +++ b/cash-service/system-service/src/main/resources/mapper/MiniAppPagesMapper.xml @@ -0,0 +1,7 @@ + + + + +