Commit 4e477fc5 by 魏文甫

update

1 parent 7de195cb
......@@ -7,7 +7,11 @@ import java.util.Map;
* Created by weiwenfu@163.com on 2020/3/12 下午 2:58.
*/
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;
import com.server.utils.ResultMapUtil;
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.mapping.CommentMapper;
import com.server.web.common.mapping.InformationMapper;
import com.server.web.common.model.TBaseSecondClass;
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.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.server.utils.ResultMapUtil.returnMap;
/**
* Created by weiwenfu@163.com on 2020/3/12 下午 4:54.
*/
......@@ -26,13 +31,17 @@ public class InformationServiceImpl implements InformationService {
private TKzyInformationMapper tKzyInformationMapper;
@Autowired
private TBaseSecondClassMapper tBaseSecondClassMapper;
@Autowired
private CommentMapper commentMapper;
@Autowired
private TKzyCommentMapper tKzyCommentMapper;
@Override
public Map<String, Object> secondClassList(Long firstId) {
TBaseSecondClassExample tBaseSecondClassExample = new TBaseSecondClassExample();
tBaseSecondClassExample.createCriteria().andFirstIdEqualTo(firstId).andStatusEqualTo(1);
List<TBaseSecondClass> list = tBaseSecondClassMapper.selectByExample(tBaseSecondClassExample);
return ResultMapUtil.returnMap("1", "", list);
return returnMap("1", "", list);
}
/**
......@@ -54,7 +63,7 @@ public class InformationServiceImpl implements InformationService {
} else {
list = informationMapper.secondClassDetailCourse(param);
}
return ResultMapUtil.returnMap("1", "", list);
return returnMap("1", "", list);
}
/**
......@@ -66,6 +75,46 @@ public class InformationServiceImpl implements InformationService {
@Override
public Map<String, Object> informationDetail(Long 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 {
resultMap.put("status", "1");
resultMap.put("message", "");
Map<String, Object> dataMap = new HashMap<>();
if (courseId != null) {
if (pageNo == null || pageNo <= 0l) {
pageNo = 1;
}
if (pageSize == null || pageSize <= 0l) {
pageSize = 20;
}
List<Map<String, Object>> list = commentMapper.commentList(courseId, (pageNo - 1) * pageSize, pageSize);
Integer count = commentMapper.commentListTotal(courseId);
dataMap.put("list", list);
dataMap.put("count", count);
resultMap.put("data", dataMap);
}
Map<String, Object> param = new HashMap<>();
param.put("courseId", courseId);
param.put("start", (pageNo - 1) * pageSize);
param.put("pageSize", pageSize);
List<Map<String, Object>> list = commentMapper.commentList(param);
Integer count = commentMapper.commentListTotal(param);
dataMap.put("list", list);
dataMap.put("count", count);
resultMap.put("data", dataMap);
return resultMap;
}
......@@ -272,6 +267,7 @@ public class TKzyCourseServiceImpl implements TKzyCourseService {
tKzyCourseComment.setRelationId(courseId);
tKzyCourseComment.setIsDelete(0);
tKzyCourseComment.setReplyContent(comment);
tKzyCourseComment.setType(2);
tKzyCommentMapper.insertSelective(tKzyCourseComment);
resultMap.put("message", "评论成功~");
resultMap.put("status", "1");
......
......@@ -6,9 +6,13 @@ import java.util.Map;
* Created by weiwenfu@163.com on 2020/3/12 下午 4:53.
*/
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;
@RestController
@RequestMapping(BaseController.WX_NAMESPACE + "/course")
@ControllerAdvice
public class CourseController extends BaseController{
public class CourseController extends BaseController {
@Autowired
private TKzyCourseService tKzyCourseService;
......@@ -41,118 +41,127 @@ public class CourseController extends BaseController{
/**
* 热门课程
*
* @return
*/
@RequestMapping("/hotCourse")
public Map<String,Object> hotCourse(){
public Map<String, Object> hotCourse() {
return tKzyCourseService.hotCourse();
}
/**
* 录播课列表
*
* @return
*/
@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){
return tKzyCourseService.recordCourse(typeId,pageNo,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
*/
@RequestMapping("/livingCourse")
public Map<String,Object> livingCourse(){
public Map<String, Object> livingCourse() {
return tKzyCourseService.livingCourse();
}
/**
* 直播课详情页
*
* @return
*/
@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);
Long userId = null;
if(tKzyUser!=null){
if (tKzyUser != null) {
userId = tKzyUser.getId();
}
return tKzyCourseService.livingCourseDetail(courseId,userId);
return tKzyCourseService.livingCourseDetail(courseId, userId);
}
/**
* 录播课详情页
*
* @return
*/
@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);
Long userId = null;
if(tKzyUser!=null){
if (tKzyUser != null) {
userId = tKzyUser.getId();
}
return tKzyCourseService.recordCourseDetail(courseId,userId);
return tKzyCourseService.recordCourseDetail(courseId, userId);
}
/**
* 评论列表
*
* @param courseId
* @return
*/
@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){
return tKzyCourseService.commentList(courseId,pageNo,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);
}
/**
* 提交评论
*
* @param courseId
* @param comment
* @return
*/
@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);
Long userId = null;
if(tKzyUser!=null){
if (tKzyUser != null) {
userId = tKzyUser.getId();
}
return tKzyCourseService.comment(courseId,userId,comment);
return tKzyCourseService.comment(courseId, userId, comment);
}
/**
* 课程分类
*
* @return
*/
@RequestMapping("/courseType")
public Map<String,Object> courseType(){
public Map<String, Object> courseType() {
return tKzyCourseService.courseType();
}
/**
* 临时设置登录信息
*
* @param request
* @param userId
* @return
*/
@RequestMapping("/tmpSetSession")
public Map<String,Object> tmpSetSession(HttpServletRequest request,@RequestParam(value = "userId",required = true) Long userId){
Map<String,Object> resultMap = new HashMap<String,Object>();
resultMap.put("status","0");
resultMap.put("message","");
if(userId==null||userId<=0l){
resultMap.put("message","用户ID不能为空~");
public Map<String, Object> tmpSetSession(HttpServletRequest request, @RequestParam(value = "userId", required = true) Long userId) {
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("status", "0");
resultMap.put("message", "");
if (userId == null || userId <= 0l) {
resultMap.put("message", "用户ID不能为空~");
return resultMap;
}
TKzyUser tKzyUser = tKzyUserMapper.selectByPrimaryKey(userId);
if(tKzyUser!=null){
request.getSession().setAttribute(WX_USER_SESSION_KEY,tKzyUser);
resultMap.put("message","操作成功~");
if (tKzyUser != null) {
request.getSession().setAttribute(WX_USER_SESSION_KEY, tKzyUser);
resultMap.put("message", "操作成功~");
return resultMap;
}else{
resultMap.put("message","未查到该用户信息~");
} else {
resultMap.put("message", "未查到该用户信息~");
return resultMap;
}
}
......
package com.server.web.controller;
import com.server.web.common.model.TKzyUser;
import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -14,7 +15,7 @@ import java.util.Map;
*/
@RestController
@RequestMapping(value = BaseController.WX_NAMESPACE + "/information", produces = "application/json")
public class InformationController {
public class InformationController extends BaseController {
@Autowired
private InformationService informationService;
......@@ -51,5 +52,36 @@ public class InformationController {
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" ?>
<!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" >
<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>
\ 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!