|
|
@ -7,10 +7,13 @@ import com.bsd.cases.mapper.*;
|
|
|
|
import com.bsd.cases.model.*;
|
|
|
|
import com.bsd.cases.model.*;
|
|
|
|
import com.bsd.cases.service.CaseContentService;
|
|
|
|
import com.bsd.cases.service.CaseContentService;
|
|
|
|
import com.bsd.cases.service.CaseUsersService;
|
|
|
|
import com.bsd.cases.service.CaseUsersService;
|
|
|
|
|
|
|
|
import com.bsd.cases.util.AjaxRequest;
|
|
|
|
|
|
|
|
import com.bsd.cases.util.AjaxResult;
|
|
|
|
import com.bsd.cases.util.PageUtils;
|
|
|
|
import com.bsd.cases.util.PageUtils;
|
|
|
|
import com.bsd.cases.vo.CaseContentDetailVo;
|
|
|
|
import com.bsd.cases.vo.CaseContentDetailVo;
|
|
|
|
import com.bsd.cases.vo.CaseContentVo;
|
|
|
|
import com.bsd.cases.vo.CaseContentVo;
|
|
|
|
import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
|
import com.sun.org.apache.bcel.internal.generic.NEW;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
@ -53,6 +56,7 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getContentListByCategoryId(Long categoryId,Integer pageNum,Integer pageSize) {
|
|
|
|
public JSONObject getContentListByCategoryId(Long categoryId,Integer pageNum,Integer pageSize) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CaseCategory caseCategory = caseCategoryMapper.selectByPrimaryKey(categoryId);
|
|
|
|
CaseContent findCaseContent = new CaseContent();
|
|
|
|
CaseContent findCaseContent = new CaseContent();
|
|
|
|
findCaseContent.setState(Constants.STATE_VALID);
|
|
|
|
findCaseContent.setState(Constants.STATE_VALID);
|
|
|
|
findCaseContent.setCategoryId(categoryId);
|
|
|
|
findCaseContent.setCategoryId(categoryId);
|
|
|
@ -78,6 +82,7 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
|
|
|
|
caseContentVoList.add(caseContentVo);
|
|
|
|
caseContentVoList.add(caseContentVo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
|
jsonObject.put("url",caseCategory.getUrl());
|
|
|
|
jsonObject.put("list",caseContentVoList);
|
|
|
|
jsonObject.put("list",caseContentVoList);
|
|
|
|
jsonObject.put("total",pageJson.getInteger("total"));
|
|
|
|
jsonObject.put("total",pageJson.getInteger("total"));
|
|
|
|
jsonObject.put("pageNum",pageNum);
|
|
|
|
jsonObject.put("pageNum",pageNum);
|
|
|
@ -157,4 +162,103 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return caseContentDetailVo;
|
|
|
|
return caseContentDetailVo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 更新或者新增文章
|
|
|
|
|
|
|
|
* @param jsonObject
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public AjaxResult saveContent(JSONObject jsonObject) {
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
|
|
|
String contentTitle = jsonObject.getString("contentTitle");
|
|
|
|
|
|
|
|
String url = jsonObject.getString("url");
|
|
|
|
|
|
|
|
String content = jsonObject.getString("content");
|
|
|
|
|
|
|
|
Long categoryId = jsonObject.getLong("categoryId");
|
|
|
|
|
|
|
|
Long contentId = jsonObject.getLong("contentId");
|
|
|
|
|
|
|
|
if (null == contentId){
|
|
|
|
|
|
|
|
//新增
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(contentTitle)){
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("文章标题不可以为空");
|
|
|
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("文章预览图地址不可以为空");
|
|
|
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(content)){
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("文章正文不可以为空");
|
|
|
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null == categoryId){
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("文章类别id不可以为空");
|
|
|
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CaseContent caseContent = new CaseContent();
|
|
|
|
|
|
|
|
caseContent.setContentTitle(contentTitle);
|
|
|
|
|
|
|
|
caseContent.setCategoryId(categoryId);
|
|
|
|
|
|
|
|
caseContent.setContent(content);
|
|
|
|
|
|
|
|
caseContent.setUrl(url);
|
|
|
|
|
|
|
|
caseContent.setUpdateDateTime(new Date());
|
|
|
|
|
|
|
|
caseContentMapper.insert(caseContent);
|
|
|
|
|
|
|
|
//插入统计
|
|
|
|
|
|
|
|
CaseContentStatical caseContentStatical = new CaseContentStatical();
|
|
|
|
|
|
|
|
caseContentStatical.setContentId(caseContent.getId());
|
|
|
|
|
|
|
|
caseContentStatical.setLikeNum(0);
|
|
|
|
|
|
|
|
caseContentStatical.setViewNum(0);
|
|
|
|
|
|
|
|
caseContentStatical.setCommentsNum(0);
|
|
|
|
|
|
|
|
caseContentStatical.setScore(0.0);
|
|
|
|
|
|
|
|
caseContentStatical.setCreateDateTime(new Date());
|
|
|
|
|
|
|
|
caseContentStatical.setUpdateDateTime(new Date());
|
|
|
|
|
|
|
|
caseContentStatical.setState(Constants.STATE_VALID);
|
|
|
|
|
|
|
|
caseContentStaticalMapper.insert(caseContentStatical);
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("文章新增成功");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//更新
|
|
|
|
|
|
|
|
CaseContent caseContent = caseContentMapper.selectByPrimaryKey(contentId);
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(contentTitle)){
|
|
|
|
|
|
|
|
caseContent.setContentTitle(contentTitle);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(url)){
|
|
|
|
|
|
|
|
caseContent.setUrl(url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(content)){
|
|
|
|
|
|
|
|
caseContent.setContent(content);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null != categoryId){
|
|
|
|
|
|
|
|
caseContent.setCategoryId(categoryId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
caseContent.setUpdateDateTime(new Date());
|
|
|
|
|
|
|
|
caseContentMapper.updateByPrimaryKeySelective(caseContent);
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("文章更新成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 删除文章
|
|
|
|
|
|
|
|
* @param contentId
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public AjaxResult delContent(Long contentId) {
|
|
|
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
|
|
|
CaseContent caseContent = caseContentMapper.selectByPrimaryKey(contentId);
|
|
|
|
|
|
|
|
if (caseContent.getState() == Constants.STATE_INVALID){
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("文章已删除,不可重复操作");
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
caseContent.setState(Constants.STATE_INVALID);
|
|
|
|
|
|
|
|
caseContent.setUpdateDateTime(new Date());
|
|
|
|
|
|
|
|
caseContentMapper.updateByPrimaryKeySelective(caseContent);
|
|
|
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
|
|
|
|
|
|
|
ajaxResult.setRetmsg("成功删除文章");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|