小程序页面
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -33,3 +33,4 @@ build/
|
|||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
/jars/
|
/jars/
|
||||||
|
/logs/
|
||||||
|
|||||||
@@ -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<Long> insertMiniAppPage(@RequestBody @Validated({InsertGroup.class}) MiniAppPagesDTO pagesDTO) {
|
||||||
|
return miniAppPageService.insertMiniAppPage(pagesDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改小程序页面
|
||||||
|
* @param pagesDTO 小程序页面
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public CzgResult<Boolean> updateMiniAppPage(@RequestBody @Validated({UpdateGroup.class}) MiniAppPagesDTO pagesDTO) {
|
||||||
|
return miniAppPageService.updateMiniAppPage(pagesDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除小程序页面
|
||||||
|
* @param id 小程序页面主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
public CzgResult<Boolean> deleteMiniAppPage(@PathVariable Long id) {
|
||||||
|
return miniAppPageService.deleteMiniAppPageById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询小程序页面 分页
|
||||||
|
* @param name 小程序页面名称
|
||||||
|
* @param path 小程序页面路径
|
||||||
|
* @param status 小程序页面状态 -1 查全部 1 启用 0 禁用
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("page")
|
||||||
|
public CzgResult<Page<MiniAppPagesDTO>> getMiniAppPage(String name, String path, Integer status) {
|
||||||
|
return miniAppPageService.getMiniAppPage(name, path, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<MiniAppPages> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增小程序页面
|
||||||
|
* @param pagesDTO 小程序页面
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
CzgResult<Long> insertMiniAppPage(MiniAppPagesDTO pagesDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改小程序页面
|
||||||
|
* @param pagesDTO 小程序页面
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
CzgResult<Boolean> updateMiniAppPage(MiniAppPagesDTO pagesDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除小程序页面
|
||||||
|
* @param id 小程序页面主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
CzgResult<Boolean> deleteMiniAppPageById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询小程序页面列表
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
CzgResult<Page<MiniAppPagesDTO>> getMiniAppPage(String name, String path, Integer status);
|
||||||
|
}
|
||||||
@@ -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<MiniAppPages> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<MiniAppPagesMapper, MiniAppPages> implements MiniAppPageService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<Long> 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<Boolean> 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<Boolean> 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<Page<MiniAppPagesDTO>> 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<MiniAppPagesDTO> dtoPage = pageAs(PageUtil.buildPage(), queryWrapper, MiniAppPagesDTO.class);
|
||||||
|
return CzgResult.success(dtoPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?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.system.mapper.MiniAppPagesMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user