Merge remote-tracking branch 'origin/master'

This commit is contained in:
landaiqing 2023-12-28 22:48:39 +08:00
commit 7753dbe753
7 changed files with 60 additions and 7 deletions

View File

@ -9,31 +9,30 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/banners")
public class BannersController {
@Autowired
private BannersService bannersService;
// 跳转链接
@RequestMapping(method = RequestMethod.GET, value = "/jump_url")
@RequestMapping(method = RequestMethod.GET, value = "/banners/jump_url")
public String jump(int id) {
return bannersService.Jump_url(id);
}
// 添加banner
@RequestMapping(method = RequestMethod.POST, value = "/add_banner")
public String add(@RequestBody Banners banners) {
@RequestMapping( "/banners/add_banner")
public String add(Banners banners) {
return bannersService.Add_banner(banners);
}
// 删除banner
@RequestMapping(method = RequestMethod.GET, value = "/delete_url")
@RequestMapping(method = RequestMethod.GET, value = "/banners/delete_url")
public String delete(int id) {
return bannersService.Delete_banner(id);
}
// 首页显示banner
@RequestMapping(method = RequestMethod.GET, value = "/view_banner")
@RequestMapping(method = RequestMethod.GET, value = "/banners/view_banner")
public String view() {
return bannersService.View_banner();
}

View File

@ -1,5 +1,7 @@
package com.lovenav.controller;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.lovenav.entity.Comment;
import com.lovenav.entity.CommentNode;
import com.lovenav.entity.CommentUser;
@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
@ -66,4 +69,13 @@ public class CommentController {
public ResponseEntity<CommentUser> queryObserveUserById (Integer Id) {
return ResponseEntity.ok(commentService.queryCommentUserById(Id));
}
@RequestMapping("/comment/deleteByCommentId")
public String deleteByCommentId(Integer commentId)
{
HashMap<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("msg", commentService.SelectChildAndDelete(commentId));
return JSONObject.toJSONString(result);
}
}

View File

@ -43,4 +43,6 @@ public interface CommentDao {
*/
List<CommentNode> querySecondCommentList(Integer UrlId);
public String queryChildId(Integer commentId);
}

View File

@ -26,4 +26,6 @@ public interface CommentService {
List<CommentNode> queryCommentByUrlId (Integer UrlId );
CommentUser queryCommentUserById(Integer id);
public String SelectChildAndDelete(Integer commentId);
}

View File

@ -6,6 +6,8 @@ import com.lovenav.entity.Banners;
import com.lovenav.service.BannersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.HashMap;
@ -31,10 +33,14 @@ public class BannersServiceImpl implements BannersService {
// 添加banner
@Override
public String Add_banner(Banners banners) {
Date date = new Date(System.currentTimeMillis());
banners.setCreatetime(date);
int result = bannersDao.insert(banners);
HashMap<String, Object> hashMap = new HashMap<>();
if(result>0){
return JSON.toJSONString(banners);
hashMap.put("code",200);
hashMap.put("msg","添加成功");
return JSON.toJSONString(hashMap);
}else{
hashMap.put("code",500);
hashMap.put("msg","添加banner失败");

View File

@ -10,6 +10,7 @@ import com.lovenav.entity.CommentUser;
import com.lovenav.entity.User;
import com.lovenav.service.CommentService;
import io.swagger.models.auth.In;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -178,5 +179,21 @@ public class CommentServiceImpl implements CommentService {
}
return firstList;
}
public String SelectChildAndDelete(Integer commentId)
{
String child = commentDao.queryChildId(commentId);
String [] childrens = child.split(",");
int flag = 0;
for(String id : childrens)
{
flag = commentDao.deleteByPrimaryKey(Integer.valueOf(id));
if (String.valueOf(flag).equals("0")){
return "出现错误";
}
}
return "处理完成";
}
}

View File

@ -55,6 +55,21 @@
delete from ln_comment
where id = #{id,jdbcType=INTEGER}
</delete>
<select id="queryChildId" parameterType="java.lang.Integer" resultType="java.lang.String">
SELECT t3.ischild
FROM(SELECT t1.*,
IF (FIND_IN_SET(root_comment_id, @pids) > 0,@pids := CONCAT(@pids, ',', id),'0') AS ischild
FROM(SELECT t.id,t.root_comment_id
FROM ln_comment AS t
ORDER BY t.id ASC) t1,
(SELECT @pids := #{commentId,jdbcType=INTEGER}) t2) t3
WHERE ischild != '0'
order by id desc
limit 1
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.lovenav.entity.Comment" useGeneratedKeys="true">
insert into ln_comment (url_id, user_id, content,
root_comment_id, like_count, comment_time,