first commit
This commit is contained in:
59
src/main/resources/application.yml
Normal file
59
src/main/resources/application.yml
Normal file
@ -0,0 +1,59 @@
|
||||
spring:
|
||||
datasource:
|
||||
|
||||
|
||||
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://8.130.119.119:3306/qingcheng?serverTimezone=Asia/Shanghai
|
||||
username: qingcheng
|
||||
password: qingcheng
|
||||
hikari:
|
||||
maximum-pool-size: 20
|
||||
max-lifetime: 120000
|
||||
|
||||
|
||||
|
||||
|
||||
data:
|
||||
redis:
|
||||
port: 6379
|
||||
host: 123.249.108.160
|
||||
database: 0
|
||||
password: yuanteng
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 20MB
|
||||
max-request-size: 20MB
|
||||
|
||||
|
||||
springdoc:
|
||||
default-flat-param-object: true
|
||||
|
||||
|
||||
|
||||
server:
|
||||
port: 3456
|
||||
|
||||
servlet:
|
||||
session:
|
||||
timeout: 720h
|
||||
cookie:
|
||||
max-age: 2592000
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
configuration:
|
||||
map-underscore-to-camel-case: false
|
||||
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
db-config:
|
||||
logic-delete-field: isDelete #全局逻辑删除的实体字段名
|
||||
logic-delete-value: 1 #逻辑已删除值(默认为1)
|
||||
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
|
||||
type-handlers-package: com.cultural.heritage.handler
|
||||
|
||||
|
||||
|
||||
knife4j:
|
||||
enable: true
|
BIN
src/main/resources/lib/2020idea-mybatis_log_plugin.jar
Normal file
BIN
src/main/resources/lib/2020idea-mybatis_log_plugin.jar
Normal file
Binary file not shown.
27
src/main/resources/mapper/UserMapper.xml
Normal file
27
src/main/resources/mapper/UserMapper.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<?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="com.greenorange.promotion.mapper.UserMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.User">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="userAccount" column="userAccount" jdbcType="VARCHAR"/>
|
||||
<result property="userPassword" column="userPassword" jdbcType="VARCHAR"/>
|
||||
<result property="miniOpenId" column="miniOpenId" jdbcType="VARCHAR"/>
|
||||
<result property="userName" column="userName" jdbcType="VARCHAR"/>
|
||||
<result property="userAvatar" column="userAvatar" jdbcType="VARCHAR"/>
|
||||
<result property="points" column="points" jdbcType="INTEGER"/>
|
||||
<result property="userRole" column="userRole" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,userAccount,userPassword,
|
||||
miniOpenId,userName,userAvatar,
|
||||
points,userRole,createTime,
|
||||
updateTime,isDelete
|
||||
</sql>
|
||||
</mapper>
|
134
src/main/resources/templates/controller.java.vm
Normal file
134
src/main/resources/templates/controller.java.vm
Normal file
@ -0,0 +1,134 @@
|
||||
package ${parentPackage}.${controllerPackage};
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${entityComment} 控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("${entityName}")
|
||||
@Slf4j
|
||||
@Tag(name = "${entityComment}管理")
|
||||
public class ${entityName}Controller {
|
||||
|
||||
@Resource
|
||||
private ${entityName}Service ${entityName}Service;
|
||||
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
/**
|
||||
* web端管理员添加${entityComment}
|
||||
* @param ${entityName}AddRequest ${entityComment}添加请求体
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@PostMapping("add")
|
||||
@Operation(summary = "web端管理员添加${entityComment}", description = "参数:${entityComment}添加请求体,权限:管理员(boss, admin),方法名:add${entityName}")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Boolean> add${entityName}(@RequestBody ${entityName}AddRequest ${entityName}AddRequest) {
|
||||
if (${entityName}AddRequest == null) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
${entityName} ${entityName} = new ${entityName}();
|
||||
BeanUtils.copyProperties(${entityName}AddRequest, ${entityName});
|
||||
boolean result = ${entityName}Service.save(${entityName});
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}添加失败");
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员更新${entityComment}
|
||||
* @param ${entityName}UpdateRequest ${entityComment}更新请求体
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
@PostMapping("update")
|
||||
@Operation(summary = "web端管理员更新${entityComment}", description = "参数:${entityComment}更新请求体,权限:管理员(boss, admin),方法名:update${entityName}")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Boolean> update${entityName}(@RequestBody ${entityName}UpdateRequest ${entityName}UpdateRequest) {
|
||||
if (${entityName}UpdateRequest == null || ${entityName}UpdateRequest.getId() <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
${entityName} ${entityName} = new ${entityName}();
|
||||
BeanUtils.copyProperties(${entityName}UpdateRequest, ${entityName});
|
||||
boolean result = ${entityName}Service.updateById(${entityName});
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}更新失败");
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员删除${entityComment}
|
||||
* @param commonRequest ${entityComment}删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
@Operation(summary = "web端管理员删除${entityComment}", description = "参数:${entityComment}删除请求体,权限:管理员(boss, admin),方法名:del${entityName}")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Boolean> del${entityName}(@RequestBody CommonRequest commonRequest) {
|
||||
if (commonRequest == null || commonRequest.getId() <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
Long id = commonRequest.getId();
|
||||
boolean result = ${entityName}Service.removeById(id);
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}删除失败");
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Web端管理员分页查看${entityComment}
|
||||
* @param ${entityName}QueryRequest ${entityComment}查询请求体
|
||||
* @return ${entityComment}列表
|
||||
*/
|
||||
@PostMapping("page")
|
||||
@Operation(summary = "Web端管理员分页查看${entityComment}", description = "参数:${entityComment}查询请求体,权限:管理员(boss, admin),方法名:list${entityName}ByPage")
|
||||
public BaseResponse<Page<${entityName}VO>> list${entityName}ByPage(@RequestBody ${entityName}QueryRequest ${entityName}QueryRequest) {
|
||||
if (${entityName}QueryRequest == null) throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
long current = ${entityName}QueryRequest.getCurrent();
|
||||
long pageSize = ${entityName}QueryRequest.getPageSize();
|
||||
QueryWrapper<${entityName}> queryWrapper = ${entityName}Service.getQueryWrapper(${entityName}QueryRequest);
|
||||
Page<${entityName}> page = ${entityName}Service.page(new Page<>(current, pageSize), queryWrapper);
|
||||
List<${entityName}> ${entityName}List = page.getRecords();
|
||||
List<${entityName}VO> ${entityName}VOList = commonService.convertList(${entityName}List, ${entityName}VO.class);
|
||||
Page<${entityName}VO> voPage = new Page<>();
|
||||
voPage.setRecords(${entityName}VOList);
|
||||
voPage.setPages(page.getPages());
|
||||
voPage.setCurrent(page.getCurrent());
|
||||
voPage.setTotal(page.getTotal());
|
||||
voPage.setSize(page.getSize());
|
||||
return ResultUtils.success(voPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员根据id查询${entityComment}
|
||||
* @param commonRequest ${entityComment}查询请求体
|
||||
* @return ${entityComment}信息
|
||||
*/
|
||||
@PostMapping("queryById")
|
||||
@Operation(summary = "web端管理员根据id查询${entityComment}", description = "参数:${entityComment}查询请求体,权限:管理员(boss, admin),方法名:query${entityName}ById")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<${entityName}VO> query${entityName}ById(@RequestBody CommonRequest commonRequest) {
|
||||
if (commonRequest == null || commonRequest.getId() <= 0) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
${entityName} ${entityName} = ${entityName}Service.getById(commonRequest.getId());
|
||||
ThrowUtils.throwIf(${entityName} == null, ErrorCode.NOT_FOUND, "${entityComment}未找到");
|
||||
${entityName}VO ${entityName}VO = commonService.convert(${entityName}, ${entityName}VO.class);
|
||||
return ResultUtils.success(${entityName}VO);
|
||||
}
|
||||
|
||||
/**
|
||||
* web端管理员批量删除${entityComment}
|
||||
* @param commonRequest ${entityComment}批量删除请求体
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@PostMapping("delBatch")
|
||||
@Operation(summary = "web端管理员批量删除${entityComment}", description = "参数:${entityComment}批量删除请求体,权限:管理员(boss, admin),方法名:delBatch${entityName}")
|
||||
@AuthCheck(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<Boolean> delBatch${entityName}(@RequestBody CommonRequest commonRequest) {
|
||||
if (commonRequest == null || commonRequest.getIds() == null || commonRequest.getIds().isEmpty()) {
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
boolean result = ${entityName}Service.removeByIds(commonRequest.getIds());
|
||||
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "${entityComment}批量删除失败");
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
}
|
29
src/main/resources/templates/dto/Addrequest.java.vm
Normal file
29
src/main/resources/templates/dto/Addrequest.java.vm
Normal file
@ -0,0 +1,29 @@
|
||||
package ${parentPackage}.${dtoPackage};
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ${entityComment}添加请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${entityComment}添加请求体", requiredProperties = {"name", "categoryId", "price", "image", "period", "isShelves"})
|
||||
public class ${entityName}AddRequest implements Serializable {
|
||||
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!$field.keyFlag && $field.propertyName != "id" && $field.propertyName != "createTime" && $field.propertyName != "updateTime" && $field.propertyName != "isDelete")
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
@Schema(description = "${field.comment}", example = "${field.example}")
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
35
src/main/resources/templates/dto/QueryRequest.java.vm
Normal file
35
src/main/resources/templates/dto/QueryRequest.java.vm
Normal file
@ -0,0 +1,35 @@
|
||||
package ${parentPackage}.${dtoPackage};
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import ${parentPackage}.common.PageRequest;
|
||||
|
||||
/**
|
||||
* ${entityComment}查询请求体,继承自分页请求 PageRequest
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${entityComment}查询请求体", requiredProperties = {"current", "pageSize"})
|
||||
public class ${entityName}QueryRequest extends PageRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* ${entityComment} ID
|
||||
*/
|
||||
@Schema(description = "${entityComment} ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!$field.keyFlag && $field.propertyName != "createTime" && $field.propertyName != "updateTime" && $field.propertyName != "isDelete")
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
@Schema(description = "${field.comment}", example = "${field.example}")
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
35
src/main/resources/templates/dto/UpdateRequest.java.vm
Normal file
35
src/main/resources/templates/dto/UpdateRequest.java.vm
Normal file
@ -0,0 +1,35 @@
|
||||
package ${parentPackage}.${dtoPackage};
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ${entityComment}更新请求体
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${entityComment}更新请求体", requiredProperties = {"id", "name", "categoryId", "price", "image", "period", "isShelves"})
|
||||
public class ${entityName}UpdateRequest implements Serializable {
|
||||
|
||||
/**
|
||||
* ${entityComment} ID
|
||||
*/
|
||||
@Schema(description = "${entityComment} ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!$field.keyFlag && $field.propertyName != "createTime" && $field.propertyName != "updateTime" && $field.propertyName != "isDelete")
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
@Schema(description = "${field.comment}", example = "${field.example}")
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
35
src/main/resources/templates/vo/VO.java.vm
Normal file
35
src/main/resources/templates/vo/VO.java.vm
Normal file
@ -0,0 +1,35 @@
|
||||
package ${parentPackage}.${voPackage};
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ${entityComment} 视图对象
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${entityComment} 视图对象")
|
||||
public class ${entityName}VO implements Serializable {
|
||||
|
||||
/**
|
||||
* ${entityComment} ID
|
||||
*/
|
||||
@Schema(description = "${entityComment} ID", example = "1")
|
||||
private Long id;
|
||||
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!$field.keyFlag && $field.propertyName != "createTime" && $field.propertyName != "updateTime" && $field.propertyName != "isDelete")
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
@Schema(description = "${field.comment}", example = "${field.example}")
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
Reference in New Issue
Block a user