Search in sources :

Example 1 with CustomFieldVo

use of com.ngtesting.platform.vo.CustomFieldVo 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 2 with CustomFieldVo

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

the class CustomFieldAction 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();
    List<CustomFieldVo> vos = customFieldService.listVos(orgId);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    ret.put("data", vos);
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) CustomFieldVo(com.ngtesting.platform.vo.CustomFieldVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with CustomFieldVo

use of com.ngtesting.platform.vo.CustomFieldVo 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 4 with CustomFieldVo

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

the class CustomFieldAction method changeOrder.

@AuthPassport(validate = true)
@RequestMapping(value = "changeOrder", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> changeOrder(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 id = json.getLong("id");
    String act = json.getString("act");
    boolean success = customFieldService.changeOrderPers(id, act);
    List<CustomFieldVo> vos = customFieldService.listVos(orgId);
    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) CustomFieldVo(com.ngtesting.platform.vo.CustomFieldVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with CustomFieldVo

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

the class CustomFieldServiceImpl method listForCaseByProject.

@Override
public List<CustomFieldVo> listForCaseByProject(Long orgId, Long projectId) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestCustomField.class);
    dc.createAlias("projectSet", "p").add(Restrictions.eq("p.id", projectId));
    dc.add(Restrictions.eq("applyTo", FieldApplyTo.test_case));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.addOrder(Order.asc("ordr"));
    List<TestCustomField> ls1 = findAllByCriteria(dc);
    DetachedCriteria dc2 = DetachedCriteria.forClass(TestCustomField.class);
    dc2.add(Restrictions.eq("orgId", orgId));
    dc2.add(Restrictions.eq("global", true));
    dc2.add(Restrictions.eq("applyTo", FieldApplyTo.test_case));
    dc2.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc2.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc2.addOrder(Order.asc("ordr"));
    List<TestCustomField> ls2 = findAllByCriteria(dc2);
    ls2.addAll(ls1);
    List<CustomFieldVo> vos = genVos(ls2);
    return vos;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) TestCustomField(com.ngtesting.platform.entity.TestCustomField) CustomFieldVo(com.ngtesting.platform.vo.CustomFieldVo)

Aggregations

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