Search in sources :

Example 1 with TestCaseStep

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

the class CaseStepServiceImpl method changeOrderPers.

@Override
public TestCaseStep changeOrderPers(JSONObject vo, String direction, Long userId) {
    TestCaseStep po = (TestCaseStep) get(TestCaseStep.class, vo.getLong("id"));
    String hql = "from TestCaseStep st where st.deleted = false and st.disabled = false " + " and testCaseId = ?";
    if ("up".equals(direction)) {
        hql += " and st.ordr < ? order by ordr desc";
    } else if ("down".equals(direction)) {
        hql += " and st.ordr > ? order by ordr asc";
    }
    TestCaseStep neighbor = (TestCaseStep) getDao().findFirstByHQL(hql, vo.getLong("caseId"), vo.getInteger("ordr"));
    TestCaseStep step = (TestCaseStep) get(TestCaseStep.class, vo.getLong("id"));
    Integer order = step.getOrdr();
    step.setOrdr(neighbor.getOrdr());
    neighbor.setOrdr(order);
    saveOrUpdate(step);
    saveOrUpdate(neighbor);
    return po;
}
Also used : TestCaseStep(com.ngtesting.platform.entity.TestCaseStep)

Example 2 with TestCaseStep

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

the class CaseStepServiceImpl method createSampleStep.

@Override
public void createSampleStep(Long caseId) {
    TestCaseStep step = new TestCaseStep(caseId, "步骤", "期待结果", 1);
    step.setTestCaseId(caseId);
    saveOrUpdate(step);
}
Also used : TestCaseStep(com.ngtesting.platform.entity.TestCaseStep)

Example 3 with TestCaseStep

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

the class CaseStepServiceImpl method delete.

@Override
public boolean delete(Long stepId, Long userId) {
    TestCaseStep step = (TestCaseStep) get(TestCaseStep.class, stepId);
    step.setDeleted(true);
    saveOrUpdate(step);
    moveOthersPers(step.getTestCaseId(), step.getOrdr(), "up");
    return true;
}
Also used : TestCaseStep(com.ngtesting.platform.entity.TestCaseStep)

Example 4 with TestCaseStep

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

the class CaseStepAction method up.

@AuthPassport(validate = true)
@RequestMapping(value = "up", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> up(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    TestCaseStep po = caseStepService.changeOrderPers(json, "up", userVo.getId());
    TestCaseStepVo stepVo = caseStepService.genVo(po);
    ret.put("data", stepVo);
    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) TestCaseStep(com.ngtesting.platform.entity.TestCaseStep) TestCaseStepVo(com.ngtesting.platform.vo.TestCaseStepVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with TestCaseStep

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

the class CaseStepAction method down.

@AuthPassport(validate = true)
@RequestMapping(value = "down", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> down(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    TestCaseStep po = caseStepService.changeOrderPers(json, "down", userVo.getId());
    TestCaseStepVo stepVo = caseStepService.genVo(po);
    ret.put("data", stepVo);
    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) TestCaseStep(com.ngtesting.platform.entity.TestCaseStep) TestCaseStepVo(com.ngtesting.platform.vo.TestCaseStepVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

TestCaseStep (com.ngtesting.platform.entity.TestCaseStep)7 TestCaseStepVo (com.ngtesting.platform.vo.TestCaseStepVo)4 JSONObject (com.alibaba.fastjson.JSONObject)3 AuthPassport (com.ngtesting.platform.util.AuthPassport)3 UserVo (com.ngtesting.platform.vo.UserVo)3 HashMap (java.util.HashMap)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3