Search in sources :

Example 1 with RelationOrgGroupUserVo

use of com.ngtesting.platform.vo.RelationOrgGroupUserVo in project ngtesting-platform by aaronchen2k.

the class RelationOrgGroupUserServiceImpl method genVo.

private RelationOrgGroupUserVo genVo(Long orgId, Long orgGroupId, Long userId) {
    RelationOrgGroupUserVo vo = new RelationOrgGroupUserVo();
    vo.setOrgId(orgId);
    if (orgGroupId != null) {
        TestOrgGroup orgGroup = (TestOrgGroup) get(TestOrgGroup.class, orgGroupId);
        vo.setOrgGroupId(orgGroupId);
        vo.setOrgGroupName(orgGroup.getName());
    }
    if (userId != null) {
        TestUser user = (TestUser) get(TestUser.class, userId);
        vo.setUserId(user.getId());
        vo.setUserName(user.getName());
    }
    return vo;
}
Also used : TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) TestUser(com.ngtesting.platform.entity.TestUser)

Example 2 with RelationOrgGroupUserVo

use of com.ngtesting.platform.vo.RelationOrgGroupUserVo in project ngtesting-platform by aaronchen2k.

the class RelationOrgGroupUserServiceImpl method listRelationsByGroup.

@Override
public List<RelationOrgGroupUserVo> listRelationsByGroup(Long orgId, Long orgGroupId) {
    List<TestUser> allUsers = listAllOrgUsers(orgId);
    List<TestRelationOrgGroupUser> relations;
    if (orgGroupId == null) {
        relations = new LinkedList<>();
    } else {
        relations = listRelations(orgId, orgGroupId, null);
    }
    List<RelationOrgGroupUserVo> vos = new LinkedList<>();
    for (TestUser user : allUsers) {
        RelationOrgGroupUserVo vo = genVo(orgId, orgGroupId, user.getId());
        vo.setSelected(false);
        vo.setSelecting(false);
        for (TestRelationOrgGroupUser po : relations) {
            if (po.getUserId().longValue() == user.getId().longValue() && po.getOrgGroupId().longValue() == orgGroupId.longValue()) {
                vo.setSelected(true);
                vo.setSelecting(true);
            }
        }
        vos.add(vo);
    }
    return vos;
}
Also used : TestRelationOrgGroupUser(com.ngtesting.platform.entity.TestRelationOrgGroupUser) TestUser(com.ngtesting.platform.entity.TestUser) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) LinkedList(java.util.LinkedList)

Example 3 with RelationOrgGroupUserVo

use of com.ngtesting.platform.vo.RelationOrgGroupUserVo in project ngtesting-platform by aaronchen2k.

the class RelationOrgGroupUserServiceImpl method listRelationsByUser.

@Override
public List<RelationOrgGroupUserVo> listRelationsByUser(Long orgId, Long userId) {
    List<TestOrgGroup> allOrgGroups = listAllOrgGroups(orgId);
    List<TestRelationOrgGroupUser> relations;
    if (userId == null) {
        relations = new LinkedList<>();
    } else {
        relations = listRelations(orgId, null, userId);
    }
    List<RelationOrgGroupUserVo> vos = new LinkedList<>();
    for (TestOrgGroup orgGroup : allOrgGroups) {
        RelationOrgGroupUserVo vo = genVo(orgId, orgGroup.getId(), userId);
        vo.setSelected(false);
        vo.setSelecting(false);
        for (TestRelationOrgGroupUser po : relations) {
            if (po.getOrgGroupId() == orgGroup.getId() && po.getUserId() == userId) {
                vo.setSelected(true);
                vo.setSelecting(true);
            }
        }
        vos.add(vo);
    }
    return vos;
}
Also used : TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) TestRelationOrgGroupUser(com.ngtesting.platform.entity.TestRelationOrgGroupUser) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) LinkedList(java.util.LinkedList)

Example 4 with RelationOrgGroupUserVo

use of com.ngtesting.platform.vo.RelationOrgGroupUserVo in project ngtesting-platform by aaronchen2k.

the class OrgGroupAction method get.

@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Long orgId = userVo.getDefaultOrgId();
    Long orgGroupId = json.getLong("id");
    List<RelationOrgGroupUserVo> relations = orgGroupUserService.listRelationsByGroup(orgId, orgGroupId);
    if (orgGroupId == null) {
        ret.put("group", new OrgGroupVo());
        ret.put("relations", relations);
        ret.put("code", Constant.RespCode.SUCCESS.getCode());
        return ret;
    }
    TestOrgGroup po = (TestOrgGroup) orgGroupService.get(TestOrgGroup.class, Long.valueOf(orgGroupId));
    OrgGroupVo group = orgGroupService.genVo(po);
    ret.put("group", group);
    ret.put("relations", relations);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) HashMap(java.util.HashMap) OrgGroupVo(com.ngtesting.platform.vo.OrgGroupVo) JSONObject(com.alibaba.fastjson.JSONObject) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with RelationOrgGroupUserVo

use of com.ngtesting.platform.vo.RelationOrgGroupUserVo in project ngtesting-platform by aaronchen2k.

the class OrgGroupAction method save.

@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Long orgId = userVo.getDefaultOrgId();
    OrgGroupVo group = JSON.parseObject(JSON.toJSONString(json.get("group")), OrgGroupVo.class);
    ;
    List<RelationOrgGroupUserVo> relations = (List<RelationOrgGroupUserVo>) json.get("relations");
    TestOrgGroup po = orgGroupService.save(group, orgId);
    boolean success = orgGroupUserService.saveRelations(relations);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) HashMap(java.util.HashMap) OrgGroupVo(com.ngtesting.platform.vo.OrgGroupVo) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RelationOrgGroupUserVo (com.ngtesting.platform.vo.RelationOrgGroupUserVo)6 TestOrgGroup (com.ngtesting.platform.entity.TestOrgGroup)4 TestRelationOrgGroupUser (com.ngtesting.platform.entity.TestRelationOrgGroupUser)3 JSONObject (com.alibaba.fastjson.JSONObject)2 TestUser (com.ngtesting.platform.entity.TestUser)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 OrgGroupVo (com.ngtesting.platform.vo.OrgGroupVo)2 UserVo (com.ngtesting.platform.vo.UserVo)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 List (java.util.List)1