代码生成:1)增加 one 情况下的示例代码;2)修复 vue3 模版现有的 bug

This commit is contained in:
YunaiV
2023-11-12 19:50:20 +08:00
parent 07e71e2ab0
commit e67a6a2fe9
27 changed files with 736 additions and 151 deletions

View File

@@ -0,0 +1,89 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*;
import cn.iocoder.yudao.module.infra.convert.demo01.InfraDemo01StudentConvert;
import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO;
import cn.iocoder.yudao.module.infra.service.demo01.InfraDemo01StudentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.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;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Tag(name = "管理后台 - 学生")
@RestController
@RequestMapping("/infra/demo01-student")
@Validated
public class InfraDemo01StudentController {
@Resource
private InfraDemo01StudentService demo01StudentService;
@PostMapping("/create")
@Operation(summary = "创建学生")
@PreAuthorize("@ss.hasPermission('infra:demo01-student:create')")
public CommonResult<Long> createDemo01Student(@Valid @RequestBody InfraDemo01StudentCreateReqVO createReqVO) {
return success(demo01StudentService.createDemo01Student(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新学生")
@PreAuthorize("@ss.hasPermission('infra:demo01-student:update')")
public CommonResult<Boolean> updateDemo01Student(@Valid @RequestBody InfraDemo01StudentUpdateReqVO updateReqVO) {
demo01StudentService.updateDemo01Student(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除学生")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('infra:demo01-student:delete')")
public CommonResult<Boolean> deleteDemo01Student(@RequestParam("id") Long id) {
demo01StudentService.deleteDemo01Student(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得学生")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('infra:demo01-student:query')")
public CommonResult<InfraDemo01StudentRespVO> getDemo01Student(@RequestParam("id") Long id) {
InfraDemo01StudentDO demo01Student = demo01StudentService.getDemo01Student(id);
return success(InfraDemo01StudentConvert.INSTANCE.convert(demo01Student));
}
@GetMapping("/page")
@Operation(summary = "获得学生分页")
@PreAuthorize("@ss.hasPermission('infra:demo01-student:query')")
public CommonResult<PageResult<InfraDemo01StudentRespVO>> getDemo01StudentPage(@Valid InfraDemo01StudentPageReqVO pageVO) {
PageResult<InfraDemo01StudentDO> pageResult = demo01StudentService.getDemo01StudentPage(pageVO);
return success(InfraDemo01StudentConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出学生 Excel")
@PreAuthorize("@ss.hasPermission('infra:demo01-student:export')")
@OperateLog(type = EXPORT)
public void exportDemo01StudentExcel(@Valid InfraDemo01StudentExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<InfraDemo01StudentDO> list = demo01StudentService.getDemo01StudentList(exportReqVO);
// 导出 Excel
List<InfraDemo01StudentExcelVO> datas = InfraDemo01StudentConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "学生.xls", "数据", InfraDemo01StudentExcelVO.class, datas);
}
}

View File

@@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 学生 Base VO提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class InfraDemo01StudentBaseVO {
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头")
@NotEmpty(message = "名字不能为空")
private String name;
@Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍")
@NotEmpty(message = "简介不能为空")
private String description;
@Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "出生日期不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime birthday;
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "性别不能为空")
private Integer sex;
@Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
@NotNull(message = "是否有效不能为空")
private Boolean enabled;
@Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png")
@NotEmpty(message = "头像不能为空")
private String avatar;
@Schema(description = "附件", example = "https://www.iocoder.cn/1.mp4")
private String video;
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注")
@NotEmpty(message = "备注不能为空")
private String memo;
}

View File

@@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo;
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 InfraDemo01StudentCreateReqVO extends InfraDemo01StudentBaseVO {
}

View File

@@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 学生 Excel VO
*
* @author 芋道源码
*/
@Data
public class InfraDemo01StudentExcelVO {
@ExcelProperty("编号")
private Long id;
@ExcelProperty("名字")
private String name;
@ExcelProperty("简介")
private String description;
@ExcelProperty("出生日期")
private LocalDateTime birthday;
@ExcelProperty(value = "性别", converter = DictConvert.class)
@DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
private Integer sex;
@ExcelProperty(value = "是否有效", converter = DictConvert.class)
@DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
private Boolean enabled;
@ExcelProperty(value = "支付方式", converter = DictConvert.class)
@DictFormat("pay_channel_code") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
private String payChannels;
@ExcelProperty("头像")
private String avatar;
@ExcelProperty("附件")
private String video;
@ExcelProperty("备注")
private String memo;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo;
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 = "管理后台 - 学生 Excel 导出 Request VO参数和 InfraDemo01StudentPageReqVO 是一致的")
@Data
public class InfraDemo01StudentExportReqVO {
@Schema(description = "名字", example = "芋头")
private String name;
@Schema(description = "出生日期")
private LocalDateTime birthday;
@Schema(description = "性别", example = "1")
private Integer sex;
@Schema(description = "是否有效", example = "true")
private Boolean enabled;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01.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;
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 InfraDemo01StudentPageReqVO extends PageParam {
@Schema(description = "名字", example = "芋头")
private String name;
@Schema(description = "出生日期")
private LocalDateTime birthday;
@Schema(description = "性别", example = "1")
private Integer sex;
@Schema(description = "是否有效", example = "true")
private Boolean enabled;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 学生 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class InfraDemo01StudentRespVO extends InfraDemo01StudentBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 学生更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class InfraDemo01StudentUpdateReqVO extends InfraDemo01StudentBaseVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "编号不能为空")
private Long id;
}

View File

@@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.infra.convert.demo01;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*;
import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO;
/**
* 学生 Convert
*
* @author 芋道源码
*/
@Mapper
public interface InfraDemo01StudentConvert {
InfraDemo01StudentConvert INSTANCE = Mappers.getMapper(InfraDemo01StudentConvert.class);
InfraDemo01StudentDO convert(InfraDemo01StudentCreateReqVO bean);
InfraDemo01StudentDO convert(InfraDemo01StudentUpdateReqVO bean);
InfraDemo01StudentRespVO convert(InfraDemo01StudentDO bean);
List<InfraDemo01StudentRespVO> convertList(List<InfraDemo01StudentDO> list);
PageResult<InfraDemo01StudentRespVO> convertPage(PageResult<InfraDemo01StudentDO> page);
List<InfraDemo01StudentExcelVO> convertList02(List<InfraDemo01StudentDO> list);
}

View File

@@ -0,0 +1,68 @@
package cn.iocoder.yudao.module.infra.dal.dataobject.demo01;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
/**
* 学生 DO
*
* @author 芋道源码
*/
@TableName("infra_demo01_student")
@KeySequence("infra_demo01_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InfraDemo01StudentDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 名字
*/
private String name;
/**
* 简介
*/
private String description;
/**
* 出生日期
*/
private LocalDateTime birthday;
/**
* 性别
*
* 枚举 {@link TODO system_user_sex 对应的类}
*/
private Integer sex;
/**
* 是否有效
*
* 枚举 {@link TODO infra_boolean_string 对应的类}
*/
private Boolean enabled;
/**
* 头像
*/
private String avatar;
/**
* 附件
*/
private String video;
/**
* 备注
*/
private String memo;
}

View File

@@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.infra.dal.mysql.demo01;
import java.util.*;
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.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*;
/**
* 学生 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface InfraDemo01StudentMapper extends BaseMapperX<InfraDemo01StudentDO> {
default PageResult<InfraDemo01StudentDO> selectPage(InfraDemo01StudentPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<InfraDemo01StudentDO>()
.likeIfPresent(InfraDemo01StudentDO::getName, reqVO.getName())
.eqIfPresent(InfraDemo01StudentDO::getBirthday, reqVO.getBirthday())
.eqIfPresent(InfraDemo01StudentDO::getSex, reqVO.getSex())
.eqIfPresent(InfraDemo01StudentDO::getEnabled, reqVO.getEnabled())
.betweenIfPresent(InfraDemo01StudentDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(InfraDemo01StudentDO::getId));
}
default List<InfraDemo01StudentDO> selectList(InfraDemo01StudentExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<InfraDemo01StudentDO>()
.likeIfPresent(InfraDemo01StudentDO::getName, reqVO.getName())
.eqIfPresent(InfraDemo01StudentDO::getBirthday, reqVO.getBirthday())
.eqIfPresent(InfraDemo01StudentDO::getSex, reqVO.getSex())
.eqIfPresent(InfraDemo01StudentDO::getEnabled, reqVO.getEnabled())
.betweenIfPresent(InfraDemo01StudentDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(InfraDemo01StudentDO::getId));
}
}

View File

@@ -16,8 +16,8 @@ public enum CodegenColumnHtmlTypeEnum {
RADIO("radio"), // 单选框
CHECKBOX("checkbox"), // 复选框
DATETIME("datetime"), // 日期控件
UPLOAD_IMAGE("upload_image"), // 上传图片
UPLOAD_FILE("upload_file"), // 上传文件
IMAGE_UPLOAD("imageUpload"), // 上传图片
FILE_UPLOAD("fileUpload"), // 上传文件
EDITOR("editor"), // 富文本控件
;

View File

@@ -49,8 +49,8 @@ public class CodegenBuilder {
.put("status", CodegenColumnHtmlTypeEnum.RADIO)
.put("sex", CodegenColumnHtmlTypeEnum.RADIO)
.put("type", CodegenColumnHtmlTypeEnum.SELECT)
.put("image", CodegenColumnHtmlTypeEnum.UPLOAD_IMAGE)
.put("file", CodegenColumnHtmlTypeEnum.UPLOAD_FILE)
.put("image", CodegenColumnHtmlTypeEnum.IMAGE_UPLOAD)
.put("file", CodegenColumnHtmlTypeEnum.FILE_UPLOAD)
.put("content", CodegenColumnHtmlTypeEnum.EDITOR)
.put("description", CodegenColumnHtmlTypeEnum.EDITOR)
.put("demo", CodegenColumnHtmlTypeEnum.EDITOR)

View File

@@ -110,21 +110,21 @@ public class CodegenEngine {
vueFilePath("api/${table.moduleName}/${classNameVar}.js"))
// Vue3 标准模版
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/index.vue"),
vue3FilePath("views/${table.moduleName}/${classNameVar}/index.vue"))
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/form.vue"),
vue3FilePath("views/${table.moduleName}/${classNameVar}/${simpleClassName}Form.vue"))
vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_normal.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}Form.vue"))
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_inner.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}Form.vue"))
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_erp.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}Form.vue"))
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_inner.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}List.vue"))
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_erp.vue"), // 特殊:主子表专属逻辑
vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}List.vue"))
vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
.put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"),
vue3FilePath("api/${table.moduleName}/${classNameVar}/index.ts"))
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
// Vue3 Schema 模版
.put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/data.ts"),
vue3FilePath("views/${table.moduleName}/${classNameVar}/${classNameVar}.data.ts"))

View File

@@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.infra.service.demo01;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*;
import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 学生 Service 接口
*
* @author 芋道源码
*/
public interface InfraDemo01StudentService {
/**
* 创建学生
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createDemo01Student(@Valid InfraDemo01StudentCreateReqVO createReqVO);
/**
* 更新学生
*
* @param updateReqVO 更新信息
*/
void updateDemo01Student(@Valid InfraDemo01StudentUpdateReqVO updateReqVO);
/**
* 删除学生
*
* @param id 编号
*/
void deleteDemo01Student(Long id);
/**
* 获得学生
*
* @param id 编号
* @return 学生
*/
InfraDemo01StudentDO getDemo01Student(Long id);
/**
* 获得学生分页
*
* @param pageReqVO 分页查询
* @return 学生分页
*/
PageResult<InfraDemo01StudentDO> getDemo01StudentPage(InfraDemo01StudentPageReqVO pageReqVO);
/**
* 获得学生列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 学生列表
*/
List<InfraDemo01StudentDO> getDemo01StudentList(InfraDemo01StudentExportReqVO exportReqVO);
}

View File

@@ -0,0 +1,81 @@
package cn.iocoder.yudao.module.infra.service.demo01;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*;
import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.infra.convert.demo01.InfraDemo01StudentConvert;
import cn.iocoder.yudao.module.infra.dal.mysql.demo01.InfraDemo01StudentMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
/**
* 学生 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class InfraDemo01StudentServiceImpl implements InfraDemo01StudentService {
@Resource
private InfraDemo01StudentMapper demo01StudentMapper;
@Override
public Long createDemo01Student(InfraDemo01StudentCreateReqVO createReqVO) {
// 插入
InfraDemo01StudentDO demo01Student = InfraDemo01StudentConvert.INSTANCE.convert(createReqVO);
demo01StudentMapper.insert(demo01Student);
// 返回
return demo01Student.getId();
}
@Override
public void updateDemo01Student(InfraDemo01StudentUpdateReqVO updateReqVO) {
// 校验存在
validateDemo01StudentExists(updateReqVO.getId());
// 更新
InfraDemo01StudentDO updateObj = InfraDemo01StudentConvert.INSTANCE.convert(updateReqVO);
demo01StudentMapper.updateById(updateObj);
}
@Override
public void deleteDemo01Student(Long id) {
// 校验存在
validateDemo01StudentExists(id);
// 删除
demo01StudentMapper.deleteById(id);
}
private void validateDemo01StudentExists(Long id) {
if (demo01StudentMapper.selectById(id) == null) {
throw exception(DEMO01_STUDENT_NOT_EXISTS);
}
}
@Override
public InfraDemo01StudentDO getDemo01Student(Long id) {
return demo01StudentMapper.selectById(id);
}
@Override
public PageResult<InfraDemo01StudentDO> getDemo01StudentPage(InfraDemo01StudentPageReqVO pageReqVO) {
return demo01StudentMapper.selectPage(pageReqVO);
}
@Override
public List<InfraDemo01StudentDO> getDemo01StudentList(InfraDemo01StudentExportReqVO exportReqVO) {
return demo01StudentMapper.selectList(exportReqVO);
}
}

View File

@@ -5,7 +5,7 @@ INSERT INTO system_menu(
)
VALUES (
'${table.classComment}管理', '', 2, 0, ${table.parentMenuId},
'${simpleClassName_strikeCase}', '', '${table.moduleName}/${classNameVar}/index', 0, '${table.className}'
'${simpleClassName_strikeCase}', '', '${table.moduleName}/${table.businessName}/index', 0, '${table.className}'
);
-- 按钮父菜单ID

View File

@@ -179,15 +179,15 @@
<el-input v-model="formData.${javaField}" placeholder="请输入${comment}" />
</el-form-item>
#elseif($column.htmlType == "imageUpload")## 图片上传
<el-form-item label="${comment}">
<el-form-item label="${comment}" prop="${javaField}">
<UploadImg v-model="formData.${javaField}" />
</el-form-item>
#elseif($column.htmlType == "fileUpload")## 文件上传
<el-form-item label="${comment}">
<el-form-item label="${comment}" prop="${javaField}">
<UploadFile v-model="formData.${javaField}" />
</el-form-item>
#elseif($column.htmlType == "editor")## 文本编辑器
<el-form-item label="${comment}">
<el-form-item label="${comment}" prop="${javaField}">
<Editor v-model="formData.${javaField}" height="150px" />
</el-form-item>
#elseif($column.htmlType == "select")## 下拉框
@@ -257,7 +257,7 @@
</template>
<script setup lang="ts">
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}'
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
const props = defineProps<{
${subJoinColumn.javaField}: undefined // ${subJoinColumn.columnComment}(主表的关联字段)

View File

@@ -31,11 +31,11 @@
<UploadImg v-model="formData.${javaField}" />
</el-form-item>
#elseif($column.htmlType == "fileUpload")## 文件上传
<el-form-item label="${comment}">
<el-form-item label="${comment}" prop="${javaField}">
<UploadFile v-model="formData.${javaField}" />
</el-form-item>
#elseif($column.htmlType == "editor")## 文本编辑器
<el-form-item label="${comment}">
<el-form-item label="${comment}" prop="${javaField}">
<Editor v-model="formData.${javaField}" height="150px" />
</el-form-item>
#elseif($column.htmlType == "select")## 下拉框
@@ -125,7 +125,7 @@
</template>
<script setup lang="ts">
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}'
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
## 特殊:主子表专属逻辑
#foreach ($subSimpleClassName in $subSimpleClassNames)
import ${subSimpleClassName}Form from './components/${subSimpleClassName}Form.vue'

View File

@@ -122,7 +122,7 @@
:formatter="dateFormatter"
width="180px"
/>
#elseif("" != $column.dictType)## 数据字典
#elseif($column.dictType && "" != $column.dictType)## 数据字典
<el-table-column label="${comment}" align="center" prop="${javaField}">
<template #default="scope">
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
@@ -171,7 +171,7 @@
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}'
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
import ${simpleClassName}Form from './${simpleClassName}Form.vue'
defineOptions({ name: '${table.className}' })

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.demo01.InfraDemo01StudentMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>