Commit 4e477fc5 by 魏文甫

update

1 parent 7de195cb
...@@ -7,7 +7,11 @@ import java.util.Map; ...@@ -7,7 +7,11 @@ import java.util.Map;
* Created by weiwenfu@163.com on 2020/3/12 下午 2:58. * Created by weiwenfu@163.com on 2020/3/12 下午 2:58.
*/ */
public interface CommentMapper { public interface CommentMapper {
List<Map<String,Object>> commentList(Long courseId, int i, Integer pageSize); List<Map<String, Object>> commentList(Map<String, Object> param);
Integer commentListTotal(Long courseId); Integer commentListTotal(Map<String, Object> param);
List<Map<String, Object>> informationCommentList(Map<String, Object> param);
Integer informationCommentListTotal(Map<String, Object> param);
} }
package com.server.web.common.service.Impl; package com.server.web.common.service.Impl;
import com.server.utils.ResultMapUtil;
import com.server.web.common.mapper.TBaseSecondClassMapper; import com.server.web.common.mapper.TBaseSecondClassMapper;
import com.server.web.common.mapper.TKzyCommentMapper;
import com.server.web.common.mapper.TKzyInformationMapper; import com.server.web.common.mapper.TKzyInformationMapper;
import com.server.web.common.mapping.CommentMapper;
import com.server.web.common.mapping.InformationMapper; import com.server.web.common.mapping.InformationMapper;
import com.server.web.common.model.TBaseSecondClass; import com.server.web.common.model.TBaseSecondClass;
import com.server.web.common.model.TBaseSecondClassExample; import com.server.web.common.model.TBaseSecondClassExample;
import com.server.web.common.model.TKzyComment;
import com.server.web.common.model.TKzyInformation; import com.server.web.common.model.TKzyInformation;
import com.server.web.common.service.InformationService; import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.server.utils.ResultMapUtil.returnMap;
/** /**
* Created by weiwenfu@163.com on 2020/3/12 下午 4:54. * Created by weiwenfu@163.com on 2020/3/12 下午 4:54.
*/ */
...@@ -26,13 +31,17 @@ public class InformationServiceImpl implements InformationService { ...@@ -26,13 +31,17 @@ public class InformationServiceImpl implements InformationService {
private TKzyInformationMapper tKzyInformationMapper; private TKzyInformationMapper tKzyInformationMapper;
@Autowired @Autowired
private TBaseSecondClassMapper tBaseSecondClassMapper; private TBaseSecondClassMapper tBaseSecondClassMapper;
@Autowired
private CommentMapper commentMapper;
@Autowired
private TKzyCommentMapper tKzyCommentMapper;
@Override @Override
public Map<String, Object> secondClassList(Long firstId) { public Map<String, Object> secondClassList(Long firstId) {
TBaseSecondClassExample tBaseSecondClassExample = new TBaseSecondClassExample(); TBaseSecondClassExample tBaseSecondClassExample = new TBaseSecondClassExample();
tBaseSecondClassExample.createCriteria().andFirstIdEqualTo(firstId).andStatusEqualTo(1); tBaseSecondClassExample.createCriteria().andFirstIdEqualTo(firstId).andStatusEqualTo(1);
List<TBaseSecondClass> list = tBaseSecondClassMapper.selectByExample(tBaseSecondClassExample); List<TBaseSecondClass> list = tBaseSecondClassMapper.selectByExample(tBaseSecondClassExample);
return ResultMapUtil.returnMap("1", "", list); return returnMap("1", "", list);
} }
/** /**
...@@ -54,7 +63,7 @@ public class InformationServiceImpl implements InformationService { ...@@ -54,7 +63,7 @@ public class InformationServiceImpl implements InformationService {
} else { } else {
list = informationMapper.secondClassDetailCourse(param); list = informationMapper.secondClassDetailCourse(param);
} }
return ResultMapUtil.returnMap("1", "", list); return returnMap("1", "", list);
} }
/** /**
...@@ -66,6 +75,46 @@ public class InformationServiceImpl implements InformationService { ...@@ -66,6 +75,46 @@ public class InformationServiceImpl implements InformationService {
@Override @Override
public Map<String, Object> informationDetail(Long informationId) { public Map<String, Object> informationDetail(Long informationId) {
TKzyInformation tKzyInformation = tKzyInformationMapper.selectByPrimaryKey(informationId); TKzyInformation tKzyInformation = tKzyInformationMapper.selectByPrimaryKey(informationId);
return ResultMapUtil.returnMap("1", "", tKzyInformation); return returnMap("1", "", tKzyInformation);
}
@Override
public Map<String, Object> informationCommentList(Long informationId, Integer pageNo, Integer pageSize) {
Map<String, Object> param = new HashMap<>();
param.put("informationId", informationId);
param.put("start", (pageNo - 1) * pageSize);
param.put("pageSize", pageSize);
List<Map<String, Object>> list = commentMapper.informationCommentList(param);
Integer count = commentMapper.informationCommentListTotal(param);
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("list", list);
dataMap.put("count", count);
return returnMap("1", "", dataMap);
}
@Override
public Map<String, Object> informationComment(Long informationId, Long userId, String comment) {
if (informationId == null || informationId <= 0l) {
return returnMap("0", "参数有误!", null);
}
TKzyInformation tKzyInformation = tKzyInformationMapper.selectByPrimaryKey(informationId);
if (tKzyInformation == null) {
return returnMap("0", "未查到该数据信息!", null);
}
if (userId == null || userId <= 0l) {
return returnMap("0", "请先登录!", null);
}
if (comment == null) {
return returnMap("0", "评论内容不能为空~", null);
}
TKzyComment tKzyCourseComment = new TKzyComment();
tKzyCourseComment.setCreateDt(new Date());
tKzyCourseComment.setUserId(userId);
tKzyCourseComment.setRelationId(informationId);
tKzyCourseComment.setIsDelete(0);
tKzyCourseComment.setReplyContent(comment);
tKzyCourseComment.setType(1);
tKzyCommentMapper.insertSelective(tKzyCourseComment);
return returnMap("1", "操作成功!", null);
} }
} }
...@@ -193,20 +193,15 @@ public class TKzyCourseServiceImpl implements TKzyCourseService { ...@@ -193,20 +193,15 @@ public class TKzyCourseServiceImpl implements TKzyCourseService {
resultMap.put("status", "1"); resultMap.put("status", "1");
resultMap.put("message", ""); resultMap.put("message", "");
Map<String, Object> dataMap = new HashMap<>(); Map<String, Object> dataMap = new HashMap<>();
if (courseId != null) { Map<String, Object> param = new HashMap<>();
if (pageNo == null || pageNo <= 0l) { param.put("courseId", courseId);
pageNo = 1; param.put("start", (pageNo - 1) * pageSize);
} param.put("pageSize", pageSize);
if (pageSize == null || pageSize <= 0l) { List<Map<String, Object>> list = commentMapper.commentList(param);
pageSize = 20; Integer count = commentMapper.commentListTotal(param);
} dataMap.put("list", list);
dataMap.put("count", count);
List<Map<String, Object>> list = commentMapper.commentList(courseId, (pageNo - 1) * pageSize, pageSize); resultMap.put("data", dataMap);
Integer count = commentMapper.commentListTotal(courseId);
dataMap.put("list", list);
dataMap.put("count", count);
resultMap.put("data", dataMap);
}
return resultMap; return resultMap;
} }
...@@ -272,6 +267,7 @@ public class TKzyCourseServiceImpl implements TKzyCourseService { ...@@ -272,6 +267,7 @@ public class TKzyCourseServiceImpl implements TKzyCourseService {
tKzyCourseComment.setRelationId(courseId); tKzyCourseComment.setRelationId(courseId);
tKzyCourseComment.setIsDelete(0); tKzyCourseComment.setIsDelete(0);
tKzyCourseComment.setReplyContent(comment); tKzyCourseComment.setReplyContent(comment);
tKzyCourseComment.setType(2);
tKzyCommentMapper.insertSelective(tKzyCourseComment); tKzyCommentMapper.insertSelective(tKzyCourseComment);
resultMap.put("message", "评论成功~"); resultMap.put("message", "评论成功~");
resultMap.put("status", "1"); resultMap.put("status", "1");
......
...@@ -6,9 +6,13 @@ import java.util.Map; ...@@ -6,9 +6,13 @@ import java.util.Map;
* Created by weiwenfu@163.com on 2020/3/12 下午 4:53. * Created by weiwenfu@163.com on 2020/3/12 下午 4:53.
*/ */
public interface InformationService { public interface InformationService {
Map<String,Object> secondClassList(Long firstId); Map<String, Object> secondClassList(Long firstId);
Map<String,Object> secondClassDetail(Long secondId, Integer pageNo, Integer pageSize); Map<String, Object> secondClassDetail(Long secondId, Integer pageNo, Integer pageSize);
Map<String,Object> informationDetail(Long informationId); Map<String, Object> informationDetail(Long informationId);
Map<String, Object> informationCommentList(Long informationId, Integer pageNo, Integer pageSize);
Map<String, Object> informationComment(Long informationId, Long userId, String comment);
} }
...@@ -25,7 +25,7 @@ import java.util.Map; ...@@ -25,7 +25,7 @@ import java.util.Map;
@RestController @RestController
@RequestMapping(BaseController.WX_NAMESPACE + "/course") @RequestMapping(BaseController.WX_NAMESPACE + "/course")
@ControllerAdvice @ControllerAdvice
public class CourseController extends BaseController{ public class CourseController extends BaseController {
@Autowired @Autowired
private TKzyCourseService tKzyCourseService; private TKzyCourseService tKzyCourseService;
...@@ -41,118 +41,127 @@ public class CourseController extends BaseController{ ...@@ -41,118 +41,127 @@ public class CourseController extends BaseController{
/** /**
* 热门课程 * 热门课程
*
* @return * @return
*/ */
@RequestMapping("/hotCourse") @RequestMapping("/hotCourse")
public Map<String,Object> hotCourse(){ public Map<String, Object> hotCourse() {
return tKzyCourseService.hotCourse(); return tKzyCourseService.hotCourse();
} }
/** /**
* 录播课列表 * 录播课列表
*
* @return * @return
*/ */
@RequestMapping("/recordCourse") @RequestMapping("/recordCourse")
public Map<String,Object> recordCourse(@RequestParam(value = "typeId",required = false) Long typeId, @RequestParam(value = "pageNo",required = false) Integer pageNo, @RequestParam(value = "pageSize",required = false) Integer pageSize){ public Map<String, Object> recordCourse(@RequestParam(value = "typeId", required = false) Long typeId, @RequestParam(value = "pageNo", required = false) Integer pageNo, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
return tKzyCourseService.recordCourse(typeId,pageNo,pageSize); return tKzyCourseService.recordCourse(typeId, pageNo, pageSize);
} }
/** /**
* 直播课列表(全查) * 直播课列表(全查)
*
* @return * @return
*/ */
@RequestMapping("/livingCourse") @RequestMapping("/livingCourse")
public Map<String,Object> livingCourse(){ public Map<String, Object> livingCourse() {
return tKzyCourseService.livingCourse(); return tKzyCourseService.livingCourse();
} }
/** /**
* 直播课详情页 * 直播课详情页
*
* @return * @return
*/ */
@RequestMapping("/livingCourseDetail") @RequestMapping("/livingCourseDetail")
public Map<String,Object> livingCourseDetail(HttpServletRequest request,@RequestParam(value = "courseId",required = true) Long courseId){ public Map<String, Object> livingCourseDetail(HttpServletRequest request, @RequestParam(value = "courseId", required = true) Long courseId) {
TKzyUser tKzyUser = getLoginUser(request); TKzyUser tKzyUser = getLoginUser(request);
Long userId = null; Long userId = null;
if(tKzyUser!=null){ if (tKzyUser != null) {
userId = tKzyUser.getId(); userId = tKzyUser.getId();
} }
return tKzyCourseService.livingCourseDetail(courseId,userId); return tKzyCourseService.livingCourseDetail(courseId, userId);
} }
/** /**
* 录播课详情页 * 录播课详情页
*
* @return * @return
*/ */
@RequestMapping("/recordCourseDetail") @RequestMapping("/recordCourseDetail")
public Map<String,Object> recordCourseDetail(HttpServletRequest request,@RequestParam(value = "courseId",required = true) Long courseId){ public Map<String, Object> recordCourseDetail(HttpServletRequest request, @RequestParam(value = "courseId", required = true) Long courseId) {
TKzyUser tKzyUser = getLoginUser(request); TKzyUser tKzyUser = getLoginUser(request);
Long userId = null; Long userId = null;
if(tKzyUser!=null){ if (tKzyUser != null) {
userId = tKzyUser.getId(); userId = tKzyUser.getId();
} }
return tKzyCourseService.recordCourseDetail(courseId,userId); return tKzyCourseService.recordCourseDetail(courseId, userId);
} }
/** /**
* 评论列表 * 评论列表
*
* @param courseId * @param courseId
* @return * @return
*/ */
@RequestMapping("/commentList") @RequestMapping("/commentList")
public Map<String,Object> commentList(@RequestParam(value = "courseId",required = true) Long courseId,@RequestParam(value = "pageNo",required = false) Integer pageNo, @RequestParam(value = "pageSize",required = false) Integer pageSize){ public Map<String, Object> commentList(@RequestParam(value = "courseId") Long courseId, @RequestParam(value = "pageNo", required = false) Integer pageNo, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
return tKzyCourseService.commentList(courseId,pageNo,pageSize); return tKzyCourseService.commentList(courseId, pageNo, pageSize);
} }
/** /**
* 提交评论 * 提交评论
*
* @param courseId * @param courseId
* @param comment * @param comment
* @return * @return
*/ */
@RequestMapping("/comment") @RequestMapping("/comment")
public Map<String,Object> comment(HttpServletRequest request,@RequestParam(value = "courseId",required = true) Long courseId, @RequestParam(value = "comment",required = true) String comment){ public Map<String, Object> comment(HttpServletRequest request, @RequestParam(value = "courseId") Long courseId, @RequestParam(value = "comment") String comment) {
TKzyUser tKzyUser = getLoginUser(request); TKzyUser tKzyUser = getLoginUser(request);
Long userId = null; Long userId = null;
if(tKzyUser!=null){ if (tKzyUser != null) {
userId = tKzyUser.getId(); userId = tKzyUser.getId();
} }
return tKzyCourseService.comment(courseId,userId,comment); return tKzyCourseService.comment(courseId, userId, comment);
} }
/** /**
* 课程分类 * 课程分类
*
* @return * @return
*/ */
@RequestMapping("/courseType") @RequestMapping("/courseType")
public Map<String,Object> courseType(){ public Map<String, Object> courseType() {
return tKzyCourseService.courseType(); return tKzyCourseService.courseType();
} }
/** /**
* 临时设置登录信息 * 临时设置登录信息
*
* @param request * @param request
* @param userId * @param userId
* @return * @return
*/ */
@RequestMapping("/tmpSetSession") @RequestMapping("/tmpSetSession")
public Map<String,Object> tmpSetSession(HttpServletRequest request,@RequestParam(value = "userId",required = true) Long userId){ public Map<String, Object> tmpSetSession(HttpServletRequest request, @RequestParam(value = "userId", required = true) Long userId) {
Map<String,Object> resultMap = new HashMap<String,Object>(); Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("status","0"); resultMap.put("status", "0");
resultMap.put("message",""); resultMap.put("message", "");
if(userId==null||userId<=0l){ if (userId == null || userId <= 0l) {
resultMap.put("message","用户ID不能为空~"); resultMap.put("message", "用户ID不能为空~");
return resultMap; return resultMap;
} }
TKzyUser tKzyUser = tKzyUserMapper.selectByPrimaryKey(userId); TKzyUser tKzyUser = tKzyUserMapper.selectByPrimaryKey(userId);
if(tKzyUser!=null){ if (tKzyUser != null) {
request.getSession().setAttribute(WX_USER_SESSION_KEY,tKzyUser); request.getSession().setAttribute(WX_USER_SESSION_KEY, tKzyUser);
resultMap.put("message","操作成功~"); resultMap.put("message", "操作成功~");
return resultMap; return resultMap;
}else{ } else {
resultMap.put("message","未查到该用户信息~"); resultMap.put("message", "未查到该用户信息~");
return resultMap; return resultMap;
} }
} }
......
package com.server.web.controller; package com.server.web.controller;
import com.server.web.common.model.TKzyUser;
import com.server.web.common.service.InformationService; import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -14,7 +15,7 @@ import java.util.Map; ...@@ -14,7 +15,7 @@ import java.util.Map;
*/ */
@RestController @RestController
@RequestMapping(value = BaseController.WX_NAMESPACE + "/information", produces = "application/json") @RequestMapping(value = BaseController.WX_NAMESPACE + "/information", produces = "application/json")
public class InformationController { public class InformationController extends BaseController {
@Autowired @Autowired
private InformationService informationService; private InformationService informationService;
...@@ -51,5 +52,36 @@ public class InformationController { ...@@ -51,5 +52,36 @@ public class InformationController {
return informationService.informationDetail(informationId); return informationService.informationDetail(informationId);
} }
/**
* 资讯评论列表
*
* @param request
* @param informationId
* @param pageNo
* @param pageSize
* @return
*/
@RequestMapping("/informationCommentList")
public Map<String, Object> informationCommentList(HttpServletRequest request, @RequestParam(value = "informationId") Long informationId,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
return informationService.informationCommentList(informationId, pageNo, pageSize);
}
/**
* 提交评论
*
* @param informationId
* @param comment
* @return
*/
@RequestMapping("/informationComment")
public Map<String, Object> informationComment(HttpServletRequest request, @RequestParam(value = "informationId") Long informationId, @RequestParam(value = "comment") String comment) {
TKzyUser tKzyUser = getLoginUser(request);
Long userId = null;
if (tKzyUser != null) {
userId = tKzyUser.getId();
}
return informationService.informationComment(informationId, userId, comment);
}
} }
<?xml version="1.0" encoding="UTF-8" ?> <?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" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.server.web.common.mapping.CommentMapper" > <mapper namespace="com.server.web.common.mapping.CommentMapper" >
<select id="commentList" resultType="java.util.HashMap">
SELECT
t.id,
t.create_dt AS createDt,
t.reply_content AS replyContent,
u.full_name AS fullName,
u.head_photo AS headPhoto
FROM
t_kzy_comment t
LEFT JOIN t_kzy_user u ON t.user_id = u.id AND t.type = 2
WHERE
t.is_delete = 0
AND t.relation_id = #{courseId,jdbcType=BIGINT}
ORDER BY
t.id DESC
LIMIT #{start,jdbcType=INTEGER},#{pageSize,jdbcType=INTEGER}
</select>
<select id="commentListTotal" resultType="java.lang.Integer">
SELECT
count(t.id)
FROM
t_kzy_comment t
LEFT JOIN t_kzy_user u ON t.user_id = u.id AND t.type = 2
WHERE
t.is_delete = 0
AND t.relation_id = #{courseId,jdbcType=BIGINT}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!