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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations