Search in sources :

Example 6 with TestCaseType

use of com.ngtesting.platform.entity.TestCaseType in project ngtesting-platform by aaronchen2k.

the class CaseTypeAction 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();
    CaseTypeVo vo = json.getObject("model", CaseTypeVo.class);
    TestCaseType po = caseTypeService.save(vo, orgId);
    CaseTypeVo projectVo = caseTypeService.genVo(po);
    Map<String, Map<String, String>> casePropertyMap = casePropertyService.getMap(orgId);
    ret.put("casePropertyMap", casePropertyMap);
    ret.put("data", projectVo);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) CaseTypeVo(com.ngtesting.platform.vo.CaseTypeVo) HashMap(java.util.HashMap) TestCaseType(com.ngtesting.platform.entity.TestCaseType) JSONObject(com.alibaba.fastjson.JSONObject) 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 7 with TestCaseType

use of com.ngtesting.platform.entity.TestCaseType in project ngtesting-platform by aaronchen2k.

the class CaseTypeServiceImpl method genVos.

@Override
public List<CaseTypeVo> genVos(List<TestCaseType> pos) {
    List<CaseTypeVo> vos = new LinkedList<CaseTypeVo>();
    for (TestCaseType po : pos) {
        CaseTypeVo vo = genVo(po);
        vos.add(vo);
    }
    return vos;
}
Also used : CaseTypeVo(com.ngtesting.platform.vo.CaseTypeVo) TestCaseType(com.ngtesting.platform.entity.TestCaseType) LinkedList(java.util.LinkedList)

Example 8 with TestCaseType

use of com.ngtesting.platform.entity.TestCaseType in project ngtesting-platform by aaronchen2k.

the class CaseTypeServiceImpl method save.

@Override
public TestCaseType save(CaseTypeVo vo, Long orgId) {
    if (vo == null) {
        return null;
    }
    TestCaseType po;
    if (vo.getId() != null) {
        po = (TestCaseType) get(TestCaseType.class, vo.getId());
    } else {
        po = new TestCaseType();
    }
    BeanUtilEx.copyProperties(po, vo);
    po.setOrgId(orgId);
    if (vo.getId() == null) {
        po.setCode(UUID.randomUUID().toString());
        String hql = "select max(displayOrder) from TestCaseType tp where tp.orgId=?";
        Integer maxOrder = (Integer) getByHQL(hql, orgId);
        po.setDisplayOrder(maxOrder + 10);
    }
    saveOrUpdate(po);
    return po;
}
Also used : TestCaseType(com.ngtesting.platform.entity.TestCaseType)

Aggregations

TestCaseType (com.ngtesting.platform.entity.TestCaseType)8 CaseTypeVo (com.ngtesting.platform.vo.CaseTypeVo)3 JSONObject (com.alibaba.fastjson.JSONObject)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)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 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1