Search in sources :

Example 1 with OrgVo

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

the class OrgServiceImpl method listVo.

@Override
public List<OrgVo> listVo(String keywords, String disabled, Long id) {
    List ls = list(keywords, disabled, id);
    List<OrgVo> vos = genVos(ls, id);
    return vos;
}
Also used : OrgVo(com.ngtesting.platform.vo.OrgVo) List(java.util.List) LinkedList(java.util.LinkedList)

Example 2 with OrgVo

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

the class OrgAction 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>();
    Long id = json.getLong("id");
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    if (id != null) {
        TestOrg po = (TestOrg) orgService.get(TestOrg.class, id);
        OrgVo vo = orgService.genVo(po);
        TestUser user = (TestUser) orgService.get(TestUser.class, userVo.getId());
        if (po.getId().longValue() == user.getDefaultOrgId().longValue()) {
            vo.setDefaultOrg(true);
        }
        ret.put("data", vo);
    }
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : OrgVo(com.ngtesting.platform.vo.OrgVo) UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestOrg(com.ngtesting.platform.entity.TestOrg) TestUser(com.ngtesting.platform.entity.TestUser) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with OrgVo

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

the class OrgAction method list.

@AuthPassport(validate = true)
@RequestMapping(value = "list", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> list(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    String keywords = json.getString("keywords");
    String disabled = json.getString("disabled");
    List<OrgVo> vos = orgService.listVo(keywords, disabled, userVo.getId());
    ret.put("data", vos);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : OrgVo(com.ngtesting.platform.vo.OrgVo) UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with OrgVo

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

the class OrgAction method save.

@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(HttpServletRequest request, @RequestBody OrgVo vo) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    orgService.save(vo, userVo.getId());
    List<OrgVo> vos = orgService.listVo(null, "false", userVo.getId());
    pushSettingsService.pushMyOrgs(userVo);
    ret.put("myOrgs", vos);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : OrgVo(com.ngtesting.platform.vo.OrgVo) UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with OrgVo

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

the class OrgServiceImpl method genVos.

@Override
public List<OrgVo> genVos(List<TestOrg> pos, Long userId) {
    TestUser user = (TestUser) get(TestUser.class, userId);
    List<OrgVo> voList = new LinkedList<OrgVo>();
    for (TestOrg po : pos) {
        OrgVo vo = genVo(po);
        if (po.getId().longValue() == user.getDefaultOrgId().longValue()) {
            vo.setDefaultOrg(true);
        }
        voList.add(vo);
    }
    return voList;
}
Also used : OrgVo(com.ngtesting.platform.vo.OrgVo) TestUser(com.ngtesting.platform.entity.TestUser) TestOrg(com.ngtesting.platform.entity.TestOrg) LinkedList(java.util.LinkedList)

Aggregations

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