mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-12-25 00:57:14 +08:00
feat: 新增生成代码接口(后端代码)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import static top.charles7c.cnadmin.common.annotation.CrudRequestMapping.Api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import top.charles7c.cnadmin.common.annotation.CrudRequestMapping;
|
||||
import top.charles7c.cnadmin.common.base.BaseController;
|
||||
import ${packageName}.model.query.${classNamePrefix}Query;
|
||||
import ${packageName}.model.request.${classNamePrefix}Request;
|
||||
import ${packageName}.model.vo.${classNamePrefix}DetailVO;
|
||||
import ${packageName}.model.vo.${classNamePrefix}VO;
|
||||
import ${packageName}.service.${classNamePrefix}Service;
|
||||
|
||||
/**
|
||||
* ${businessName}管理 API
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Tag(name = "${businessName}管理 API")
|
||||
@RestController
|
||||
@CrudRequestMapping(value = "/${moduleName}/${apiName}", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT})
|
||||
public class ${className} extends BaseController<${classNamePrefix}Service, ${classNamePrefix}VO, ${classNamePrefix}DetailVO, ${classNamePrefix}Query, ${classNamePrefix}Request> {}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDetailVO;
|
||||
|
||||
/**
|
||||
* ${businessName}详情信息
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@Schema(description = "${businessName}详情信息")
|
||||
public class ${className} extends BaseDetailVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
@ExcelProperty(value = "${fieldConfig.comment}")
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseDO;
|
||||
|
||||
/**
|
||||
* ${businessName}实体
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
public class ${className} extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseMapper;
|
||||
import ${packageName}.model.entity.${classNamePrefix}DO;
|
||||
|
||||
/**
|
||||
* ${businessName} Mapper
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${className} extends BaseMapper<${classNamePrefix}DO> {}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import java.io.Serializable;
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
<#if hasListQueryField>
|
||||
import java.util.List;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.annotation.Query;
|
||||
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
|
||||
|
||||
/**
|
||||
* ${businessName}查询条件
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${businessName}查询条件")
|
||||
public class ${className} implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInQuery>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
@Query(type = QueryTypeEnum.${fieldConfig.queryType})
|
||||
<#if fieldConfig.queryType == 'IN' || fieldConfig.queryType == 'NOT_IN' || fieldConfig.queryType == 'BETWEEN'>
|
||||
private List<${fieldConfig.fieldType}> ${fieldConfig.fieldName};
|
||||
<#else>
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
<#if hasRequiredField>
|
||||
import javax.validation.constraints.*;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseRequest;
|
||||
|
||||
/**
|
||||
* 创建或修改${businessName}信息
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建或修改${businessName}信息")
|
||||
public class ${className} extends BaseRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInForm>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
<#if fieldConfig.isRequired>
|
||||
<#if fieldConfig.fieldType = 'String'>
|
||||
@NotBlank(message = "${fieldConfig.comment}不能为空")
|
||||
<#else>
|
||||
@NotNull(message = "${fieldConfig.comment}不能为空")
|
||||
</#if>
|
||||
</#if>
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseService;
|
||||
import ${packageName}.model.query.${classNamePrefix}Query;
|
||||
import ${packageName}.model.request.${classNamePrefix}Request;
|
||||
import ${packageName}.model.vo.${classNamePrefix}DetailVO;
|
||||
import ${packageName}.model.vo.${classNamePrefix}VO;
|
||||
|
||||
/**
|
||||
* ${businessName}业务接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${className} extends BaseService<${classNamePrefix}VO, ${classNamePrefix}DetailVO, ${classNamePrefix}Query, ${classNamePrefix}Request> {}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseServiceImpl;
|
||||
import ${packageName}.mapper.${classNamePrefix}Mapper;
|
||||
import ${packageName}.model.entity.${classNamePrefix}DO;
|
||||
import ${packageName}.model.query.${classNamePrefix}Query;
|
||||
import ${packageName}.model.request.${classNamePrefix}Request;
|
||||
import ${packageName}.model.vo.${classNamePrefix}DetailVO;
|
||||
import ${packageName}.model.vo.${classNamePrefix}VO;
|
||||
import ${packageName}.service.${classNamePrefix}Service;
|
||||
|
||||
/**
|
||||
* ${businessName}业务实现
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ${className} extends BaseServiceImpl<${classNamePrefix}Mapper, ${classNamePrefix}DO, ${classNamePrefix}VO, ${classNamePrefix}DetailVO, ${classNamePrefix}Query, ${classNamePrefix}Request> implements ${classNamePrefix}Service {}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.charles7c.cnadmin.common.base.BaseVO;
|
||||
|
||||
/**
|
||||
* ${businessName}信息
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${businessName}信息")
|
||||
public class ${className} extends BaseVO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInList>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
Reference in New Issue
Block a user