From 7ea5eece501c98a91555a5358931367e78e9d23b Mon Sep 17 00:00:00 2001 From: baizonghao <1719256278@qq.com> Date: 星期四, 25 五月 2023 15:40:09 +0800 Subject: [PATCH] 11 --- src/main/java/com/example/jz/controller/GroupController.java | 74 +++++++++++++++++++++++++++++++++---- 1 files changed, 66 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/example/jz/controller/GroupController.java b/src/main/java/com/example/jz/controller/GroupController.java index 41a8655..e11878e 100644 --- a/src/main/java/com/example/jz/controller/GroupController.java +++ b/src/main/java/com/example/jz/controller/GroupController.java @@ -1,15 +1,17 @@ package com.example.jz.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.api.ApiController; -import com.baomidou.mybatisplus.extension.api.R; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.example.jz.modle.R; import com.example.jz.modle.entity.Announcement; import com.example.jz.modle.entity.Group; +import com.example.jz.modle.entity.GroupUser; import com.example.jz.modle.vo.GroupMessageVo; import com.example.jz.modle.vo.GroupUserVo; import com.example.jz.service.GroupService; +import com.example.jz.service.GroupUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -17,8 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import java.io.Serializable; import java.util.List; /** @@ -38,8 +38,12 @@ public void setGroupService(GroupService groupService) { this.groupService = groupService; } + + @Autowired + GroupUserService groupUserService; + /** - * 鏍规嵁缇ょ粍id鑾峰彇褰撳墠缇ょ粍鎵�鏈夌殑娑堟伅 + * 鏍规嵁缇ょ粍id鑾峰彇褰撳墠缇ょ粍鎵�鏈夌殑娑堟伅 淇敼 * * @param id 缇ょ粍id * @return 褰撳墠缇ょ粍鎵�鏈夌殑娑堟伅 @@ -49,6 +53,51 @@ @ApiImplicitParam(name = "id", value = "缇ょ粍id", required = true, dataType = "Integer") public R<List<GroupMessageVo>> getAllMessage(@RequestParam("id") Integer id) { return R.ok(groupService.getAllMessage(id)); + } + +// @GetMapping("deleteGroupMessage") +// @ApiOperation(value = "鍒犻櫎缇ゆ秷鎭�") +// @ApiImplicitParam(name = "messageId", value = "娑堟伅id", required = true, dataType = "Integer") +// public R deleteMessage(@RequestParam("messageId") Integer messageId){ +// boolean flag = groupService.removeById(messageId); +// return flag ? R.ok(true, "鍒犻櫎鎴愬姛") : R.failed("鍒犻櫎鎴愬姛"); +// } + + + @GetMapping("getGroupMessage") + @ApiOperation(value = "鑾峰彇褰撳墠缇ょ粍娑堟伅閫氳繃鎴愬憳鎴栬�呭唴瀹�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "report", value = "缇ょ粍id", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "context", value = "缇ょ粍id", required = true, dataType = "String") + }) + public R<List<GroupMessageVo>> get(@RequestParam(value = "report", required = false) String reporter, @RequestParam(value = "context", required = false) String context, Integer groupId) { + return R.ok(groupService.getByCondition(reporter, context, groupId)); + } + + @PutMapping("banSpeech") + @ApiOperation(value = "绂佽█") + @ApiImplicitParam(name = "id", value = "缇ょ粍id", required = true, dataType = "Integer") + public R setBanSpeech(@RequestParam("id") Integer id, @RequestParam("groupId") Integer groupId) { + return R.ok(groupUserService.update(new UpdateWrapper<GroupUser>().set("ban_speech", 1).eq("user_id", id).eq("group_id", groupId))); + } + + @PutMapping("allowSpeech") + @ApiOperation(value = "鍏佽鍙戣█") + @ApiImplicitParam(name = "id", value = "缇ょ粍id", required = true, dataType = "Integer") + public R setAllowSpeech(@RequestParam("id") Integer id, @RequestParam("groupId") Integer groupId) { + return R.ok(groupUserService.update(new UpdateWrapper<GroupUser>().set("ban_speech", 0).eq("user_id", id).eq("group_id", groupId))); + } + + @PutMapping("banSpeechAll") + @ApiOperation(value = "鍏ㄩ儴绂佽█") + public R setBanSpeechAll(@RequestParam("id") Integer id) { + return R.ok(groupUserService.update(new UpdateWrapper<GroupUser>().set("ban_speech", 1).eq("group_id", id))); + } + + @PutMapping("banSpeechRemark") + @ApiOperation(value = "鍏ㄩ儴鍏佽鍙戣█") + public R setBanSpeechRemark(@RequestParam("id") Integer id) { + return R.ok(groupUserService.update(new UpdateWrapper<GroupUser>().set("ban_speech", 0).eq("group_id", id))); } /** @@ -78,11 +127,14 @@ @ApiImplicitParam(name = "id", value = "缇ょ粍id", required = true, dataType = "Integer") }) public R<Boolean> sendMessage(@RequestParam("id") Integer id, @RequestParam("text") String text) { + if (StringUtils.isBlank(text)) { + return R.failed("鏂囨湰涓虹┖"); + } return R.ok(groupService.sendMessage(id, text)); } /** - * 鑾峰彇缇ょ粍鎵�鏈変汉鍛樺垪琛� + * 鑾峰彇缇ょ粍鎵�鏈変汉鍛樺垪琛� 淇敼 * * @param id 缇ょ粍id * @return 缇ょ粍鎵�鏈変汉鍛樺垪琛� @@ -93,4 +145,10 @@ public R<List<GroupUserVo>> getAllUser(@RequestParam("id") Integer id) { return R.ok(groupService.getAllUser(id)); } -} + + @GetMapping("getAllGroupName") + @ApiOperation(value = "鑾峰彇缇ょ粍鍚嶇О") + public R<List<Group>> getAllGroupName() { + return R.ok(groupService.list()); + } +} \ No newline at end of file -- Gitblit v1.8.0