Commit 527a4ad5 by 陶光胜

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-auth into developer
parents 8f09d428 245f766b
......@@ -96,6 +96,16 @@ public class UserDTO implements UserInfo,Serializable{
@NotBlank(message = "手机国际区号不能为空", groups = {SaveUserValid.class, EditUserValid.class, UserQoValid.class})
private String phoneAreaCode;
/**
* 受审组,可以有多个,用英文逗号隔开
*/
private String userGroupIds;
/**
* 登陆账号类型 1:运营 0:默认GIC
*/
private Integer loginType;
public Integer getUserId() {
return userId;
}
......@@ -191,4 +201,20 @@ public class UserDTO implements UserInfo,Serializable{
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}
public String getUserGroupIds() {
return userGroupIds;
}
public void setUserGroupIds(String userGroupIds) {
this.userGroupIds = userGroupIds;
}
public Integer getLoginType() {
return loginType;
}
public void setLoginType(Integer loginType) {
this.loginType = loginType;
}
}
package com.gic.auth.entity;
package com.gic.auth.dto;
import java.io.Serializable;
import java.util.Date;
/**
* tab_user
* 用户资源组关联表
* @ClassName: UserResourceDTO

* @Description: 

* @author guojuxing

* @date 2019/9/2 10:54 AM

*/
public class TabUser {
/**
* 用户id
*/
private Integer userId;
public class UserResourceDTO implements Serializable{
private static final long serialVersionUID = 5635155351382206941L;
/**
* 用户名
* id
*/
private String userName;
private Integer userResourceId;
/**
* 手机号码
* 角色集id
*/
private String phoneNumber;
private Integer resourceId;
/**
* 密码
* 管理员ID
*/
private String password;
private Integer userId;
/**
* 是否是超级管理员
* 企业ID
*/
private Integer superAdmin;
private Integer enterpriseId;
/**
* 状态,1有效,0无效
* 状态1:有效 0:无效
*/
private Integer status;
/**
*
*
*/
private Date createTime;
/**
*
*
*/
private Date updateTime;
/**
*
*/
private Integer enterpriseId;
/**
* 国际区号,如中国 86
*/
private String phoneAreaCode;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
public Integer getUserResourceId() {
return userResourceId;
}
public void setUserName(String userName) {
this.userName = userName;
public void setUserResourceId(Integer userResourceId) {
this.userResourceId = userResourceId;
}
public String getPhoneNumber() {
return phoneNumber;
public Integer getResourceId() {
return resourceId;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
public void setResourceId(Integer resourceId) {
this.resourceId = resourceId;
}
public String getPassword() {
return password;
public Integer getUserId() {
return userId;
}
public void setPassword(String password) {
this.password = password;
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getSuperAdmin() {
return superAdmin;
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setSuperAdmin(Integer superAdmin) {
this.superAdmin = superAdmin;
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getStatus() {
......@@ -119,20 +103,4 @@ public class TabUser {
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getPhoneAreaCode() {
return phoneAreaCode;
}
public void setPhoneAreaCode(String phoneAreaCode) {
this.phoneAreaCode = phoneAreaCode;
}
}
\ No newline at end of file
}
package com.gic.auth.dto;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* 用户角色关联表
* @ClassName: UserRoleDTO

* @Description: 

* @author guojuxing

* @date 2019/9/2 10:53 AM

*/
public class UserRoleDTO implements Serializable{
private static final long serialVersionUID = 8183365108130027735L;
public interface SaveUserRoleValid {
}
/**
* id
*/
private Integer userRoleId;
/**
* 角色集id
*/
@NotNull(message = "角色不能为空", groups = {SaveUserRoleValid.class})
private Integer roleId;
/**
* 管理员ID
*/
@NotNull(message = "用户不能为空", groups = {SaveUserRoleValid.class})
private Integer userId;
/**
* 企业ID
*/
@NotNull(message = "商户不能为空", groups = {SaveUserRoleValid.class})
private Integer enterpriseId;
/**
* 状态1:有效 0:无效
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getUserRoleId() {
return userRoleId;
}
public void setUserRoleId(Integer userRoleId) {
this.userRoleId = userRoleId;
}
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
package com.gic.auth.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserResourceDTO;
/**
* 用户资源组关联
* @ClassName: UserResourceApiService

* @Description: 

* @author guojuxing

* @date 2019/9/2 10:58 AM

*/
public interface UserResourceApiService {
/**
* 新增
* @Title: save

* @Description:

 * @author guojuxing
* @param dto

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


 */
ServiceResponse<Void> save(UserResourceDTO dto);
}
package com.gic.auth.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserRoleDTO;
/**
* 用户角色关联表
* @ClassName: UserRoleApiService

* @Description: 

* @author guojuxing

* @date 2019/9/2 10:55 AM

*/
public interface UserRoleApiService {
/**
* 新增
* @Title: save

* @Description:

 * @author guojuxing
* @param dto

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


 */
ServiceResponse<Void> save(UserRoleDTO dto);
}
package com.gic.auth.dao.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gic.auth.entity.TabSysUser;
public interface TabSysUserMapper {
......@@ -50,4 +54,20 @@ public interface TabSysUserMapper {
* @return 更新条目数
*/
int updateByPrimaryKey(TabSysUser record);
/**
* 手机号码查询个数
* @param phone
* @param userId
* @return
*/
int countByPhone(@Param("phone") String phone, @Param("userId") Integer userId);
TabSysUser selectByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
List<TabSysUser> listAllUserByPhoneNumber(@Param("phoneNumber") String phoneNumber);
TabSysUser login(@Param("phoneNumber") String phoneNumber,
@Param("password") String password,
@Param("enterpriseId") Integer enterpriseId);
}
\ No newline at end of file
package com.gic.auth.dao.mapper;
import com.gic.auth.entity.TabSysUserRole;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabSysUserRoleMapper {
/**
......@@ -50,4 +53,23 @@ public interface TabSysUserRoleMapper {
* @return 更新条目数
*/
int updateByPrimaryKey(TabSysUserRole record);
/**
* 删除用户关联数据
* @Title: deleteByUserId

* @Description:

 * @author guojuxing
* @param userId

* @return int


 */
int deleteByUserId(@Param("userId") Integer userId);
/**
* 查询用户关联数据
* @Title: listUserRoleByUserId

* @Description:

 * @author guojuxing
* @param userId

* @return java.util.List<com.gic.auth.entity.TabSysUserRole>


 */
List<TabSysUserRole> listUserRoleByUserId(@Param("userId") Integer userId);
}
\ No newline at end of file
package com.gic.auth.dao.mapper;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabUser;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabUserMapper {
/**
* 根据主键删除
*
* @param userId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer userId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabUser record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabUser record);
/**
* 根据主键查询
*
* @param userId 主键
* @return 实体对象
*/
TabUser selectByPrimaryKey(Integer userId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabUser record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabUser record);
/**
* 手机号码查询个数
* @param phone
* @param userId
* @return
*/
int countByPhone(@Param("phone") String phone, @Param("userId") Integer userId);
TabUser selectByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
List<TabUser> listAllUserByPhoneNumber(@Param("phoneNumber") String phoneNumber);
TabUser login(@Param("phoneNumber") String phoneNumber,
@Param("password") String password,
@Param("enterpriseId") Integer enterpriseId);
}
\ No newline at end of file
......@@ -64,7 +64,7 @@ public class TabSysUser {
/**
* 登陆账号类型 1:运营 0:默认GIC
*/
private Integer loginType;
private Integer loginType = 0;
public Integer getUserId() {
return userId;
......
package com.gic.auth.service;
import com.gic.auth.dto.UserRoleDTO;
import com.gic.auth.entity.TabSysUserRole;
import java.util.List;
/**
* 用户角色关联
* @ClassName: UserRoleService

* @Description: 

* @author guojuxing

* @date 2019/9/2 11:01 AM

*/
public interface UserRoleService {
/**
* 新增
* @Title: save

* @Description:

 * @author guojuxing
* @param dto

* @return void


 */
void save(UserRoleDTO dto);
/**
* 删除用户关联数据
* @Title: deleteByUserId

* @Description:

 * @author guojuxing
* @param userId

* @return void


 */
void deleteByUserId(Integer userId);
/**
* 查询用户关联数据
* @Title: listUserRoleByUserId

* @Description:

 * @author guojuxing
* @param userId

* @return java.util.List<com.gic.auth.entity.TabSysUserRole>


 */
List<UserRoleDTO> listUserRoleByUserId(Integer userId);
}
package com.gic.auth.service;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabUser;
import java.util.List;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabSysUser;
/**
* @author guojx
* @date 2019/7/16 6:50 PM
......@@ -25,7 +25,7 @@ public interface UserService {
* @param userId
* @return
*/
TabUser getUserById(Integer userId);
TabSysUser getUserById(Integer userId);
/**
* 手机号码是否重复
......@@ -35,9 +35,9 @@ public interface UserService {
*/
boolean isPhoneRepeat(Integer userId, String phone);
TabUser getUserByEnterpriseId(Integer enterpriseId);
TabSysUser getUserByEnterpriseId(Integer enterpriseId);
List<TabUser> listAllUserByPhoneNumber(String phoneNumber);
List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber);
TabUser login(String phoneNumber, Integer enterpriseId, String password);
TabSysUser login(String phoneNumber, Integer enterpriseId, String password);
}
package com.gic.auth.service.impl;
import com.gic.auth.dao.mapper.TabSysUserRoleMapper;
import com.gic.auth.dto.UserRoleDTO;
import com.gic.auth.entity.TabSysUserRole;
import com.gic.auth.service.UserRoleService;
import com.gic.commons.util.EntityUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service("userRoleService")
public class UserRoleServiceImpl implements UserRoleService{
@Autowired
private TabSysUserRoleMapper tabSysUserRoleMapper;
@Override
public void save(UserRoleDTO dto) {
tabSysUserRoleMapper.insert(EntityUtil.changeEntityNew(TabSysUserRole.class, dto));
}
@Override
public void deleteByUserId(Integer userId) {
tabSysUserRoleMapper.deleteByUserId(userId);
}
@Override
public List<UserRoleDTO> listUserRoleByUserId(Integer userId) {
List<TabSysUserRole> list = tabSysUserRoleMapper.listUserRoleByUserId(userId);
if (CollectionUtils.isNotEmpty(list)) {
return EntityUtil.changeEntityListNew(UserRoleDTO.class, list);
}
return new ArrayList<>();
}
}
package com.gic.auth.service.impl;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabUser;
import com.gic.auth.service.UserService;
import com.gic.commons.util.EntityUtil;
import com.gic.auth.dao.mapper.TabUserMapper;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import com.gic.auth.dao.mapper.TabSysUserMapper;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.service.UserService;
import com.gic.commons.util.EntityUtil;
/**
* @author guojx
......@@ -17,28 +18,28 @@ import java.util.List;
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private TabUserMapper tabUserMapper;
private TabSysUserMapper tabSysUserMapper;
@Override
public int saveUser(UserDTO userDTO) {
TabUser tabUser = EntityUtil.changeEntityNew(TabUser.class, userDTO);
tabUserMapper.insert(tabUser);
TabSysUser tabUser = EntityUtil.changeEntityNew(TabSysUser.class, userDTO);
tabSysUserMapper.insert(tabUser);
return tabUser.getUserId();
}
@Override
public void editUser(UserDTO userDTO) {
TabUser tabUser = EntityUtil.changeEntityNew(TabUser.class, userDTO);
tabUserMapper.updateByPrimaryKeySelective(tabUser);
TabSysUser tabUser = EntityUtil.changeEntityNew(TabSysUser.class, userDTO);
tabSysUserMapper.updateByPrimaryKeySelective(tabUser);
}
@Override
public TabUser getUserById(Integer userId) {
return tabUserMapper.selectByPrimaryKey(userId);
public TabSysUser getUserById(Integer userId) {
return tabSysUserMapper.selectByPrimaryKey(userId);
}
@Override
public boolean isPhoneRepeat(Integer userId, String phone) {
int count = tabUserMapper.countByPhone(phone, userId);
int count = tabSysUserMapper.countByPhone(phone, userId);
if (count > 0) {
return true;
}
......@@ -46,17 +47,17 @@ public class UserServiceImpl implements UserService {
}
@Override
public TabUser getUserByEnterpriseId(Integer enterpriseId) {
public TabSysUser getUserByEnterpriseId(Integer enterpriseId) {
return null;
}
@Override
public List<TabUser> listAllUserByPhoneNumber(String phoneNumber) {
return this.tabUserMapper.listAllUserByPhoneNumber(phoneNumber);
public List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber) {
return this.tabSysUserMapper.listAllUserByPhoneNumber(phoneNumber);
}
@Override
public TabUser login(String phoneNumber, Integer enterpriseId, String password) {
return this.tabUserMapper.login(phoneNumber, password, enterpriseId);
public TabSysUser login(String phoneNumber, Integer enterpriseId, String password) {
return this.tabSysUserMapper.login(phoneNumber, password, enterpriseId);
}
}
package com.gic.auth.service.outer.impl;
import java.util.Date;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.service.UserApiService;
import com.gic.auth.service.UserService;
import com.gic.commons.util.EntityUtil;
import com.gic.auth.entity.TabUser;
import com.gic.enterprise.error.ErrorCode;
import com.gic.auth.service.UserService;
import com.gic.store.utils.valid.ValidUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author guojx
......@@ -47,7 +48,7 @@ public class UserApiServiceImpl implements UserApiService{
if (!paramResult.isSuccess()) {
return paramResult;
}
TabUser tabUser = userService.getUserById(userDTO.getUserId());
TabSysUser tabUser = userService.getUserById(userDTO.getUserId());
if (tabUser == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误");
}
......@@ -61,7 +62,7 @@ public class UserApiServiceImpl implements UserApiService{
@Override
public ServiceResponse<UserDTO> getUserById(Integer userId) {
TabUser tabUser = userService.getUserById(userId);
TabSysUser tabUser = userService.getUserById(userId);
if (tabUser == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误");
}
......@@ -70,7 +71,7 @@ public class UserApiServiceImpl implements UserApiService{
@Override
public ServiceResponse<UserDTO> getUserByEnterpriseId(Integer enterpriseId) {
TabUser tabUser = userService.getUserByEnterpriseId(enterpriseId);
TabSysUser tabUser = userService.getUserByEnterpriseId(enterpriseId);
if (enterpriseId == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "商户ID输入有误");
}
......@@ -79,7 +80,7 @@ public class UserApiServiceImpl implements UserApiService{
@Override
public ServiceResponse<List<UserDTO>> listUserByPhoneNumber(String phoneNumber) {
List<TabUser> list = this.userService.listAllUserByPhoneNumber(phoneNumber);
List<TabSysUser> list = this.userService.listAllUserByPhoneNumber(phoneNumber);
if(CollectionUtils.isNotEmpty(list)){
return ServiceResponse.success(EntityUtil.changeEntityListByJSON(UserDTO.class, list));
}
......@@ -88,7 +89,7 @@ public class UserApiServiceImpl implements UserApiService{
@Override
public ServiceResponse<UserDTO> login(String phoneNumber, Integer enterpriseId, String password) {
TabUser user = this.userService.login(phoneNumber, enterpriseId, password);
TabSysUser user = this.userService.login(phoneNumber, enterpriseId, password);
return ServiceResponse.success(EntityUtil.changeEntityByJSON(UserDTO.class, user));
}
}
package com.gic.auth.service.outer.impl;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserResourceDTO;
import com.gic.auth.service.UserResourceApiService;
import org.springframework.stereotype.Service;
@Service("userResourceApiService")
public class UserResourceApiServiceImpl implements UserResourceApiService{
@Override
public ServiceResponse<Void> save(UserResourceDTO dto) {
return null;
}
}
package com.gic.auth.service.outer.impl;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserRoleDTO;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.service.UserRoleApiService;
import com.gic.auth.service.UserRoleService;
import com.gic.auth.service.UserService;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.valid.ValidParamsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("userRoleApiService")
public class UserRoleApiServiceImpl implements UserRoleApiService{
@Autowired
private UserRoleService userRoleService;
@Autowired
private UserService userService;
@Override
public ServiceResponse<Void> save(UserRoleDTO dto) {
ServiceResponse paramValid = ValidParamsUtils.allCheckValidate(dto, UserRoleDTO.SaveUserRoleValid.class);
if (!paramValid.isSuccess()) {
return paramValid;
}
TabSysUser user = userService.getUserById(dto.getUserId());
if (user == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户数据有误,查无数据");
}
userRoleService.deleteByUserId(user.getUserId());
dto.setCreateTime(new Date());
dto.setUpdateTime(new Date());
dto.setStatus(1);
userRoleService.save(dto);
return ServiceResponse.success();
}
}
......@@ -174,4 +174,41 @@
login_type = #{loginType,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<select id="countByPhone" resultType="int">
select count(1) from tab_sys_user
where status = 1
<if test="userId != null">
user_id <![CDATA[ <> ]]> #{userId}
</if>
and phone_number = #{phone}
</select>
<select id="selectByEnterpriseId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where enterprise_id = #{enterpriseId,jdbcType=INTEGER}
and status = 1
and super_admin = 1
</select>
<select id="listAllUserByPhoneNumber" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where phone_number = #{phoneNumber}
and status = 1
</select>
<select id="login" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where phone_number = #{phoneNumber}
and status = 1
and enterprise_id = #{enterpriseId}
and password = #{password}
</select>
</mapper>
\ No newline at end of file
......@@ -114,4 +114,18 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where user_role_id = #{userRoleId,jdbcType=INTEGER}
</update>
<update id="deleteByUserId" parameterType="java.lang.Integer">
UPDATE tab_sys_user_role set status = 0
where user_id = #{userId}
and status = 1
</update>
<select id="listUserRoleByUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user_role
where user_id = #{userId}
and status = 1
</select>
</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.gic.auth.dao.mapper.TabUserMapper">
<resultMap id="BaseResultMap" type="com.gic.auth.entity.TabUser">
<id column="user_id" jdbcType="INTEGER" property="userId" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="phone_number" jdbcType="VARCHAR" property="phoneNumber" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="super_admin" jdbcType="INTEGER" property="superAdmin" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="phone_area_code" jdbcType="VARCHAR" property="phoneAreaCode" />
</resultMap>
<sql id="Base_Column_List">
user_id, user_name, phone_number, password, super_admin, status, create_time, update_time,
enterprise_id, phone_area_code
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where user_id = #{userId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_sys_user
where user_id = #{userId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.auth.entity.TabUser" useGeneratedKeys="true" keyProperty="userId">
insert into tab_sys_user (user_id, user_name, phone_number,
password, super_admin, status,
create_time, update_time, enterprise_id,
phone_area_code)
values (#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{phoneNumber,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{superAdmin,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{enterpriseId,jdbcType=INTEGER},
#{phoneAreaCode,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.gic.auth.entity.TabUser">
insert into tab_sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="userName != null">
user_name,
</if>
<if test="phoneNumber != null">
phone_number,
</if>
<if test="password != null">
password,
</if>
<if test="superAdmin != null">
super_admin,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="phoneAreaCode != null">
phone_area_code,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="phoneNumber != null">
#{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="superAdmin != null">
#{superAdmin,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
</if>
<if test="phoneAreaCode != null">
#{phoneAreaCode,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.auth.entity.TabUser">
update tab_sys_user
<set>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="phoneNumber != null">
phone_number = #{phoneNumber,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="superAdmin != null">
super_admin = #{superAdmin,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if test="phoneAreaCode != null">
phone_area_code = #{phoneAreaCode,jdbcType=VARCHAR},
</if>
</set>
where user_id = #{userId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.auth.entity.TabUser">
update tab_sys_user
set user_name = #{userName,jdbcType=VARCHAR},
phone_number = #{phoneNumber,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
super_admin = #{superAdmin,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
phone_area_code = #{phoneAreaCode,jdbcType=VARCHAR}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<select id="countByPhone" resultType="int">
select count(1) from tab_sys_user
where status = 1
<if test="userId != null">
user_id <![CDATA[ <> ]]> #{userId}
</if>
and phone_number = #{phone}
</select>
<select id="selectByEnterpriseId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where enterprise_id = #{enterpriseId,jdbcType=INTEGER}
and status = 1
and super_admin = 1
</select>
<select id="listAllUserByPhoneNumber" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where phone_number = #{phoneNumber}
and status = 1
</select>
<select id="login" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_user
where phone_number = #{phoneNumber}
and status = 1
and enterprise_id = #{enterpriseId}
and password = #{password}
</select>
</mapper>
\ No newline at end of file
package com.gic.auth.web.controller;
import com.gic.auth.service.UserApiService;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class UserController {
private final Logger logger = LogManager.getLogger(UserController.class);
@Autowired
private UserApiService userApiService;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment