jinpengyong
2021-08-09 e742dd813ca48cbca806130f8419150441113e3d
获取用户角色修改
9 files modified
54 ■■■■ changed files
screen-api/src/main/java/com/moral/api/controller/GroupController.java 14 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/UserController.java 1 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/GroupMapper.java 2 ●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/bo/UserBO.java 2 ●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/GroupService.java 2 ●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/GroupServiceImpl.java 6 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java 15 ●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/GroupMapper.xml 8 ●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/UserMapper.xml 4 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/GroupController.java
@@ -12,6 +12,7 @@
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -102,20 +103,19 @@
        return ResultMessage.ok(pageResult);
    }
    @ApiOperation(value = "获取用户所属组ids", notes = "获取用户所属组ids")
    @ApiOperation(value = "获取用户组(角色)", notes = "获取用户组(角色)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "getGroupIds", method = RequestMethod.GET)
    public ResultMessage getGroupIds(Integer userId) {
        System.out.println(userId);
        if (userId == null) {
    @RequestMapping(value = "getGroup", method = RequestMethod.GET)
    public ResultMessage getGroup(Integer userId) {
        if (ObjectUtils.isEmpty(userId)) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<Map<String, Object>> groups = groupService.getGroupIds(userId);
        return ResultMessage.ok(groups);
        Map<String, Object> group = groupService.getGroup(userId);
        return ResultMessage.ok(group);
    }
    @ApiOperation(value = "用户分配组", notes = "用户分配组")
screen-api/src/main/java/com/moral/api/controller/UserController.java
@@ -41,7 +41,6 @@
    })
    @RequestMapping(value = "insert", method = RequestMethod.POST)
    public ResultMessage insert(@RequestBody User user) {
        System.out.println(user);
        if (user.getAccount().isEmpty() || user.getPassword().isEmpty()) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
screen-api/src/main/java/com/moral/api/mapper/GroupMapper.java
@@ -16,6 +16,6 @@
 */
public interface GroupMapper extends BaseMapper<Group> {
    List<Map<String, Object>> selectUserGroup(Map<String, Object> parameters);
    Map<String, Object> selectUserGroup(Integer userId);
}
screen-api/src/main/java/com/moral/api/pojo/bo/UserBO.java
@@ -20,6 +20,6 @@
    private Organization organization;
    private List<Group> groups;
    private Group group;
}
screen-api/src/main/java/com/moral/api/service/GroupService.java
@@ -31,6 +31,6 @@
    Page<Group> selectGroups(Map<String, Object> parameters);
    //获取用户组(角色)
    List<Map<String, Object>> getGroupIds(Integer userId);
    Map<String, Object> getGroup(Integer userId);
}
screen-api/src/main/java/com/moral/api/service/impl/GroupServiceImpl.java
@@ -166,9 +166,7 @@
    }
    @Override
    public List<Map<String, Object>> getGroupIds(Integer userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        return groupMapper.selectUserGroup(params);
    public Map<String, Object> getGroup(Integer userId) {
        return groupMapper.selectUserGroup(userId);
    }
}
screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java
@@ -139,14 +139,13 @@
        userInfo.put("organization", orgInfo);
        //用户组信息
        List<Map<String, Object>> groups = new ArrayList<>();
        for (Group group : userBo.getGroups()) {
            HashMap<String, Object> groupMap = new LinkedHashMap<>();
            groupMap.put("id", group.getId());
            groupMap.put("groupName", group.getGroupName());
            groups.add(groupMap);
        }
        userInfo.put("groups", groups);
        Group group = userBo.getGroup();
        HashMap<String, Object> groupMap = new LinkedHashMap<>();
        groupMap.put("id", group.getId());
        groupMap.put("groupName", group.getGroupName());
        userInfo.put("group", groupMap);
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userBo.getId());
screen-api/src/main/resources/mapper/GroupMapper.xml
@@ -12,13 +12,13 @@
        <result column="is_delete" property="isDelete"/>
    </resultMap>
    <select id="selectUserGroup" resultMap="BaseResultMap">
        SELECT g.id,g.group_name
    <select id="selectUserGroup" resultType="java.util.Map">
        SELECT g.id,g.group_name groupName
        FROM `group` g,`user_group` ug
        WHERE ug.user_id = #{userId}
        AND ug.group_id = g.id
        AND g.is_delete = 0
        AND ug.is_delete = 0
        AND g.is_delete = '0'
        AND ug.is_delete = '0'
        ORDER BY g.id
    </select>
</mapper>
screen-api/src/main/resources/mapper/UserMapper.xml
@@ -28,10 +28,10 @@
            <result column="org_expire_time" property="expireTime"/>
        </association>
        <!--用户组-->
        <collection property="groups" ofType="com.moral.api.entity.Group" javaType="java.util.ArrayList">
        <association property="group" javaType="com.moral.api.entity.Group">
            <id column="group_id" property="id" jdbcType="INTEGER"/>
            <result column="group_name" property="groupName" jdbcType="VARCHAR"/>
        </collection>
        </association>
    </resultMap>
    <!--查询用户信息,包含组织,角色-->