Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7753dbe753
@ -9,31 +9,30 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/banners")
|
|
||||||
public class BannersController {
|
public class BannersController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BannersService bannersService;
|
private BannersService bannersService;
|
||||||
|
|
||||||
// 跳转链接
|
// 跳转链接
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/jump_url")
|
@RequestMapping(method = RequestMethod.GET, value = "/banners/jump_url")
|
||||||
public String jump(int id) {
|
public String jump(int id) {
|
||||||
return bannersService.Jump_url(id);
|
return bannersService.Jump_url(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加banner
|
// 添加banner
|
||||||
@RequestMapping(method = RequestMethod.POST, value = "/add_banner")
|
@RequestMapping( "/banners/add_banner")
|
||||||
public String add(@RequestBody Banners banners) {
|
public String add(Banners banners) {
|
||||||
return bannersService.Add_banner(banners);
|
return bannersService.Add_banner(banners);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除banner
|
// 删除banner
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/delete_url")
|
@RequestMapping(method = RequestMethod.GET, value = "/banners/delete_url")
|
||||||
public String delete(int id) {
|
public String delete(int id) {
|
||||||
return bannersService.Delete_banner(id);
|
return bannersService.Delete_banner(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 首页显示banner
|
// 首页显示banner
|
||||||
@RequestMapping(method = RequestMethod.GET, value = "/view_banner")
|
@RequestMapping(method = RequestMethod.GET, value = "/banners/view_banner")
|
||||||
public String view() {
|
public String view() {
|
||||||
return bannersService.View_banner();
|
return bannersService.View_banner();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.lovenav.controller;
|
package com.lovenav.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.lovenav.entity.Comment;
|
import com.lovenav.entity.Comment;
|
||||||
import com.lovenav.entity.CommentNode;
|
import com.lovenav.entity.CommentNode;
|
||||||
import com.lovenav.entity.CommentUser;
|
import com.lovenav.entity.CommentUser;
|
||||||
@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@ -66,4 +69,13 @@ public class CommentController {
|
|||||||
public ResponseEntity<CommentUser> queryObserveUserById (Integer Id) {
|
public ResponseEntity<CommentUser> queryObserveUserById (Integer Id) {
|
||||||
return ResponseEntity.ok(commentService.queryCommentUserById(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,4 +43,6 @@ public interface CommentDao {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
List<CommentNode> querySecondCommentList(Integer UrlId);
|
List<CommentNode> querySecondCommentList(Integer UrlId);
|
||||||
|
|
||||||
|
public String queryChildId(Integer commentId);
|
||||||
}
|
}
|
@ -26,4 +26,6 @@ public interface CommentService {
|
|||||||
List<CommentNode> queryCommentByUrlId (Integer UrlId );
|
List<CommentNode> queryCommentByUrlId (Integer UrlId );
|
||||||
|
|
||||||
CommentUser queryCommentUserById(Integer id);
|
CommentUser queryCommentUserById(Integer id);
|
||||||
|
|
||||||
|
public String SelectChildAndDelete(Integer commentId);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import com.lovenav.entity.Banners;
|
|||||||
import com.lovenav.service.BannersService;
|
import com.lovenav.service.BannersService;
|
||||||
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.List;
|
import java.util.List;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -31,10 +33,14 @@ public class BannersServiceImpl implements BannersService {
|
|||||||
// 添加banner
|
// 添加banner
|
||||||
@Override
|
@Override
|
||||||
public String Add_banner(Banners banners) {
|
public String Add_banner(Banners banners) {
|
||||||
|
Date date = new Date(System.currentTimeMillis());
|
||||||
|
banners.setCreatetime(date);
|
||||||
int result = bannersDao.insert(banners);
|
int result = bannersDao.insert(banners);
|
||||||
HashMap<String, Object> hashMap = new HashMap<>();
|
HashMap<String, Object> hashMap = new HashMap<>();
|
||||||
if(result>0){
|
if(result>0){
|
||||||
return JSON.toJSONString(banners);
|
hashMap.put("code",200);
|
||||||
|
hashMap.put("msg","添加成功");
|
||||||
|
return JSON.toJSONString(hashMap);
|
||||||
}else{
|
}else{
|
||||||
hashMap.put("code",500);
|
hashMap.put("code",500);
|
||||||
hashMap.put("msg","添加banner失败");
|
hashMap.put("msg","添加banner失败");
|
||||||
|
@ -10,6 +10,7 @@ import com.lovenav.entity.CommentUser;
|
|||||||
import com.lovenav.entity.User;
|
import com.lovenav.entity.User;
|
||||||
import com.lovenav.service.CommentService;
|
import com.lovenav.service.CommentService;
|
||||||
import io.swagger.models.auth.In;
|
import io.swagger.models.auth.In;
|
||||||
|
import org.checkerframework.checker.units.qual.C;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -178,5 +179,21 @@ public class CommentServiceImpl implements CommentService {
|
|||||||
}
|
}
|
||||||
return firstList;
|
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 "处理完成";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,21 @@
|
|||||||
delete from ln_comment
|
delete from ln_comment
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</delete>
|
</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 id="insert" keyColumn="id" keyProperty="id" parameterType="com.lovenav.entity.Comment" useGeneratedKeys="true">
|
||||||
insert into ln_comment (url_id, user_id, content,
|
insert into ln_comment (url_id, user_id, content,
|
||||||
root_comment_id, like_count, comment_time,
|
root_comment_id, like_count, comment_time,
|
||||||
|
Loading…
Reference in New Issue
Block a user