attachment

master
ck 5 years ago
parent 2a96ff4b67
commit c729748faa

@ -1,10 +1,13 @@
package com.bsd.cases.service; package com.bsd.cases.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bsd.cases.util.AjaxResult;
import java.util.List; import java.util.List;
public interface CaseContentCommentsService<CaseContentComments> extends BaseService<CaseContentComments> { public interface CaseContentCommentsService<CaseContentComments> extends BaseService<CaseContentComments> {
JSONObject getCaseContentCommentsByContentId(Long contentId, Integer pageNum, Integer pageSize); JSONObject getCaseContentCommentsByContentId(Long contentId, Integer pageNum, Integer pageSize);
AjaxResult addComments(Long contentId,String comments);
} }

@ -3,8 +3,11 @@ package com.bsd.cases.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bsd.cases.constants.Constants; import com.bsd.cases.constants.Constants;
import com.bsd.cases.mapper.CaseContentCommentsMapper; import com.bsd.cases.mapper.CaseContentCommentsMapper;
import com.bsd.cases.mapper.CaseContentStaticalMapper;
import com.bsd.cases.model.CaseContentComments; import com.bsd.cases.model.CaseContentComments;
import com.bsd.cases.model.CaseContentStatical;
import com.bsd.cases.service.CaseContentCommentsService; import com.bsd.cases.service.CaseContentCommentsService;
import com.bsd.cases.util.AjaxResult;
import com.bsd.cases.util.PageUtils; import com.bsd.cases.util.PageUtils;
import com.bsd.cases.vo.CaseContentCommentsVo; import com.bsd.cases.vo.CaseContentCommentsVo;
import com.sun.org.apache.bcel.internal.generic.NEW; import com.sun.org.apache.bcel.internal.generic.NEW;
@ -13,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.yaml.snakeyaml.scanner.Constant; import org.yaml.snakeyaml.scanner.Constant;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
import java.util.List; import java.util.List;
@Service("caseContentCommentsService") @Service("caseContentCommentsService")
@ -21,6 +25,8 @@ public class CaseContentCommentsServiceImpl extends BaseServiceImpl<CaseContentC
implements CaseContentCommentsService<CaseContentComments> { implements CaseContentCommentsService<CaseContentComments> {
@Resource @Resource
private CaseContentCommentsMapper caseContentCommentsMapper; private CaseContentCommentsMapper caseContentCommentsMapper;
@Resource
private CaseContentStaticalMapper caseContentStaticalMapper;
/** /**
@ -39,4 +45,36 @@ public class CaseContentCommentsServiceImpl extends BaseServiceImpl<CaseContentC
JSONObject jsonObject = PageUtils.page(caseContentCommentsList,pageNum,pageSize); JSONObject jsonObject = PageUtils.page(caseContentCommentsList,pageNum,pageSize);
return jsonObject; return jsonObject;
} }
/**
*
* @param contentId
* @return
*/
@Override
public AjaxResult addComments(Long contentId,String comments) {
CaseContentComments caseContentComments = new CaseContentComments();
caseContentComments.setContentId(contentId);
caseContentComments.setState(Constants.STATE_VALID);
caseContentComments.setComments(comments);
caseContentComments.setCreateDateTime(new Date());
caseContentComments.setUpdateDateTime(new Date());
//插人的信息
caseContentCommentsMapper.insert(caseContentComments);
//更新统计
CaseContentStatical findCaseContentStatical = new CaseContentStatical();
findCaseContentStatical.setState(Constants.STATE_VALID);
findCaseContentStatical.setContentId(contentId);
CaseContentStatical caseContentStatical = caseContentStaticalMapper.selectOne(findCaseContentStatical);
CaseContentComments findCaseContentComments = new CaseContentComments();
findCaseContentComments.setState(Constants.STATE_VALID);
findCaseContentComments.setContentId(contentId);
Integer num = caseContentCommentsMapper.selectCount(findCaseContentComments);
caseContentStatical.setCommentsNum(num);
caseContentStatical.setUpdateDateTime(new Date());
caseContentStaticalMapper.updateByPrimaryKeySelective(caseContentStatical);
return null;
}
} }

Loading…
Cancel
Save