目录
Entity
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
#parse("Entity Header.java")
@Data
@TableName("")
@ExcelIgnoreUnannotated
public class ${NAME} implements Serializable {
private static final long serialVersionUID = 1L;
private String id;//
@DateTimeFormat("yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
@ExcelProperty("申请日期")
private Date applicationDate;//
@ExcelProperty("申请人")
private String applicationName;//
@ExcelProperty("工号")
private String jobNumber;//
@ExcelProperty("部门")
private String department;//
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelProperty("审批时间")
private Date passDate;//
/** 日期查询条件 */
private String startDate;
private String endDate;
}
Mapper
新建时名称不用带后缀
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
#parse("Mapper Header.java")
@Mapper
public interface ${NAME}Mapper extends BaseMapper<${NAME}> {
List<${NAME}> query${NAME}List(${NAME} o);
}
Mapper.xml
新建时名称带后缀
<?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="${NAME}Mapper">
<!-- 实体类 -->
<resultMap type="${NAME}" id="${NAME}Result">
</resultMap>
<!-- sql语句 -->
<sql id="select${NAME}List">
</sql>
<!-- 方法 -->
<select id="query${NAME}List" parameterType="${NAME}" resultMap="${NAME}Result">
<include refid="select${NAME}List"/>
<where>
<if test="fieldName != null and fieldName != ''"> and tableFieldName like concat('%', #{fieldName}, '%')</if>
<if test="startDate != null and startDate != ''">and tableFieldName >= #{startDate}</if>
<if test="endDate != null and endDate != ''">and tableFieldName <= #{endDate}</if>
</where>
</select>
</mapper>
Mapper.xml(去后缀)配置方式
红框处配置后,自动添加名称后缀
Service
新建时名称不用带后缀
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import java.util.List;
#parse("Service Header.java")
public interface ${NAME}Service {
List<${NAME}> query${NAME}List(${NAME} o);
}
ServiceImpl
新建时名称不用带后缀
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
#parse("ServiceImpl Header.java")
@Service
@DataSource(value = DataSourceType.EKP)
public class ${NAME}ServiceImpl extends ServiceImpl<${NAME}Mapper, ${NAME}> implements ${NAME}Service {
@Autowired
private ${NAME}Mapper ${NAME}Mapper;
@Override
public List<${NAME}> query${NAME}List(${NAME} o) {
return ${NAME}Mapper.query${NAME}List(o);
}
}
Controller
新建时名称不用带后缀
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#parse("Controller Header.java")
@RestController
@RequestMapping("/${NAME}")
public class ${NAME}Controller {
}
application.yml
server:
port: 8081
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
spring:
profiles: # 指定配置文件 只有一个配置文件就去掉这个配置
active: dev
datasource: # 数据源
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# driver-class-name: net.sourceforge.jtds.jdbc.Driver
druid:
master: # 主数据源
url: jdbc:sqlserver://localhost:1433;DatabaseName=dataBase
username: root
password: root
slave: # 从库数据源
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
ekp:
enabled: true
url: jdbc:sqlserver://localhost:1433;SelectMethod=cursor;DatabaseName=dataBase
username: root
password: root
hikari:
connection-test-query: SELECT 1 #测试连接是否可用
# redis 配置
redis:
# 地址
host: localhost
# 端口,默认为6379
port: 6379
# 数据库索引
database: 10
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
banner:
location: banner.txt # banner样式
servlet: # 文件上传
multipart:
max-file-size: 10MB # 单个文件大小,默认为10MB
max-request-size: 50MB # 总上传文件大小,默认为50MB
mvc:
async:
request-timeout: 60000
messages: # 资源信息
basename: i18n/messages # 国际化资源文件路径
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
mybatis-plus:
mapper-locations: classpath:mapper/**/*Mapper.xml # xml文件路径扫描
typeAliasesPackage: com.**.**.entity # 实体类包路径扫描
global-config:
db-config:
id-type: AUTO
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
mapUnderscoreToCamelCase: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# PageHelper分页插件
pagehelper:
helperDialect: sqlserver
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /dev-api
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期(默认30分钟)
expireTime: 30
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间(默认10分钟)
lockTime: 10
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 日志配置
logging:
level:
com.akesobio: debug
org.springframework: warn
application.yml 精简
server:
port: 9093
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数,默认为200
max: 800
# Tomcat启动初始化的线程数,默认值10
min-spare: 100
spring:
# 切换配置文件
profiles:
active: prod
# banner样式
banner:
location: banner.txt
# 文件上传
servlet:
multipart:
max-file-size: 10MB # 单个文件上传大小,默认为10MB
max-request-size: 50MB # 总上传文件大小,默认为50MB
mvc:
async:
request-timeout: 60000
mybatis-plus:
mapper-locations: classpath:mapper/**/*Mapper.xml
typeAliasesPackage: com.leslie.**.entity
global-config:
db-config:
id-type: auto
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
mapUnderscoreToCamelCase: true
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 注释后 SQL 查询数据,控制台不打印结果
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 日志配置
logging:
level:
com.leslie: debug
org.springframework: warn
application-prod.yml
spring:
datasource: # 数据源 单数据源时,url、username、password 挪到第一个 datasource 下
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
# hikari:
# connection-test-query: SELECT 1 #测试连接是否可用
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:sqlserver://ip:1433;DatabaseName=
username:
password:
department:
# enabled: true
url: jdbc:sqlserver://ip:1433;SelectMethod=cursor;DatabaseName=
username:
password:
# 初始连接数
druid:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 900000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 900000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
index.vue
基础版
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="申请日期">
<el-date-picker
v-model="queryParams.queryDate"
style="width: 240px;"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item label="姓名" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入..."
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['Leslie:Lee:export']"
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange" border :max-height="tableMaxHeight">
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="ID" align="center" prop="id" width="100" :show-overflow-tooltip='true' v-if="false"/>
<el-table-column label="申请日期" align="center" prop="applicationDate" width="100" fixed>
<template v-slot="scope">
<span>{{ parseTime(scope.row.applicationDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="单号" align="center" prop="oddNumber" width="160" :show-overflow-tooltip="true" fixed>
<template v-slot="scope">
<span @click="jump(scope.row)" style="color: #3967FF;cursor:pointer;">{{ scope.row.oddNumber }}</span>
</template>
</el-table-column>
<el-table-column label="姓名" align="center" prop="name" width="200" :show-overflow-tooltip="true" fixed/>
<el-table-column label="审批时间" align="center" prop="passDate" width="170">
<template v-slot="scope">
<span>{{ parseTime(scope.row.passDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import {query${CLASSNAME}List} from "@/api/leslie/${CLASSNAME}.js";
export default {
name: "${CLASSNAME}",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 表单参数
form: {},
// 表单校验
rules: {},
// 数据集合
dataList: [],
// 查询参数
queryParams: {
// 页码、页显示量
pageNum: 1,
pageSize: 10,
// 日期查询控件值集合
queryDate: null,
// 日期范围查询开始、结束
startDate: null,
endDate: null,
// 其他查询参数
id: null,
name: null,
applicationDate: null,
},/** queryParams 范围 */
};/** return 范围 */
},/** data 范围 */
created() {
this.getList();
},/** created 范围 */
computed: {
/** 页面适应 */
tableMaxHeight() {
const screenHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
return screenHeight - 230;
}
},/** computed 范围 */
methods: {
/** 数据查询 */
getList() {
this.loading = true;
this.queryParams.params = {};
if (this.queryParams.queryDate != null && this.queryParams.queryDate !== '') {
this.queryParams.startDate = this.queryParams.queryDate[0];
this.queryParams.endDate = this.queryParams.queryDate[1];
}
query${CLASSNAME}List(this.queryParams).then(response => {
this.dataList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams.queryDate = null;
this.queryParams.startDate = null;
this.queryParams.endDate = null;
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.oddNumbers)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 导出按钮操作 */
handleExport() {
var date = new Date()
var year = date.getFullYear().toString()
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : (date.getMonth() + 1).toString()
var day = date.getDate() < 10 ? '0' + date.getDate().toString() : date.getDate().toString()
var h = date.getHours() < 10 ? '0' + date.getHours().toString() : date.getHours().toString()
var m = date.getMinutes() < 10 ? '0' + date.getMinutes().toString() : date.getMinutes().toString()
var s = date.getSeconds() < 10 ? '0' + date.getSeconds().toString() : date.getSeconds().toString()
var dateTime = year + '-' + month + '-' + day + "_" + h + m + s
this.download('Leslie/Lee/export', {
...this.queryParams
}, `导出_{dateTime}.xlsx`)
},
jump(row) {
window.open("url" + row.id)
},
},/** methods 范围 */
watch: {
// 监听日期清理后数据为null进行处理否则会报错
'queryParams.queryDate'(newVal) {
if (newVal == null) {
this.queryParams.queryDate = ''
this.queryParams.startDate = ''
this.queryParams.endDate = ''
}
}
},/** watch 范围 */
};
</script>
注意事项:导出按钮函数处 {dateTime} 需要在前面加 $ 符号,变为 ${dateTime}
Idea 配置方法
使用方法
在需要新建的文件夹路径,右键选择新建
上图中此内容为头部注释配置
#parse("Controller Header.java")