Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/com/bsd/cases/service/CaseUsersService.javamaster
commit
b434d6a811
@ -0,0 +1,49 @@
|
|||||||
|
package com.bsd.cases.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bsd.cases.service.CaseContentAttachmentService;
|
||||||
|
import com.bsd.cases.util.AjaxRequest;
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/case-content-attachment")
|
||||||
|
public class CaseContentAttachmentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseContentAttachmentService caseContentAttachmentService;
|
||||||
|
|
||||||
|
@RequestMapping("/get-attachment-by-content-id")
|
||||||
|
public AjaxResult getCaseContentAttachment(@RequestBody AjaxRequest ajaxRequest, HttpServletRequest request) {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
JSONObject data = ajaxRequest.getData();
|
||||||
|
if (null == data){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("data missing");
|
||||||
|
}else {
|
||||||
|
Integer pageNum = data.getInteger("pageNum");
|
||||||
|
Integer pageSize = data.getInteger("pageSize");
|
||||||
|
if (null==pageNum|| null == pageSize){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("分页参数不可为空");
|
||||||
|
}else {
|
||||||
|
Long contentId = data.getLong("contentId");
|
||||||
|
if (null == contentId){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("文章id不可为空");
|
||||||
|
}else {
|
||||||
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
||||||
|
ajaxResult.setData(caseContentAttachmentService.getCaseContentAttachment(contentId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package com.bsd.cases.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bsd.cases.service.CaseContentCommentsService;
|
||||||
|
import com.bsd.cases.util.AjaxRequest;
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/case-content-comments")
|
||||||
|
public class CaseContentCommentsController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseContentCommentsService caseContentCommentsService;
|
||||||
|
|
||||||
|
@RequestMapping("/get-comments-by-content-id")
|
||||||
|
public AjaxResult getCaseContentCommentsByContentId(@RequestBody AjaxRequest ajaxRequest, HttpServletRequest request) {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
JSONObject data = ajaxRequest.getData();
|
||||||
|
if (null == data){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("data missing");
|
||||||
|
}else {
|
||||||
|
Integer pageNum = data.getInteger("pageNum");
|
||||||
|
Integer pageSize = data.getInteger("pageSize");
|
||||||
|
if (null==pageNum|| null == pageSize){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("分页参数不可为空");
|
||||||
|
}else {
|
||||||
|
Long contentId = data.getLong("contentId");
|
||||||
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
||||||
|
ajaxResult.setData(caseContentCommentsService.getCaseContentCommentsByContentId(contentId,pageNum,pageSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
package com.bsd.cases.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bsd.cases.service.CaseContentScoreService;
|
||||||
|
import com.bsd.cases.util.AjaxRequest;
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/case-content-score")
|
||||||
|
public class CaseContentScoreController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseContentScoreService caseContentScoreService;
|
||||||
|
|
||||||
|
@RequestMapping("/add-score")
|
||||||
|
public AjaxResult addScore(@RequestBody AjaxRequest ajaxRequest, HttpServletRequest request) {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
JSONObject data = ajaxRequest.getData();
|
||||||
|
if (null == data){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("data missing");
|
||||||
|
}else {
|
||||||
|
Long contentId = data.getLong("contentId");
|
||||||
|
Double score = data.getDouble("score");
|
||||||
|
if (null==contentId){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("文章id不可为空");
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
if (null == score){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("评分不可为空");
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
ajaxResult = caseContentScoreService.addScore(contentId,score);
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.bsd.cases.mapper;
|
||||||
|
|
||||||
|
import com.bsd.cases.model.CaseContentScore;
|
||||||
|
import com.bsd.cases.util.CommonMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CaseContentScoreMapper extends CommonMapper<CaseContentScore> {
|
||||||
|
Double getAverageScore(@Param("contentId")Long contentId);
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.bsd.cases.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("case_content_score")
|
||||||
|
public class CaseContentScore extends BaseEntity{
|
||||||
|
|
||||||
|
private Long contentId;
|
||||||
|
|
||||||
|
private Double score;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.bsd.cases.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("case_store")
|
||||||
|
public class CaseStore extends BaseEntity{
|
||||||
|
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
private String companyCode;
|
||||||
|
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
|
private String storeId;
|
||||||
|
|
||||||
|
private String storeName;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.bsd.cases.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("case_users")
|
||||||
|
public class CaseUsers extends BaseEntity{
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
private String userNo;
|
||||||
|
|
||||||
|
private String openId;
|
||||||
|
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
private String userImage;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
private String companyCode;
|
||||||
|
|
||||||
|
private String companyName;
|
||||||
|
|
||||||
|
private Long storeId;
|
||||||
|
|
||||||
|
private String storeCode;
|
||||||
|
|
||||||
|
private String storeName;
|
||||||
|
|
||||||
|
private Integer role;
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.bsd.cases.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("case_company")
|
||||||
|
public class case_company extends BaseEntity{
|
||||||
|
|
||||||
|
private Integer areaId;
|
||||||
|
|
||||||
|
private String companyId;
|
||||||
|
|
||||||
|
private String companyName;
|
||||||
|
}
|
||||||
@ -1,4 +1,7 @@
|
|||||||
package com.bsd.cases.service;
|
package com.bsd.cases.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface CaseContentAttachmentService<CaseContentAttachment> extends BaseService<CaseContentAttachment> {
|
public interface CaseContentAttachmentService<CaseContentAttachment> extends BaseService<CaseContentAttachment> {
|
||||||
|
List<CaseContentAttachment> getCaseContentAttachment(Long contentId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,13 @@
|
|||||||
package com.bsd.cases.service;
|
package com.bsd.cases.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
AjaxResult addComments(Long contentId,String comments);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.bsd.cases.service;
|
||||||
|
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
|
||||||
|
public interface CaseContentScoreService<CaseContentScore> extends BaseService<CaseContentScore> {
|
||||||
|
|
||||||
|
AjaxResult addScore(Long contentId, Double score);
|
||||||
|
}
|
||||||
@ -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.vo.CaseContentDetailVo;
|
||||||
import com.bsd.cases.vo.CaseContentVo;
|
import com.bsd.cases.vo.CaseContentVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface CaseContentService<CaseContent> extends BaseService<CaseContent> {
|
public interface CaseContentService<CaseContent> extends BaseService<CaseContent> {
|
||||||
JSONObject getContentListByCategoryId(Long categoryId, Integer pageNum, Integer pageSize);
|
JSONObject getContentListByCategoryId(Long categoryId, Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
CaseContentDetailVo getContentDetailByContentId(Long contentId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,29 @@
|
|||||||
package com.bsd.cases.service.impl;
|
package com.bsd.cases.service.impl;
|
||||||
|
|
||||||
|
import com.bsd.cases.constants.Constants;
|
||||||
import com.bsd.cases.mapper.CaseContentAttachmentMapper;
|
import com.bsd.cases.mapper.CaseContentAttachmentMapper;
|
||||||
import com.bsd.cases.model.CaseContentAttachment;
|
import com.bsd.cases.model.CaseContentAttachment;
|
||||||
import com.bsd.cases.service.CaseContentAttachmentService;
|
import com.bsd.cases.service.CaseContentAttachmentService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service("caseContentAttachmentService")
|
@Service("caseContentAttachmentService")
|
||||||
@Transactional
|
@Transactional
|
||||||
public class CaseContentAttachmentServiceImpl extends BaseServiceImpl<CaseContentAttachmentMapper, CaseContentAttachment>
|
public class CaseContentAttachmentServiceImpl extends BaseServiceImpl<CaseContentAttachmentMapper, CaseContentAttachment>
|
||||||
implements CaseContentAttachmentService<CaseContentAttachment> {
|
implements CaseContentAttachmentService<CaseContentAttachment> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseContentAttachmentMapper caseContentAttachmentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CaseContentAttachment> getCaseContentAttachment(Long contentId) {
|
||||||
|
CaseContentAttachment findCaseContentAttachment = new CaseContentAttachment();
|
||||||
|
findCaseContentAttachment.setContentId(contentId);
|
||||||
|
findCaseContentAttachment.setState(Constants.STATE_VALID);
|
||||||
|
List<CaseContentAttachment> caseContentAttachmentList = caseContentAttachmentMapper.select(findCaseContentAttachment);
|
||||||
|
return caseContentAttachmentList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,80 @@
|
|||||||
package com.bsd.cases.service.impl;
|
package com.bsd.cases.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
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.vo.CaseContentCommentsVo;
|
||||||
|
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.yaml.snakeyaml.scanner.Constant;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service("caseContentCommentsService")
|
@Service("caseContentCommentsService")
|
||||||
@Transactional
|
@Transactional
|
||||||
public class CaseContentCommentsServiceImpl extends BaseServiceImpl<CaseContentCommentsMapper, CaseContentComments>
|
public class CaseContentCommentsServiceImpl extends BaseServiceImpl<CaseContentCommentsMapper, CaseContentComments>
|
||||||
implements CaseContentCommentsService<CaseContentComments> {
|
implements CaseContentCommentsService<CaseContentComments> {
|
||||||
|
@Resource
|
||||||
|
private CaseContentCommentsMapper caseContentCommentsMapper;
|
||||||
|
@Resource
|
||||||
|
private CaseContentStaticalMapper caseContentStaticalMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过文章id查询文章评论
|
||||||
|
* @param contentId
|
||||||
|
* @param pageNum
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public JSONObject getCaseContentCommentsByContentId(Long contentId, Integer pageNum, Integer pageSize) {
|
||||||
|
CaseContentComments findCaseContentComments = new CaseContentComments();
|
||||||
|
findCaseContentComments.setState(Constants.STATE_VALID);
|
||||||
|
findCaseContentComments.setContentId(contentId);
|
||||||
|
List<CaseContentComments> caseContentCommentsList = caseContentCommentsMapper.select(findCaseContentComments);
|
||||||
|
JSONObject jsonObject = PageUtils.page(caseContentCommentsList,pageNum,pageSize);
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,73 @@
|
|||||||
|
package com.bsd.cases.service.impl;
|
||||||
|
|
||||||
|
import com.bsd.cases.constants.Constants;
|
||||||
|
import com.bsd.cases.mapper.CaseContentMapper;
|
||||||
|
import com.bsd.cases.mapper.CaseContentScoreMapper;
|
||||||
|
import com.bsd.cases.mapper.CaseContentStaticalMapper;
|
||||||
|
import com.bsd.cases.model.CaseContent;
|
||||||
|
import com.bsd.cases.model.CaseContentScore;
|
||||||
|
import com.bsd.cases.model.CaseContentStatical;
|
||||||
|
import com.bsd.cases.service.CaseContentScoreService;
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
import org.apache.ibatis.annotations.Case;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Service("caseContentScoreService")
|
||||||
|
@Transactional
|
||||||
|
public class CaseContentScoreServiceImpl extends BaseServiceImpl<CaseContentScoreMapper, CaseContentScore>
|
||||||
|
implements CaseContentScoreService<CaseContentScore> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseContentScoreMapper caseContentScoreMapper;
|
||||||
|
@Resource
|
||||||
|
private CaseContentMapper caseContentMapper;
|
||||||
|
@Resource
|
||||||
|
private CaseContentStaticalMapper caseContentStaticalMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评分
|
||||||
|
* @param contentId
|
||||||
|
* @param score
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult addScore(Long contentId, Double score) {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
CaseContent findCaseContent = new CaseContent();
|
||||||
|
findCaseContent.setState(Constants.STATE_VALID);
|
||||||
|
findCaseContent.setId(contentId);
|
||||||
|
CaseContent caseContent = caseContentMapper.selectOne(findCaseContent);
|
||||||
|
if (null == caseContent){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("未找到该文章");
|
||||||
|
}else {
|
||||||
|
if (score>5||score<0){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("评分不可大于5或小于0");
|
||||||
|
}else {
|
||||||
|
CaseContentScore caseContentScore = new CaseContentScore();
|
||||||
|
caseContentScore.setScore(score);
|
||||||
|
caseContentScore.setContentId(contentId);
|
||||||
|
caseContentScore.setCreateDateTime(new Date());
|
||||||
|
caseContentScore.setUpdateDateTime(new Date());
|
||||||
|
//set 人
|
||||||
|
caseContentScore.setState(Constants.STATE_VALID);
|
||||||
|
caseContentScoreMapper.insert(caseContentScore);
|
||||||
|
Double averageScore = caseContentScoreMapper.getAverageScore(contentId);
|
||||||
|
CaseContentStatical findCaseContentStatical = new CaseContentStatical();
|
||||||
|
findCaseContentStatical.setState(Constants.STATE_VALID);
|
||||||
|
findCaseContentStatical.setContentId(contentId);
|
||||||
|
CaseContentStatical caseContentStatical = caseContentStaticalMapper.selectOne(findCaseContentStatical);
|
||||||
|
caseContentStatical.setScore(averageScore);
|
||||||
|
caseContentStatical.setUpdateDateTime(new Date());
|
||||||
|
caseContentStaticalMapper.updateByPrimaryKeySelective(caseContentStatical);
|
||||||
|
ajaxResult.setRetmsg("已成功评分");
|
||||||
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.bsd.cases.vo;
|
||||||
|
|
||||||
|
import com.bsd.cases.model.CaseContentComments;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CaseContentCommentsVo extends CaseContentComments {
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.bsd.cases.vo;
|
||||||
|
|
||||||
|
import com.bsd.cases.model.CaseContentAttachment;
|
||||||
|
import com.bsd.cases.model.CaseContentMaterial;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CaseContentDetailVo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String contentTitle;
|
||||||
|
|
||||||
|
private Double score;
|
||||||
|
//二级
|
||||||
|
private Long categoryId;
|
||||||
|
//二级
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
private List<CaseContentMaterial> caseContentMaterialList;
|
||||||
|
|
||||||
|
// private List<CaseContentAttachment> caseContentAttachmentList;
|
||||||
|
|
||||||
|
private Boolean isLike = false;
|
||||||
|
|
||||||
|
private Boolean isScore = false;
|
||||||
|
|
||||||
|
private Integer commentsNum;
|
||||||
|
|
||||||
|
private Integer likeNum;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bsd.cases.mapper.CaseContentScoreMapper">
|
||||||
|
<select id="getAverageScore" resultType="Double">
|
||||||
|
SELECT round(AVG(score),1)as score FROM `case_content_score` where content_id = #{contentId};
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue