作者 朱兆平

mysql mapper 大小写问题。Mysql版本不同大小写要注意

... ... @@ -35,7 +35,7 @@ public class UserController {
@ApiImplicitParam(name = "pageSize", value = "分页-每页显示多少条", required = false, dataType = "int",defaultValue = "5")})
@RequestRequire
@GetMapping("/list")
public PageInfo<USERS> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
public ResultJson<PageInfo> list(@RequestParam(value = "pageNum",required = false,defaultValue = "1")
int pageNum,
@RequestParam(value = "pageSize",required = false,defaultValue = "5")
int pageSize,
... ... @@ -45,7 +45,8 @@ public class UserController {
USERS user = new USERS();
user.setUsername(username);
user.setRealname(realname);
return userService.selectAllUser(pageNum,pageSize,user);
PageInfo<USERS> usersPageInfo = userService.selectAllUser(pageNum,pageSize,user);
return new ResultJson("200","success",usersPageInfo);
}
public String getCurrentUser(){
... ...
... ... @@ -5,15 +5,17 @@ import lombok.Data;
import java.io.Serializable;
@Data
public class ResultJson implements Serializable{
public class ResultJson<T> implements Serializable{
private static final long serialVersionUID = 1L;
// 状态码 正确为0
private String code = "0";
// 错误描述
// 状态码 正确为200
private String code = "200";
// 描述
private String msg = "";
private String error;
// 返回对象
private Object data = "";
private T data;
//返回的JWT
private String jwtToken;
... ... @@ -29,11 +31,11 @@ public class ResultJson implements Serializable{
this.msg = msg;
}
public ResultJson(Object data) {
public ResultJson(T data) {
this.data = data;
}
public ResultJson(String code, String msg, Object data) {
public ResultJson(String code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
... ...
#服务端口
server.port=7003
server.servlet.context-path=${SERVER_CONTEXTPATH:}
#静态资源,设置上传文件的访问,上传文件的路径,要带斜杠
web.upload-path=upload/
#表示所有的访问经过静态资源路径
springboot.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/static,classpath:/resources/,file:${web.upload-path}
#服务名
spring.application.name=tianbo.base.dev.devkit
spring.jackson.serialization.fail-on-empty-beans=false
spring.profiles.active=dev
#springboot2.0之后会把Date类型字段自动给转成UTC字符串 如:1990-11-26T16:00:00.000+0000,如果想转成时间戳在application.properties配置文件增加以下配置
#jackson相关配置
spring.jackson.date-format = yyyy-MM-dd HH:mm:ss
spring.jackson.serialization.write-dates-as-timestamps=false
#时区必须要设置
spring.jackson.time-zone=GMT+8
#ALWAYS的意思是即时属性为null,仍然也会输出这个key
spring.jackson.default-property-inclusion=always
#springcloud 基本配置
#eureka主机名,会在控制页面中显示
#DEV环境关闭注册。
spring.cloud.features.enabled=false
spring.cloud.discovery.enabled=false
spring.cloud.service-registry.auto-registration.enabled=false
#eureka.instance.hostname=${spring.cloud.client.ip-address}
#eureka服务器页面中status的请求路径
#eureka.instance.status-page-url=http://${eureka.instance.hostname}:${server.port}/index
#eureka注册中心服务器地址
#eureka.client.service-url.defaultZone=http://10.50.3.82:19527/eureka/
#eureka.instance.prefer-ip-address=true
#eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port}
#eureka.client.registry-fetch-interval-seconds=30
#eureka.instance.lease-renewal-interval-in-seconds=15
#eureka.instance.lease-expiration-duration-in-seconds=45
#spring.datasource oracle
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#spring.datasource.url=jdbc:oracle:thin:@10.50.3.68:1521:CGODW
#spring.datasource.username=CGOETL
#spring.datasource.password=1q2w3e4r
#spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码
spring.datasource.url=jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5
#配置初始化大小/最小/最大
spring.datasource.druid.initial-size=1
spring.datasource.druid.min-idle=1
spring.datasource.druid.max-active=20
#获取连接等待超时时间
spring.datasource.druid.max-wait=60000
#一个连接在池中最小生存的时间
spring.datasource.druid.min-evictable-idle-time-millis=300000
#间隔多久进行一次检测,检测需要关闭的空闲连接
spring.datasource.druid.time-between-eviction-runs-millis=60000
#oracle
#spring.datasource.druid.validation-query=SELECT 'x' FROM DUAL
#mysql
spring.datasource.druid.validation-query=SELECT 1 FROM DUAL
spring.datasource.druid.test-while-idle=true
spring.datasource.druid.test-on-borrow=false
spring.datasource.druid.test-on-return=false
spring.datasource.druid.default-auto-commit=true
mybatis.mapper-locations=classpath:mapping/*.xml
mybatis.type-aliases-package=com.tianbo.warehouse.model
pagehelper.helper-dialect=mysql
#pagehelper.auto-dialect=true
#pagehelper.auto-runtime-dialect=true
pagehelper.reasonable=true
pagehelper.support-methods-arguments=true
pagehelper.params=count=countSql
#debug配置
trace=false
debug=false
logging.level.org.apache.tomcat=info
logging.level.com.tianbo.warehouse.dao=DEBUG
logging.level.org.springframework.security =info
... ... @@ -40,29 +40,29 @@
</select>
<select id="getAllMenus" resultMap="BaseResultMap" >
SELECT
P .*
P.*
FROM
permission P
WHERE
P .PERMISSION_ID IN (
P.permission_id IN (
SELECT
RP.permission_id
FROM
ROLE_PERMISSION RP
role_permission RP
WHERE
RP.role_id IN (
SELECT
R.ROLE_ID
R.role_id
FROM
role R
WHERE
R.ROLE_ID IN (
R.role_id IN (
SELECT
UR.ROLE_ID
UR.role_id
FROM
USER_ROLE UR
user_role UR
WHERE
UR.USER_ID = #{userId,jdbcType=INTEGER} AND P.ismenu is TRUE
UR.user_id = #{userId,jdbcType=INTEGER} AND P.ismenu is TRUE
)
)
) ORDER BY P.permission_order
... ... @@ -76,34 +76,34 @@
FROM
permission P
LEFT JOIN role_permission RP ON P.permission_id = RP.permission_id
LEFT JOIN ROLE R ON R.ROLE_ID= RP.ROLE_ID
LEFT JOIN role R ON R.role_id= RP.role_id
where P.url = #{permissionUrl,jdbcType=VARCHAR} ORDER BY permission_order
</select>
<select id="findByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT
P .*
P.*
FROM
permission P
WHERE
P .PERMISSION_ID IN (
P.permission_id IN (
SELECT
RP.permission_id
FROM
ROLE_PERMISSION RP
role_permission RP
WHERE
RP.role_id IN (
SELECT
R.ROLE_ID
R.role_id
FROM
role R
WHERE
R.ROLE_ID IN (
R.role_id IN (
SELECT
UR.ROLE_ID
UR.role_id
FROM
USER_ROLE UR
user_role UR
WHERE
UR.USER_ID = #{userId,jdbcType=INTEGER}
UR.user_id = #{userId,jdbcType=INTEGER}
)
)
) ORDER BY permission_order
... ...
... ... @@ -26,10 +26,10 @@
SELECT
R.*
FROM
USERS U
LEFT JOIN USER_ROLE UR ON U .USER_ID = UR.USER_ID
LEFT JOIN ROLE R ON R.ROLE_ID= UR.ROLE_ID
where U.USER_ID = #{userId,jdbcType=INTEGER}
users U
LEFT JOIN user_role UR ON U.user_id = UR.user_id
LEFT JOIN role R ON R.role_id= UR.role_id
where U.user_id = #{userId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from role
... ...
... ... @@ -17,6 +17,19 @@
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="age" property="age" jdbcType="INTEGER" />
</resultMap>
<resultMap id="SecurityResult" type="com.tianbo.warehouse.model.USERS">
<id column="user_id" property="userId" jdbcType="INTEGER" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="birthday" property="birthday" jdbcType="TIMESTAMP" />
<result column="sex" property="sex" jdbcType="CHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="state" property="state" jdbcType="BIT" />
<result column="mobilePhone" property="mobilephone" jdbcType="VARCHAR" />
<result column="userFace" property="userface" jdbcType="VARCHAR" />
<result column="realName" property="realname" jdbcType="VARCHAR" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="age" property="age" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
user_id, username, password, birthday, sex, address, state, mobilePhone, creatTime,
updateTime, userFace, realName, email, age
... ... @@ -33,10 +46,10 @@
<select id="selectByUsername" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from USERS
where USERNAME = #{username,jdbcType=VARCHAR}
from users
where username = #{username,jdbcType=VARCHAR}
</select>
<select id="selectAllUser" resultMap="BaseResultMap" parameterType="com.tianbo.warehouse.model.USERS" >
<select id="selectAllUser" resultMap="SecurityResult" parameterType="com.tianbo.warehouse.model.USERS" >
select
<include refid="user_List" />
from USERS
... ...