Commit b9e32446 by 314581947

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-auth into developer
parents e964d423 aa145dfc
......@@ -50,7 +50,7 @@ public class UserDTO implements UserInfo,Serializable{
/**
* 密码
*/
@NotBlank(message = "密码不能为空", groups = {SaveUserValid.class, EditUserValid.class})
@NotBlank(message = "密码不能为空", groups = {SaveUserValid.class})
private String password;
/**
......@@ -113,6 +113,10 @@ public class UserDTO implements UserInfo,Serializable{
* 用户资源组授权,可以多选,用英文逗号隔开
*/
private String userResourceIds;
/**
* 1:是编辑操作,并且没修改过密码 2:与1相反
*/
private Integer operPasswordType;
public Integer getUserId() {
return userId;
......@@ -241,4 +245,12 @@ public class UserDTO implements UserInfo,Serializable{
public void setUserResourceIds(String userResourceIds) {
this.userResourceIds = userResourceIds;
}
public Integer getOperPasswordType() {
return operPasswordType;
}
public void setOperPasswordType(Integer operPasswordType) {
this.operPasswordType = operPasswordType;
}
}
......@@ -77,4 +77,16 @@ public interface TabSysRoleMapper {
int deleteByRoleId(@Param("roleId") Integer roleId);
List<TabSysRole> listRoleNoPage(@Param("enterpriseId") Integer enterpriseId);
/**
* 查询数量根据名称
* @Title: countRepeatRoleName

* @Description:

 * @author guojuxing
* @param enterpriseId
* @param roleId
* @param roleName

* @return int


 */
int countRepeatRoleName(@Param("enterpriseId") Integer enterpriseId, @Param("roleId") Integer roleId, @Param("roleName") String roleName);
}
\ No newline at end of file
......@@ -61,9 +61,10 @@ public interface TabSysUserMapper {
* 手机号码查询个数
* @param phone
* @param userId
* @param enterpriseId
* @return
*/
int countByPhone(@Param("phone") String phone, @Param("userId") Integer userId);
int countByPhone(@Param("phone") String phone, @Param("userId") Integer userId, @Param("enterpriseId") Integer enterpriseId);
TabSysUser selectByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
......
......@@ -68,4 +68,16 @@ public interface RoleService {
* @return java.util.List<com.gic.auth.entity.TabSysRole>


 */
List<TabSysRole> listRole(Integer enterpriseId);
/**
* 权限名称是否重复
* @Title: isRepeatRoleName

* @Description:

 * @author guojuxing
* @param enterpriseId
* @param roleId
* @param roleName

* @return boolean


 */
boolean isRepeatRoleName(Integer enterpriseId, Integer roleId, String roleName);
}
......@@ -34,9 +34,10 @@ public interface UserService {
* 手机号码是否重复
* @param userId
* @param phone
* @param enterpriseId
* @return
*/
boolean isPhoneRepeat(Integer userId, String phone);
boolean isPhoneRepeat(Integer userId, String phone, Integer enterpriseId);
TabSysUser getUserByEnterpriseId(Integer enterpriseId);
......
......@@ -58,4 +58,13 @@ public class RoleServiceImpl implements RoleService{
public List<TabSysRole> listRole(Integer enterpriseId) {
return tabSysRoleMapper.listRoleNoPage(enterpriseId);
}
@Override
public boolean isRepeatRoleName(Integer enterpriseId, Integer roleId, String roleName) {
int count = tabSysRoleMapper.countRepeatRoleName(enterpriseId, roleId, roleName);
if (count > 0) {
return true;
}
return false;
}
}
......@@ -46,8 +46,8 @@ public class UserServiceImpl implements UserService {
}
@Override
public boolean isPhoneRepeat(Integer userId, String phone) {
int count = tabSysUserMapper.countByPhone(phone, userId);
public boolean isPhoneRepeat(Integer userId, String phone, Integer enterpriseId) {
int count = tabSysUserMapper.countByPhone(phone, userId, enterpriseId);
if (count > 0) {
return true;
}
......
......@@ -48,6 +48,11 @@ public class RoleApiServiceImpl implements RoleApiService{
dto.setCreateTime(new Date());
dto.setStatus(1);
//验证名称不能重复
if (roleService.isRepeatRoleName(dto.getEnterpriseId(), null, dto.getRoleName())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "权限名称重复");
}
Integer roleId = roleService.save(dto);
//删除之前的角色菜单数据
......@@ -72,6 +77,11 @@ public class RoleApiServiceImpl implements RoleApiService{
return paramValid;
}
//验证名称不能重复
if (roleService.isRepeatRoleName(record.getEnterpriseId(), dto.getRoleId(), dto.getRoleName())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "权限名称重复");
}
roleService.update(dto);
//删除之前的角色菜单数据
menuRoleService.deleteByRoleId(dto.getRoleId());
......
......@@ -56,7 +56,7 @@ public class UserApiServiceImpl implements UserApiService {
if (!paramResult.isSuccess()) {
return paramResult;
}
if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber())) {
if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber(), userDTO.getEnterpriseId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
}
......@@ -121,7 +121,7 @@ public class UserApiServiceImpl implements UserApiService {
if (tabUser == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误");
}
if (userService.isPhoneRepeat(userDTO.getUserId(), userDTO.getPhoneNumber())) {
if (userService.isPhoneRepeat(userDTO.getUserId(), userDTO.getPhoneNumber(), tabUser.getEnterpriseId())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
}
......
......@@ -130,4 +130,15 @@
where status = 1
and enterprise_id = #{enterpriseId}
</select>
<select id="countRepeatRoleName" resultType="int">
select count(1) from tab_sys_role
where status = 1
<if test="roleId != null">
and role_id <![CDATA[ <> ]]> #{roleId}
</if>
and enterprise_id = #{enterpriseId}
and role_name = #{roleName}
</select>
</mapper>
\ No newline at end of file
......@@ -191,8 +191,9 @@
select count(1) from tab_sys_user
where status = 1
<if test="userId != null">
user_id <![CDATA[ <> ]]> #{userId}
and user_id <![CDATA[ <> ]]> #{userId}
</if>
and enterprise_id = #{enterpriseId}
and phone_number = #{phone}
</select>
......@@ -251,6 +252,8 @@
</if>
GROUP BY a.user_id
order by a.create_time desc
</select>
......
......@@ -134,7 +134,7 @@
select
<include refid="Base_Column_List" />
from tab_sys_user_role
where role_id = #{userId}
where role_id = #{roleId}
and status = 1
</select>
</mapper>
\ No newline at end of file
......@@ -29,9 +29,15 @@ public class UserController {
@RequestMapping("/save-or-update-user")
public RestResponse editUser(@Validated({ UserDTO.UserQoValid.class }) UserDTO userDTO) {
Integer operationPassword = userDTO.getOperPasswordType();
userDTO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
String password = UserPasswordUtils.validPassword(userDTO.getPasswordType(), userDTO.getPassword());
userDTO.setPassword(UserPasswordUtils.getEncryptPassword(password));
if (operationPassword != null && operationPassword.intValue() == 1) {
//如果是1,则不用验证密码
} else {
String password = UserPasswordUtils.validPassword(userDTO.getPasswordType(), userDTO.getPassword());
userDTO.setPassword(UserPasswordUtils.getEncryptPassword(password));
}
ServiceResponse userResult;
//普通用户
userDTO.setSuperAdmin(0);
......
......@@ -3,9 +3,9 @@ package com.gic.auth.web.utils;
import org.apache.commons.lang3.StringUtils;
import com.gic.auth.constant.UserConstants;
import com.gic.auth.exception.AuthException;
import com.gic.commons.util.Md5Util;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.exception.CommonException;
import com.gic.enterprise.utils.CreateRandomUtils;
/**
* 用户密码生成
......@@ -54,7 +54,7 @@ public class UserPasswordUtils {
if (StringUtils.isNotBlank(password)) {
return password;
} else {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "密码不能为空");
throw new AuthException(ErrorCode.PARAMETER_ERROR.getCode(), "密码不能为空");
}
}
}
......
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