Commit 299e3bc7 by guojuxing

超级管理员

parent 6aff576f
package com.gic.auth.dto;
import java.io.Serializable;
import java.util.Date;
/**
* tab_city
*/
public class CityDTO implements Serializable {
/**
* 城市id
*/
private String cityId;
/**
* 城市名称
*/
private String cityName;
/**
* 省份id
*/
private String provinceId;
/**
* 城市拼音
*/
private String cityPy;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityPy() {
return cityPy;
}
public void setCityPy(String cityPy) {
this.cityPy = cityPy;
}
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;
}
}
\ No newline at end of file
package com.gic.auth.dto;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @author guojx
* @date 2019/7/16 6:49 PM
*/
public class UserDTO implements Serializable{
private static final long serialVersionUID = 7296135586565827660L;
public interface SaveUserValid {
}
/**
* 用户id
*/
private Integer userId;
/**
* 用户名
*/
@NotBlank(message = "用户名不能为空", groups = {SaveUserValid.class})
private String userName;
/**
* 手机号码
*/
@NotBlank(message = "手机号不能为空", groups = {SaveUserValid.class})
private String phoneNumber;
/**
* 密码
*/
@NotBlank(message = "密码不能为空", groups = {SaveUserValid.class})
private String password;
/**
* 是否是超级管理员
*/
@NotNull(message = "用户类型不能为空", groups = {SaveUserValid.class})
private Integer superAdmin;
/**
* 状态,1有效,0无效
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*
*/
@NotNull(message = "企业ID不能为空", groups = {SaveUserValid.class})
private Integer enterpriseId;
/**
* 国际区号,如中国 86
*/
@NotBlank(message = "手机国际区号不能为空", groups = {SaveUserValid.class})
private String phoneAreaCode;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getSuperAdmin() {
return superAdmin;
}
public void setSuperAdmin(Integer superAdmin) {
this.superAdmin = superAdmin;
}
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;
}
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;
}
}
package com.gic.auth.service;
import com.gic.api.base.commons.ServiceResponse;
import java.util.List;
public interface ProvincesApiService {
}
package com.gic.auth.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
/**
* @author guojx
* @date 2019/7/16 6:48 PM
*/
public interface UserApiService {
/**
* 新增用户
* @param userDTO
* @return
*/
ServiceResponse<Integer> saveUser(UserDTO userDTO);
}
......@@ -23,6 +23,7 @@
<gic-store-api>4.0-SNAPSHOT</gic-store-api>
<gic-redis-data>4.0-SNAPSHOT</gic-redis-data>
<gic-bizdict-api>4.0.0-SNAPSHOT</gic-bizdict-api>
<gic-platform-auth-api>4.0-SNAPSHOT</gic-platform-auth-api>
</properties>
<dependencies>
......@@ -107,6 +108,11 @@
<artifactId>gic-enterprise-base-api</artifactId>
<version>${gic-enterprise-base-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-platform-auth-api</artifactId>
<version>${gic-platform-auth-api}</version>
</dependency>
</dependencies>
<build>
......
package com.gic.enterprise.dao.mapper;
import com.gic.store.entity.TabCity;
import org.apache.ibatis.annotations.Param;
import com.gic.enterprise.entity.TabUser;
import java.util.List;
public interface TabCityMapper {
public interface TabUserMapper {
/**
* 根据主键删除
*
* @param cityId 主键
* @param userId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(String cityId);
int deleteByPrimaryKey(Integer userId);
/**
* 插入一条记录
......@@ -20,7 +17,7 @@ public interface TabCityMapper {
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabCity record);
int insert(TabUser record);
/**
* 动态插入一条记录
......@@ -28,15 +25,15 @@ public interface TabCityMapper {
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabCity record);
int insertSelective(TabUser record);
/**
* 根据主键查询
*
* @param cityId 主键
* @param userId 主键
* @return 实体对象
*/
TabCity selectByPrimaryKey(String cityId);
TabUser selectByPrimaryKey(Integer userId);
/**
* 根据主键动态更新记录
......@@ -44,7 +41,7 @@ public interface TabCityMapper {
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabCity record);
int updateByPrimaryKeySelective(TabUser record);
/**
* 根据主键更新记录
......@@ -52,13 +49,5 @@ public interface TabCityMapper {
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabCity record);
/**
* 查询所有城市
* @return
*/
List<TabCity> selectAllCity();
List<TabCity> queryCity(@Param("search")String search);
int updateByPrimaryKey(TabUser record);
}
\ No newline at end of file
package com.gic.enterprise.entity;
import java.util.Date;
/**
* tab_city
*/
public class TabCity {
/**
* 城市id
*/
private String cityId;
/**
* 城市名称
*/
private String cityName;
/**
* 省份id
*/
private String provinceId;
/**
* 城市拼音
*/
private String cityPy;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public String getCityId() {
return cityId;
}
public void setCityId(String cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public String getCityPy() {
return cityPy;
}
public void setCityPy(String cityPy) {
this.cityPy = cityPy;
}
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;
}
}
\ No newline at end of file
package com.gic.enterprise.entity;
import java.util.Date;
/**
* tab_user
*/
public class TabUser {
/**
* 用户id
*/
private Integer userId;
/**
* 用户名
*/
private String userName;
/**
* 手机号码
*/
private String phoneNumber;
/**
* 密码
*/
private String password;
/**
* 是否是超级管理员
*/
private Integer superAdmin;
/**
* 状态,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 void setUserName(String userName) {
this.userName = userName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getSuperAdmin() {
return superAdmin;
}
public void setSuperAdmin(Integer superAdmin) {
this.superAdmin = superAdmin;
}
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;
}
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.enterprise.service;
import com.gic.auth.dto.UserDTO;
/**
* @author guojx
* @date 2019/7/16 6:50 PM
*/
public interface UserService {
/**
* 新增
* @param userDTO
* @return
*/
int saveUser(UserDTO userDTO);
}
package com.gic.enterprise.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("provincesService")
public class ProvincesServiceImpl {
}
package com.gic.enterprise.service.impl;
import com.gic.auth.dto.UserDTO;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.dao.mapper.TabUserMapper;
import com.gic.enterprise.entity.TabUser;
import com.gic.enterprise.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author guojx
* @date 2019/7/16 6:52 PM
*/
@Service("userService")
public class UserServiceImpl implements UserService{
@Autowired
private TabUserMapper tabUserMapper;
@Override
public int saveUser(UserDTO userDTO) {
TabUser tabUser = EntityUtil.changeEntityNew(TabUser.class, userDTO);
tabUserMapper.insert(tabUser);
return tabUser.getUserId();
}
}
package com.gic.enterprise.service.outer;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Service("provincesApiService")
public class ProvincesApiServiceImpl {
}
package com.gic.enterprise.service.outer;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.service.UserApiService;
import com.gic.enterprise.service.UserService;
import com.gic.store.utils.valid.ValidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @author guojx
* @date 2019/7/16 6:55 PM
*/
@Service("userApiService")
public class UserApiServiceImpl implements UserApiService{
@Autowired
private UserService userService;
@Override
public ServiceResponse<Integer> saveUser(UserDTO userDTO) {
//valid param
ServiceResponse paramResult = ValidUtil.allCheckValidate(userDTO, UserDTO.SaveUserValid.class);
if (!paramResult.isSuccess()) {
return paramResult;
}
userDTO.setCreateTime(new Date());
userDTO.setUpdateTime(new Date());
userDTO.setStatus(1);
return ServiceResponse.success(userService.saveUser(userDTO));
}
}
<?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.enterprise.dao.mapper.TabUserMapper">
<resultMap id="BaseResultMap" type="com.gic.enterprise.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_user
where user_id = #{userId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_user
where user_id = #{userId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabUser" useGeneratedKeys="true" keyProperty="userId">
insert into tab_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.enterprise.entity.TabUser">
insert into tab_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.enterprise.entity.TabUser">
update tab_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.enterprise.entity.TabUser">
update tab_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>
</mapper>
\ No newline at end of file
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