Demo
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.template;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 项目的启动类
|
||||
*
|
||||
* @author 周迪
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class TemplateServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TemplateServerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.template.controller.admin.example.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
|
||||
@Schema(description = "管理后台 - 模板样例分页 Request VO")
|
||||
@Data
|
||||
public class ExamplePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "字符串")
|
||||
private String strTemp;
|
||||
|
||||
@Schema(description = "整数")
|
||||
private Integer intTemp;
|
||||
|
||||
@Schema(description = "小整数")
|
||||
private Short sintTemp;
|
||||
|
||||
@Schema(description = "布尔值")
|
||||
private Boolean bitTemp;
|
||||
|
||||
@Schema(description = "数值类型")
|
||||
private BigDecimal decimalTemp;
|
||||
|
||||
@Schema(description = "日期类型")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate dateTemp;
|
||||
|
||||
@Schema(description = "时间类型")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime datetimeTemp;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package cn.iocoder.yudao.module.template.controller.admin.example.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
|
||||
@Schema(description = "管理后台 - 模板样例 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ExampleRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24968")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "字符串")
|
||||
@ExcelProperty("字符串")
|
||||
private String strTemp;
|
||||
|
||||
@Schema(description = "整数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("整数")
|
||||
private Integer intTemp;
|
||||
|
||||
@Schema(description = "小整数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("小整数")
|
||||
private Short sintTemp;
|
||||
|
||||
@Schema(description = "布尔值", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("布尔值")
|
||||
private Boolean bitTemp;
|
||||
|
||||
@Schema(description = "数值类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("数值类型")
|
||||
private BigDecimal decimalTemp;
|
||||
|
||||
@Schema(description = "日期类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("日期类型")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate dateTemp;
|
||||
|
||||
@Schema(description = "时间类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("时间类型")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime datetimeTemp;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.template.controller.admin.example.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
|
||||
@Schema(description = "管理后台 - 模板样例新增/修改 Request VO")
|
||||
@Data
|
||||
public class ExampleSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24968")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "字符串")
|
||||
private String strTemp;
|
||||
|
||||
@Schema(description = "整数")
|
||||
// @NotNull(message = "整数不能为空")
|
||||
private Integer intTemp;
|
||||
|
||||
@Schema(description = "小整数")
|
||||
// @NotNull(message = "小整数不能为空")
|
||||
private Short sintTemp;
|
||||
|
||||
@Schema(description = "布尔值")
|
||||
// @NotNull(message = "布尔值不能为空")
|
||||
private Boolean bitTemp;
|
||||
|
||||
@Schema(description = "数值类型")
|
||||
// @NotNull(message = "数值类型不能为空")
|
||||
private BigDecimal decimalTemp;
|
||||
|
||||
@Schema(description = "日期类型")
|
||||
// @NotNull(message = "日期类型不能为空")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate dateTemp;
|
||||
|
||||
@Schema(description = "时间类型")
|
||||
// @NotNull(message = "时间类型不能为空")
|
||||
@JsonFormat(timezone = TIME_ZONE_DEFAULT, pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime datetimeTemp;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.iocoder.yudao.module.template.dal.dataobject.example;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
|
||||
/**
|
||||
* 模板样例 DO
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@TableName("template_example")
|
||||
@KeySequence("template_example_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
// public class ExampleDO extends TenantBaseDO {
|
||||
public class ExampleDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 字符串
|
||||
*/
|
||||
private String strTemp;
|
||||
/**
|
||||
* 整数
|
||||
*/
|
||||
private Integer intTemp;
|
||||
/**
|
||||
* 小整数
|
||||
*/
|
||||
private Short sintTemp;
|
||||
/**
|
||||
* 布尔值
|
||||
*/
|
||||
@TableField(value = "bit_temp", typeHandler = org.apache.ibatis.type.BooleanTypeHandler.class)
|
||||
private Boolean bitTemp;
|
||||
/**
|
||||
* 数值类型
|
||||
*/
|
||||
private BigDecimal decimalTemp;
|
||||
/**
|
||||
* 日期类型
|
||||
*/
|
||||
private LocalDate dateTemp;
|
||||
/**
|
||||
* 时间类型
|
||||
*/
|
||||
private LocalDateTime datetimeTemp;
|
||||
|
||||
/**
|
||||
* 多租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
private String creator;
|
||||
private String updater;
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Boolean deleted;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.template.dal.mysql.example;
|
||||
|
||||
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.template.dal.dataobject.example.ExampleDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.example.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 模板样例 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface ExampleMapper extends BaseMapperX<ExampleDO> {
|
||||
|
||||
default PageResult<ExampleDO> selectPage(ExamplePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ExampleDO>()
|
||||
.likeIfPresent(ExampleDO::getStrTemp, reqVO.getStrTemp())
|
||||
.eqIfPresent(ExampleDO::getIntTemp, reqVO.getIntTemp())
|
||||
.eqIfPresent(ExampleDO::getSintTemp, reqVO.getSintTemp())
|
||||
.eqIfPresent(ExampleDO::getBitTemp, reqVO.getBitTemp())
|
||||
.eqIfPresent(ExampleDO::getDecimalTemp, reqVO.getDecimalTemp())
|
||||
.eqIfPresent(ExampleDO::getDateTemp, reqVO.getDateTemp())
|
||||
.eqIfPresent(ExampleDO::getDatetimeTemp, reqVO.getDatetimeTemp())
|
||||
.betweenIfPresent(ExampleDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ExampleDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.template.framework.security.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer;
|
||||
import cn.iocoder.yudao.module.infra.enums.ApiConstants;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
|
||||
|
||||
|
||||
/**
|
||||
* Template 模块的 Security 配置
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class SecurityConfiguration {
|
||||
|
||||
@Bean
|
||||
public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
|
||||
return new AuthorizeRequestsCustomizer() {
|
||||
|
||||
@Override
|
||||
public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
|
||||
// Swagger 接口文档
|
||||
registry.requestMatchers("/v3/api-docs/**").permitAll()
|
||||
.requestMatchers("/webjars/**").permitAll()
|
||||
.requestMatchers("/swagger-ui").permitAll()
|
||||
.requestMatchers("/swagger-ui/**").permitAll();
|
||||
// Druid 监控
|
||||
registry.requestMatchers("/druid/**").permitAll();
|
||||
// Spring Boot Actuator 的安全配置
|
||||
registry.requestMatchers("/actuator").permitAll()
|
||||
.requestMatchers("/actuator/**").permitAll();
|
||||
// RPC 服务的安全配置
|
||||
registry.requestMatchers(ApiConstants.PREFIX + "/**").permitAll();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.template.service.example;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.example.vo.*;
|
||||
import cn.iocoder.yudao.module.template.dal.dataobject.example.ExampleDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 模板样例 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface ExampleService {
|
||||
|
||||
/**
|
||||
* 创建模板样例
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createExample(@Valid ExampleSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新模板样例
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateExample(@Valid ExampleSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除模板样例
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteExample(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除模板样例
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteExampleListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得模板样例
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 模板样例
|
||||
*/
|
||||
ExampleDO getExample(Long id);
|
||||
|
||||
/**
|
||||
* 获得模板样例分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 模板样例分页
|
||||
*/
|
||||
PageResult<ExampleDO> getExamplePage(ExamplePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.iocoder.yudao.module.template.service.example;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.example.vo.*;
|
||||
import cn.iocoder.yudao.module.template.dal.dataobject.example.ExampleDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.template.dal.mysql.example.ExampleMapper;
|
||||
|
||||
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.template.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 模板样例 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ExampleServiceImpl implements ExampleService {
|
||||
|
||||
@Resource
|
||||
private ExampleMapper exampleMapper;
|
||||
|
||||
@Override
|
||||
public Long createExample(ExampleSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ExampleDO example = BeanUtils.toBean(createReqVO, ExampleDO.class);
|
||||
exampleMapper.insert(example);
|
||||
// 返回
|
||||
return example.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExample(ExampleSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateExampleExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ExampleDO updateObj = BeanUtils.toBean(updateReqVO, ExampleDO.class);
|
||||
exampleMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteExample(Long id) {
|
||||
// 校验存在
|
||||
validateExampleExists(id);
|
||||
// 删除
|
||||
exampleMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteExampleListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateExampleExists(ids);
|
||||
// 删除
|
||||
exampleMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateExampleExists(List<Long> ids) {
|
||||
List<ExampleDO> list = exampleMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(EXAMPLE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateExampleExists(Long id) {
|
||||
if (exampleMapper.selectById(id) == null) {
|
||||
throw exception(EXAMPLE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExampleDO getExample(Long id) {
|
||||
return exampleMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ExampleDO> getExamplePage(ExamplePageReqVO pageReqVO) {
|
||||
return exampleMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user