Search in sources :

Example 1 with ProjectRoleVo

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

the class ProjectRoleServiceImpl method list.

@Override
public List list(Long orgId, String keywords, String disabled) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestProjectRoleForOrg.class);
    dc.add(Restrictions.eq("orgId", orgId));
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    if (StringUtil.isNotEmpty(keywords)) {
        dc.add(Restrictions.like("name", "%" + keywords + "%"));
    }
    if (StringUtil.isNotEmpty(disabled)) {
        dc.add(Restrictions.eq("disabled", Boolean.valueOf(disabled)));
    }
    dc.addOrder(Order.asc("id"));
    List ls = findAllByCriteria(dc);
    List<ProjectRoleVo> vos = this.genVos(ls);
    return vos;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) List(java.util.List) LinkedList(java.util.LinkedList) ProjectRoleVo(com.ngtesting.platform.vo.ProjectRoleVo)

Example 2 with ProjectRoleVo

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

the class ProjectRoleServiceImpl method genVos.

// @Override
// public TestProjectRoleForOrg createDefaultBasicDataPers(Long orgId) {
// List<TestProjectPrivilegeDefine> allProjectPrivileges =
// projectPrivilegeService.listAllProjectPrivileges();
// 
// DetachedCriteria dc = DetachedCriteria.forClass(TestProjectRoleForOrg.class);
// dc.add(Restrictions.eq("isBuildIn", true));
// dc.add(Restrictions.eq("disabled", Boolean.FALSE));
// dc.add(Restrictions.eq("deleted", Boolean.FALSE));
// 
// dc.addOrder(Order.asc("id"));
// List<TestProjectRoleForOrg> ls = findAllByCriteria(dc);
// 
// TestProjectRoleForOrg defaultRole = null;
// String sql = "";
// for (TestProjectRoleForOrg p : ls) {
// TestProjectRoleForOrg temp = new TestProjectRoleForOrg();
// BeanUtilEx.copyProperties(temp, p);
// temp.setId(null);
// temp.setOrgId(orgId);
// temp.setBuildIn(false);
// saveOrUpdate(temp);
// 
// if ("test_leader".equals(temp.getCode())) {
// defaultRole = temp;
// sql += projectRolePriviledgeRelationService.addPriviledgeForLeaderPers(allProjectPrivileges, temp.getId());
// } else if ("test_designer".equals(temp.getCode())) {
// sql += projectRolePriviledgeRelationService.addPriviledgeForDesignerPers(allProjectPrivileges, temp.getId());
// } else if ("tester".equals(temp.getCode())) {
// sql += projectRolePriviledgeRelationService.addPriviledgeForTesterPers(allProjectPrivileges, temp.getId());
// }
// }
// getDao().querySql(sql);
// return defaultRole;
// }
@Override
public List<ProjectRoleVo> genVos(List<TestProjectRoleForOrg> pos) {
    List<ProjectRoleVo> vos = new LinkedList<ProjectRoleVo>();
    for (TestProjectRoleForOrg po : pos) {
        ProjectRoleVo vo = genVo(po);
        vos.add(vo);
    }
    return vos;
}
Also used : TestProjectRoleForOrg(com.ngtesting.platform.entity.TestProjectRoleForOrg) ProjectRoleVo(com.ngtesting.platform.vo.ProjectRoleVo) LinkedList(java.util.LinkedList)

Example 3 with ProjectRoleVo

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

the class ProjectRoleAction 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();
    ProjectRoleVo projectRoleVo = JSON.parseObject(JSON.toJSONString(json.get("projectRole")), ProjectRoleVo.class);
    TestProjectRoleForOrg po = projectRoleService.save(projectRoleVo, orgId);
    Map<String, List<ProjectPrivilegeDefineVo>> projectPrivileges = (Map<String, List<ProjectPrivilegeDefineVo>>) json.get("projectPrivileges");
    int i = 0;
    boolean success = projectPrivilegeService.saveProjectPrivileges(po.getId(), projectPrivileges);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : HashMap(java.util.HashMap) ProjectPrivilegeDefineVo(com.ngtesting.platform.vo.ProjectPrivilegeDefineVo) ProjectRoleVo(com.ngtesting.platform.vo.ProjectRoleVo) UserVo(com.ngtesting.platform.vo.UserVo) TestProjectRoleForOrg(com.ngtesting.platform.entity.TestProjectRoleForOrg) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with ProjectRoleVo

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

the class ProjectRoleAction 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);
    Long orgId = userVo.getDefaultOrgId();
    String keywords = json.getString("keywords");
    String disabled = json.getString("disabled");
    List<ProjectRoleVo> vos = projectRoleService.list(orgId, keywords, disabled);
    ret.put("data", vos);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) ProjectRoleVo(com.ngtesting.platform.vo.ProjectRoleVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with ProjectRoleVo

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

the class ProjectRoleAction method get.

@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject req) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Long orgId = userVo.getDefaultOrgId();
    Long roleId = req.getLong("id");
    Map<String, List<ProjectPrivilegeDefineVo>> orgPrivileges = projectPrivilegeService.listPrivilegesByOrgAndProjectRole(orgId, roleId);
    if (roleId == null) {
        ret.put("projectRole", new ProjectRoleVo());
        ret.put("projectPrivileges", orgPrivileges);
        ret.put("code", Constant.RespCode.SUCCESS.getCode());
        return ret;
    }
    TestProjectRoleForOrg po = (TestProjectRoleForOrg) projectRoleService.get(TestProjectRoleForOrg.class, roleId);
    ProjectRoleVo vo = projectRoleService.genVo(po);
    ret.put("projectRole", vo);
    ret.put("projectPrivileges", orgPrivileges);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) TestProjectRoleForOrg(com.ngtesting.platform.entity.TestProjectRoleForOrg) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) ProjectRoleVo(com.ngtesting.platform.vo.ProjectRoleVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ProjectRoleVo (com.ngtesting.platform.vo.ProjectRoleVo)6 JSONObject (com.alibaba.fastjson.JSONObject)3 TestProjectRoleForOrg (com.ngtesting.platform.entity.TestProjectRoleForOrg)3 AuthPassport (com.ngtesting.platform.util.AuthPassport)3 UserVo (com.ngtesting.platform.vo.UserVo)3 HashMap (java.util.HashMap)3 List (java.util.List)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 LinkedList (java.util.LinkedList)2 ProjectPrivilegeDefineVo (com.ngtesting.platform.vo.ProjectPrivilegeDefineVo)1 Map (java.util.Map)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1