Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro
# Conflicts: # pom.xml # yudao-dependencies/pom.xml # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/CodegenCreateListReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/CodegenUpdateReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/column/CodegenColumnSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/ConfigController.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/config/vo/ConfigSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/db/DataSourceConfigController.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/db/vo/DataSourceConfigSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/vo/Demo02CategorySaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/inner/vo/Demo03StudentInnerSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileConfigController.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/config/FileConfigSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/FileUploadReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobRespVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/job/vo/job/JobSaveReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/ApiAccessLogController.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/ApiErrorLogController.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/redis/RedisController.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/vo/AppFileUploadReqVO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileConfigDO.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/config/ConfigService.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImpl.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigService.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImpl.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactService.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactServiceImpl.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo02/Demo02CategoryService.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo02/Demo02CategoryServiceImpl.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpService.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/erp/Demo03StudentErpServiceImpl.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigService.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImpl.java # yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobService.java
This commit is contained in:
commit
93982451eb
2
pom.xml
2
pom.xml
@ -38,7 +38,7 @@
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>
|
||||
<maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
|
||||
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
|
||||
<!-- 看看咋放到 bom 里 -->
|
||||
|
@ -14,7 +14,7 @@
|
||||
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
|
||||
|
||||
<properties>
|
||||
<revision>2.5.0-jdk8-SNAPSHOT</revision>
|
||||
<revision>2.6.0-jdk8-SNAPSHOT</revision>
|
||||
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
|
||||
<!-- 统一依赖管理 -->
|
||||
<spring.framework.version>5.3.39</spring.framework.version>
|
||||
|
@ -53,4 +53,14 @@ public abstract class BaseDO implements Serializable, TransPojo {
|
||||
@TableLogic
|
||||
private Boolean deleted;
|
||||
|
||||
/**
|
||||
* 把 creator、createTime、updateTime、updater 都清空,避免前端直接传递 creator 之类的字段,直接就被更新了
|
||||
*/
|
||||
public void clean(){
|
||||
this.creator = null;
|
||||
this.createTime = null;
|
||||
this.updater = null;
|
||||
this.updateTime = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -215,4 +215,11 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
||||
return delete(new LambdaQueryWrapper<T>().eq(field, value));
|
||||
}
|
||||
|
||||
default int deleteBatch(SFunction<T, ?> field, Collection<?> values) {
|
||||
if (CollUtil.isEmpty(values)) {
|
||||
return 0;
|
||||
}
|
||||
return delete(new LambdaQueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public class AiUtils {
|
||||
public static ChatOptions buildChatOptions(AiPlatformEnum platform, String model, Double temperature, Integer maxTokens,
|
||||
Set<String> toolNames, Map<String, Object> toolContext) {
|
||||
toolNames = ObjUtil.defaultIfNull(toolNames, Collections.emptySet());
|
||||
toolContext = ObjUtil.defaultIfNull(toolContext, Collections.emptyMap());
|
||||
// noinspection EnhancedSwitchMigration
|
||||
switch (platform) {
|
||||
case TONG_YI:
|
||||
|
@ -51,7 +51,7 @@ public class BpmProcessIdRedisDAO {
|
||||
String noPrefix = processIdRule.getPrefix() + infix + processIdRule.getPostfix();
|
||||
String key = RedisKeyConstants.BPM_PROCESS_ID + noPrefix;
|
||||
Long no = stringRedisTemplate.opsForValue().increment(key);
|
||||
if (StrUtil.isEmpty(infix)) {
|
||||
if (StrUtil.isNotEmpty(infix)) {
|
||||
// 特殊:没有前缀,则不能过期,不能每次都是从 0 开始
|
||||
stringRedisTemplate.expire(key, Duration.ofDays(1L));
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.codegen.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 基于数据库的表结构,创建代码生成器的表和字段定义 Request VO")
|
||||
|
@ -3,10 +3,10 @@ package cn.iocoder.yudao.module.infra.controller.admin.codegen.vo;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.column.CodegenColumnSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.CodegenTableSaveReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成表和字段的修改 Request VO")
|
||||
|
@ -1,10 +1,9 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.column;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成字段定义创建/修改 Request VO")
|
||||
@Data
|
||||
public class CodegenColumnSaveReqVO {
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - 表定义分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CodegenTablePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "表名称,模糊匹配", example = "yudao")
|
||||
|
@ -5,11 +5,10 @@ import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum;
|
||||
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.AssertTrue;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 代码生成表定义创建/修改 Response VO")
|
||||
@Data
|
||||
public class CodegenTableSaveReqVO {
|
||||
|
@ -5,7 +5,9 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.*;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.config.ConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants;
|
||||
@ -13,13 +15,13 @@ import cn.iocoder.yudao.module.infra.service.config.ConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "数据源名称,模糊匹配", example = "名称")
|
||||
|
@ -1,13 +1,12 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置创建/修改 Request VO")
|
||||
@Data
|
||||
public class ConfigSaveReqVO {
|
||||
|
@ -9,12 +9,12 @@ import cn.iocoder.yudao.module.infra.service.db.DataSourceConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.db.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 数据源配置创建/修改 Request VO")
|
||||
@Data
|
||||
|
@ -60,6 +60,15 @@ public class Demo01ContactController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除示例联系人")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:delete')")
|
||||
public CommonResult<Boolean> deleteDemo0iContactList(@RequestParam("ids") List<Long> ids) {
|
||||
demo01ContactService.deleteDemo0iContactListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得示例联系人")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@ -82,12 +91,12 @@ public class Demo01ContactController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo01ContactExcel(@Valid Demo01ContactPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<Demo01ContactDO> list = demo01ContactService.getDemo01ContactPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "示例联系人.xls", "数据", Demo01ContactRespVO.class,
|
||||
BeanUtils.toBean(list, Demo01ContactRespVO.class));
|
||||
BeanUtils.toBean(list, Demo01ContactRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 示例联系人分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class Demo01ContactPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字", example = "张三")
|
||||
|
@ -1,14 +1,13 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
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;
|
||||
|
||||
@Schema(description = "管理后台 - 示例联系人 Response VO")
|
||||
@Data
|
||||
|
@ -1,10 +1,10 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 示例联系人新增/修改 Request VO")
|
||||
|
@ -80,11 +80,11 @@ public class Demo02CategoryController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo02-category:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo02CategoryExcel(@Valid Demo02CategoryListReqVO listReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "示例分类.xls", "数据", Demo02CategoryRespVO.class,
|
||||
BeanUtils.toBean(list, Demo02CategoryRespVO.class));
|
||||
BeanUtils.toBean(list, Demo02CategoryRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 示例分类新增/修改 Request VO")
|
||||
@Data
|
||||
public class Demo02CategorySaveReqVO {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03;
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
@ -6,13 +6,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import cn.iocoder.yudao.module.infra.service.demo.demo03.Demo03StudentService;
|
||||
import cn.iocoder.yudao.module.infra.service.demo.demo03.erp.Demo03StudentErpService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -31,25 +31,25 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 学生")
|
||||
@RestController
|
||||
@RequestMapping("/infra/demo03-student")
|
||||
@RequestMapping("/infra/demo03-student-erp")
|
||||
@Validated
|
||||
public class Demo03StudentController {
|
||||
public class Demo03StudentErpController {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentService demo03StudentService;
|
||||
private Demo03StudentErpService demo03StudentErpService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO createReqVO) {
|
||||
return success(demo03StudentService.createDemo03Student(createReqVO));
|
||||
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO createReqVO) {
|
||||
return success(demo03StudentErpService.createDemo03Student(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO updateReqVO) {
|
||||
demo03StudentService.updateDemo03Student(updateReqVO);
|
||||
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO updateReqVO) {
|
||||
demo03StudentErpService.updateDemo03Student(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -58,7 +58,17 @@ public class Demo03StudentController {
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
|
||||
demo03StudentService.deleteDemo03Student(id);
|
||||
demo03StudentErpService.deleteDemo03Student(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03StudentList(@RequestParam("ids") List<Long> ids) {
|
||||
// TODO @puhui999:deleteDemo03StudentList
|
||||
demo03StudentErpService.deleteDemo03StudentListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -66,30 +76,30 @@ public class Demo03StudentController {
|
||||
@Operation(summary = "获得学生")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03StudentRespVO> getDemo03Student(@RequestParam("id") Long id) {
|
||||
Demo03StudentDO demo03Student = demo03StudentService.getDemo03Student(id);
|
||||
return success(BeanUtils.toBean(demo03Student, Demo03StudentRespVO.class));
|
||||
public CommonResult<Demo03StudentErpRespVO> getDemo03Student(@RequestParam("id") Long id) {
|
||||
Demo03StudentDO demo03Student = demo03StudentErpService.getDemo03Student(id);
|
||||
return success(BeanUtils.toBean(demo03Student, Demo03StudentErpRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得学生分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03StudentRespVO>> getDemo03StudentPage(@Valid Demo03StudentPageReqVO pageReqVO) {
|
||||
PageResult<Demo03StudentDO> pageResult = demo03StudentService.getDemo03StudentPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, Demo03StudentRespVO.class));
|
||||
public CommonResult<PageResult<Demo03StudentErpRespVO>> getDemo03StudentPage(@Valid Demo03StudentErpPageReqVO pageReqVO) {
|
||||
PageResult<Demo03StudentDO> pageResult = demo03StudentErpService.getDemo03StudentPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, Demo03StudentErpRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出学生 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo03StudentExcel(@Valid Demo03StudentPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
public void exportDemo03StudentExcel(@Valid Demo03StudentErpPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<Demo03StudentDO> list = demo03StudentService.getDemo03StudentPage(pageReqVO).getList();
|
||||
List<Demo03StudentDO> list = demo03StudentErpService.getDemo03StudentPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentRespVO.class,
|
||||
BeanUtils.toBean(list, Demo03StudentRespVO.class));
|
||||
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentErpRespVO.class,
|
||||
BeanUtils.toBean(list, Demo03StudentErpRespVO.class));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
@ -100,21 +110,21 @@ public class Demo03StudentController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03CourseDO>> getDemo03CoursePage(PageParam pageReqVO,
|
||||
@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03CoursePage(pageReqVO, studentId));
|
||||
return success(demo03StudentErpService.getDemo03CoursePage(pageReqVO, studentId));
|
||||
}
|
||||
|
||||
@PostMapping("/demo03-course/create")
|
||||
@Operation(summary = "创建学生课程")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
|
||||
return success(demo03StudentService.createDemo03Course(demo03Course));
|
||||
return success(demo03StudentErpService.createDemo03Course(demo03Course));
|
||||
}
|
||||
|
||||
@PutMapping("/demo03-course/update")
|
||||
@Operation(summary = "更新学生课程")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
|
||||
demo03StudentService.updateDemo03Course(demo03Course);
|
||||
demo03StudentErpService.updateDemo03Course(demo03Course);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -123,7 +133,16 @@ public class Demo03StudentController {
|
||||
@Operation(summary = "删除学生课程")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Course(@RequestParam("id") Long id) {
|
||||
demo03StudentService.deleteDemo03Course(id);
|
||||
demo03StudentErpService.deleteDemo03Course(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/demo03-course/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除学生课程")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03CourseList(@RequestParam("ids") List<Long> ids) {
|
||||
demo03StudentErpService.deleteDemo03CourseListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -132,15 +151,7 @@ public class Demo03StudentController {
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03CourseDO> getDemo03Course(@RequestParam("id") Long id) {
|
||||
return success(demo03StudentService.getDemo03Course(id));
|
||||
}
|
||||
|
||||
@GetMapping("/demo03-course/list-by-student-id")
|
||||
@Operation(summary = "获得学生课程列表")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03CourseListByStudentId(studentId));
|
||||
return success(demo03StudentErpService.getDemo03Course(id));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
@ -151,21 +162,21 @@ public class Demo03StudentController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03GradeDO>> getDemo03GradePage(PageParam pageReqVO,
|
||||
@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03GradePage(pageReqVO, studentId));
|
||||
return success(demo03StudentErpService.getDemo03GradePage(pageReqVO, studentId));
|
||||
}
|
||||
|
||||
@PostMapping("/demo03-grade/create")
|
||||
@Operation(summary = "创建学生班级")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
|
||||
return success(demo03StudentService.createDemo03Grade(demo03Grade));
|
||||
return success(demo03StudentErpService.createDemo03Grade(demo03Grade));
|
||||
}
|
||||
|
||||
@PutMapping("/demo03-grade/update")
|
||||
@Operation(summary = "更新学生班级")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
|
||||
demo03StudentService.updateDemo03Grade(demo03Grade);
|
||||
demo03StudentErpService.updateDemo03Grade(demo03Grade);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -174,7 +185,16 @@ public class Demo03StudentController {
|
||||
@Operation(summary = "删除学生班级")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Grade(@RequestParam("id") Long id) {
|
||||
demo03StudentService.deleteDemo03Grade(id);
|
||||
demo03StudentErpService.deleteDemo03Grade(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/demo03-grade/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除学生班级")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03GradeList(@RequestParam("ids") List<Long> ids) {
|
||||
demo03StudentErpService.deleteDemo03GradeListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -183,15 +203,7 @@ public class Demo03StudentController {
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03GradeDO> getDemo03Grade(@RequestParam("id") Long id) {
|
||||
return success(demo03StudentService.getDemo03Grade(id));
|
||||
}
|
||||
|
||||
@GetMapping("/demo03-grade/get-by-student-id")
|
||||
@Operation(summary = "获得学生班级")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentService.getDemo03GradeByStudentId(studentId));
|
||||
return success(demo03StudentErpService.getDemo03Grade(id));
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 学生分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class Demo03StudentPageReqVO extends PageParam {
|
||||
public class Demo03StudentErpPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字", example = "芋艿")
|
||||
private String name;
|
@ -1,17 +1,18 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
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;
|
||||
|
||||
@Schema(description = "管理后台 - 学生 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class Demo03StudentRespVO {
|
||||
public class Demo03StudentErpRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
@ExcelProperty("编号")
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 学生新增/修改 Request VO")
|
||||
@Data
|
||||
public class Demo03StudentErpSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "名字不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "出生日期不能为空")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@NotEmpty(message = "简介不能为空")
|
||||
private String description;
|
||||
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import cn.iocoder.yudao.module.infra.service.demo.demo03.inner.Demo03StudentInnerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 学生")
|
||||
@RestController
|
||||
@RequestMapping("/infra/demo03-student-inner")
|
||||
@Validated
|
||||
public class Demo03StudentInnerController {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentInnerService demo03StudentInnerService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentInnerSaveReqVO createReqVO) {
|
||||
return success(demo03StudentInnerService.createDemo03Student(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentInnerSaveReqVO updateReqVO) {
|
||||
demo03StudentInnerService.updateDemo03Student(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除学生")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
|
||||
demo03StudentInnerService.deleteDemo03Student(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03StudentList(@RequestParam("ids") List<Long> ids) {
|
||||
demo03StudentInnerService.deleteDemo03StudentListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得学生")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03StudentInnerRespVO> getDemo03Student(@RequestParam("id") Long id) {
|
||||
Demo03StudentDO demo03Student = demo03StudentInnerService.getDemo03Student(id);
|
||||
return success(BeanUtils.toBean(demo03Student, Demo03StudentInnerRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得学生分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03StudentInnerRespVO>> getDemo03StudentPage(@Valid Demo03StudentInnerPageReqVO pageReqVO) {
|
||||
PageResult<Demo03StudentDO> pageResult = demo03StudentInnerService.getDemo03StudentPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, Demo03StudentInnerRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出学生 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo03StudentExcel(@Valid Demo03StudentInnerPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<Demo03StudentDO> list = demo03StudentInnerService.getDemo03StudentPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentInnerRespVO.class,
|
||||
BeanUtils.toBean(list, Demo03StudentInnerRespVO.class));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
@GetMapping("/demo03-course/list-by-student-id")
|
||||
@Operation(summary = "获得学生课程列表")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentInnerService.getDemo03CourseListByStudentId(studentId));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
@GetMapping("/demo03-grade/get-by-student-id")
|
||||
@Operation(summary = "获得学生班级")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentInnerService.getDemo03GradeByStudentId(studentId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 学生分页 Request VO")
|
||||
@Data
|
||||
public class Demo03StudentInnerPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "简介", example = "随便")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
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;
|
||||
|
||||
@Schema(description = "管理后台 - 学生 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class Demo03StudentInnerRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("名字")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class)
|
||||
@DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("出生日期")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@ExcelProperty("简介")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,16 +1,18 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 学生新增/修改 Request VO")
|
||||
@Data
|
||||
public class Demo03StudentSaveReqVO {
|
||||
public class Demo03StudentInnerSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
private Long id;
|
||||
@ -31,9 +33,10 @@ public class Demo03StudentSaveReqVO {
|
||||
@NotEmpty(message = "简介不能为空")
|
||||
private String description;
|
||||
|
||||
|
||||
@Schema(description = "学生课程列表")
|
||||
private List<Demo03CourseDO> demo03Courses;
|
||||
|
||||
@Schema(description = "学生班级")
|
||||
private Demo03GradeDO demo03Grade;
|
||||
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import cn.iocoder.yudao.module.infra.service.demo.demo03.normal.Demo03StudentNormalService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 学生")
|
||||
@RestController
|
||||
@RequestMapping("/infra/demo03-student-normal")
|
||||
@Validated
|
||||
public class Demo03StudentNormalController {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentNormalService demo03StudentNormalService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
|
||||
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO createReqVO) {
|
||||
return success(demo03StudentNormalService.createDemo03Student(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
|
||||
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO updateReqVO) {
|
||||
demo03StudentNormalService.updateDemo03Student(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除学生")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
|
||||
demo03StudentNormalService.deleteDemo03Student(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除学生")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
|
||||
public CommonResult<Boolean> deleteDemo03StudentList(@RequestParam("ids") List<Long> ids) {
|
||||
demo03StudentNormalService.deleteDemo03StudentListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得学生")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03StudentNormalRespVO> getDemo03Student(@RequestParam("id") Long id) {
|
||||
Demo03StudentDO demo03Student = demo03StudentNormalService.getDemo03Student(id);
|
||||
return success(BeanUtils.toBean(demo03Student, Demo03StudentNormalRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得学生分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<PageResult<Demo03StudentNormalRespVO>> getDemo03StudentPage(@Valid Demo03StudentNormalPageReqVO pageReqVO) {
|
||||
PageResult<Demo03StudentDO> pageResult = demo03StudentNormalService.getDemo03StudentPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, Demo03StudentNormalRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出学生 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemo03StudentExcel(@Valid Demo03StudentNormalPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<Demo03StudentDO> list = demo03StudentNormalService.getDemo03StudentPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentNormalRespVO.class,
|
||||
BeanUtils.toBean(list, Demo03StudentNormalRespVO.class));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
@GetMapping("/demo03-course/list-by-student-id")
|
||||
@Operation(summary = "获得学生课程列表")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentNormalService.getDemo03CourseListByStudentId(studentId));
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
@GetMapping("/demo03-grade/get-by-student-id")
|
||||
@Operation(summary = "获得学生班级")
|
||||
@Parameter(name = "studentId", description = "学生编号")
|
||||
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
|
||||
public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
|
||||
return success(demo03StudentNormalService.getDemo03GradeByStudentId(studentId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 学生分页 Request VO")
|
||||
@Data
|
||||
public class Demo03StudentNormalPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "名字", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "简介", example = "随便")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
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;
|
||||
|
||||
@Schema(description = "管理后台 - 学生 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class Demo03StudentNormalRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("名字")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class)
|
||||
@DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("出生日期")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@ExcelProperty("简介")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 学生新增/修改 Request VO")
|
||||
@Data
|
||||
public class Demo03StudentNormalSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "名字不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "性别不能为空")
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "出生日期不能为空")
|
||||
private LocalDateTime birthday;
|
||||
|
||||
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@NotEmpty(message = "简介不能为空")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "学生课程列表")
|
||||
private List<Demo03CourseDO> demo03Courses;
|
||||
|
||||
@Schema(description = "学生班级")
|
||||
private Demo03GradeDO demo03Grade;
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03;
|
@ -11,13 +11,12 @@ import cn.iocoder.yudao.module.infra.service.file.FileConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 文件配置")
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.infra.controller.admin.file.vo.config;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FileConfigPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "配置名", example = "S3 - 阿里云")
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.file.vo.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置创建/修改 Request VO")
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.infra.controller.admin.file.vo.file;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - 文件分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FilePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "文件路径,模糊匹配", example = "yudao")
|
||||
|
@ -1,11 +1,10 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.file.vo.file;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 上传文件 Request VO")
|
||||
@Data
|
||||
public class FileUploadReqVO {
|
||||
|
@ -71,10 +71,10 @@ public class JobController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除定时任务")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:delete')")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:delete')")
|
||||
public CommonResult<Boolean> deleteJob(@RequestParam("id") Long id)
|
||||
throws SchedulerException {
|
||||
jobService.deleteJob(id);
|
||||
|
@ -3,13 +3,9 @@ package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JobPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "任务名称,模糊匹配", example = "测试任务")
|
||||
|
@ -6,9 +6,9 @@ import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务 Response VO")
|
||||
|
@ -1,11 +1,10 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务创建/修改 Request VO")
|
||||
@Data
|
||||
public class JobSaveReqVO {
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JobLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "任务编号", example = "10")
|
||||
|
@ -12,15 +12,15 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,13 +14,13 @@ 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.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@ -63,7 +63,7 @@ public class ApiErrorLogController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportApiErrorLogExcel(@Valid ApiErrorLogPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - API 访问日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ApiAccessLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户编号", example = "666")
|
||||
|
@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -13,8 +11,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - API 错误日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ApiErrorLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户编号", example = "666")
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.infra.controller.admin.redis.vo.RedisMonitorRespV
|
||||
import cn.iocoder.yudao.module.infra.convert.redis.RedisConvert;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@ -13,7 +14,6 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Properties;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -34,7 +34,7 @@ public class RedisController {
|
||||
Properties info = stringRedisTemplate.execute((RedisCallback<Properties>) RedisServerCommands::info);
|
||||
Long dbSize = stringRedisTemplate.execute(RedisServerCommands::dbSize);
|
||||
Properties commandStats = stringRedisTemplate.execute((
|
||||
RedisCallback<Properties>) connection -> connection.info("commandstats"));
|
||||
RedisCallback<Properties>) connection -> connection.serverCommands().info("commandstats"));
|
||||
assert commandStats != null; // 断言,避免警告
|
||||
// 拼接结果返回
|
||||
return success(RedisConvert.INSTANCE.build(info, dbSize, commandStats));
|
||||
|
@ -1,11 +1,10 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.app.file.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "用户 App - 上传文件 Request VO")
|
||||
@Data
|
||||
public class AppFileUploadReqVO {
|
||||
|
@ -79,7 +79,8 @@ public class FileConfigDO extends BaseDO {
|
||||
|
||||
@Override
|
||||
public Object parse(String json) {
|
||||
FileClientConfig config = JsonUtils.parseObjectQuietly(json, new TypeReference<FileClientConfig>() {});
|
||||
FileClientConfig config = JsonUtils.parseObjectQuietly(json, new TypeReference<>() {
|
||||
});
|
||||
if (config != null) {
|
||||
return config;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo01;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
@ -1,13 +1,13 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo02;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 示例分类 Mapper
|
||||
*
|
||||
@ -24,9 +24,9 @@ public interface Demo02CategoryMapper extends BaseMapperX<Demo02CategoryDO> {
|
||||
.orderByDesc(Demo02CategoryDO::getId));
|
||||
}
|
||||
|
||||
default Demo02CategoryDO selectByParentIdAndName(Long parentId, String name) {
|
||||
return selectOne(Demo02CategoryDO::getParentId, parentId, Demo02CategoryDO::getName, name);
|
||||
}
|
||||
default Demo02CategoryDO selectByParentIdAndName(Long parentId, String name) {
|
||||
return selectOne(Demo02CategoryDO::getParentId, parentId, Demo02CategoryDO::getName, name);
|
||||
}
|
||||
|
||||
default Long selectCountByParentId(Long parentId) {
|
||||
return selectCount(Demo02CategoryDO::getParentId, parentId);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -15,7 +15,7 @@ import java.util.List;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03CourseMapper extends BaseMapperX<Demo03CourseDO> {
|
||||
public interface Demo03CourseErpMapper extends BaseMapperX<Demo03CourseDO> {
|
||||
|
||||
default PageResult<Demo03CourseDO> selectPage(PageParam reqVO, Long studentId) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03CourseDO>()
|
||||
@ -23,12 +23,12 @@ public interface Demo03CourseMapper extends BaseMapperX<Demo03CourseDO> {
|
||||
.orderByDesc(Demo03CourseDO::getId));
|
||||
}
|
||||
|
||||
default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
|
||||
return selectList(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentId(Long studentId) {
|
||||
return delete(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
}
|
||||
default int deleteByStudentIds(List<Long> studentIds) {
|
||||
return deleteBatch(Demo03CourseDO::getStudentId, studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -7,13 +7,15 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生班级 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03GradeMapper extends BaseMapperX<Demo03GradeDO> {
|
||||
public interface Demo03GradeErpMapper extends BaseMapperX<Demo03GradeDO> {
|
||||
|
||||
default PageResult<Demo03GradeDO> selectPage(PageParam reqVO, Long studentId) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03GradeDO>()
|
||||
@ -29,4 +31,8 @@ public interface Demo03GradeMapper extends BaseMapperX<Demo03GradeDO> {
|
||||
return delete(Demo03GradeDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
}
|
||||
default int deleteByStudentIds(List<Long> studentIds) {
|
||||
return deleteBatch(Demo03GradeDO::getStudentId, studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.*;
|
||||
|
||||
/**
|
||||
* 学生 Mapper
|
||||
@ -13,9 +13,9 @@ import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.*;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03StudentMapper extends BaseMapperX<Demo03StudentDO> {
|
||||
public interface Demo03StudentErpMapper extends BaseMapperX<Demo03StudentDO> {
|
||||
|
||||
default PageResult<Demo03StudentDO> selectPage(Demo03StudentPageReqVO reqVO) {
|
||||
default PageResult<Demo03StudentDO> selectPage(Demo03StudentErpPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
|
||||
.likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
|
||||
.eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.inner;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生课程 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03CourseInnerMapper extends BaseMapperX<Demo03CourseDO> {
|
||||
|
||||
default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
|
||||
return selectList(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentId(Long studentId) {
|
||||
return delete(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentIds(List<Long> studentIds) {
|
||||
return deleteBatch(Demo03CourseDO::getStudentId, studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.inner;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生班级 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03GradeInnerMapper extends BaseMapperX<Demo03GradeDO> {
|
||||
|
||||
default Demo03GradeDO selectByStudentId(Long studentId) {
|
||||
return selectOne(Demo03GradeDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentId(Long studentId) {
|
||||
return delete(Demo03GradeDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentIds(List<Long> studentIds) {
|
||||
return deleteBatch(Demo03GradeDO::getStudentId, studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.inner;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 学生 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03StudentInnerMapper extends BaseMapperX<Demo03StudentDO> {
|
||||
|
||||
default PageResult<Demo03StudentDO> selectPage(Demo03StudentInnerPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
|
||||
.likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
|
||||
.eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
|
||||
.eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription())
|
||||
.betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(Demo03StudentDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生课程 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03CourseNormalMapper extends BaseMapperX<Demo03CourseDO> {
|
||||
|
||||
default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
|
||||
return selectList(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentId(Long studentId) {
|
||||
return delete(Demo03CourseDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentIds(List<Long> studentIds) {
|
||||
return deleteBatch(Demo03CourseDO::getStudentId, studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生班级 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03GradeNormalMapper extends BaseMapperX<Demo03GradeDO> {
|
||||
|
||||
default Demo03GradeDO selectByStudentId(Long studentId) {
|
||||
return selectOne(Demo03GradeDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentId(Long studentId) {
|
||||
return delete(Demo03GradeDO::getStudentId, studentId);
|
||||
}
|
||||
|
||||
default int deleteByStudentIds(List<Long> studentIds) {
|
||||
return deleteBatch(Demo03GradeDO::getStudentId, studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 学生 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface Demo03StudentNormalMapper extends BaseMapperX<Demo03StudentDO> {
|
||||
|
||||
default PageResult<Demo03StudentDO> selectPage(Demo03StudentNormalPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
|
||||
.likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
|
||||
.eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
|
||||
.eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription())
|
||||
.betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(Demo03StudentDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -34,7 +34,7 @@ public interface JobLogMapper extends BaseMapperX<JobLogDO> {
|
||||
* 物理删除指定时间之前的日志
|
||||
*
|
||||
* @param createTime 最大时间
|
||||
* @param limit 删除条数,防止一次删除太多
|
||||
* @param limit 删除条数,防止一次删除太多
|
||||
* @return 删除条数
|
||||
*/
|
||||
@Delete("DELETE FROM infra_job_log WHERE create_time < #{createTime} LIMIT #{limit}")
|
||||
|
@ -36,7 +36,7 @@ public interface ApiAccessLogMapper extends BaseMapperX<ApiAccessLogDO> {
|
||||
* 物理删除指定时间之前的日志
|
||||
*
|
||||
* @param createTime 最大时间
|
||||
* @param limit 删除条数,防止一次删除太多
|
||||
* @param limit 删除条数,防止一次删除太多
|
||||
* @return 删除条数
|
||||
*/
|
||||
@Delete("DELETE FROM infra_api_access_log WHERE create_time < #{createTime} LIMIT #{limit}")
|
||||
|
@ -35,10 +35,10 @@ public interface ApiErrorLogMapper extends BaseMapperX<ApiErrorLogDO> {
|
||||
* 物理删除指定时间之前的日志
|
||||
*
|
||||
* @param createTime 最大时间
|
||||
* @param limit 删除条数,防止一次删除太多
|
||||
* @param limit 删除条数,防止一次删除太多
|
||||
* @return 删除条数
|
||||
*/
|
||||
@Delete("DELETE FROM infra_api_error_log WHERE create_time < #{createTime} LIMIT #{limit}")
|
||||
Integer deleteByCreateTimeLt(@Param("createTime") LocalDateTime createTime, @Param("limit")Integer limit);
|
||||
Integer deleteByCreateTimeLt(@Param("createTime") LocalDateTime createTime, @Param("limit") Integer limit);
|
||||
|
||||
}
|
||||
|
@ -65,7 +65,8 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode DEMO02_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_001_201_005, "已经存在该名字的示例分类");
|
||||
ErrorCode DEMO02_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_001_201_006, "不能设置自己的子示例分类为父示例分类");
|
||||
ErrorCode DEMO03_STUDENT_NOT_EXISTS = new ErrorCode(1_001_201_007, "学生不存在");
|
||||
ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_008, "学生班级不存在");
|
||||
ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_009, "学生班级已存在");
|
||||
ErrorCode DEMO03_COURSE_NOT_EXISTS = new ErrorCode(1_001_201_008, "学生课程不存在");
|
||||
ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_009, "学生班级不存在");
|
||||
ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_010, "学生班级已存在");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.infra.enums.codegen;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 代码生成的 VO 类型枚举
|
||||
*
|
||||
* 目前的作用:Controller 新增、修改、响应时,使用 VO 还是 DO
|
||||
* 注意:不包括 Controller 的分页参数!
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum CodegenVOTypeEnum {
|
||||
|
||||
VO(10, "VO"),
|
||||
DO(20, "DO");
|
||||
|
||||
/**
|
||||
* 场景
|
||||
*/
|
||||
private final Integer type;
|
||||
/**
|
||||
* 场景名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.infra.framework.codegen.config;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum;
|
||||
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenVOTypeEnum;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -34,6 +35,20 @@ public class CodegenProperties {
|
||||
@NotNull(message = "代码生成的前端类型不能为空")
|
||||
private Integer frontType;
|
||||
|
||||
/**
|
||||
* 代码生成的 VO 类型
|
||||
*
|
||||
* 枚举 {@link CodegenVOTypeEnum#getType()}
|
||||
*/
|
||||
@NotNull(message = "代码生成的 VO 类型不能为空")
|
||||
private Integer voType;
|
||||
|
||||
/**
|
||||
* 是否生成批量删除接口
|
||||
*/
|
||||
@NotNull(message = "是否生成批量删除接口不能为空")
|
||||
private Boolean deleteBatchEnable;
|
||||
|
||||
/**
|
||||
* 是否生成单元测试
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
||||
@Slf4j
|
||||
public class FileTypeUtils {
|
||||
|
||||
private static final ThreadLocal<Tika> TIKA = TransmittableThreadLocal.withInitial(Tika::new);
|
||||
private static final Tika TIKA = new Tika();
|
||||
|
||||
/**
|
||||
* 获得文件的 mineType,对于 doc,jar 等文件会有误差
|
||||
@ -31,7 +31,7 @@ public class FileTypeUtils {
|
||||
*/
|
||||
@SneakyThrows
|
||||
public static String getMineType(byte[] data) {
|
||||
return TIKA.get().detect(data);
|
||||
return TIKA.detect(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public class FileTypeUtils {
|
||||
* @return mineType 无法识别时会返回“application/octet-stream”
|
||||
*/
|
||||
public static String getMineType(String name) {
|
||||
return TIKA.get().detect(name);
|
||||
return TIKA.detect(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ public class FileTypeUtils {
|
||||
* @return mineType 无法识别时会返回“application/octet-stream”
|
||||
*/
|
||||
public static String getMineType(byte[] data, String name) {
|
||||
return TIKA.get().detect(data, name);
|
||||
return TIKA.detect(data, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ public interface CodegenService {
|
||||
* 基于数据库的表结构,创建代码生成器的表定义
|
||||
*
|
||||
* @param author 作者
|
||||
* @param reqVO 表信息
|
||||
* @param reqVO 表信息
|
||||
* @return 创建的表定义的编号数组
|
||||
*/
|
||||
List<Long> createCodegenList(String author, CodegenCreateListReqVO reqVO);
|
||||
@ -92,8 +92,8 @@ public interface CodegenService {
|
||||
* 获得数据库自带的表定义列表
|
||||
*
|
||||
* @param dataSourceConfigId 数据源的配置编号
|
||||
* @param name 表名称
|
||||
* @param comment 表描述
|
||||
* @param name 表名称
|
||||
* @param comment 表描述
|
||||
* @return 表定义列表
|
||||
*/
|
||||
List<DatabaseTableRespVO> getDatabaseTableList(Long dataSourceConfigId, String name, String comment);
|
||||
|
@ -214,7 +214,6 @@ public class CodegenBuilder {
|
||||
// description、memo、remark
|
||||
if (StrUtil.endWithAnyIgnoreCase(column.getColumnName(), "description", "memo", "remark")) {
|
||||
column.setExample(randomEle(new String[]{"你猜", "随便", "你说的对"}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;
|
||||
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum;
|
||||
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum;
|
||||
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum;
|
||||
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenVOTypeEnum;
|
||||
import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableTable;
|
||||
@ -220,7 +221,7 @@ public class CodegenEngine {
|
||||
this.templateEngine = new VelocityEngine(config);
|
||||
// 设置 javaxEnable,按照是否使用 JDK17 来判断
|
||||
this.jakartaEnable = SystemUtil.getJavaInfo().isJavaVersionAtLeast(1700) // 17.00 * 100
|
||||
&& ClassUtils.isPresent("jakarta.annotation.Resource", ClassUtils.getDefaultClassLoader());
|
||||
&& ClassUtils.isPresent("jakarta.annotation.Resource", ClassUtils.getDefaultClassLoader());
|
||||
// 设置 cloudEnable,按照是否使用 Spring Cloud 来判断
|
||||
this.cloudEnable = ClassUtils.isPresent("cn.iocoder.yudao.module.infra.framework.rpc.config.RpcConfiguration",
|
||||
ClassUtils.getDefaultClassLoader());
|
||||
@ -234,6 +235,8 @@ public class CodegenEngine {
|
||||
globalBindingMap.put("baseFrameworkPackage", codegenProperties.getBasePackage()
|
||||
+ '.' + "framework"); // 用于后续获取测试类的 package 地址
|
||||
globalBindingMap.put("jakartaPackage", jakartaEnable ? "jakarta" : "javax");
|
||||
globalBindingMap.put("voType", codegenProperties.getVoType());
|
||||
globalBindingMap.put("deleteBatchEnable", codegenProperties.getDeleteBatchEnable());
|
||||
// 全局 Java Bean
|
||||
globalBindingMap.put("CommonResultClassName", CommonResult.class.getName());
|
||||
globalBindingMap.put("PageResultClassName", PageResult.class.getName());
|
||||
@ -255,14 +258,15 @@ public class CodegenEngine {
|
||||
globalBindingMap.put("ApiAccessLogClassName", ApiAccessLog.class.getName());
|
||||
globalBindingMap.put("OperateTypeEnumClassName", OperateTypeEnum.class.getName());
|
||||
globalBindingMap.put("BeanUtils", BeanUtils.class.getName());
|
||||
globalBindingMap.put("CollectionUtilsClassName", CollectionUtils.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成代码
|
||||
*
|
||||
* @param table 表定义
|
||||
* @param columns table 的字段定义数组
|
||||
* @param subTables 子表数组,当且仅当主子表时使用
|
||||
* @param table 表定义
|
||||
* @param columns table 的字段定义数组
|
||||
* @param subTables 子表数组,当且仅当主子表时使用
|
||||
* @param subColumnsList subTables 的字段定义数组
|
||||
* @return 生成的代码,key 是路径,value 是对应代码
|
||||
*/
|
||||
@ -380,14 +384,15 @@ public class CodegenEngine {
|
||||
bindingMap.put("columns", columns);
|
||||
bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段
|
||||
bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene()));
|
||||
|
||||
// className 相关
|
||||
// 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀
|
||||
String className = table.getClassName();
|
||||
String simpleClassName = equalsAnyIgnoreCase(table.getClassName(), table.getModuleName()) ? table.getClassName()
|
||||
: removePrefix(table.getClassName(), upperFirst(table.getModuleName()));
|
||||
String classNameVar = lowerFirst(simpleClassName);
|
||||
bindingMap.put("simpleClassName", simpleClassName);
|
||||
bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type
|
||||
bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量
|
||||
bindingMap.put("classNameVar", classNameVar); // 将 DictType 转换成 dictType,用于变量
|
||||
// 将 DictType 转换成 dict-type
|
||||
String simpleClassNameStrikeCase = toSymbolCase(simpleClassName, '-');
|
||||
bindingMap.put("simpleClassName_strikeCase", simpleClassNameStrikeCase);
|
||||
@ -441,6 +446,22 @@ public class CodegenEngine {
|
||||
bindingMap.put("subClassNameVars", subClassNameVars);
|
||||
bindingMap.put("subSimpleClassName_strikeCases", subSimpleClassNameStrikeCases);
|
||||
}
|
||||
|
||||
// 多个 vm 公用的 VO 变量
|
||||
if (ObjectUtil.equal(codegenProperties.getVoType(), CodegenVOTypeEnum.VO.getType())) {
|
||||
String prefixClass = CodegenSceneEnum.valueOf(table.getScene()).getPrefixClass();
|
||||
bindingMap.put("saveReqVOClass", prefixClass + className + "SaveReqVO");
|
||||
bindingMap.put("updateReqVOClass", prefixClass + className + "SaveReqVO");
|
||||
bindingMap.put("respVOClass", prefixClass + className + "RespVO");
|
||||
bindingMap.put("saveReqVOVar", "createReqVO");
|
||||
bindingMap.put("updateReqVOVar", "updateReqVO");
|
||||
} else if (ObjectUtil.equal(codegenProperties.getVoType(), CodegenVOTypeEnum.DO.getType())) {
|
||||
bindingMap.put("saveReqVOClass", className + "DO");
|
||||
bindingMap.put("updateReqVOClass", className + "DO");
|
||||
bindingMap.put("respVOClass", className + "DO");
|
||||
bindingMap.put("saveReqVOVar", classNameVar);
|
||||
bindingMap.put("updateReqVOVar", classNameVar);
|
||||
}
|
||||
return bindingMap;
|
||||
}
|
||||
|
||||
@ -461,6 +482,11 @@ public class CodegenEngine {
|
||||
templates.remove(javaTemplatePath("test/serviceTest"));
|
||||
templates.remove("codegen/sql/h2.vm");
|
||||
}
|
||||
// 如果禁用 VO 类型,则移除对应的模版
|
||||
if (ObjectUtil.notEqual(codegenProperties.getVoType(), CodegenVOTypeEnum.VO.getType())) {
|
||||
templates.remove(javaTemplatePath("controller/vo/respVO"));
|
||||
templates.remove(javaTemplatePath("controller/vo/saveReqVO"));
|
||||
}
|
||||
return templates;
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* 参数配置 Service 接口
|
||||
|
@ -8,12 +8,11 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||
|
||||
|
@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.infra.service.db;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -7,10 +7,10 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.db.DataSourceConfigMapper;
|
||||
import com.baomidou.dynamic.datasource.creator.DataSourceProperty;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -15,8 +15,8 @@ public interface DatabaseTableService {
|
||||
* 获得表列表,基于表名称 + 表描述进行模糊匹配
|
||||
*
|
||||
* @param dataSourceConfigId 数据源配置的编号
|
||||
* @param nameLike 表名称,模糊匹配
|
||||
* @param commentLike 表描述,模糊匹配
|
||||
* @param nameLike 表名称,模糊匹配
|
||||
* @param commentLike 表描述,模糊匹配
|
||||
* @return 表列表
|
||||
*/
|
||||
List<TableInfo> getTableList(Long dataSourceConfigId, String nameLike, String commentLike);
|
||||
@ -25,7 +25,7 @@ public interface DatabaseTableService {
|
||||
* 获得指定表名
|
||||
*
|
||||
* @param dataSourceConfigId 数据源配置的编号
|
||||
* @param tableName 表名称
|
||||
* @param tableName 表名称
|
||||
* @return 表
|
||||
*/
|
||||
TableInfo getTable(Long dataSourceConfigId, String tableName);
|
||||
|
@ -1,11 +1,12 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo01;
|
||||
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 示例联系人 Service 接口
|
||||
@ -36,6 +37,13 @@ public interface Demo01ContactService {
|
||||
*/
|
||||
void deleteDemo01Contact(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除示例联系人
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteDemo0iContactListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得示例联系人
|
||||
*
|
||||
|
@ -1,19 +1,20 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo01;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo01.Demo01ContactMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DEMO01_CONTACT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 示例联系人 Service 实现类
|
||||
@ -53,6 +54,21 @@ public class Demo01ContactServiceImpl implements Demo01ContactService {
|
||||
demo01ContactMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo0iContactListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateDemo01ContactExists(ids);
|
||||
// 删除
|
||||
demo01ContactMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateDemo01ContactExists(List<Long> ids) {
|
||||
List<Demo01ContactDO> list = demo01ContactMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(DEMO01_CONTACT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDemo01ContactExists(Long id) {
|
||||
if (demo01ContactMapper.selectById(id) == null) {
|
||||
throw exception(DEMO01_CONTACT_NOT_EXISTS);
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo02;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 示例分类 Service 接口
|
||||
|
@ -5,10 +5,10 @@ import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02Categ
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo02.Demo02CategoryMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03;
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03.erp;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -16,7 +16,7 @@ import java.util.List;
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface Demo03StudentService {
|
||||
public interface Demo03StudentErpService {
|
||||
|
||||
/**
|
||||
* 创建学生
|
||||
@ -24,14 +24,14 @@ public interface Demo03StudentService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo03Student(@Valid Demo03StudentSaveReqVO createReqVO);
|
||||
Long createDemo03Student(@Valid Demo03StudentErpSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新学生
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDemo03Student(@Valid Demo03StudentSaveReqVO updateReqVO);
|
||||
void updateDemo03Student(@Valid Demo03StudentErpSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除学生
|
||||
@ -40,6 +40,13 @@ public interface Demo03StudentService {
|
||||
*/
|
||||
void deleteDemo03Student(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除学生
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteDemo03StudentListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得学生
|
||||
*
|
||||
@ -54,19 +61,10 @@ public interface Demo03StudentService {
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 学生分页
|
||||
*/
|
||||
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO);
|
||||
|
||||
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO);
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
/**
|
||||
* 获得学生课程列表
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生课程列表
|
||||
*/
|
||||
List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
|
||||
|
||||
/**
|
||||
* 获得学生课程分页
|
||||
*
|
||||
@ -98,6 +96,13 @@ public interface Demo03StudentService {
|
||||
*/
|
||||
void deleteDemo03Course(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除学生课程
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteDemo03CourseListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得学生课程
|
||||
*
|
||||
@ -108,14 +113,6 @@ public interface Demo03StudentService {
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
/**
|
||||
* 获得学生班级
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生班级
|
||||
*/
|
||||
Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
|
||||
|
||||
/**
|
||||
* 获得学生班级分页
|
||||
*
|
||||
@ -147,6 +144,13 @@ public interface Demo03StudentService {
|
||||
*/
|
||||
void deleteDemo03Grade(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除学生班级
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteDemo03GradeListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得学生班级
|
||||
*
|
@ -1,21 +1,22 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03;
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03.erp;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03CourseMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03GradeMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03StudentMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03CourseErpMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03GradeErpMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.erp.Demo03StudentErpMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -28,41 +29,31 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class Demo03StudentServiceImpl implements Demo03StudentService {
|
||||
public class Demo03StudentErpServiceImpl implements Demo03StudentErpService {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentMapper demo03StudentMapper;
|
||||
private Demo03StudentErpMapper demo03StudentErpMapper;
|
||||
@Resource
|
||||
private Demo03CourseMapper demo03CourseMapper;
|
||||
private Demo03CourseErpMapper demo03CourseErpMapper;
|
||||
@Resource
|
||||
private Demo03GradeMapper demo03GradeMapper;
|
||||
private Demo03GradeErpMapper demo03GradeErpMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createDemo03Student(Demo03StudentSaveReqVO createReqVO) {
|
||||
public Long createDemo03Student(Demo03StudentErpSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
|
||||
demo03StudentMapper.insert(demo03Student);
|
||||
|
||||
// 插入子表
|
||||
createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
|
||||
createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
|
||||
demo03StudentErpMapper.insert(demo03Student);
|
||||
// 返回
|
||||
return demo03Student.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDemo03Student(Demo03StudentSaveReqVO updateReqVO) {
|
||||
public void updateDemo03Student(Demo03StudentErpSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(updateReqVO.getId());
|
||||
// 更新
|
||||
Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
|
||||
demo03StudentMapper.updateById(updateObj);
|
||||
|
||||
// 更新子表
|
||||
updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
|
||||
updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
|
||||
demo03StudentErpMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,119 +62,117 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(id);
|
||||
// 删除
|
||||
demo03StudentMapper.deleteById(id);
|
||||
demo03StudentErpMapper.deleteById(id);
|
||||
|
||||
// 删除子表
|
||||
deleteDemo03CourseByStudentId(id);
|
||||
deleteDemo03GradeByStudentId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDemo03StudentListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(ids);
|
||||
// 删除
|
||||
demo03StudentErpMapper.deleteByIds(ids);
|
||||
|
||||
// 删除子表
|
||||
deleteDemo03CourseByStudentIds(ids);
|
||||
deleteDemo03GradeByStudentIds(ids);
|
||||
}
|
||||
|
||||
private void validateDemo03StudentExists(List<Long> ids) {
|
||||
List<Demo03StudentDO> list = demo03StudentErpMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(DEMO03_STUDENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDemo03StudentExists(Long id) {
|
||||
if (demo03StudentMapper.selectById(id) == null) {
|
||||
if (demo03StudentErpMapper.selectById(id) == null) {
|
||||
throw exception(DEMO03_STUDENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03StudentDO getDemo03Student(Long id) {
|
||||
return demo03StudentMapper.selectById(id);
|
||||
return demo03StudentErpMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO) {
|
||||
return demo03StudentMapper.selectPage(pageReqVO);
|
||||
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO) {
|
||||
return demo03StudentErpMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
@Override
|
||||
public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
|
||||
return demo03CourseMapper.selectListByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
if (list != null) {
|
||||
list.forEach(o -> o.setStudentId(studentId));
|
||||
}
|
||||
demo03CourseMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
deleteDemo03CourseByStudentId(studentId);
|
||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
||||
createDemo03CourseList(studentId, list);
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentId(Long studentId) {
|
||||
demo03CourseMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId) {
|
||||
return demo03CourseMapper.selectPage(pageReqVO, studentId);
|
||||
return demo03CourseErpMapper.selectPage(pageReqVO, studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createDemo03Course(Demo03CourseDO demo03Course) {
|
||||
demo03CourseMapper.insert(demo03Course);
|
||||
demo03CourseErpMapper.insert(demo03Course);
|
||||
return demo03Course.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDemo03Course(Demo03CourseDO demo03Course) {
|
||||
demo03CourseMapper.updateById(demo03Course);
|
||||
// 校验存在
|
||||
validateDemo03CourseExists(demo03Course.getId());
|
||||
// 更新
|
||||
demo03Course.clean();
|
||||
demo03CourseErpMapper.updateById(demo03Course);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo03Course(Long id) {
|
||||
demo03CourseMapper.deleteById(id);
|
||||
// 删除
|
||||
demo03CourseErpMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo03CourseListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
demo03CourseErpMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03CourseDO getDemo03Course(Long id) {
|
||||
return demo03CourseMapper.selectById(id);
|
||||
return demo03CourseErpMapper.selectById(id);
|
||||
}
|
||||
|
||||
private void validateDemo03CourseExists(Long id) {
|
||||
if (demo03CourseErpMapper.selectById(id) == null) {
|
||||
throw exception(DEMO03_COURSE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentId(Long studentId) {
|
||||
demo03CourseErpMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentIds(List<Long> studentIds) {
|
||||
demo03CourseErpMapper.deleteByStudentIds(studentIds);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
@Override
|
||||
public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
|
||||
return demo03GradeMapper.selectByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId);
|
||||
demo03GradeMapper.insert(demo03Grade);
|
||||
}
|
||||
|
||||
private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId);
|
||||
demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
|
||||
demo03GradeMapper.insertOrUpdate(demo03Grade);
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentId(Long studentId) {
|
||||
demo03GradeMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId) {
|
||||
return demo03GradeMapper.selectPage(pageReqVO, studentId);
|
||||
return demo03GradeErpMapper.selectPage(pageReqVO, studentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createDemo03Grade(Demo03GradeDO demo03Grade) {
|
||||
// 校验是否已经存在
|
||||
if (demo03GradeMapper.selectByStudentId(demo03Grade.getStudentId()) != null) {
|
||||
if (demo03GradeErpMapper.selectByStudentId(demo03Grade.getStudentId()) != null) {
|
||||
throw exception(DEMO03_GRADE_EXISTS);
|
||||
}
|
||||
demo03GradeMapper.insert(demo03Grade);
|
||||
// 插入
|
||||
demo03GradeErpMapper.insert(demo03Grade);
|
||||
return demo03Grade.getId();
|
||||
}
|
||||
|
||||
@ -192,26 +181,39 @@ public class Demo03StudentServiceImpl implements Demo03StudentService {
|
||||
// 校验存在
|
||||
validateDemo03GradeExists(demo03Grade.getId());
|
||||
// 更新
|
||||
demo03GradeMapper.updateById(demo03Grade);
|
||||
demo03Grade.clean();
|
||||
demo03GradeErpMapper.updateById(demo03Grade);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo03Grade(Long id) {
|
||||
// 校验存在
|
||||
validateDemo03GradeExists(id);
|
||||
// 删除
|
||||
demo03GradeMapper.deleteById(id);
|
||||
demo03GradeErpMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemo03GradeListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
demo03GradeErpMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03GradeDO getDemo03Grade(Long id) {
|
||||
return demo03GradeMapper.selectById(id);
|
||||
return demo03GradeErpMapper.selectById(id);
|
||||
}
|
||||
|
||||
private void validateDemo03GradeExists(Long id) {
|
||||
if (demo03GradeMapper.selectById(id) == null) {
|
||||
if (demo03GradeErpMapper.selectById(id) == null) {
|
||||
throw exception(DEMO03_GRADE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentId(Long studentId) {
|
||||
demo03GradeErpMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentIds(List<Long> studentIds) {
|
||||
demo03GradeErpMapper.deleteByStudentIds(studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03.inner;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface Demo03StudentInnerService {
|
||||
|
||||
/**
|
||||
* 创建学生
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo03Student(@Valid Demo03StudentInnerSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新学生
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDemo03Student(@Valid Demo03StudentInnerSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除学生
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemo03Student(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除学生
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteDemo03StudentListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得学生
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 学生
|
||||
*/
|
||||
Demo03StudentDO getDemo03Student(Long id);
|
||||
|
||||
/**
|
||||
* 获得学生分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 学生分页
|
||||
*/
|
||||
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentInnerPageReqVO pageReqVO);
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
/**
|
||||
* 获得学生课程列表
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生课程列表
|
||||
*/
|
||||
List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
/**
|
||||
* 获得学生班级
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生班级
|
||||
*/
|
||||
Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
|
||||
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03.inner;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.inner.Demo03CourseInnerMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.inner.Demo03GradeInnerMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.inner.Demo03StudentInnerMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DEMO03_STUDENT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 学生 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class Demo03StudentInnerServiceImpl implements Demo03StudentInnerService {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentInnerMapper demo03StudentInnerMapper;
|
||||
@Resource
|
||||
private Demo03CourseInnerMapper demo03CourseInnerMapper;
|
||||
@Resource
|
||||
private Demo03GradeInnerMapper demo03GradeInnerMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createDemo03Student(Demo03StudentInnerSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
|
||||
demo03StudentInnerMapper.insert(demo03Student);
|
||||
|
||||
// 插入子表
|
||||
createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
|
||||
createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
|
||||
// 返回
|
||||
return demo03Student.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDemo03Student(Demo03StudentInnerSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(updateReqVO.getId());
|
||||
// 更新
|
||||
Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
|
||||
demo03StudentInnerMapper.updateById(updateObj);
|
||||
|
||||
// 更新子表
|
||||
updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
|
||||
updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDemo03Student(Long id) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(id);
|
||||
// 删除
|
||||
demo03StudentInnerMapper.deleteById(id);
|
||||
|
||||
// 删除子表
|
||||
deleteDemo03CourseByStudentId(id);
|
||||
deleteDemo03GradeByStudentId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDemo03StudentListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(ids);
|
||||
// 删除
|
||||
demo03StudentInnerMapper.deleteByIds(ids);
|
||||
|
||||
// 删除子表
|
||||
deleteDemo03CourseByStudentIds(ids);
|
||||
deleteDemo03GradeByStudentIds(ids);
|
||||
}
|
||||
|
||||
private void validateDemo03StudentExists(List<Long> ids) {
|
||||
List<Demo03StudentDO> list = demo03StudentInnerMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(DEMO03_STUDENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDemo03StudentExists(Long id) {
|
||||
if (demo03StudentInnerMapper.selectById(id) == null) {
|
||||
throw exception(DEMO03_STUDENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03StudentDO getDemo03Student(Long id) {
|
||||
return demo03StudentInnerMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentInnerPageReqVO pageReqVO) {
|
||||
return demo03StudentInnerMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
@Override
|
||||
public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
|
||||
return demo03CourseInnerMapper.selectListByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
list.forEach(o -> o.setStudentId(studentId).clean());
|
||||
demo03CourseInnerMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
list.forEach(o -> o.setStudentId(studentId).clean());
|
||||
List<Demo03CourseDO> oldList = demo03CourseInnerMapper.selectListByStudentId(studentId);
|
||||
List<List<Demo03CourseDO>> diffList = diffList(oldList, list, (oldVal, newVal) -> {
|
||||
boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId());
|
||||
if (same) {
|
||||
newVal.setId(oldVal.getId());
|
||||
}
|
||||
return same;
|
||||
});
|
||||
|
||||
// 第二步,批量添加、修改、删除
|
||||
if (CollUtil.isNotEmpty(diffList.get(0))) {
|
||||
demo03CourseInnerMapper.insertBatch(diffList.get(0));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(diffList.get(1))) {
|
||||
demo03CourseInnerMapper.updateBatch(diffList.get(1));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(diffList.get(2))) {
|
||||
demo03CourseInnerMapper.deleteByIds(convertList(diffList.get(2), Demo03CourseDO::getId));
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentId(Long studentId) {
|
||||
demo03CourseInnerMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentIds(List<Long> studentIds) {
|
||||
demo03CourseInnerMapper.deleteByStudentIds(studentIds);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
@Override
|
||||
public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
|
||||
return demo03GradeInnerMapper.selectByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId);
|
||||
demo03GradeInnerMapper.insert(demo03Grade);
|
||||
}
|
||||
|
||||
private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId).clean();
|
||||
demo03GradeInnerMapper.insertOrUpdate(demo03Grade);
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentId(Long studentId) {
|
||||
demo03GradeInnerMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentIds(List<Long> studentIds) {
|
||||
demo03GradeInnerMapper.deleteByStudentIds(studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03.normal;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface Demo03StudentNormalService {
|
||||
|
||||
/**
|
||||
* 创建学生
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemo03Student(@Valid Demo03StudentNormalSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新学生
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDemo03Student(@Valid Demo03StudentNormalSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除学生
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemo03Student(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除学生
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteDemo03StudentListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得学生
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 学生
|
||||
*/
|
||||
Demo03StudentDO getDemo03Student(Long id);
|
||||
|
||||
/**
|
||||
* 获得学生分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 学生分页
|
||||
*/
|
||||
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO);
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
/**
|
||||
* 获得学生课程列表
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生课程列表
|
||||
*/
|
||||
List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
/**
|
||||
* 获得学生班级
|
||||
*
|
||||
* @param studentId 学生编号
|
||||
* @return 学生班级
|
||||
*/
|
||||
Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
|
||||
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
package cn.iocoder.yudao.module.infra.service.demo.demo03.normal;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03CourseNormalMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03GradeNormalMapper;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.normal.Demo03StudentNormalMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DEMO03_STUDENT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 学生 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class Demo03StudentNormalServiceImpl implements Demo03StudentNormalService {
|
||||
|
||||
@Resource
|
||||
private Demo03StudentNormalMapper demo03StudentNormalMapper;
|
||||
@Resource
|
||||
private Demo03CourseNormalMapper demo03CourseNormalMapper;
|
||||
@Resource
|
||||
private Demo03GradeNormalMapper demo03GradeNormalMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createDemo03Student(Demo03StudentNormalSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
|
||||
demo03StudentNormalMapper.insert(demo03Student);
|
||||
|
||||
// 插入子表
|
||||
createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
|
||||
createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
|
||||
// 返回
|
||||
return demo03Student.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDemo03Student(Demo03StudentNormalSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(updateReqVO.getId());
|
||||
// 更新
|
||||
Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
|
||||
demo03StudentNormalMapper.updateById(updateObj);
|
||||
|
||||
// 更新子表
|
||||
updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
|
||||
updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDemo03Student(Long id) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(id);
|
||||
// 删除
|
||||
demo03StudentNormalMapper.deleteById(id);
|
||||
|
||||
// 删除子表
|
||||
deleteDemo03CourseByStudentId(id);
|
||||
deleteDemo03GradeByStudentId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDemo03StudentListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateDemo03StudentExists(ids);
|
||||
// 删除
|
||||
demo03StudentNormalMapper.deleteByIds(ids);
|
||||
|
||||
// 删除子表
|
||||
deleteDemo03CourseByStudentIds(ids);
|
||||
deleteDemo03GradeByStudentIds(ids);
|
||||
}
|
||||
|
||||
private void validateDemo03StudentExists(List<Long> ids) {
|
||||
List<Demo03StudentDO> list = demo03StudentNormalMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(DEMO03_STUDENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDemo03StudentExists(Long id) {
|
||||
if (demo03StudentNormalMapper.selectById(id) == null) {
|
||||
throw exception(DEMO03_STUDENT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Demo03StudentDO getDemo03Student(Long id) {
|
||||
return demo03StudentNormalMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO) {
|
||||
return demo03StudentNormalMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生课程) ====================
|
||||
|
||||
@Override
|
||||
public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
|
||||
return demo03CourseNormalMapper.selectListByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
list.forEach(o -> o.setStudentId(studentId).clean());
|
||||
demo03CourseNormalMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
|
||||
list.forEach(o -> o.setStudentId(studentId).clean());
|
||||
List<Demo03CourseDO> oldList = demo03CourseNormalMapper.selectListByStudentId(studentId);
|
||||
List<List<Demo03CourseDO>> diffList = diffList(oldList, list, (oldVal, newVal) -> {
|
||||
boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId());
|
||||
if (same) {
|
||||
newVal.setId(oldVal.getId());
|
||||
}
|
||||
return same;
|
||||
});
|
||||
|
||||
// 第二步,批量添加、修改、删除
|
||||
if (CollUtil.isNotEmpty(diffList.get(0))) {
|
||||
demo03CourseNormalMapper.insertBatch(diffList.get(0));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(diffList.get(1))) {
|
||||
demo03CourseNormalMapper.updateBatch(diffList.get(1));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(diffList.get(2))) {
|
||||
demo03CourseNormalMapper.deleteByIds(convertList(diffList.get(2), Demo03CourseDO::getId));
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentId(Long studentId) {
|
||||
demo03CourseNormalMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void deleteDemo03CourseByStudentIds(List<Long> studentIds) {
|
||||
demo03CourseNormalMapper.deleteByStudentIds(studentIds);
|
||||
}
|
||||
|
||||
// ==================== 子表(学生班级) ====================
|
||||
|
||||
@Override
|
||||
public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
|
||||
return demo03GradeNormalMapper.selectByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId);
|
||||
demo03GradeNormalMapper.insert(demo03Grade);
|
||||
}
|
||||
|
||||
private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
|
||||
if (demo03Grade == null) {
|
||||
return;
|
||||
}
|
||||
demo03Grade.setStudentId(studentId).clean();
|
||||
demo03GradeNormalMapper.insertOrUpdate(demo03Grade);
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentId(Long studentId) {
|
||||
demo03GradeNormalMapper.deleteByStudentId(studentId);
|
||||
}
|
||||
|
||||
private void deleteDemo03GradeByStudentIds(List<Long> studentIds) {
|
||||
demo03GradeNormalMapper.deleteByStudentIds(studentIds);
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
package cn.iocoder.yudao.module.infra.service.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
/**
|
||||
* 文件配置 Service 接口
|
||||
|
@ -4,27 +4,26 @@ import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientFactory;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.file.FileConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.file.FileConfigMapper;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientFactory;
|
||||
import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Validator;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Validator;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -138,7 +137,7 @@ public class FileConfigServiceImpl implements FileConfigService {
|
||||
/**
|
||||
* 清空指定文件配置
|
||||
*
|
||||
* @param id 配置编号
|
||||
* @param id 配置编号
|
||||
* @param master 是否主配置
|
||||
*/
|
||||
private void clearCache(Long id, Boolean master) {
|
||||
|
@ -25,10 +25,10 @@ public interface FileService {
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @param name 文件名称,允许空
|
||||
* @param content 文件内容
|
||||
* @param name 文件名称,允许空
|
||||
* @param directory 目录,允许空
|
||||
* @param type 文件的 MIME 类型,允许空
|
||||
* @param type 文件的 MIME 类型,允许空
|
||||
* @return 文件路径
|
||||
*/
|
||||
String createFile(@NotEmpty(message = "文件内容不能为空") byte[] content,
|
||||
@ -37,7 +37,7 @@ public interface FileService {
|
||||
/**
|
||||
* 生成文件预签名地址信息
|
||||
*
|
||||
* @param name 文件名
|
||||
* @param name 文件名
|
||||
* @param directory 目录
|
||||
* @return 预签名地址信息
|
||||
*/
|
||||
|
@ -31,7 +31,7 @@ public interface JobLogService extends JobLogFrameworkService {
|
||||
/**
|
||||
* 清理 exceedDay 天前的任务日志
|
||||
*
|
||||
* @param exceedDay 超过多少天就进行清理
|
||||
* @param exceedDay 超过多少天就进行清理
|
||||
* @param deleteLimit 清理的间隔条数
|
||||
*/
|
||||
Integer cleanJobLog(Integer exceedDay, Integer deleteLimit);
|
||||
|
@ -5,12 +5,12 @@ import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.job.JobLogStatusEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
|
@ -4,10 +4,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
import jakarta.validation.Valid;
|
||||
import org.quartz.SchedulerException;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 定时任务 Service 接口
|
||||
*
|
||||
@ -33,7 +32,7 @@ public interface JobService {
|
||||
/**
|
||||
* 更新定时任务的状态
|
||||
*
|
||||
* @param id 任务编号
|
||||
* @param id 任务编号
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateJobStatus(Long id, Integer status) throws SchedulerException;
|
||||
|
@ -190,7 +190,7 @@ public class JobServiceImpl implements JobService {
|
||||
|
||||
@Override
|
||||
public PageResult<JobDO> getJobPage(JobPageReqVO pageReqVO) {
|
||||
return jobMapper.selectPage(pageReqVO);
|
||||
return jobMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
private static void fillJobMonitorTimeoutEmpty(JobDO job) {
|
||||
|
@ -30,7 +30,7 @@ public interface ApiAccessLogService {
|
||||
/**
|
||||
* 清理 exceedDay 天前的访问日志
|
||||
*
|
||||
* @param exceedDay 超过多少天就进行清理
|
||||
* @param exceedDay 超过多少天就进行清理
|
||||
* @param deleteLimit 清理的间隔条数
|
||||
*/
|
||||
Integer cleanAccessLog(Integer exceedDay, Integer deleteLimit);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.biz.infra.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
|
||||
@ -30,7 +30,7 @@ public interface ApiErrorLogService {
|
||||
/**
|
||||
* 更新 API 错误日志已处理
|
||||
*
|
||||
* @param id API 日志编号
|
||||
* @param id API 日志编号
|
||||
* @param processStatus 处理结果
|
||||
* @param processUserId 处理人
|
||||
*/
|
||||
@ -39,7 +39,7 @@ public interface ApiErrorLogService {
|
||||
/**
|
||||
* 清理 exceedDay 天前的错误日志
|
||||
*
|
||||
* @param exceedDay 超过多少天就进行清理
|
||||
* @param exceedDay 超过多少天就进行清理
|
||||
* @param deleteLimit 清理的间隔条数
|
||||
*/
|
||||
Integer cleanErrorLog(Integer exceedDay, Integer deleteLimit);
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.biz.infra.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||
import cn.iocoder.yudao.framework.common.biz.infra.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper;
|
||||
|
@ -49,8 +49,8 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
|
||||
#end
|
||||
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO) {
|
||||
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
||||
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${saveReqVOClass} ${saveReqVOVar}) {
|
||||
return success(${classNameVar}Service.create${simpleClassName}(${saveReqVOVar}));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ -58,8 +58,8 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
|
||||
#end
|
||||
public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO) {
|
||||
${classNameVar}Service.update${simpleClassName}(updateReqVO);
|
||||
public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${updateReqVOClass} ${updateReqVOVar}) {
|
||||
${classNameVar}Service.update${simpleClassName}(${updateReqVOVar});
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -74,15 +74,32 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除${table.classComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
|
||||
#end
|
||||
public CommonResult<Boolean> delete${simpleClassName}List(@RequestParam("ids") List<${primaryColumn.javaType}> ids) {
|
||||
${classNameVar}Service.delete${simpleClassName}ListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
#end
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得${table.classComment}")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
public CommonResult<${sceneEnum.prefixClass}${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||
public CommonResult<${respVOClass}> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
||||
${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
|
||||
return success(BeanUtils.toBean(${classNameVar}, ${sceneEnum.prefixClass}${table.className}RespVO.class));
|
||||
#if ($voType == 10)
|
||||
return success(BeanUtils.toBean(${classNameVar}, ${respVOClass}.class));
|
||||
#else
|
||||
return success(${classNameVar});
|
||||
#end
|
||||
}
|
||||
|
||||
#if ( $table.templateType != 2 )
|
||||
@ -91,9 +108,13 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
public CommonResult<PageResult<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) {
|
||||
public CommonResult<PageResult<${respVOClass}>> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) {
|
||||
PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ${sceneEnum.prefixClass}${table.className}RespVO.class));
|
||||
#if ($voType == 10)
|
||||
return success(BeanUtils.toBean(pageResult, ${respVOClass}.class));
|
||||
#else
|
||||
return success(pageResult);
|
||||
#end
|
||||
}
|
||||
|
||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||
@ -103,9 +124,13 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
||||
#end
|
||||
public CommonResult<List<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}List(@Valid ${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO) {
|
||||
public CommonResult<List<${respVOClass}>> get${simpleClassName}List(@Valid ${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO) {
|
||||
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(listReqVO);
|
||||
return success(BeanUtils.toBean(list, ${sceneEnum.prefixClass}${table.className}RespVO.class));
|
||||
#if ($voType == 10)
|
||||
return success(BeanUtils.toBean(list, ${respVOClass}.class));
|
||||
#else
|
||||
return success(list);
|
||||
#end
|
||||
}
|
||||
|
||||
#end
|
||||
@ -121,8 +146,8 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}Page(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${sceneEnum.prefixClass}${table.className}RespVO.class,
|
||||
BeanUtils.toBean(list, ${sceneEnum.prefixClass}${table.className}RespVO.class));
|
||||
ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${respVOClass}.class,
|
||||
BeanUtils.toBean(list, ${respVOClass}.class));
|
||||
}
|
||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||
#else
|
||||
@ -218,6 +243,19 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
#if ($deleteBatchEnable)
|
||||
@DeleteMapping("/${subSimpleClassName_strikeCase}/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除${subTable.classComment}")
|
||||
#if ($sceneEnum.scene == 1)
|
||||
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
|
||||
#end
|
||||
public CommonResult<Boolean> delete${subSimpleClassName}List(@RequestParam("ids") List<${subPrimaryColumn.javaType}> ids) {
|
||||
${classNameVar}Service.delete${subSimpleClassName}ListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
#end
|
||||
|
||||
@GetMapping("/${subSimpleClassName_strikeCase}/get")
|
||||
@Operation(summary = "获得${subTable.classComment}")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
|
@ -28,8 +28,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "${sceneEnum.name} - ${table.classComment}分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user