Commit 96d49375 by guojuxing

角色菜单权限接口

parent b3fe64e6
......@@ -14,7 +14,7 @@ public class TabSysRole {
/**
* 管理员角色名称
*/
private Integer roleName;
private String roleName;
/**
* 企业ID
......@@ -44,11 +44,11 @@ public class TabSysRole {
this.roleId = roleId;
}
public Integer getRoleName() {
public String getRoleName() {
return roleName;
}
public void setRoleName(Integer roleName) {
public void setRoleName(String roleName) {
this.roleName = roleName;
}
......
......@@ -3,6 +3,8 @@ package com.gic.auth.service.outer.impl;
import java.util.Date;
import java.util.List;
import com.gic.auth.entity.TabSysResource;
import com.gic.auth.entity.TabSysRole;
import com.gic.auth.utils.ValidSplitUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
......@@ -41,6 +43,10 @@ public class UserApiServiceImpl implements UserApiService {
private UserRoleService userRoleService;
@Autowired
private UserResourceService userResourceService;
@Autowired
private ResourceService resourceService;
@Autowired
private RoleService roleService;
@Transactional(rollbackFor = Exception.class)
@Override
......@@ -201,7 +207,12 @@ public class UserApiServiceImpl implements UserApiService {
userRoleDTO.setEnterpriseId(enterpriseId);
userRoleDTO.setUserId(userId);
for (String userRole : userRoleIdArr) {
userRoleDTO.setRoleId(Integer.parseInt(userRole));
int roleId = Integer.parseInt(userRole);
TabSysRole tabSysRole = roleService.getById(roleId);
if (tabSysRole == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "角色数据有误,无此角色数据");
}
userRoleDTO.setRoleId(roleId);
ServiceResponse result = userRoleApiService.save(userRoleDTO);
if (!result.isSuccess()) {
return result;
......@@ -212,7 +223,12 @@ public class UserApiServiceImpl implements UserApiService {
userResourceDTO.setUserId(userId);
userResourceDTO.setEnterpriseId(enterpriseId);
for (String userResource : userResourceIdArr) {
userResourceDTO.setResourceId(Integer.parseInt(userResource));
int resourceId = Integer.parseInt(userResource);
TabSysResource tabSysResource = resourceService.getResource(resourceId);
if (tabSysResource == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "资源数据有误,无此资源数据");
}
userResourceDTO.setResourceId(resourceId);
ServiceResponse result = userResourceApiService.save(userResourceDTO);
if (!result.isSuccess()) {
return result;
......
......@@ -3,7 +3,7 @@
<mapper namespace="com.gic.auth.dao.mapper.TabSysRoleMapper">
<resultMap id="BaseResultMap" type="com.gic.auth.entity.TabSysRole">
<id column="role_id" jdbcType="INTEGER" property="roleId" />
<result column="role_name" jdbcType="INTEGER" property="roleName" />
<result column="role_name" jdbcType="VARCHAR" property="roleName" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
......@@ -26,7 +26,7 @@
insert into tab_sys_role (role_id, role_name, enterprise_id,
status, create_time, update_time
)
values (#{roleId,jdbcType=INTEGER}, #{roleName,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER},
values (#{roleId,jdbcType=INTEGER}, #{roleName,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=INTEGER},
#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
......@@ -57,7 +57,7 @@
#{roleId,jdbcType=INTEGER},
</if>
<if test="roleName != null">
#{roleName,jdbcType=INTEGER},
#{roleName,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
......@@ -77,7 +77,7 @@
update tab_sys_role
<set>
<if test="roleName != null">
role_name = #{roleName,jdbcType=INTEGER},
role_name = #{roleName,jdbcType=VARCHAR},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
......@@ -96,7 +96,7 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.auth.entity.TabSysRole">
update tab_sys_role
set role_name = #{roleName,jdbcType=INTEGER},
set role_name = #{roleName,jdbcType=VARCHAR},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
......
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