作者 朱兆平

spring security 切换到mysql 数据库

package com.tianbo.warehouse.dao;
import com.tianbo.warehouse.model.PERMISSION;
import java.math.BigDecimal;
import java.util.List;
public interface PERMISSIONMapper {
int deleteByPrimaryKey(BigDecimal permissionId);
int deleteByPrimaryKey(Integer permissionId);
int insert(PERMISSION record);
int insertSelective(PERMISSION record);
List<PERMISSION> selectByPrimaryKey(BigDecimal permissionId);
PERMISSION selectByPrimaryKey(Integer permissionId);
int updateByPrimaryKeySelective(PERMISSION record);
... ... @@ -19,5 +20,5 @@ public interface PERMISSIONMapper {
List<PERMISSION> findAll();
List<PERMISSION> findByUserId(BigDecimal userId);
List<PERMISSION> findByUserId(Integer userId);
}
\ No newline at end of file
... ...
package com.tianbo.warehouse.dao;
import com.tianbo.warehouse.model.ROLE;
import java.math.BigDecimal;
import java.util.List;
public interface ROLEMapper {
int deleteByPrimaryKey(BigDecimal roleId);
int deleteByPrimaryKey(Integer roleId);
int insert(ROLE record);
int insertSelective(ROLE record);
ROLE selectByPrimaryKey(BigDecimal roleId);
ROLE selectByPrimaryKey(Integer roleId);
int updateByPrimaryKeySelective(ROLE record);
int updateByPrimaryKey(ROLE record);
List<ROLE> findRolesByUserId(BigDecimal userId);
List<ROLE> findRolesByUserId(Integer userId);
}
\ No newline at end of file
... ...
package com.tianbo.warehouse.dao;
import com.tianbo.warehouse.model.ROLE;
import com.tianbo.warehouse.model.USERS;
import java.math.BigDecimal;
import java.util.List;
public interface USERSMapper {
int deleteByPrimaryKey(BigDecimal userId);
int deleteByPrimaryKey(Integer userId);
int insert(USERS record);
int insertSelective(USERS record);
USERS selectByPrimaryKey(BigDecimal userId);
List<USERS> selectByUsername(String userName);
USERS selectByPrimaryKey(Integer userId);
int updateByPrimaryKeySelective(USERS record);
int updateByPrimaryKey(USERS record);
List<USERS> selectAllUser();
List<USERS> selectByUsername(String userName);
List<USERS> selectAllUser();
}
\ No newline at end of file
... ...
... ... @@ -2,13 +2,10 @@ package com.tianbo.warehouse.model;
import org.springframework.security.core.GrantedAuthority;
import java.math.BigDecimal;
public class PERMISSION implements GrantedAuthority {
private static final long serialVersionUID = -3957539165716897100L;
public class PERMISSION implements GrantedAuthority{
private static final long serialVersionUID = -3957539165716897200L;
private BigDecimal permissionId;
private Integer permissionId;
private String permissionName;
... ... @@ -18,11 +15,23 @@ public class PERMISSION implements GrantedAuthority{
private String groupName;
public BigDecimal getPermissionId() {
private Integer parentId;
private String path;
private String url;
private String ext1;
private String ext2;
private String ext3;
public Integer getPermissionId() {
return permissionId;
}
public void setPermissionId(BigDecimal permissionId) {
public void setPermissionId(Integer permissionId) {
this.permissionId = permissionId;
}
... ... @@ -58,6 +67,54 @@ public class PERMISSION implements GrantedAuthority{
this.groupName = groupName == null ? null : groupName.trim();
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path == null ? null : path.trim();
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url == null ? null : url.trim();
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1 == null ? null : ext1.trim();
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2 == null ? null : ext2.trim();
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3 == null ? null : ext3.trim();
}
@Override
public String getAuthority(){
return this.getPermissionName();
... ...
package com.tianbo.warehouse.model;
import org.springframework.security.core.GrantedAuthority;
import java.math.BigDecimal;
public class ROLE{
private BigDecimal roleId;
public class ROLE {
private Integer roleId;
private String roleName;
... ... @@ -16,11 +9,11 @@ public class ROLE{
private String description;
public BigDecimal getRoleId() {
public Integer getRoleId() {
return roleId;
}
public void setRoleId(BigDecimal roleId) {
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
... ... @@ -47,6 +40,4 @@ public class ROLE{
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
}
\ No newline at end of file
... ...
... ... @@ -4,46 +4,49 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
public class USERS implements UserDetails{
private static final long serialVersionUID = 1L;
private BigDecimal userId;
public class USERS implements UserDetails {
private Integer userId;
private String username;
private String password;
private Short state;
private Date creattime;
private Date birthday;
private String sex;
private String address;
private Date birthday;
private Boolean state;
private String mobilephone;
private Date creattime;
private Date updatetime;
private String userface;
private String ext1;
private String ext2;
private String ext3;
private List<ROLE> roles;
private List<PERMISSION> permissions;
public BigDecimal getUserId() {
public Integer getUserId() {
return userId;
}
public void setUserId(BigDecimal userId) {
public void setUserId(Integer userId) {
this.userId = userId;
}
... ... @@ -65,20 +68,12 @@ public class USERS implements UserDetails{
this.password = password == null ? null : password.trim();
}
public Short getState() {
return state;
}
public void setState(Short state) {
this.state = state;
}
public Date getCreattime() {
return creattime;
public Date getBirthday() {
return birthday;
}
public void setCreattime(Date creattime) {
this.creattime = creattime;
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getSex() {
... ... @@ -97,12 +92,12 @@ public class USERS implements UserDetails{
this.address = address == null ? null : address.trim();
}
public Date getBirthday() {
return birthday;
public Boolean getState() {
return state;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
public void setState(Boolean state) {
this.state = state;
}
public String getMobilephone() {
... ... @@ -113,6 +108,14 @@ public class USERS implements UserDetails{
this.mobilephone = mobilephone == null ? null : mobilephone.trim();
}
public Date getCreattime() {
return creattime;
}
public void setCreattime(Date creattime) {
this.creattime = creattime;
}
public Date getUpdatetime() {
return updatetime;
}
... ... @@ -121,6 +124,38 @@ public class USERS implements UserDetails{
this.updatetime = updatetime;
}
public String getUserface() {
return userface;
}
public void setUserface(String userface) {
this.userface = userface == null ? null : userface.trim();
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1 == null ? null : ext1.trim();
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2 == null ? null : ext2.trim();
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3 == null ? null : ext3.trim();
}
public List<ROLE> getRoles() {
return roles;
}
... ... @@ -179,7 +214,7 @@ public class USERS implements UserDetails{
*/
@Override
public Collection<? extends GrantedAuthority> getAuthorities(){
List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
List<GrantedAuthority> auths = new ArrayList<>();
List<PERMISSION> permissions = this.getPermissions();
for (PERMISSION permission : permissions) {
auths.add(new SimpleGrantedAuthority(permission.getAuthority()));
... ...
... ... @@ -4,8 +4,8 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
<!--<classPathEntry location="/Users/mrz/Downloads/mybatis-generator-core-1.3.2/lib/mysql-connector-java-5.1.25-bin.jar"/>-->
<classPathEntry location="/Users/mrz/Documents/maven/ojdbc6.jar"/>
<classPathEntry location="/Users/mrz/Downloads/mybatis-generator-core-1.3.2/lib/mysql-connector-java-5.1.25-bin.jar"/>
<!--<classPathEntry location="/Users/mrz/Documents/maven/ojdbc6.jar"/>-->
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
... ... @@ -13,13 +13,16 @@
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<!--<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3307/statistics" userId="root" password="">-->
<!--</jdbcConnection>-->
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@10.50.3.68:1521:CGODW"
userId="CGOETL"
password="1q2w3e4r">
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3307/statistics"
userId="root"
password="">
</jdbcConnection>
<!--<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"-->
<!--connectionURL="jdbc:oracle:thin:@10.50.3.68:1521:CGODW"-->
<!--userId="CGOETL"-->
<!--password="1q2w3e4r">-->
<!--</jdbcConnection>-->
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和
NUMERIC 类型解析为java.math.BigDecimal -->
<!--<javaTypeResolver>-->
... ... @@ -42,6 +45,6 @@
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="PERMISSION" domainObjectName="PERMISSION" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="permission" domainObjectName="PERMISSION" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
\ No newline at end of file
... ...
... ... @@ -2,88 +2,116 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.tianbo.warehouse.dao.PERMISSIONMapper" >
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.PERMISSION" >
<id column="PERMISSION_ID" property="permissionId" jdbcType="DECIMAL" />
<result column="PERMISSION_NAME" property="permissionName" jdbcType="VARCHAR" />
<result column="PERMISSION_SIGN" property="permissionSign" jdbcType="VARCHAR" />
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
<result column="GROUP_NAME" property="groupName" jdbcType="VARCHAR" />
<id column="permission_id" property="permissionId" jdbcType="INTEGER" />
<result column="permission_name" property="permissionName" jdbcType="VARCHAR" />
<result column="permission_sign" property="permissionSign" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="group_name" property="groupName" jdbcType="VARCHAR" />
<result column="parent_id" property="parentId" jdbcType="INTEGER" />
<result column="path" property="path" jdbcType="VARCHAR" />
<result column="url" property="url" jdbcType="VARCHAR" />
<result column="ext1" property="ext1" jdbcType="VARCHAR" />
<result column="ext2" property="ext2" jdbcType="VARCHAR" />
<result column="ext3" property="ext3" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
PERMISSION_ID, PERMISSION_NAME, PERMISSION_SIGN, DESCRIPTION, GROUP_NAME
permission_id, permission_name, permission_sign, description, group_name, parent_id,
path, url, ext1, ext2, ext3
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.math.BigDecimal" >
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from PERMISSION
where PERMISSION_ID = #{permissionId,jdbcType=DECIMAL}
from permission
where permission_id = #{permissionId,jdbcType=INTEGER}
</select>
<select id="findAll" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from PERMISSION
from permission
</select>
<select id="findByUserId" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
<select id="findByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT
P .*
FROM
PERMISSION P
WHERE
P .PERMISSION_ID IN (
SELECT
RP.permission_id
FROM
ROLE_PERMISSION RP
WHERE
RP.role_id IN (
SELECT
R.ROLE_ID
FROM
ROLE R
WHERE
R.ROLE_ID IN (
SELECT
UR.ROLE_ID
FROM
USER_ROLE UR
WHERE
UR.USER_ID = #{userId,jdbcType=DECIMAL}
)
)
)
P .*
FROM
permission P
WHERE
P .PERMISSION_ID IN (
SELECT
RP.permission_id
FROM
ROLE_PERMISSION RP
WHERE
RP.role_id IN (
SELECT
R.ROLE_ID
FROM
role R
WHERE
R.ROLE_ID IN (
SELECT
UR.ROLE_ID
FROM
USER_ROLE UR
WHERE
UR.USER_ID = #{userId,jdbcType=INTEGER}
)
)
)
</select>
<delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal" >
delete from PERMISSION
where PERMISSION_ID = #{permissionId,jdbcType=DECIMAL}
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from permission
where permission_id = #{permissionId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.tianbo.warehouse.model.PERMISSION" >
insert into PERMISSION (PERMISSION_ID, PERMISSION_NAME, PERMISSION_SIGN,
DESCRIPTION, GROUP_NAME)
values (#{permissionId,jdbcType=DECIMAL}, #{permissionName,jdbcType=VARCHAR}, #{permissionSign,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{groupName,jdbcType=VARCHAR})
insert into permission (permission_id, permission_name, permission_sign,
description, group_name, parent_id,
path, url, ext1, ext2,
ext3)
values (#{permissionId,jdbcType=INTEGER}, #{permissionName,jdbcType=VARCHAR}, #{permissionSign,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{groupName,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER},
#{path,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR},
#{ext3,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.PERMISSION" >
insert into PERMISSION
insert into permission
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="permissionId != null" >
PERMISSION_ID,
permission_id,
</if>
<if test="permissionName != null" >
PERMISSION_NAME,
permission_name,
</if>
<if test="permissionSign != null" >
PERMISSION_SIGN,
permission_sign,
</if>
<if test="description != null" >
DESCRIPTION,
description,
</if>
<if test="groupName != null" >
GROUP_NAME,
group_name,
</if>
<if test="parentId != null" >
parent_id,
</if>
<if test="path != null" >
path,
</if>
<if test="url != null" >
url,
</if>
<if test="ext1 != null" >
ext1,
</if>
<if test="ext2 != null" >
ext2,
</if>
<if test="ext3 != null" >
ext3,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="permissionId != null" >
#{permissionId,jdbcType=DECIMAL},
#{permissionId,jdbcType=INTEGER},
</if>
<if test="permissionName != null" >
#{permissionName,jdbcType=VARCHAR},
... ... @@ -97,32 +125,74 @@ WHERE
<if test="groupName != null" >
#{groupName,jdbcType=VARCHAR},
</if>
<if test="parentId != null" >
#{parentId,jdbcType=INTEGER},
</if>
<if test="path != null" >
#{path,jdbcType=VARCHAR},
</if>
<if test="url != null" >
#{url,jdbcType=VARCHAR},
</if>
<if test="ext1 != null" >
#{ext1,jdbcType=VARCHAR},
</if>
<if test="ext2 != null" >
#{ext2,jdbcType=VARCHAR},
</if>
<if test="ext3 != null" >
#{ext3,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.PERMISSION" >
update PERMISSION
update permission
<set >
<if test="permissionName != null" >
PERMISSION_NAME = #{permissionName,jdbcType=VARCHAR},
permission_name = #{permissionName,jdbcType=VARCHAR},
</if>
<if test="permissionSign != null" >
PERMISSION_SIGN = #{permissionSign,jdbcType=VARCHAR},
permission_sign = #{permissionSign,jdbcType=VARCHAR},
</if>
<if test="description != null" >
DESCRIPTION = #{description,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
</if>
<if test="groupName != null" >
GROUP_NAME = #{groupName,jdbcType=VARCHAR},
group_name = #{groupName,jdbcType=VARCHAR},
</if>
<if test="parentId != null" >
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="path != null" >
path = #{path,jdbcType=VARCHAR},
</if>
<if test="url != null" >
url = #{url,jdbcType=VARCHAR},
</if>
<if test="ext1 != null" >
ext1 = #{ext1,jdbcType=VARCHAR},
</if>
<if test="ext2 != null" >
ext2 = #{ext2,jdbcType=VARCHAR},
</if>
<if test="ext3 != null" >
ext3 = #{ext3,jdbcType=VARCHAR},
</if>
</set>
where PERMISSION_ID = #{permissionId,jdbcType=DECIMAL}
where permission_id = #{permissionId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.PERMISSION" >
update PERMISSION
set PERMISSION_NAME = #{permissionName,jdbcType=VARCHAR},
PERMISSION_SIGN = #{permissionSign,jdbcType=VARCHAR},
DESCRIPTION = #{description,jdbcType=VARCHAR},
GROUP_NAME = #{groupName,jdbcType=VARCHAR}
where PERMISSION_ID = #{permissionId,jdbcType=DECIMAL}
update permission
set permission_name = #{permissionName,jdbcType=VARCHAR},
permission_sign = #{permissionSign,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
group_name = #{groupName,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=INTEGER},
path = #{path,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
ext1 = #{ext1,jdbcType=VARCHAR},
ext2 = #{ext2,jdbcType=VARCHAR},
ext3 = #{ext3,jdbcType=VARCHAR}
where permission_id = #{permissionId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
<?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.tianbo.warehouse.dao.ROLEMapper" >
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.ROLE" >
<id column="ROLE_ID" property="roleId" jdbcType="DECIMAL" />
<result column="ROLE_NAME" property="roleName" jdbcType="VARCHAR" />
<result column="ROLE_SIGN" property="roleSign" jdbcType="VARCHAR" />
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
<?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.tianbo.warehouse.dao.ROLEMapper">
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.ROLE">
<id column="role_id" jdbcType="INTEGER" property="roleId" />
<result column="role_name" jdbcType="VARCHAR" property="roleName" />
<result column="role_sign" jdbcType="VARCHAR" property="roleSign" />
<result column="description" jdbcType="VARCHAR" property="description" />
</resultMap>
<sql id="Base_Column_List" >
ROLE_ID, ROLE_NAME, ROLE_SIGN, DESCRIPTION
<sql id="Base_Column_List">
role_id, role_name, role_sign, description
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.math.BigDecimal" >
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ROLE
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
from role
where role_id = #{roleId,jdbcType=INTEGER}
</select>
<select id="findRolesByUserId" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
<select id="findRolesByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
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=DECIMAL}
where U.USER_ID = #{userId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal" >
delete from ROLE
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from role
where role_id = #{roleId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.tianbo.warehouse.model.ROLE" >
insert into ROLE (ROLE_ID, ROLE_NAME, ROLE_SIGN,
DESCRIPTION)
values (#{roleId,jdbcType=DECIMAL}, #{roleName,jdbcType=VARCHAR}, #{roleSign,jdbcType=VARCHAR},
<insert id="insert" parameterType="com.tianbo.warehouse.model.ROLE">
insert into role (role_id, role_name, role_sign,
description)
values (#{roleId,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR}, #{roleSign,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.ROLE" >
insert into ROLE
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="roleId != null" >
ROLE_ID,
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.ROLE">
insert into role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="roleId != null">
role_id,
</if>
<if test="roleName != null" >
ROLE_NAME,
<if test="roleName != null">
role_name,
</if>
<if test="roleSign != null" >
ROLE_SIGN,
<if test="roleSign != null">
role_sign,
</if>
<if test="description != null" >
DESCRIPTION,
<if test="description != null">
description,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="roleId != null" >
#{roleId,jdbcType=DECIMAL},
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="roleId != null">
#{roleId,jdbcType=INTEGER},
</if>
<if test="roleName != null" >
<if test="roleName != null">
#{roleName,jdbcType=VARCHAR},
</if>
<if test="roleSign != null" >
<if test="roleSign != null">
#{roleSign,jdbcType=VARCHAR},
</if>
<if test="description != null" >
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.ROLE" >
update ROLE
<set >
<if test="roleName != null" >
ROLE_NAME = #{roleName,jdbcType=VARCHAR},
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.ROLE">
update role
<set>
<if test="roleName != null">
role_name = #{roleName,jdbcType=VARCHAR},
</if>
<if test="roleSign != null" >
ROLE_SIGN = #{roleSign,jdbcType=VARCHAR},
<if test="roleSign != null">
role_sign = #{roleSign,jdbcType=VARCHAR},
</if>
<if test="description != null" >
DESCRIPTION = #{description,jdbcType=VARCHAR},
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
</set>
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
where role_id = #{roleId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.ROLE" >
update ROLE
set ROLE_NAME = #{roleName,jdbcType=VARCHAR},
ROLE_SIGN = #{roleSign,jdbcType=VARCHAR},
DESCRIPTION = #{description,jdbcType=VARCHAR}
where ROLE_ID = #{roleId,jdbcType=DECIMAL}
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.ROLE">
update role
set role_name = #{roleName,jdbcType=VARCHAR},
role_sign = #{roleSign,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR}
where role_id = #{roleId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -2,89 +2,107 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.tianbo.warehouse.dao.USERSMapper" >
<resultMap id="BaseResultMap" type="com.tianbo.warehouse.model.USERS" >
<id column="USER_ID" property="userId" jdbcType="DECIMAL" />
<result column="USERNAME" property="username" jdbcType="VARCHAR" />
<result column="PASSWORD" property="password" jdbcType="VARCHAR" />
<result column="STATE" property="state" jdbcType="DECIMAL" />
<result column="CREATTIME" property="creattime" jdbcType="TIMESTAMP" />
<result column="SEX" property="sex" jdbcType="VARCHAR" />
<result column="ADDRESS" property="address" jdbcType="VARCHAR" />
<result column="BIRTHDAY" property="birthday" jdbcType="TIMESTAMP" />
<result column="MOBILEPHONE" property="mobilephone" jdbcType="VARCHAR" />
<result column="UPDATETIME" property="updatetime" jdbcType="TIMESTAMP" />
<id column="user_id" property="userId" jdbcType="INTEGER" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="password" property="password" 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="creatTime" property="creattime" jdbcType="TIMESTAMP" />
<result column="updateTime" property="updatetime" jdbcType="TIMESTAMP" />
<result column="userFace" property="userface" jdbcType="VARCHAR" />
<result column="ext1" property="ext1" jdbcType="VARCHAR" />
<result column="ext2" property="ext2" jdbcType="VARCHAR" />
<result column="ext3" property="ext3" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
USER_ID, USERNAME, PASSWORD, STATE, CREATTIME, SEX, ADDRESS, BIRTHDAY, MOBILEPHONE,
UPDATETIME
user_id, username, password, birthday, sex, address, state, mobilePhone, creatTime,
updateTime, userFace, ext1, ext2, ext3
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.math.BigDecimal" >
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from USERS
where USER_ID = #{userId,jdbcType=DECIMAL}
from users
where user_id = #{userId,jdbcType=INTEGER}
</select>
<select id="selectByUsername" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from USERS
where USERNAME = #{username,jdbcType=VARCHAR}
</select>
select
<include refid="Base_Column_List" />
from USERS
where USERNAME = #{username,jdbcType=VARCHAR}
</select>
<select id="selectAllUser" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from USERS
</select>
<delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal" >
delete from USERS
where USER_ID = #{userId,jdbcType=DECIMAL}
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from users
where user_id = #{userId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.tianbo.warehouse.model.USERS" >
insert into USERS (USER_ID, USERNAME, PASSWORD,
STATE, CREATTIME, SEX,
ADDRESS, BIRTHDAY, MOBILEPHONE,
UPDATETIME)
values (#{userId,jdbcType=DECIMAL}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{state,jdbcType=DECIMAL}, #{creattime,jdbcType=TIMESTAMP}, #{sex,jdbcType=VARCHAR},
#{address,jdbcType=VARCHAR}, #{birthday,jdbcType=TIMESTAMP}, #{mobilephone,jdbcType=VARCHAR},
#{updatetime,jdbcType=TIMESTAMP})
insert into users (user_id, username, password,
birthday, sex, address,
state, mobilePhone, creatTime,
updateTime, userFace, ext1,
ext2, ext3)
values (#{userId,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{birthday,jdbcType=TIMESTAMP}, #{sex,jdbcType=CHAR}, #{address,jdbcType=VARCHAR},
#{state,jdbcType=BIT}, #{mobilephone,jdbcType=VARCHAR}, #{creattime,jdbcType=TIMESTAMP},
#{updatetime,jdbcType=TIMESTAMP}, #{userface,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR},
#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tianbo.warehouse.model.USERS" >
insert into USERS
insert into users
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="userId != null" >
USER_ID,
user_id,
</if>
<if test="username != null" >
USERNAME,
username,
</if>
<if test="password != null" >
PASSWORD,
</if>
<if test="state != null" >
STATE,
password,
</if>
<if test="creattime != null" >
CREATTIME,
<if test="birthday != null" >
birthday,
</if>
<if test="sex != null" >
SEX,
sex,
</if>
<if test="address != null" >
ADDRESS,
address,
</if>
<if test="birthday != null" >
BIRTHDAY,
<if test="state != null" >
state,
</if>
<if test="mobilephone != null" >
MOBILEPHONE,
mobilePhone,
</if>
<if test="creattime != null" >
creatTime,
</if>
<if test="updatetime != null" >
UPDATETIME,
updateTime,
</if>
<if test="userface != null" >
userFace,
</if>
<if test="ext1 != null" >
ext1,
</if>
<if test="ext2 != null" >
ext2,
</if>
<if test="ext3 != null" >
ext3,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="userId != null" >
#{userId,jdbcType=DECIMAL},
#{userId,jdbcType=INTEGER},
</if>
<if test="username != null" >
#{username,jdbcType=VARCHAR},
... ... @@ -92,73 +110,101 @@
<if test="password != null" >
#{password,jdbcType=VARCHAR},
</if>
<if test="state != null" >
#{state,jdbcType=DECIMAL},
</if>
<if test="creattime != null" >
#{creattime,jdbcType=TIMESTAMP},
<if test="birthday != null" >
#{birthday,jdbcType=TIMESTAMP},
</if>
<if test="sex != null" >
#{sex,jdbcType=VARCHAR},
#{sex,jdbcType=CHAR},
</if>
<if test="address != null" >
#{address,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
#{birthday,jdbcType=TIMESTAMP},
<if test="state != null" >
#{state,jdbcType=BIT},
</if>
<if test="mobilephone != null" >
#{mobilephone,jdbcType=VARCHAR},
</if>
<if test="creattime != null" >
#{creattime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null" >
#{updatetime,jdbcType=TIMESTAMP},
</if>
<if test="userface != null" >
#{userface,jdbcType=VARCHAR},
</if>
<if test="ext1 != null" >
#{ext1,jdbcType=VARCHAR},
</if>
<if test="ext2 != null" >
#{ext2,jdbcType=VARCHAR},
</if>
<if test="ext3 != null" >
#{ext3,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.tianbo.warehouse.model.USERS" >
update USERS
update users
<set >
<if test="username != null" >
USERNAME = #{username,jdbcType=VARCHAR},
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null" >
PASSWORD = #{password,jdbcType=VARCHAR},
</if>
<if test="state != null" >
STATE = #{state,jdbcType=DECIMAL},
password = #{password,jdbcType=VARCHAR},
</if>
<if test="creattime != null" >
CREATTIME = #{creattime,jdbcType=TIMESTAMP},
<if test="birthday != null" >
birthday = #{birthday,jdbcType=TIMESTAMP},
</if>
<if test="sex != null" >
SEX = #{sex,jdbcType=VARCHAR},
sex = #{sex,jdbcType=CHAR},
</if>
<if test="address != null" >
ADDRESS = #{address,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
BIRTHDAY = #{birthday,jdbcType=TIMESTAMP},
<if test="state != null" >
state = #{state,jdbcType=BIT},
</if>
<if test="mobilephone != null" >
MOBILEPHONE = #{mobilephone,jdbcType=VARCHAR},
mobilePhone = #{mobilephone,jdbcType=VARCHAR},
</if>
<if test="creattime != null" >
creatTime = #{creattime,jdbcType=TIMESTAMP},
</if>
<if test="updatetime != null" >
UPDATETIME = #{updatetime,jdbcType=TIMESTAMP},
updateTime = #{updatetime,jdbcType=TIMESTAMP},
</if>
<if test="userface != null" >
userFace = #{userface,jdbcType=VARCHAR},
</if>
<if test="ext1 != null" >
ext1 = #{ext1,jdbcType=VARCHAR},
</if>
<if test="ext2 != null" >
ext2 = #{ext2,jdbcType=VARCHAR},
</if>
<if test="ext3 != null" >
ext3 = #{ext3,jdbcType=VARCHAR},
</if>
</set>
where USER_ID = #{userId,jdbcType=DECIMAL}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.tianbo.warehouse.model.USERS" >
update USERS
set USERNAME = #{username,jdbcType=VARCHAR},
PASSWORD = #{password,jdbcType=VARCHAR},
STATE = #{state,jdbcType=DECIMAL},
CREATTIME = #{creattime,jdbcType=TIMESTAMP},
SEX = #{sex,jdbcType=VARCHAR},
ADDRESS = #{address,jdbcType=VARCHAR},
BIRTHDAY = #{birthday,jdbcType=TIMESTAMP},
MOBILEPHONE = #{mobilephone,jdbcType=VARCHAR},
UPDATETIME = #{updatetime,jdbcType=TIMESTAMP}
where USER_ID = #{userId,jdbcType=DECIMAL}
update users
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
birthday = #{birthday,jdbcType=TIMESTAMP},
sex = #{sex,jdbcType=CHAR},
address = #{address,jdbcType=VARCHAR},
state = #{state,jdbcType=BIT},
mobilePhone = #{mobilephone,jdbcType=VARCHAR},
creatTime = #{creattime,jdbcType=TIMESTAMP},
updateTime = #{updatetime,jdbcType=TIMESTAMP},
userFace = #{userface,jdbcType=VARCHAR},
ext1 = #{ext1,jdbcType=VARCHAR},
ext2 = #{ext2,jdbcType=VARCHAR},
ext3 = #{ext3,jdbcType=VARCHAR}
where user_id = #{userId,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...