From 5f25e3c9065e77945f649e75c041df8cefa3c268 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 19 八月 2024 09:08:08 +0800 Subject: [PATCH] system-app --- iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppRespVO.java | 83 ++++++++++ iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppSaveReqVO.java | 63 +++++++ iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppServiceImpl.java | 56 +++++++ iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/dataobject/app/AppDO.java | 102 ++++++++++++ iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppPageReqVO.java | 23 ++ iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/mysql/app/AppMapper.java | 24 +++ iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/AppController.java | 91 +++++++++++ iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppService.java | 24 +++ 8 files changed, 466 insertions(+), 0 deletions(-) diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/AppController.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/AppController.java new file mode 100644 index 0000000..289cf41 --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/AppController.java @@ -0,0 +1,91 @@ +package com.iailab.module.system.controller.admin.app; + +import com.iailab.framework.apilog.core.annotation.ApiAccessLog; +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.pojo.PageParam; +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.framework.excel.core.util.ExcelUtils; +import com.iailab.module.system.controller.admin.app.vo.AppPageReqVO; +import com.iailab.module.system.controller.admin.app.vo.AppRespVO; +import com.iailab.module.system.controller.admin.app.vo.AppSaveReqVO; +import com.iailab.module.system.dal.dataobject.app.AppDO; +import com.iailab.module.system.service.app.AppService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +import java.io.IOException; +import java.util.List; + +import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static com.iailab.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 应用管理") +@RestController +@RequestMapping("/system/app") +public class AppController { + + @Autowired + private AppService appService; + + @PostMapping("/create") + @Operation(summary = "创建应用") + @PreAuthorize("@ss.hasPermission('system:app:create')") + public CommonResult<Long> createApp(@Valid @RequestBody AppSaveReqVO createReqVO) { + return success(appService.create(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新应用") + @PreAuthorize("@ss.hasPermission('system:app:update')") + public CommonResult<Boolean> updateApp(@Valid @RequestBody AppSaveReqVO updateReqVO) { + appService.update(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除应用") + @Parameter(name = "id", description = "ID", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:app:delete')") + public CommonResult<Boolean> deleteApp(@RequestParam("id") Long id) { + appService.delete(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得应用") + @Parameter(name = "id", description = "ID", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:app:query')") + public CommonResult<AppRespVO> getTenant(@RequestParam("id") Long id) { + AppDO data = appService.getInfo(id); + return success(BeanUtils.toBean(data, AppRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得租户分页") + @PreAuthorize("@ss.hasPermission('system:app:query')") + public CommonResult<PageResult<AppRespVO>> getTenantPage(@Valid AppPageReqVO pageVO) { + PageResult<AppDO> pageResult = appService.getPage(pageVO); + return success(BeanUtils.toBean(pageResult, AppRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出租户 Excel") + @PreAuthorize("@ss.hasPermission('system:tenant:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportTenantExcel(@Valid AppPageReqVO exportReqVO, + HttpServletResponse response) throws IOException { + exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List<AppDO> list = appService.getPage(exportReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "租户.xls", "数据", AppRespVO.class, + BeanUtils.toBean(list, AppRespVO.class)); + } +} \ No newline at end of file diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppPageReqVO.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppPageReqVO.java new file mode 100644 index 0000000..e57a05e --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppPageReqVO.java @@ -0,0 +1,23 @@ +package com.iailab.module.system.controller.admin.app.vo; + +import com.iailab.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月17日 + */ +@Schema(description = "管理后台 - 租户分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class AppPageReqVO extends PageParam { + + private String appCode; + + private String appName; +} \ No newline at end of file diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppRespVO.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppRespVO.java new file mode 100644 index 0000000..b7431b6 --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppRespVO.java @@ -0,0 +1,83 @@ +package com.iailab.module.system.controller.admin.app.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月18日 + */ +@Schema(description = "管理后台 - 应用 Response VO") +@Data +@ExcelIgnoreUnannotated +public class AppRespVO { + + @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("应用编号") + private Long id; + + @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用编号") + @ExcelProperty("应用编号") + private String appCode; + + @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用名称") + @ExcelProperty("应用名称") + private String appName; + + @Schema(description = "应用域名", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用域名") + @ExcelProperty("应用域名") + private String appDomain; + + @Schema(description = "接口域名", requiredMode = Schema.RequiredMode.REQUIRED, example = "接口域名") + @ExcelProperty("接口域名") + private String apiDomain; + + @Schema(description = "应用账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用账号") + @ExcelProperty("应用账号") + private String appKey; + + @Schema(description = "应用密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用密码") + @ExcelProperty("应用密码") + private String appSecret; + + @Schema(description = "应用分组", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用分组") + @ExcelProperty("应用分组") + private String appGroup; + + @Schema(description = "应用加载类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用加载类型") + @ExcelProperty("应用加载类型") + private Integer loadType; + + @Schema(description = "应用图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "应用图标") + @ExcelProperty("应用图标") + private String icon; + + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "排序") + @ExcelProperty("排序") + private Integer orderNum; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "状态") + @ExcelProperty("状态") + private Integer status; + + @Schema(description = "开发者ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "开发者ID") + @ExcelProperty("开发者ID") + private String devId; + + @Schema(description = "开发者名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "开发者名称") + @ExcelProperty("开发者名称") + private String devName; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; +} diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppSaveReqVO.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppSaveReqVO.java new file mode 100644 index 0000000..8e11b46 --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/app/vo/AppSaveReqVO.java @@ -0,0 +1,63 @@ +package com.iailab.module.system.controller.admin.app.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月17日 + */ +@Schema(description = "管理后台 - 应用创建/修改 Request VO") +@Data +public class AppSaveReqVO { + + @Schema(description = "ID") + private Long id; + + @Schema(description = "应用编号", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "应用编号不能为空") + private String appCode; + + @Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "应用名称不能为空") + private String appName; + + @Schema(description = "应用域名", example = "") + private String appDomain; + + @Schema(description = "接口域名", example = "") + private String apiDomain; + + @Schema(description = "应用账号", example = "") + private String appKey; + + @Schema(description = "应用密码", example = "") + private String appSecret; + + @Schema(description = "应用分组", example = "") + private String appGroup; + + @Schema(description = "应用加载类型", example = "") + private Integer loadType; + + @Schema(description = "应用图标", example = "") + private String icon; + + @Schema(description = "排序", example = "") + private Integer orderNum; + + @Schema(description = "状态", example = "") + private Integer status; + + @Schema(description = "开发者ID", example = "") + private String devId; + + @Schema(description = "开发者名称", example = "") + private String devName; + + @Schema(description = "备注", example = "") + private String remark; +} \ No newline at end of file diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/dataobject/app/AppDO.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/dataobject/app/AppDO.java new file mode 100644 index 0000000..2198bc7 --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/dataobject/app/AppDO.java @@ -0,0 +1,102 @@ +package com.iailab.module.system.dal.dataobject.app; + +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iailab.framework.mybatis.core.dataobject.BaseDO; +import com.iailab.framework.tenant.core.db.TenantBaseDO; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 应用表 + * + * @author PanZhibao + * @Description + * @createTime 2024年08月16日 + */ +@TableName("system_app") +@KeySequence("system_app_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +public class AppDO extends BaseDO { + + public static final Long PARENT_ID_ROOT = 0L; + + /** + * ID + */ + @TableId + private Long id; + + /** + * 应用编号 + */ + private String appCode; + + /** + * 应用名称 + */ + private String appName; + + /** + * 应用域名 + */ + private String appDomain; + + /** + * 接口域名 + */ + private String apiDomain; + + /** + * 应用账号 + */ + private String appKey; + + /** + * 应用密码 + */ + private String appSecret; + + /** + * 应用分组 + */ + private String appGroup; + + /** + * 应用加载类型 + */ + private Integer loadType; + + /** + * 应用图标 + */ + private String icon; + + /** + * 排序 + */ + private Integer orderNum; + + /** + * 状态 + */ + private Integer status; + + /** + * 开发者ID + */ + private String devId; + + /** + * 开发者名称 + */ + private String devName; + + /** + * 备注 + */ + private String remark; + +} \ No newline at end of file diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/mysql/app/AppMapper.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/mysql/app/AppMapper.java new file mode 100644 index 0000000..fc04cee --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/dal/mysql/app/AppMapper.java @@ -0,0 +1,24 @@ +package com.iailab.module.system.dal.mysql.app; + +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.mybatis.core.mapper.BaseMapperX; +import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.iailab.module.system.controller.admin.app.vo.AppPageReqVO; +import com.iailab.module.system.dal.dataobject.app.AppDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月16日 + */ +@Mapper +public interface AppMapper extends BaseMapperX<AppDO> { + + default PageResult<AppDO> selectPage(AppPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX<AppDO>() + .likeIfPresent(AppDO::getAppCode, reqVO.getAppCode()) + .likeIfPresent(AppDO::getAppName, reqVO.getAppName()) + .orderByDesc(AppDO::getId)); + } +} diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppService.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppService.java new file mode 100644 index 0000000..8c9bd4e --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppService.java @@ -0,0 +1,24 @@ +package com.iailab.module.system.service.app; + +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.module.system.controller.admin.app.vo.AppPageReqVO; +import com.iailab.module.system.controller.admin.app.vo.AppSaveReqVO; +import com.iailab.module.system.dal.dataobject.app.AppDO; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月17日 + */ +public interface AppService { + + Long create(AppSaveReqVO createReqVO); + + Long update(AppSaveReqVO createReqVO); + + void delete(Long id); + + AppDO getInfo(Long id); + + PageResult<AppDO> getPage(AppPageReqVO pageReqVO); +} diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppServiceImpl.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppServiceImpl.java new file mode 100644 index 0000000..cbfe760 --- /dev/null +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/app/AppServiceImpl.java @@ -0,0 +1,56 @@ +package com.iailab.module.system.service.app; + +import com.iailab.framework.common.pojo.PageResult; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.system.controller.admin.app.vo.AppPageReqVO; +import com.iailab.module.system.controller.admin.app.vo.AppSaveReqVO; +import com.iailab.module.system.dal.dataobject.app.AppDO; +import com.iailab.module.system.dal.mysql.app.AppMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月17日 + */ +@Service +@Slf4j +public class AppServiceImpl implements AppService { + + @Resource + private AppMapper appMapper; + + + @Override + public Long create(AppSaveReqVO createReqVO) { + AppDO app = BeanUtils.toBean(createReqVO, AppDO.class); + appMapper.insert(app); + return app.getId(); + } + + @Override + public Long update(AppSaveReqVO createReqVO) { + AppDO app = BeanUtils.toBean(createReqVO, AppDO.class); + appMapper.updateById(app); + return app.getId(); + } + + @Override + public void delete(Long id) { + appMapper.deleteById(id); + } + + @Override + public AppDO getInfo(Long id) { + return appMapper.selectById(id); + } + + @Override + public PageResult<AppDO> getPage(AppPageReqVO pageReqVO) { + return appMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file -- Gitblit v1.9.3