Search in sources :

Example 1 with TestCaseCommentsVo

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

the class CaseCommentsServiceImpl method save.

@Override
public TestCaseCommentsVo save(JSONObject json, UserVo userVo) {
    TestCaseCommentsVo vo = JSON.parseObject(JSON.toJSONString(json), TestCaseCommentsVo.class);
    TestCaseComments po = new TestCaseComments();
    if (vo.getId() != null) {
        po = (TestCaseComments) get(TestCaseComments.class, vo.getId());
    } else {
        po.setId(null);
    }
    po.setSummary(vo.getSummary());
    po.setContent(vo.getContent());
    po.setTestCaseId(vo.getTestCaseId());
    po.setUserId(userVo.getId());
    po.setChangeTime(new Date());
    saveOrUpdate(po);
    return genVo(po);
}
Also used : TestCaseComments(com.ngtesting.platform.entity.TestCaseComments) TestCaseCommentsVo(com.ngtesting.platform.vo.TestCaseCommentsVo) Date(java.util.Date)

Example 2 with TestCaseCommentsVo

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

the class CaseCommentsServiceImpl method genVo.

@Override
public TestCaseCommentsVo genVo(TestCaseComments po) {
    TestCaseCommentsVo vo = new TestCaseCommentsVo();
    BeanUtilEx.copyProperties(vo, po);
    if (vo.getUpdateTime() == null) {
        vo.setUpdateTime(vo.getCreateTime());
    }
    TestUser user = (TestUser) get(TestUser.class, po.getUserId());
    vo.setUserName(user.getName());
    vo.setUserAvatar(user.getAvatar());
    return vo;
}
Also used : TestCaseCommentsVo(com.ngtesting.platform.vo.TestCaseCommentsVo) TestUser(com.ngtesting.platform.entity.TestUser)

Example 3 with TestCaseCommentsVo

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

the class CaseCommentsAction 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);
    TestCaseCommentsVo vo = commentsService.save(json, userVo);
    ret.put("data", vo);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) TestCaseCommentsVo(com.ngtesting.platform.vo.TestCaseCommentsVo) JSONObject(com.alibaba.fastjson.JSONObject) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

TestCaseCommentsVo (com.ngtesting.platform.vo.TestCaseCommentsVo)3 JSONObject (com.alibaba.fastjson.JSONObject)1 TestCaseComments (com.ngtesting.platform.entity.TestCaseComments)1 TestUser (com.ngtesting.platform.entity.TestUser)1 AuthPassport (com.ngtesting.platform.util.AuthPassport)1 UserVo (com.ngtesting.platform.vo.UserVo)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1