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)); } } 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; } 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; } 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; } 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; } 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)); } } 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); } 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); } }