Search in sources :

Example 1 with TestProjectVo

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

the class ProjectServiceImpl method genGroupVos.

@Override
public List<TestProjectVo> genGroupVos(List<TestProject> pos) {
    List<TestProjectVo> voList = new LinkedList<TestProjectVo>();
    for (TestProject po : pos) {
        TestProjectVo vo = genVo(po);
        voList.add(vo);
    }
    return voList;
}
Also used : TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) TestProject(com.ngtesting.platform.entity.TestProject) LinkedList(java.util.LinkedList)

Example 2 with TestProjectVo

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

the class CustomFieldServiceImpl method saveRelationsProjects.

@Override
public boolean saveRelationsProjects(Long fieldId, List<TestProjectVo> projects) {
    if (projects == null) {
        return false;
    }
    TestCustomField field = (TestCustomField) get(TestCustomField.class, fieldId);
    Set<TestProject> projectSet = field.getProjectSet();
    for (Object obj : projects) {
        TestProjectVo vo = JSON.parseObject(JSON.toJSONString(obj), TestProjectVo.class);
        if (vo.getSelecting() != vo.getSelected()) {
            // 变化了
            TestProject project = (TestProject) get(TestProject.class, vo.getId());
            if (vo.getSelecting() && !projectSet.contains(project)) {
                // 勾选
                projectSet.add(project);
            } else if (project != null) {
                // 取消
                projectSet.remove(project);
            }
        }
    }
    saveOrUpdate(field);
    return true;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) TestCustomField(com.ngtesting.platform.entity.TestCustomField)

Example 3 with TestProjectVo

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

the class CustomFieldAction 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();
    CustomFieldVo customField = JSON.parseObject(JSON.toJSONString(json.get("model")), CustomFieldVo.class);
    List<TestProjectVo> projects = (List<TestProjectVo>) json.get("relations");
    TestCustomField po = customFieldService.save(customField, orgId);
    boolean success = customFieldService.saveRelationsProjects(po.getId(), projects);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) CustomFieldVo(com.ngtesting.platform.vo.CustomFieldVo) TestCustomField(com.ngtesting.platform.entity.TestCustomField) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with TestProjectVo

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

the class CustomFieldAction 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 customFieldId = json.getLong("id");
    CustomFieldVo vo;
    if (customFieldId == null) {
        vo = new CustomFieldVo();
        vo.setMyColumn(customFieldService.getLastUnusedColumn(orgId));
        vo.setCode(UUID.randomUUID().toString());
    } else {
        TestCustomField po = (TestCustomField) customFieldService.get(TestCustomField.class, customFieldId);
        vo = customFieldService.genVo(po);
    }
    if (vo.getMyColumn() == null) {
        ret.put("code", Constant.RespCode.BIZ_FAIL.getCode());
        ret.put("msg", "自定义字段不能超过20个");
    }
    List<String> applyToList = customFieldService.listApplyTo();
    List<String> typeList = customFieldService.listType();
    List<String> formatList = customFieldService.listFormat();
    List<TestProjectVo> projectList = customFieldService.listProjectsForField(orgId, customFieldId);
    ret.put("data", vo);
    ret.put("applyToList", applyToList);
    ret.put("typeList", typeList);
    ret.put("formatList", formatList);
    ret.put("projects", projectList);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) TestProjectVo(com.ngtesting.platform.vo.TestProjectVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) CustomFieldVo(com.ngtesting.platform.vo.CustomFieldVo) TestCustomField(com.ngtesting.platform.entity.TestCustomField) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with TestProjectVo

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

the class ProjectServiceImpl method genVo.

@Override
public TestProjectVo genVo(TestProject po) {
    if (po == null) {
        return null;
    }
    TestProjectVo vo = new TestProjectVo();
    BeanUtilEx.copyProperties(vo, po);
    if (po.getParentId() == null) {
        vo.setParentId(null);
    }
    return vo;
}
Also used : TestProjectVo(com.ngtesting.platform.vo.TestProjectVo)

Aggregations

TestProjectVo (com.ngtesting.platform.vo.TestProjectVo)9 TestProject (com.ngtesting.platform.entity.TestProject)6 TestCustomField (com.ngtesting.platform.entity.TestCustomField)4 LinkedList (java.util.LinkedList)3 JSONObject (com.alibaba.fastjson.JSONObject)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 CustomFieldVo (com.ngtesting.platform.vo.CustomFieldVo)2 UserVo (com.ngtesting.platform.vo.UserVo)2 HashMap (java.util.HashMap)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 TestUser (com.ngtesting.platform.entity.TestUser)1 List (java.util.List)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1