Compare commits

..

No commits in common. 'a9e44bf6afe55e2248c8b27d65e84da90ff28515' and '2ea2957ea5b858ff81169d4a2264422101d6900a' have entirely different histories.

@ -13,7 +13,7 @@ public class CaseContent extends BaseEntity {
private String url;
private byte[] content;
private String content;
private Long categoryId;
}

@ -9,13 +9,12 @@ import com.bsd.cases.vo.CaseContentDetailBakVo;
import com.bsd.cases.vo.CaseContentDetailVo;
import com.bsd.cases.vo.CaseContentVo;
import java.io.UnsupportedEncodingException;
import java.util.List;
public interface CaseContentService<CaseContent> extends BaseService<CaseContent> {
JSONObject getContentListByCategoryId(Long categoryId, Integer pageNum, Integer pageSize);
CaseContentDetailVo getContentDetailByContentId(Long contentId) throws UnsupportedEncodingException;
CaseContentDetailVo getContentDetailByContentId(Long contentId);
AjaxResult saveContent(JSONObject jsonObject);
@ -31,5 +30,5 @@ public interface CaseContentService<CaseContent> extends BaseService<CaseContent
*/
PageAjax<CaseContentBakVo> searchBakContentByParam(String name, Long level1, Long level2, Long level3, Integer pageNum);
CaseContentDetailBakVo getCaseContentDetailBakVoByContentID(Long contentId) throws UnsupportedEncodingException;
CaseContentDetailBakVo getCaseContentDetailBakVoByContentID(Long contentId);
}

@ -7,6 +7,7 @@ import com.bsd.cases.mapper.*;
import com.bsd.cases.model.*;
import com.bsd.cases.service.CaseContentService;
import com.bsd.cases.service.CaseUsersService;
import com.bsd.cases.util.AjaxRequest;
import com.bsd.cases.util.AjaxResult;
import com.bsd.cases.util.PageAjax;
import com.bsd.cases.util.PageUtils;
@ -15,12 +16,12 @@ import com.bsd.cases.vo.CaseContentDetailBakVo;
import com.bsd.cases.vo.CaseContentDetailVo;
import com.bsd.cases.vo.CaseContentVo;
import com.github.pagehelper.PageHelper;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -51,25 +52,24 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
/**
*
*
* @param categoryId
* @param pageNum
* @param pageSize
* @return
*/
@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();
findCaseContent.setState(Constants.STATE_VALID);
findCaseContent.setCategoryId(categoryId);
List<CaseContent> caseContentList = caseContentMapper.select(findCaseContent);
JSONObject pageJson = PageUtils.page(caseContentList, pageNum, pageSize);
JSONObject pageJson = PageUtils.page(caseContentList,pageNum,pageSize);
JSONArray jsonArray = pageJson.getJSONArray("list");
caseContentList = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), CaseContent.class);
List<CaseContentVo> caseContentVoList = new ArrayList<>();
for (CaseContent caseContent : caseContentList) {
for (CaseContent caseContent:caseContentList){
CaseContentVo caseContentVo = new CaseContentVo();
CaseContentStatical findCaseContentStatical = new CaseContentStatical();
findCaseContentStatical.setState(Constants.STATE_VALID);
@ -86,23 +86,22 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
caseContentVoList.add(caseContentVo);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("url", caseCategory.getUrl());
jsonObject.put("list", caseContentVoList);
jsonObject.put("total", pageJson.getInteger("total"));
jsonObject.put("pageNum", pageNum);
jsonObject.put("pageSize", pageSize);
jsonObject.put("pages", (int) Math.ceil(Double.valueOf(pageJson.getInteger("total")) / Double.valueOf(pageSize)));
jsonObject.put("url",caseCategory.getUrl());
jsonObject.put("list",caseContentVoList);
jsonObject.put("total",pageJson.getInteger("total"));
jsonObject.put("pageNum",pageNum);
jsonObject.put("pageSize",pageSize);
jsonObject.put("pages",(int) Math.ceil(Double.valueOf(pageJson.getInteger("total")) / Double.valueOf(pageSize)));
return jsonObject;
}
/**
*
*
* @param contentId
* @return
*/
@Override
public CaseContentDetailVo getContentDetailByContentId(Long contentId) throws UnsupportedEncodingException {
public CaseContentDetailVo getContentDetailByContentId(Long contentId) {
CaseUsers caseUsers = caseUsersService.currentUser();
CaseContentView newCaseContentView = new CaseContentView();
@ -131,8 +130,7 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
CaseContent caseContent = caseContentMapper.selectByPrimaryKey(contentId);
CaseContentDetailVo caseContentDetailVo = new CaseContentDetailVo();
caseContentDetailVo.setId(contentId);
String content = new String(caseContent.getContent(), "utf8");
caseContentDetailVo.setContent(content);
caseContentDetailVo.setContent(caseContent.getContent());
caseContentDetailVo.setCategoryId(caseContent.getCategoryId());
CaseCategory caseCategory = caseCategoryMapper.selectByPrimaryKey(caseContent.getCategoryId());
caseContentDetailVo.setCategoryName(caseCategory.getName());
@ -154,7 +152,7 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
findCaseContentLike.setState(Constants.STATE_VALID);
findCaseContentLike.setCreateBy(caseUsers.getId());
CaseContentLike caseContentLike = caseContentLikeMapper.selectOne(findCaseContentLike);
if (null != caseContentLike) {
if (null!=caseContentLike){
caseContentDetailVo.setIsLike(true);
}
//判断是否已评分过
@ -163,7 +161,7 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
findCaseContentScore.setState(Constants.STATE_VALID);
findCaseContentScore.setCreateBy(caseUsers.getId());
CaseContentScore caseContentScore = caseContentScoreMapper.selectOne(findCaseContentScore);
if (null != caseContentScore) {
if (null!=caseContentScore){
caseContentDetailVo.setIsScore(true);
}
return caseContentDetailVo;
@ -171,7 +169,6 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
/**
*
*
* @param jsonObject
* @return
*/
@ -186,24 +183,24 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
JSONArray contentAttachmentJson = jsonObject.getJSONArray("contentAttachmentJson");
JSONArray contentMaterialJson = jsonObject.getJSONArray("contentMaterialJson");
if (null == contentId) {
if (null == contentId){
//新增
if (StringUtils.isBlank(contentTitle)) {
if (StringUtils.isBlank(contentTitle)){
ajaxResult.setRetcode(AjaxResult.FAILED);
ajaxResult.setRetmsg("文章标题不可以为空");
return ajaxResult;
}
if (StringUtils.isBlank(url)) {
if (StringUtils.isBlank(url)){
ajaxResult.setRetcode(AjaxResult.FAILED);
ajaxResult.setRetmsg("文章预览图地址不可以为空");
return ajaxResult;
}
if (StringUtils.isBlank(content)) {
if (StringUtils.isBlank(content)){
ajaxResult.setRetcode(AjaxResult.FAILED);
ajaxResult.setRetmsg("文章正文不可以为空");
return ajaxResult;
}
if (null == categoryId) {
if (null == categoryId){
ajaxResult.setRetcode(AjaxResult.FAILED);
ajaxResult.setRetmsg("文章类别id不可以为空");
return ajaxResult;
@ -211,7 +208,7 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
CaseContent caseContent = new CaseContent();
caseContent.setContentTitle(contentTitle);
caseContent.setCategoryId(categoryId);
caseContent.setContent(content.getBytes());
caseContent.setContent(content);
caseContent.setUrl(url);
caseContent.setCreateDateTime(new Date());
caseContent.setUpdateDateTime(new Date());
@ -230,40 +227,40 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
caseContentStaticalMapper.insert(caseContentStatical);
ajaxResult.setRetmsg("文章新增成功");
} else {
}else {
//更新
CaseContent caseContent = caseContentMapper.selectByPrimaryKey(contentId);
if (StringUtils.isNotEmpty(contentTitle)) {
if (StringUtils.isNotEmpty(contentTitle)){
caseContent.setContentTitle(contentTitle);
}
if (StringUtils.isNotEmpty(url)) {
if (StringUtils.isNotEmpty(url)){
caseContent.setUrl(url);
}
if (StringUtils.isNotEmpty(content)) {
caseContent.setContent(content.getBytes());
if (StringUtils.isNotEmpty(content)){
caseContent.setContent(content);
}
if (null != categoryId) {
if (null != categoryId){
caseContent.setCategoryId(categoryId);
}
caseContent.setUpdateDateTime(new Date());
caseContentMapper.updateByPrimaryKeySelective(caseContent);
if (contentMaterialJson != null && contentAttachmentJson.size() > 0) {
if (contentMaterialJson !=null && contentAttachmentJson.size()>0){
CaseContentMaterial findCaseContentMaterial = new CaseContentMaterial();
findCaseContentMaterial.setContentId(contentId);
findCaseContentMaterial.setState(Constants.STATE_VALID);
List<CaseContentMaterial> caseContentMaterialList = caseContentMaterialMapper.select(findCaseContentMaterial);
for (CaseContentMaterial caseContentMaterial : caseContentMaterialList) {
for (CaseContentMaterial caseContentMaterial:caseContentMaterialList){
caseContentMaterial.setState(Constants.STATE_INVALID);
caseContentMaterial.setUpdateDateTime(new Date());
caseContentMaterialMapper.updateByPrimaryKeySelective(caseContentMaterial);
}
}
if (contentAttachmentJson != null && contentAttachmentJson.size() > 0) {
if (contentAttachmentJson !=null && contentAttachmentJson.size()>0 ){
CaseContentAttachment findCaseContentAttachment = new CaseContentAttachment();
findCaseContentAttachment.setContentId(contentId);
findCaseContentAttachment.setState(Constants.STATE_VALID);
List<CaseContentAttachment> caseContentAttachmentList = caseContentAttachmentMapper.select(findCaseContentAttachment);
for (CaseContentAttachment caseContentAttachment : caseContentAttachmentList) {
for (CaseContentAttachment caseContentAttachment:caseContentAttachmentList){
caseContentAttachment.setState(Constants.STATE_INVALID);
caseContentAttachment.setUpdateDateTime(new Date());
caseContentAttachmentMapper.updateByPrimaryKeySelective(caseContentAttachment);
@ -272,9 +269,9 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
ajaxResult.setRetmsg("文章更新成功");
}
if (contentMaterialJson != null && contentAttachmentJson.size() > 0) {
if (contentMaterialJson !=null && contentAttachmentJson.size()>0){
List<CaseContentMaterial> caseContentMaterialList = new ArrayList<>();
for (int i = 0; i < contentMaterialJson.size(); i++) {
for (int i = 0;i<contentMaterialJson.size();i++){
CaseContentMaterial caseContentMaterial = new CaseContentMaterial();
caseContentMaterial.setContentId(contentId);
JSONObject materialJson = contentMaterialJson.getJSONObject(i);
@ -292,12 +289,12 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
caseContentMaterialMapper.insertList(caseContentMaterialList);
}
if (contentAttachmentJson != null && contentAttachmentJson.size() > 0) {
if (contentAttachmentJson !=null && contentAttachmentJson.size()>0 ){
List<CaseContentAttachment> caseContentAttachmentList = new ArrayList<>();
for (int i = 0; i < contentAttachmentJson.size(); i++) {
for (int i = 0;i<contentAttachmentJson.size(); i++ ){
CaseContentAttachment caseContentAttachment = new CaseContentAttachment();
caseContentAttachment.setContentId(contentId);
JSONObject attachmentJson = contentAttachmentJson.getJSONObject(i);
JSONObject attachmentJson =contentAttachmentJson.getJSONObject(i);
String attachmentUrl = attachmentJson.getString("attachmentUrl");
caseContentAttachment.setAttachmentUrl(attachmentUrl);
String size = attachmentJson.getString("size");
@ -320,7 +317,6 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
/**
*
*
* @param contentId
* @return
*/
@ -328,10 +324,10 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
public AjaxResult delContent(Long contentId) {
AjaxResult ajaxResult = new AjaxResult();
CaseContent caseContent = caseContentMapper.selectByPrimaryKey(contentId);
if (caseContent.getState() == Constants.STATE_INVALID) {
if (caseContent.getState() == Constants.STATE_INVALID){
ajaxResult.setRetmsg("文章已删除,不可重复操作");
ajaxResult.setRetcode(AjaxResult.FAILED);
} else {
}else {
caseContent.setState(Constants.STATE_INVALID);
caseContent.setUpdateDateTime(new Date());
caseContentMapper.updateByPrimaryKeySelective(caseContent);
@ -342,22 +338,21 @@ public class CaseContentServiceImpl extends BaseServiceImpl<CaseContentMapper, C
}
@Override
public PageAjax<CaseContentBakVo> searchBakContentByParam(String name, Long level1, Long level2, Long level3, Integer pageNum) {
public PageAjax<CaseContentBakVo> searchBakContentByParam(String name, Long level1, Long level2, Long level3,Integer pageNum) {
PageHelper.startPage(pageNum, Constants.PAGE_SIZE);
List<CaseContentBakVo> caseContentBakVoList = caseContentMapper.searchBak(name, level1, level2, level3);
List<CaseContentBakVo> caseContentBakVoList = caseContentMapper.searchBak(name,level1,level2,level3);
PageAjax<CaseContentBakVo> pageAjax = new PageAjax<>(caseContentBakVoList);
return pageAjax;
}
@Override
public CaseContentDetailBakVo getCaseContentDetailBakVoByContentID(Long contentId) throws UnsupportedEncodingException {
public CaseContentDetailBakVo getCaseContentDetailBakVoByContentID(Long contentId) {
CaseContent caseContent = caseContentMapper.selectByPrimaryKey(contentId);
CaseContentDetailBakVo caseContentDetailBakVo = new CaseContentDetailBakVo();
caseContentDetailBakVo.setId(contentId);
caseContentDetailBakVo.setCategoryId(caseContent.getCategoryId());
String content = new String(caseContent.getContent(), "UTF-8");
caseContentDetailBakVo.setContentStr(content);
caseContentDetailBakVo.setContent(caseContent.getContent());
caseContentDetailBakVo.setContentTitle(caseContent.getContentTitle());
caseContentDetailBakVo.setUrl(caseContent.getUrl());
caseContentDetailBakVo.setState(caseContent.getState());

@ -10,8 +10,6 @@ import java.util.List;
@Data
public class CaseContentDetailBakVo extends CaseContent {
private String contentStr;
private List<CaseContentMaterial> caseContentMaterialList;
private List<CaseContentAttachment> caseContentAttachmentList;

Loading…
Cancel
Save