Commit 996b4eab by duanhq

获取用户列表修改 by duanht 2019/2/27

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17844 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 8909e3e7
......@@ -13,11 +13,13 @@ import com.glsx.common.feign.client.CommonClient;
import com.glsx.common.utils.*;
import com.glsx.common.utils.StringUtils;
import com.glsx.usercenter.constants.Constants;
import com.glsx.usercenter.dto.MerchantInfo;
import com.glsx.usercenter.mapper.DictionaryTypeMapper;
import com.glsx.usercenter.mapper.SysRoleMapper;
import com.glsx.usercenter.mapper.SysUserImageMapper;
import com.glsx.usercenter.pojo.dictionary.DictionaryData;
import com.glsx.usercenter.pojo.user.*;
import com.glsx.usercenter.service.IAreaService;
import com.glsx.usercenter.utils.AccountValidatorUtil;
import com.glsx.usercenter.utils.QRCodeUtil;
import com.glsx.usercenter.utils.RedisCacheUtil;
......@@ -79,6 +81,9 @@ public class UserController extends BaseController {
@Autowired
private SysUserImageMapper sysUserImageMapper;
@Autowired
private IAreaService iAreaService;
/**
* @param userQueryVo
* @return ResultObject
......@@ -551,7 +556,13 @@ public class UserController extends BaseController {
if (merchantId == null) {
merchantId = UserUtils.getUserId(request);
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), sysUserService.getMerchantById(merchantId));
MerchantInfo merchantInfo = new MerchantInfo();
SysMerchant sysMerchant = sysUserService.getMerchantById(merchantId);
merchantInfo.setId(sysMerchant.getId());
merchantInfo.setName(sysMerchant.getName());
merchantInfo.setPhoneNumber(sysMerchant.getPhoneNumber());
merchantInfo.setSysArea(iAreaService.getAllChargeItems(Integer.valueOf(sysMerchant.getDistrict())));
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), merchantInfo);
}
......
package com.glsx.usercenter.dto;
import com.glsx.usercenter.pojo.user.SysArea;
/**
* @author duanht
* @version 1.0.0
* @Title MerchantInfo
* @Package com.glsx.usercenter.dto
* @Description ${todo}
* @date 2019/2/26 20:48
*/
public class MerchantInfo {
private Integer id;
private String name;
private String phoneNumber;
private SysArea sysArea;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public SysArea getSysArea() {
return sysArea;
}
public void setSysArea(SysArea sysArea) {
this.sysArea = sysArea;
}
}
package com.glsx.usercenter.mapper;
import com.glsx.usercenter.pojo.user.SysArea;
import com.glsx.usercenter.pojo.user.SysAreaExample;
import java.util.List;
public interface SysAreaMapper {
long countByExample(SysAreaExample example);
int deleteByPrimaryKey(Integer id);
int insert(SysArea record);
int insertSelective(SysArea record);
List<SysArea> selectByExample(SysAreaExample example);
SysArea selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysArea record);
int updateByPrimaryKey(SysArea record);
List<SysArea> getAllChargeItems(Integer parentId);
}
\ No newline at end of file
package com.glsx.usercenter.pojo.user;
import java.util.Date;
import java.util.List;
public class SysArea {
private Integer id;
private String areaName;
private String areaCode;
private Integer parentId;
private Date initDate;
private List<SysArea> Children;
public List<SysArea> getChildren() {
return Children;
}
public void setChildren(List<SysArea> children) {
Children = children;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName == null ? null : areaName.trim();
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode == null ? null : areaCode.trim();
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Date getInitDate() {
return initDate;
}
public void setInitDate(Date initDate) {
this.initDate = initDate;
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ public class UserQueryVo extends BaseQueryVo {
/**
*登录名称
*/
private String userName;
private String username;
/**
* 用户状态
......@@ -103,12 +103,12 @@ public class UserQueryVo extends BaseQueryVo {
this.ids = ids;
}
public String getUserName() {
return userName;
public String getUsername() {
return username;
}
public void setUserName(String userName) {
this.userName = userName;
public void setUsername(String username) {
this.username = username;
}
public Integer getUserStatus() {
......
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.usercenter.service;
import com.glsx.usercenter.pojo.user.SysArea;
import com.glsx.usercenter.pojo.user.SysAreaExample;
import java.util.List;
/**
* @ClassName: IAreaService
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月23日
*
*/
public interface IAreaService {
List<SysArea> selectByExample(SysAreaExample example);
SysArea getAllChargeItems(Integer id);
}
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.usercenter.service.impl;
import com.glsx.usercenter.mapper.SysAreaMapper;
import com.glsx.usercenter.pojo.user.SysArea;
import com.glsx.usercenter.pojo.user.SysAreaExample;
import com.glsx.usercenter.service.IAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @ClassName: AreaServiceImpl
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月23日
*
*/
@Service
public class AreaServiceImpl implements IAreaService {
@Autowired
private SysAreaMapper sysAreaMapper;
@Override
public List<SysArea> selectByExample(SysAreaExample example) {
return sysAreaMapper.selectByExample(example);
}
@Override
public SysArea getAllChargeItems(Integer id) {
SysAreaExample example=new SysAreaExample ();
example.createCriteria().andIdEqualTo(id);
List<SysArea> child = sysAreaMapper.selectByExample(example);
example.clear();
example.createCriteria().andIdEqualTo(child.get(0).getParentId());
List<SysArea> parent= sysAreaMapper.selectByExample(example);
example.clear();
example.createCriteria().andIdEqualTo(parent.get(0).getParentId());
SysArea prandPa= sysAreaMapper.selectByExample(example).get(0);
parent.get(0).setChildren(child);
prandPa.setChildren(parent);
return prandPa;
}
}
......@@ -228,7 +228,7 @@ public class SysUserServiceImpl implements SysUserService {
private void updateUserInfo(SysManager sysManager) {
//更新主表
sysUserMapper.updateByPrimaryKeySelective(sysManager);
sysUserMapper.updateSysUser(sysManager);
//更新管理员详细表
if (sysManager.getUserType() == 0) {
sysUserMapper.updateManager(sysManager);
......
<?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.glsx.usercenter.mapper.SysAreaMapper">
<resultMap id="BaseResultMap" type="com.glsx.usercenter.pojo.user.SysArea">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="area_name" jdbcType="VARCHAR" property="areaName" />
<result column="area_code" jdbcType="VARCHAR" property="areaCode" />
<result column="parent_id" jdbcType="INTEGER" property="parentId" />
<result column="init_date" jdbcType="TIMESTAMP" property="initDate" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, area_name, area_code, parent_id, init_date
</sql>
<select id="selectByExample" parameterType="com.glsx.usercenter.pojo.user.SysAreaExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
'false' as QUERYID,
<include refid="Base_Column_List" />
from sys_area
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_area
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_area
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.glsx.usercenter.pojo.user.SysArea">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_area (area_name, area_code, parent_id,
init_date)
values (#{areaName,jdbcType=VARCHAR}, #{areaCode,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER},
#{initDate,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.glsx.usercenter.pojo.user.SysArea">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_area
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaName != null">
area_name,
</if>
<if test="areaCode != null">
area_code,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="initDate != null">
init_date,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="areaName != null">
#{areaName,jdbcType=VARCHAR},
</if>
<if test="areaCode != null">
#{areaCode,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=INTEGER},
</if>
<if test="initDate != null">
#{initDate,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.glsx.usercenter.pojo.user.SysAreaExample" resultType="java.lang.Long">
select count(*) from sys_area
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.usercenter.pojo.user.SysArea">
update sys_area
<set>
<if test="areaName != null">
area_name = #{areaName,jdbcType=VARCHAR},
</if>
<if test="areaCode != null">
area_code = #{areaCode,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="initDate != null">
init_date = #{initDate,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.usercenter.pojo.user.SysArea">
update sys_area
set area_name = #{areaName,jdbcType=VARCHAR},
area_code = #{areaCode,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=INTEGER},
init_date = #{initDate,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<!-- //1.定义返回resultMap -->
<resultMap id="chargeItemSelectMap" type="com.glsx.usercenter.pojo.user.SysArea" extends="BaseResultMap">
<collection property="children" ofType="com.glsx.usercenter.pojo.user.SysArea" select="getSubChargeItem"
column="id"></collection>
</resultMap>
<!--2.定义查询父的方法 -->
<select id="getAllChargeItems" resultMap="chargeItemSelectMap">
SELECT
<include refid="Base_Column_List" />
from sys_area WHERE parent_id = 0
</select>
<!-- 3.定义查询子的方法 -->
<select id="getSubChargeItem" resultMap="chargeItemSelectMap">
SELECT
<include refid="Base_Column_List" />
from sys_area WHERE parent_id = #{id}
</select>
</mapper>
\ No newline at end of file
......@@ -569,37 +569,49 @@
u.create_time createTime,
u.update_by updateBy,
u.update_time updateTime,
u.user_type userType,
PASSWORD,
mail,
sex,
occupation,
u.remark
FROM
sys_user u
LEFT JOIN sys_user_org uo ON uo.org_id = u.org_id
LEFT JOIN sys_organization so ON uo.org_id = so.id
LEFT JOIN sys_manager sm ON sm.user_id = u.id
<choose>
<when test="userStatus != null">
<when test="userId != 0 and userId!=''">
FROM
sys_user_org suo
LEFT JOIN sys_organization so ON suo.org_id = so.id
LEFT JOIN sys_user u ON u.org_id = so.id
LEFT JOIN sys_manager sm ON sm.user_id = u.id
WHERE suo.user_id = #{userId,jdbcType=INTEGER}
</when>
<otherwise>
FROM
sys_user u
LEFT JOIN sys_organization so ON u.org_id = so.id
LEFT JOIN sys_manager sm ON sm.user_id = u.id
</otherwise>
</choose>
<choose>
<when test="userStatus != null and userStatus!=''">
WHERE u.user_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
WHERE u.user_status &lt;&gt; 2
</otherwise>
</choose>
<if test="userId != 0">
and uo.user_id = #{userId,jdbcType=INTEGER}
<if test="id != null and id!=''">
and u.id = #{id,jdbcType=VARCHAR}
</if>
<if test="userName != null">
and u.userName like #{userName,jdbcType=VARCHAR}
<if test="username != null and userName!=''">
and u.username like "%"#{username,jdbcType=VARCHAR}"%"
</if>
<if test="phoneNumber != null">
and u.phone_number like #{phoneNumber,jdbcType=VARCHAR}
<if test="phoneNumber != null and phoneNumber!=''">
and u.phone_number like "%"#{phoneNumber,jdbcType=VARCHAR}"%"
</if>
<if test="orgId != null">
<if test="orgId != null and orgId!=''">
and u.org_id = #{orgId,jdbcType=INTEGER}
</if>
<if test="sTime != null and eTime!=null and sTime !='' and eTime !=''">
......@@ -623,44 +635,52 @@
sdd.data_key serviceKey,
sdd.data_value serviceItems,
sm.merchant_status
FROM
sys_user u
LEFT JOIN sys_user_org uo ON uo.org_id = u.org_id
LEFT JOIN sys_organization so ON uo.org_id = so.id
<choose>
<when test="userId != 0 and userId!=''">
FROM
sys_user_org suo
LEFT JOIN sys_organization so ON suo.org_id = so.id
LEFT JOIN sys_user u ON u.org_id = so.id
LEFT JOIN sys_manager sm ON sm.user_id = u.id
WHERE suo.user_id = #{userId,jdbcType=INTEGER}
</when>
<otherwise>
FROM
sys_user u
LEFT JOIN sys_organization so ON u.org_id = so.id
</otherwise>
</choose>
LEFT JOIN sys_merchant sm ON sm.user_id = u.id
LEFT JOIN sys_user_services sms ON sm.user_id = sms.user_id
LEFT JOIN sys_dict_data sdd ON sms.service_key = sdd.data_key
WHERE u.user_type = 2
<if test="userId != 0">
AND uo.user_id = #{userId,jdbcType=INTEGER}
</if>
<if test="id != null">
<if test="id != null and id!=''">
and u.id = #{id,jdbcType=VARCHAR}
</if>
<if test="serviceKey != null">
<if test="serviceKey != null and serviceKey!=''">
and sdd.data_key = #{serviceKey,jdbcType=VARCHAR}
</if>
<if test="shopName != null">
and sm.shop_name like #{shopName,jdbcType=VARCHAR}
<if test="shopName != null and shopName!=''">
and sm.shop_name like "%"%#{shopName,jdbcType=VARCHAR}"%"
</if>
<if test="serviceType != null">
<if test="serviceType != null and serviceType!=''">
and sm.service_type = #{serviceType,jdbcType=VARCHAR}
</if>
<if test="name != null">
and u.name like #{name,jdbcType=VARCHAR}
<if test="name != null and name!=''">
and u.name like "%"#{name,jdbcType=VARCHAR}"%"
</if>
<if test="phoneNumber != null">
and u.phone_number like #{phoneNumber,jdbcType=VARCHAR}
<if test="phoneNumber != null and phoneNumber!=''">
and u.phone_number like "%"#{phoneNumber,jdbcType=VARCHAR}"%"
</if>
<if test="listType == 2">
<choose>
<when test="userStatus != null">
<when test="userStatus != null and userStatus!=''">
and u.user_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
......@@ -672,7 +692,7 @@
<if test="listType == 3">
and u.user_status IN (1)
<choose>
<when test="userStatus != null">
<when test="userStatus != null and userStatus!=''">
and u.merchant_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
......@@ -684,7 +704,7 @@
<if test="listType == 4">
and u.user_status IN (1)
<choose>
<when test="userStatus != null">
<when test="userStatus != null and userStatus!=''">
and u.merchant_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
......@@ -699,6 +719,7 @@
<select id="getSysMechanicList" parameterType="com.glsx.usercenter.pojo.vo.UserQueryVo"
resultType="com.glsx.usercenter.pojo.user.SysMechanic">
SELECT
DISTINCT
u.id,
u.org_id orgId,
so.name orgName,
......@@ -716,34 +737,42 @@
sm.work_time_start workTimeStart,
sm.work_time_end workTimeEnd,
sm.dispatch_type dispatchType
FROM
sys_user u
LEFT JOIN sys_user_org uo ON uo.org_id = u.org_id
LEFT JOIN sys_organization so ON uo.org_id = so.id
<choose>
<when test="userId != 0 and userId!=''">
FROM
sys_user_org suo
LEFT JOIN sys_organization so ON suo.org_id = so.id
LEFT JOIN sys_user u ON u.org_id = so.id
LEFT JOIN sys_manager sm ON sm.user_id = u.id
WHERE suo.user_id = #{userId,jdbcType=INTEGER}
</when>
<otherwise>
FROM
sys_user u
LEFT JOIN sys_organization so ON u.org_id = so.id
</otherwise>
</choose>
LEFT JOIN sys_mechanic sm ON sm.user_id = u.id
LEFT JOIN sys_user_services sms ON sm.user_id = sms.user_id
LEFT JOIN sys_dict_data sdd ON sms.service_key = sdd.data_key
WHERE u.user_type = 3
<if test="userId != 0">
AND uo.user_id = #{userId,jdbcType=INTEGER}
</if>
<if test="id != null">
<if test="id != null and id!=''">
and u.id = #{id,jdbcType=VARCHAR}
</if>
<if test="serviceType != null">
and sm.service_type like #{serviceType,jdbcType=VARCHAR}
<if test="serviceType != null and serviceType!=''">
and sm.service_type like "%"#{serviceType,jdbcType=VARCHAR}"%"
</if>
<if test="name != null">
and u.name like #{name,jdbcType=VARCHAR}
<if test="name != null and name!=''">
and u.name like '%#{name,jdbcType=VARCHAR}%'
</if>
<if test="phoneNumber != null">
and u.phone_number like #{phoneNumber,jdbcType=VARCHAR}
<if test="phoneNumber != null and phoneNumber!=''">
and u.phone_number like "%"#{phoneNumber,jdbcType=VARCHAR}"%"
</if>
<if test="listType == 0">
<choose>
<when test="userStatus != null">
<when test="userStatus != null and userStatus!=''">
and u.user_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
......@@ -754,7 +783,7 @@
<if test="listType == 1">
<choose>
<when test="userStatus != null">
<when test="userStatus != null and userStatus!=''">
and u.user_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
......@@ -787,11 +816,11 @@
LEFT JOIN sys_user_org uo ON uo.org_id = u.org_id
LEFT JOIN sys_organization so ON uo.org_id = so.id
WHERE u.user_type = 1
<if test="id != 0">
<if test="id != 0 and id!=''">
AND uo.user_id = #{id,jdbcType=INTEGER}
</if>
<if test="name != null">
AND u.name LIKE #{name,jdbcType=VARCHAR}
<if test="name != null and name!=''">
AND u.name LIKE "%"#{name,jdbcType=VARCHAR}"%"
</if>
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!