Commit 8f772efc by duanhq

用户中心更新 by duanht 2019/2/13

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17318 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent a8c12bfe
......@@ -5,6 +5,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
......@@ -26,6 +28,9 @@ import org.springframework.validation.FieldError;
*/
public class BaseController {
@Resource
protected HttpServletRequest request;
public Logger logger = LoggerFactory.getLogger(getClass());
/**
......
......@@ -47,7 +47,7 @@ public interface SysUserMapper {
List<SysMerchant> getSysMerchantList(UserQueryVo userQueryVo);
int deleteUserById(Integer[] id);
int deleteUserById(UserQueryVo userQueryVo);
List<SysMechanic> getSysMechanicList(UserQueryVo userQueryVo);
......@@ -57,5 +57,5 @@ public interface SysUserMapper {
List<SysOrganization> getAllLevel(@Param("id") Integer id);
List<SysUser> getMechanicByOrgId(@Param("orgId") Integer orgId);
List<SysUser> getMechanicByOrgId(UserQueryVo userQueryVo);
}
\ No newline at end of file
package com.glsx.usercenter.pojo.vo;
import java.io.Serializable;
import java.util.List;
import java.util.Date;
/**
* 查询条件基类,所有的QueryVo都要继承这个类
......@@ -16,35 +16,10 @@ public class BaseQueryVo implements Serializable {
* 查询值
*/
private Integer id;
private Integer int1;
private Integer int2;
private Integer int3;
private String string1;
private String string2;
private String string3;
/**
* 对应Mapper.xml foreach collection的list/array
*/
// private List<Integer> list;
// private Integer[] array;
/**
* 用户id,分组id,分类id,车辆id,工单id,设备id
* List对应Mapper.xml foreach collection的list
*/
private Integer userId;
private Integer groupId;
private Integer classId;
private Integer vehicleId;
private Integer wordOrderId;
private Integer trackInfoId;
private List<Integer> groupIdList;
private List<Integer> classIdList;
private List<Integer> vehicleIdList;
private List<Integer> wordOrderIdList;
private List<Integer> trackInfoIdList;
private Date time;
/**
* 开始时间
......@@ -61,68 +36,12 @@ public class BaseQueryVo implements Serializable {
*/
private String cTime;
/**
* 追加table关联
*/
private String appendSqlWithTable;
/**
* 追加table关联,带列参数
*/
private String appendSqlWithInTable;
/**
* 权限控制的关联条件(sql语句),追加Where条件
*/
private String appendSqlWithCondition;
/**
* 权限控制的关联条件(sql语句),追加Order排序
*/
private String appendSqlWithOrderByTemp;
/**
* 分组权限控制的表关联
*/
private String appendSqlWithGroupTable;
/**
* 分组权限控制的关联条件(sql语句)
*/
private String appendSqlWithGroupCondition;
/**
* 分类权限控制的表关联
*/
private String appendSqlWithClassTable;
/**
* 分类权限控制的关联条件(sql语句)
*/
private String appendSqlWithClassCondition;
/**
* 映射用户对应车辆关系sql
*/
private String appendSqlWithOrTable;
/**
* 根据时间段拼装sql语句
*/
private String appendSqlByTimeRange;
public Date getTime() {
return time;
}
/**
* 清除所有sql
*/
public void emptyAllSql() {
setAppendSqlWithTable("");
setAppendSqlWithInTable("");
setAppendSqlWithCondition("");
setAppendSqlWithOrderByTemp("");
setAppendSqlWithGroupTable("");
setAppendSqlWithGroupCondition("");
setAppendSqlWithClassTable("");
setAppendSqlWithClassCondition("");
public void setTime(Date time) {
this.time = time;
}
public Integer getId() {
......@@ -133,54 +52,6 @@ public class BaseQueryVo implements Serializable {
this.id = id;
}
public Integer getInt1() {
return int1;
}
public void setInt1(Integer int1) {
this.int1 = int1;
}
public Integer getInt2() {
return int2;
}
public void setInt2(Integer int2) {
this.int2 = int2;
}
public Integer getInt3() {
return int3;
}
public void setInt3(Integer int3) {
this.int3 = int3;
}
public String getString1() {
return string1;
}
public void setString1(String string1) {
this.string1 = string1;
}
public String getString2() {
return string2;
}
public void setString2(String string2) {
this.string2 = string2;
}
public String getString3() {
return string3;
}
public void setString3(String string3) {
this.string3 = string3;
}
public Integer getUserId() {
return userId;
}
......@@ -189,102 +60,6 @@ public class BaseQueryVo implements Serializable {
this.userId = userId;
}
public Integer getGroupId() {
return groupId;
}
public void setGroupId(Integer groupId) {
this.groupId = groupId;
}
public Integer getClassId() {
return classId;
}
public void setClassId(Integer classId) {
this.classId = classId;
}
public Integer getVehicleId() {
return vehicleId;
}
public void setVehicleId(Integer vehicleId) {
this.vehicleId = vehicleId;
}
public Integer getWordOrderId() {
return wordOrderId;
}
public void setWordOrderId(Integer wordOrderId) {
this.wordOrderId = wordOrderId;
}
public Integer getTrackInfoId() {
return trackInfoId;
}
public void setTrackInfoId(Integer trackInfoId) {
this.trackInfoId = trackInfoId;
}
public List<Integer> getGroupIdList() {
return groupIdList;
}
public void setGroupIdList(List<Integer> groupIdList) {
this.groupIdList = groupIdList;
}
public List<Integer> getClassIdList() {
return classIdList;
}
public void setClassIdList(List<Integer> classIdList) {
this.classIdList = classIdList;
}
public List<Integer> getVehicleIdList() {
return vehicleIdList;
}
public void setVehicleIdList(List<Integer> vehicleIdList) {
this.vehicleIdList = vehicleIdList;
}
public List<Integer> getWordOrderIdList() {
return wordOrderIdList;
}
public void setWordOrderIdList(List<Integer> wordOrderIdList) {
this.wordOrderIdList = wordOrderIdList;
}
public List<Integer> getTrackInfoIdList() {
return trackInfoIdList;
}
public void setTrackInfoIdList(List<Integer> trackInfoIdList) {
this.trackInfoIdList = trackInfoIdList;
}
// public List<Integer> getList() {
// return list;
// }
//
// public void setList(List<Integer> list) {
// this.list = list;
// }
//
// public Integer[] getArray() {
// return array;
// }
//
// public void setArray(Integer[] array) {
// this.array = array;
// }
public String getsTime() {
return sTime;
}
......@@ -309,83 +84,4 @@ public class BaseQueryVo implements Serializable {
this.cTime = cTime;
}
public String getAppendSqlWithTable() {
return appendSqlWithTable;
}
public void setAppendSqlWithTable(String appendSqlWithTable) {
this.appendSqlWithTable = appendSqlWithTable;
}
public String getAppendSqlWithInTable() {
return appendSqlWithInTable;
}
public void setAppendSqlWithInTable(String appendSqlWithInTable) {
this.appendSqlWithInTable = appendSqlWithInTable;
}
public String getAppendSqlWithCondition() {
return appendSqlWithCondition;
}
public void setAppendSqlWithCondition(String appendSqlWithCondition) {
this.appendSqlWithCondition = appendSqlWithCondition;
}
public String getAppendSqlWithOrderByTemp() {
return appendSqlWithOrderByTemp;
}
public void setAppendSqlWithOrderByTemp(String appendSqlWithOrderByTemp) {
this.appendSqlWithOrderByTemp = appendSqlWithOrderByTemp;
}
public String getAppendSqlWithGroupTable() {
return appendSqlWithGroupTable;
}
public void setAppendSqlWithGroupTable(String appendSqlWithGroupTable) {
this.appendSqlWithGroupTable = appendSqlWithGroupTable;
}
public String getAppendSqlWithGroupCondition() {
return appendSqlWithGroupCondition;
}
public void setAppendSqlWithGroupCondition(String appendSqlWithGroupCondition) {
this.appendSqlWithGroupCondition = appendSqlWithGroupCondition;
}
public String getAppendSqlWithClassTable() {
return appendSqlWithClassTable;
}
public void setAppendSqlWithClassTable(String appendSqlWithClassTable) {
this.appendSqlWithClassTable = appendSqlWithClassTable;
}
public String getAppendSqlWithClassCondition() {
return appendSqlWithClassCondition;
}
public void setAppendSqlWithClassCondition(String appendSqlWithClassCondition) {
this.appendSqlWithClassCondition = appendSqlWithClassCondition;
}
public String getAppendSqlWithOrTable() {
return appendSqlWithOrTable;
}
public void setAppendSqlWithOrTable(String appendSqlWithOrTable) {
this.appendSqlWithOrTable = appendSqlWithOrTable;
}
public String getAppendSqlByTimeRange() {
return appendSqlByTimeRange;
}
public void setAppendSqlByTimeRange(String appendSqlByTimeRange) {
this.appendSqlByTimeRange = appendSqlByTimeRange;
}
}
......@@ -6,9 +6,9 @@ import java.util.List;
public class UserQueryVo extends BaseQueryVo {
/**
* 勾选导出
* 多选id
*/
private List<Integer> idList;
private List<Integer> ids;
/**
*登录名称
......@@ -91,15 +91,14 @@ public class UserQueryVo extends BaseQueryVo {
this.orgId = orgId;
}
public List<Integer> getIdList() {
return idList;
public List<Integer> getIds() {
return ids;
}
public void setIdList(List<Integer> idList) {
this.idList = idList;
public void setIds(List<Integer> ids) {
this.ids = ids;
}
public String getUserName() {
return userName;
}
......
......@@ -63,13 +63,13 @@ public interface SysUserService {
SysUser selectByPrimaryKey(Integer id);
/**
* @param id
* @param userQueryVo
* @return int
* @author duanht
* @Title: deleteUser
* @Description: TODO 注销用户
*/
int deleteUser(Integer[] id);
int deleteUser(UserQueryVo userQueryVo);
/**
* @param userName
......
......@@ -4,6 +4,7 @@ package com.glsx.usercenter.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.glsx.common.utils.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.IncorrectCredentialsException;
......@@ -153,12 +154,12 @@ public class SysUserServiceImpl implements SysUserService {
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteUser(Integer[] id) {
for (Integer userId : id) {
public int deleteUser(UserQueryVo userQueryVo) {
for (Integer userId : userQueryVo.getIds()) {
sysUserRoleMapper.deleteByUserId(userId);
sysUserOrgMapper.deleteByUserId(userId);
}
return sysUserMapper.deleteUserById(id);
return sysUserMapper.deleteUserById(userQueryVo);
}
@Override
......@@ -345,7 +346,14 @@ public class SysUserServiceImpl implements SysUserService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public int updateSysMechanic(SysMechanic sysMechanic) {
//修改主体信息中的更新人和更新时间
SysUser sysUser = new SysUser();
sysUser.setUpdateBy(sysMechanic.getUpdateBy());
sysUser.setUpdateTime(DateUtil.getCurrentTime());
sysUser.setId(sysMechanic.getId());
sysUserMapper.updateSysUser(sysUser);
return sysUserMapper.updateSysMechanic(sysMechanic);
}
......@@ -414,7 +422,7 @@ public class SysUserServiceImpl implements SysUserService {
userQueryVo.setOrgId(sysOrganizations.get(i).getId());
//只有机构下面才能有技工
if (sysOrganizations.get(i).getOrgType() == 2) {
List<SysUser> sysUserList = sysUserMapper.getMechanicByOrgId(userQueryVo.getOrgId());
List<SysUser> sysUserList = sysUserMapper.getMechanicByOrgId(userQueryVo);
sysOrganizations.get(i).setSysUserList(sysUserList);
}
//递归查询子组织
......@@ -468,7 +476,7 @@ public class SysUserServiceImpl implements SysUserService {
}
return sysUser;
}
public String encryptPassword(String password) {
return new Md5Hash(password).toHex().toString();
}
......
......@@ -81,6 +81,19 @@
id, username, name, org_id, phone_number, user_status, create_by, create_time, update_by,
update_time, password, sex, remark
</sql>
<sql id="getAllGroup">
SELECT DISTINCT
so.id id,
so.NAME NAME,
so.org_type,
uo.user_id
FROM
sys_user u
LEFT JOIN sys_user_org uo ON uo.user_id = u.id
LEFT JOIN sys_organization so ON uo.org_id = so.id
</sql>
<select id="selectByExample" parameterType="com.glsx.usercenter.pojo.user.SysUserExample" resultMap="BaseResultMap">
select
<if test="distinct">
......@@ -568,11 +581,22 @@
occupation,
u.remark
FROM
sys_user_org uo
LEFT JOIN sys_user u ON uo.org_id = u.org_id
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
WHERE uo.user_id = #{userId,jdbcType=INTEGER}
<choose>
<when test="userStatus != null">
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>
<if test="userName != null">
and u.userName like #{userName,jdbcType=VARCHAR}
</if>
......@@ -584,15 +608,6 @@
<if test="orgId != null">
and u.org_id = #{orgId,jdbcType=INTEGER}
</if>
<choose>
<when test="userStatus != null">
and u.user_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
and u.user_status &lt;&gt; 2
</otherwise>
</choose>
<if test="sTime != null and eTime!=null and sTime !='' and eTime !=''">
and u.create_time between #{sTime,jdbcType=TIMESTAMP} and #{eTime,jdbcType=TIMESTAMP}
</if>
......@@ -615,20 +630,22 @@
sdd.data_value serviceItems,
sm.merchant_status
FROM
sys_user_org uo
LEFT JOIN sys_user u ON uo.org_id = u.org_id
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_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 uo.user_id = #{userId,jdbcType=INTEGER}
AND u.user_type = 2
WHERE u.user_type = 2
<if test="userId != 0">
AND uo.user_id = #{userId,jdbcType=INTEGER}
</if>
<if test="id != null">
and u.id = #{id,jdbcType=VARCHAR}
</if>
<if test="serviceItem != null">
and sdd.data_key = #{serviceItem,jdbcType=VARCHAR}
<if test="serviceKey != null">
and sdd.data_key = #{serviceKey,jdbcType=VARCHAR}
</if>
<if test="shopName != null">
......@@ -659,24 +676,24 @@
</if>
<if test="listType == 3">
and u.user_status IN (1)
<choose>
<when test="userStatus != null">
and u.user_status = #{userStatus,jdbcType=TINYINT}
and u.merchant_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
and u.user_status IN (1)
and sm.merchant_status IN (1,2,3)
</otherwise>
</choose>
</if>
<if test="listType == 4">
and u.user_status IN (1)
<choose>
<when test="userStatus != null">
and u.user_status = #{userStatus,jdbcType=TINYINT}
and u.merchant_status = #{userStatus,jdbcType=TINYINT}
</when>
<otherwise>
and u.user_status IN (1)
and sm.merchant_status IN (2,3)
</otherwise>
</choose>
......@@ -706,14 +723,16 @@
sm.work_time_end workTimeEnd,
sm.dispatch_type dispatchType
FROM
sys_user_org uo
LEFT JOIN sys_user u ON uo.org_id = u.org_id
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_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_id = sdd.id
WHERE uo.user_id = #{userId,jdbcType=INTEGER}
AND u.user_type = 3
WHERE u.user_type = 3
<if test="userId != 0">
AND uo.user_id = #{userId,jdbcType=INTEGER}
</if>
<if test="id != null">
and u.id = #{id,jdbcType=VARCHAR}
</if>
......@@ -753,34 +772,74 @@
</select>
<update id="deleteUserById" parameterType="java.util.List">
<update id="deleteUserById" parameterType="com.glsx.usercenter.pojo.vo.UserQueryVo">
update sys_user
set user_status = 2
set user_status = 2,update_by= #{name,jdbcType=VARCHAR},update_time= #{time,jdbcType=TIMESTAMP}
where id in
<foreach collection="list" index="index" item="id"
<foreach collection="ids" index="index" item="id"
separator="," open="(" close=")">
#{id,jdbcType=TINYINT}
</foreach>
</update>
<!--<select id="getOrgList" resultType="com.glsx.usercenter.pojo.menu.SysOrganization">-->
<!--SELECT-->
<!--so.id,-->
<!--so.name,-->
<!--so.sort-->
<!--FROM-->
<!--sys_user_org uo-->
<!--LEFT JOIN sys_user u ON uo.org_id = u.org_id-->
<!--LEFT JOIN sys_organization so ON uo.org_id = so.id-->
<!--WHERE uo.user_id = #{id,jdbcType=INTEGER}-->
<!--<choose>-->
<!--<when test="userStatus != null">-->
<!--and u.user_status = #{userStatus,jdbcType=TINYINT}-->
<!--</when>-->
<!--<otherwise>-->
<!--and u.user_status IN (0,1)-->
<!--</otherwise>-->
<!--</choose>-->
<!--</select>-->
<select id="getUserByIdAndName" resultType="com.glsx.usercenter.pojo.user.SysUser">
SELECT
u.id id,
u.name name,
u.org_id orgId
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
WHERE u.user_type = 1
<if test="id != 0">
AND uo.user_id = #{id,jdbcType=INTEGER}
</if>
<if test="name != null">
AND u.name LIKE #{name,jdbcType=VARCHAR}
</if>
</select>
<resultMap type="com.glsx.usercenter.pojo.menu.SysOrganization" id="sysOrganizationMap">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="org_type" property="orgType"/>
<collection property="children" ofType="com.glsx.usercenter.pojo.menu.SysOrganization"
column="{id=id,userId = user_id}"
select="getAllLevelById"/>
</resultMap>
<select id="getAllLevel" resultMap="sysOrganizationMap">
<include refid="getAllGroup"/>
WHERE so.parent_id = 0
<if test="id != 0">
AND uo.user_id = #{id,jdbcType=INTEGER}
</if>
</select>
<select id="getAllLevelById" resultMap="sysOrganizationMap">
<include refid="getAllGroup"/>
WHERE
so.parent_id = #{id}
<if test="userId != 0">
AND uo.user_id = #{userId,jdbcType=INTEGER}
</if>
</select>
<select id="getMechanicByOrgId" parameterType="com.glsx.usercenter.pojo.vo.UserQueryVo"
resultType="com.glsx.usercenter.pojo.user.SysUser">
SELECT
su.name name,
su.phone_number phoneNumber,
su.id
FROM sys_resource_matching srm LEFT JOIN sys_service_mechanic ssm ON srm.user_id = ssm.service_id
LEFT JOIN sys_user su ON ssm.mechanic_id = su.id
WHERE srm.merchant_id = #{id,jdbcType=INTEGER} AND srm.service_key = #{serviceKey,jdbcType=VARCHAR}
AND su.user_status = 1
<if test="orgId != null">
AND su.org_id = #{orgId,jdbcType=INTEGER}
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!