pom.xml
@@ -17,34 +17,41 @@ <java.version>1.8</java.version> </properties> <dependencies> <!-- springboot web --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 实体类 --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <!-- 数据库驱动 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- springboot 测试 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.3.2</version> </dependency> <!-- minio SDK --> <dependency> <groupId>io.minio</groupId> <artifactId>minio</artifactId> <version>7.1.0</version> </dependency> <!-- swagger API --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> @@ -75,6 +82,7 @@ <artifactId>swagger-bootstrap-ui</artifactId> <version>1.9.6</version> </dependency> <!-- hutool 工具包 --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> src/main/java/com/example/jz/JzApplication.java
@@ -1,11 +1,9 @@ package com.example.jz; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @MapperScan("com.example.jz.dao") public class JzApplication { public static void main(String[] args) { src/main/java/com/example/jz/config/MybatisPlusConfig.java
@@ -11,6 +11,7 @@ @Configuration @MapperScan({"com.example.jz.dao"}) public class MybatisPlusConfig { /** * 分页插件 * @@ -21,5 +22,4 @@ public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); } } src/main/java/com/example/jz/config/SwaggerConfig.java
@@ -31,7 +31,7 @@ .title("青羊经侦接口文档") .description("青羊经侦接口文档Swagger版") .termsOfServiceUrl("https://www.baidu.com/") .contact(new Contact("优创立", "https://www.baidu.com/", "1070107765@qq.com")) .contact(new Contact("优创力", "https://www.baidu.com/", "1070107765@qq.com")) .version("1.0") .build(); } src/main/java/com/example/jz/controller/CommonQuestionController.java
@@ -24,7 +24,7 @@ */ @RestController @RequestMapping("commonQuestion") @Api(tags = "常见问题表(CommonQuestion)表接口") @Api(tags = "常见问题接口") public class CommonQuestionController extends ApiController { /** * 服务对象 src/main/java/com/example/jz/controller/GroupController.java
@@ -1,13 +1,20 @@ package com.example.jz.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.entity.Announcement; import com.example.jz.modle.entity.Group; import com.example.jz.modle.vo.GroupMessageVo; import com.example.jz.modle.vo.GroupUserVo; import com.example.jz.service.GroupService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -16,73 +23,74 @@ /** * 群表 (Group)表控制层 * (Group)表控制层 * * @author makejava * @since 2022-07-11 16:35:57 */ @RestController @RequestMapping("group") @Api(tags = "群组接口") public class GroupController extends ApiController { /** * 服务对象 */ @Resource private GroupService groupService; @Autowired public void setGroupService(GroupService groupService) { this.groupService = groupService; } /** * 分页查询所有数据 * 根据群组id获取当前群组所有的消息 * * @param page 分页对象 * @param group 查询实体 * @return 所有数据 * @param id 群组id * @return 当前群组所有的消息 */ @GetMapping public R selectAll(Page<Group> page, Group group) { return success(this.groupService.page(page, new QueryWrapper<>(group))); @GetMapping("getAllMessage") @ApiOperation(value = "获取当前群组所有的消息") @ApiImplicitParam(name = "id", value = "群组id", required = true, dataType = "Integer") public R<List<GroupMessageVo>> getAllMessage(@RequestParam("id") Integer id) { return R.ok(groupService.getAllMessage(id)); } /** * 通过主键查询单条数据 * 根据群组id获取当前群组所有公告 * * @param id 主键 * @return 单条数据 * @param id 群组id * @return 当前群组所有的消息 */ @GetMapping("{id}") public R selectOne(@PathVariable Serializable id) { return success(this.groupService.getById(id)); @GetMapping("getAllNotice") @ApiOperation(value = "获取当前群组所有的公告") @ApiImplicitParam(name = "id", value = "群组id", required = true, dataType = "Integer") public R<List<Announcement>> getAllNotice(@RequestParam("id") Integer id) { return R.ok(groupService.getAllNotice(id)); } /** * 新增数据 * 发送信息 * * @param group 实体对象 * @return 新增结果 * @param id 群组id * @param text 消息内容 * @return 发送结果 */ @PostMapping public R insert(@RequestBody Group group) { return success(this.groupService.save(group)); @GetMapping("sendMessage") @ApiOperation(value = "发送信息") @ApiImplicitParams({ @ApiImplicitParam(name = "text", value = "消息文本", required = true, dataType = "String"), @ApiImplicitParam(name = "id", value = "群组id", required = true, dataType = "Integer") }) public R<Boolean> sendMessage(@RequestParam("id") Integer id, @RequestParam("text") String text) { return R.ok(groupService.sendMessage(id, text)); } /** * 修改数据 * 获取群组所有人员列表 * * @param group 实体对象 * @return 修改结果 * @param id 群组id * @return 群组所有人员列表 */ @PutMapping public R update(@RequestBody Group group) { return success(this.groupService.updateById(group)); } /** * 删除数据 * * @param idList 主键结合 * @return 删除结果 */ @DeleteMapping public R delete(@RequestParam("idList") List<Long> idList) { return success(this.groupService.removeByIds(idList)); @GetMapping("getAllUser") @ApiOperation(value = "获取群组所有人员列表") @ApiImplicitParam(name = "id", value = "群组id", required = true, dataType = "Integer") public R<List<GroupUserVo>> getAllUser(@RequestParam("id") Integer id) { return R.ok(groupService.getAllUser(id)); } } src/main/java/com/example/jz/controller/MessageController.java
@@ -1,13 +1,17 @@ package com.example.jz.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.entity.Message; import com.example.jz.modle.vo.GroupMessageVo; import com.example.jz.service.MessageService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -22,6 +26,7 @@ */ @RestController @RequestMapping("message") @Api(tags = "群组消息") public class MessageController extends ApiController { /** * 服务对象 @@ -29,59 +34,5 @@ @Resource private MessageService messageService; /** * 分页查询所有数据 * * @param page 分页对象 * @param message 查询实体 * @return 所有数据 */ @GetMapping public R selectAll(Page<Message> page, Message message) { return success(this.messageService.page(page, new QueryWrapper<>(message))); } /** * 通过主键查询单条数据 * * @param id 主键 * @return 单条数据 */ @GetMapping("{id}") public R selectOne(@PathVariable Serializable id) { return success(this.messageService.getById(id)); } /** * 新增数据 * * @param message 实体对象 * @return 新增结果 */ @PostMapping public R insert(@RequestBody Message message) { return success(this.messageService.save(message)); } /** * 修改数据 * * @param message 实体对象 * @return 修改结果 */ @PutMapping public R update(@RequestBody Message message) { return success(this.messageService.updateById(message)); } /** * 删除数据 * * @param idList 主键结合 * @return 删除结果 */ @DeleteMapping public R delete(@RequestParam("idList") List<Long> idList) { return success(this.messageService.removeByIds(idList)); } } src/main/java/com/example/jz/controller/PublicityController.java
@@ -24,7 +24,7 @@ */ @RestController @RequestMapping("publicity") @Api(tags = "公共宣传表(Publicity)表接口") @Api(tags = "公共宣传接口") public class PublicityController { /** * 服务对象 src/main/java/com/example/jz/controller/ReportController.java
@@ -1,27 +1,30 @@ package com.example.jz.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; 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.Report; import com.example.jz.service.ReportService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.Serializable; import java.util.Date; import java.util.List; /** * 报案表(Report)表控制层 * * @author makejava * @author 安瑾然 * @since 2022-07-13 11:52:58 */ @RestController @RequestMapping("report") @Api(value = "报案接口", tags = "报案接口") public class ReportController extends ApiController { /** * 服务对象 @@ -32,13 +35,14 @@ /** * 分页查询所有数据 * * @param page 分页对象 * @param page 分页对象 * @param report 查询实体 * @return 所有数据 */ @GetMapping public R selectAll(Page<Report> page, Report report) { return success(this.reportService.page(page, new QueryWrapper<>(report))); @ApiOperation(value = "分页查询所有数据") public R<IPage<Report>> selectAll(Page<Report> page, Report report) { return R.ok(reportService.page(page, new QueryWrapper<>(report))); } /** @@ -48,41 +52,37 @@ * @return 单条数据 */ @GetMapping("{id}") public R selectOne(@PathVariable Serializable id) { return success(this.reportService.getById(id)); @ApiOperation(value = "通过主键查询单条数据") public R<Report> selectOne(@PathVariable Serializable id) { return R.ok(reportService.getById(id)); } /** * 新增数据 * 报案 * * @param report 实体对象 * @return 新增结果 */ @PostMapping public R insert(@RequestBody Report report) { return success(this.reportService.save(report)); @ApiOperation(value = "报案") public R<Boolean> insert(@RequestBody Report report) { report.setCtime(new Date()); report.setStatus(0); //TODO 动态获取当前的用户id report.setUserId(1); return R.ok(reportService.save(report)); } /** * 修改数据 * 审核通过并且关联案件id * * @param report 实体对象 * @return 修改结果 */ @PutMapping public R update(@RequestBody Report report) { return success(this.reportService.updateById(report)); } /** * 删除数据 * * @param idList 主键结合 * @return 删除结果 */ @DeleteMapping public R delete(@RequestParam("idList") List<Long> idList) { return success(this.reportService.removeByIds(idList)); @PostMapping("/audit") @ApiOperation(value = "审核通过") public R<Boolean> audit(@RequestBody Report report) { return R.ok(reportService.audit(report)); } } src/main/java/com/example/jz/controller/SensitiveController.java
@@ -31,7 +31,7 @@ @RestController @RequestMapping("sensitive") @ApiOperation("敏感词表(Sensitive)表控制层") @Api(tags = "敏感词表(Sensitive)表接口") @Api(tags = "敏感词接口") public class SensitiveController extends ApiController { /** * 服务对象 src/main/java/com/example/jz/dao/AnnouncementDao.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.jz.modle.entity.Announcement; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** * 公告表(Announcement)表数据库访问层 @@ -9,6 +12,7 @@ * @author makejava * @since 2022-07-11 16:35:52 */ @Mapper public interface AnnouncementDao extends BaseMapper<Announcement> { } src/main/java/com/example/jz/dao/CauseDao.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.jz.modle.entity.Cause; import org.apache.ibatis.annotations.Mapper; /** * 案件表(Cause)表数据库访问层 @@ -9,6 +10,7 @@ * @author makejava * @since 2022-07-13 11:52:57 */ @Mapper public interface CauseDao extends BaseMapper<Cause> { } src/main/java/com/example/jz/dao/GroupDao.java
@@ -2,6 +2,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.jz.modle.entity.Group; import com.example.jz.modle.vo.GroupUserVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * 群表 @@ -10,6 +15,9 @@ * @author makejava * @since 2022-07-11 16:35:57 */ @Mapper public interface GroupDao extends BaseMapper<Group> { List<GroupUserVo> getAllUser(@Param("groupId") Integer id); } src/main/java/com/example/jz/dao/GroupUserDao.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.jz.modle.entity.GroupUser; import org.apache.ibatis.annotations.Mapper; /** * 用户和群中间表(GroupUser)表数据库访问层 @@ -9,6 +10,7 @@ * @author makejava * @since 2022-07-11 16:35:57 */ @Mapper public interface GroupUserDao extends BaseMapper<GroupUser> { } src/main/java/com/example/jz/dao/MessageDao.java
@@ -2,6 +2,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.jz.modle.entity.Message; import com.example.jz.modle.vo.GroupMessageVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * 消息表(Message)表数据库访问层 @@ -9,6 +14,9 @@ * @author makejava * @since 2022-07-11 16:35:57 */ @Mapper public interface MessageDao extends BaseMapper<Message> { List<GroupMessageVo> getAllMessageByGroup(@Param("groupId") Integer id); } src/main/java/com/example/jz/dao/ReportDao.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.example.jz.modle.entity.Report; import org.apache.ibatis.annotations.Mapper; /** * 报案表(Report)表数据库访问层 @@ -9,6 +10,7 @@ * @author makejava * @since 2022-07-13 11:52:58 */ @Mapper public interface ReportDao extends BaseMapper<Report> { } src/main/java/com/example/jz/modle/entity/Announcement.java
@@ -1,5 +1,12 @@ package com.example.jz.modle.entity; import com.baomidou.mybatisplus.annotation.TableName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; @@ -9,6 +16,12 @@ * @author makejava * @since 2022-07-12 16:50:56 */ @TableName("qyjz.announcement") @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class Announcement implements Serializable { private static final long serialVersionUID = -64538879138052915L; /** @@ -27,39 +40,5 @@ * 创建时间 */ private Date ctime; public String getText() { return text; } public void setText(String text) { this.text = text; } public Integer getGroupId() { return groupId; } public void setGroupId(Integer groupId) { this.groupId = groupId; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Date getCtime() { return ctime; } public void setCtime(Date ctime) { this.ctime = ctime; } } src/main/java/com/example/jz/modle/entity/Group.java
@@ -1,6 +1,12 @@ package com.example.jz.modle.entity; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; @@ -9,10 +15,15 @@ * 群表 (Group)实体类 * * @author makejava * @author 安瑾然 * @since 2022-07-12 16:50:59 */ @TableName("qyjz.group") @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class Group implements Serializable { private static final long serialVersionUID = 208063400600909704L; /** @@ -30,6 +41,7 @@ /** * 群 id */ @TableId private Integer id; /** * 创建人id @@ -39,55 +51,9 @@ * 群创建时间 */ private Date ctime; public String getGroupName() { return groupName; } public void setGroupName(String groupName) { this.groupName = groupName; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public Integer getGroupAnnouncementId() { return groupAnnouncementId; } public void setGroupAnnouncementId(Integer groupAnnouncementId) { this.groupAnnouncementId = groupAnnouncementId; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } public Date getCtime() { return ctime; } public void setCtime(Date ctime) { this.ctime = ctime; } /** * 案件id */ private Integer causeId; } src/main/java/com/example/jz/modle/entity/GroupUser.java
@@ -1,5 +1,12 @@ package com.example.jz.modle.entity; import com.baomidou.mybatisplus.annotation.TableName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; @@ -9,6 +16,12 @@ * @author makejava * @since 2022-07-12 16:50:59 */ @TableName("qyjz.group_user") @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class GroupUser implements Serializable { private static final long serialVersionUID = -27152838957515341L; /** @@ -27,39 +40,5 @@ * 创建时间 */ private Date ctime; public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } public Integer getGroupId() { return groupId; } public void setGroupId(Integer groupId) { this.groupId = groupId; } public Object getBanSpeech() { return banSpeech; } public void setBanSpeech(Object banSpeech) { this.banSpeech = banSpeech; } public Date getCtime() { return ctime; } public void setCtime(Date ctime) { this.ctime = ctime; } } src/main/java/com/example/jz/modle/entity/Message.java
@@ -1,5 +1,14 @@ package com.example.jz.modle.entity; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; @@ -9,7 +18,13 @@ * @author makejava * @since 2022-07-12 16:50:59 */ public class Message implements Serializable { @TableName("qyjz.message") @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class Message extends Model<Message> implements Serializable { private static final long serialVersionUID = -28737108473853898L; /** * 消息内容 @@ -26,50 +41,19 @@ /** * 消息id */ @TableId private Integer id; private Date ctime; public String getText() { return text; /** * 获取主键值 * * @return 主键值 */ @Override protected Serializable pkVal() { return this.id; } public void setText(String text) { this.text = text; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } public Integer getGroupId() { return groupId; } public void setGroupId(Integer groupId) { this.groupId = groupId; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Date getCtime() { return ctime; } public void setCtime(Date ctime) { this.ctime = ctime; } } src/main/java/com/example/jz/modle/entity/Report.java
@@ -4,6 +4,12 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; /** @@ -13,6 +19,11 @@ * @since 2022-07-13 11:52:58 */ @TableName("qyjz.report") @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class Report extends Model<Report> { //案件ID private Integer id; @@ -23,7 +34,7 @@ //是否代办 1(代办) 0(不是代办) private String isCommission; //涉案金额 private String amountInvolved; private Double amountInvolved; //报案材料图片地址 多个用,分隔 private String reportMaterials; //报案时间 @@ -40,120 +51,8 @@ private Date cheatTime; //补充信息 private String information; //案件id //案件Id private Integer causeId; public Integer getCauseId() { return causeId; } public void setCauseId(Integer causeId) { this.causeId = causeId; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getPic() { return pic; } public void setPic(String pic) { this.pic = pic; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } public String getIsCommission() { return isCommission; } public void setIsCommission(String isCommission) { this.isCommission = isCommission; } public String getAmountInvolved() { return amountInvolved; } public void setAmountInvolved(String amountInvolved) { this.amountInvolved = amountInvolved; } public String getReportMaterials() { return reportMaterials; } public void setReportMaterials(String reportMaterials) { this.reportMaterials = reportMaterials; } public Date getReportTime() { return reportTime; } public void setReportTime(Date reportTime) { this.reportTime = reportTime; } public String getReportMethod() { return reportMethod; } public void setReportMethod(String reportMethod) { this.reportMethod = reportMethod; } public Integer getCreator() { return creator; } public void setCreator(Integer creator) { this.creator = creator; } public Integer getStatus() { return status; } public void setStatus(Integer status) { this.status = status; } public Date getCtime() { return ctime; } public void setCtime(Date ctime) { this.ctime = ctime; } public Date getCheatTime() { return cheatTime; } public void setCheatTime(Date cheatTime) { this.cheatTime = cheatTime; } public String getInformation() { return information; } public void setInformation(String information) { this.information = information; } /** * 获取主键值 @@ -164,5 +63,5 @@ protected Serializable pkVal() { return this.id; } } } src/main/java/com/example/jz/modle/vo/GroupMessageVo.java
New file @@ -0,0 +1,34 @@ package com.example.jz.modle.vo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.util.Date; /** * @author 安瑾然 * @data 2022/7/14 - 9:56 AM * @description */ @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class GroupMessageVo { /** * 用户名 */ private String userName; /** * 文本内容 */ private String text; /** * 创建时间 */ private Date ctime; } src/main/java/com/example/jz/modle/vo/GroupUserVo.java
New file @@ -0,0 +1,34 @@ package com.example.jz.modle.vo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.util.Date; /** * @author 安瑾然 * @data 2022/7/14 - 9:56 AM * @description */ @Data @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = false) public class GroupUserVo { /** * 用户名 */ private String userId; /** * 文本内容 */ private String userName; /** * 是否禁言(0为否1为是) */ private Object banSpeech; } src/main/java/com/example/jz/service/GroupService.java
@@ -1,7 +1,12 @@ package com.example.jz.service; import com.baomidou.mybatisplus.extension.service.IService; import com.example.jz.modle.entity.Announcement; import com.example.jz.modle.entity.Group; import com.example.jz.modle.vo.GroupMessageVo; import com.example.jz.modle.vo.GroupUserVo; import java.util.List; /** * 群表 @@ -11,5 +16,11 @@ * @since 2022-07-11 16:35:57 */ public interface GroupService extends IService<Group> { List<GroupMessageVo> getAllMessage(Integer id); List<Announcement> getAllNotice(Integer id); Boolean sendMessage(Integer id, String text); List<GroupUserVo> getAllUser(Integer id); } src/main/java/com/example/jz/service/MessageService.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.example.jz.modle.entity.Message; import com.example.jz.modle.vo.GroupMessageVo; import java.util.List; /** * 消息表(Message)表服务接口 @@ -11,4 +14,7 @@ */ public interface MessageService extends IService<Message> { } src/main/java/com/example/jz/service/ReportService.java
@@ -11,5 +11,6 @@ */ public interface ReportService extends IService<Report> { Boolean audit(Report report); } src/main/java/com/example/jz/service/impl/GroupServiceImpl.java
@@ -1,19 +1,70 @@ package com.example.jz.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.jz.dao.AnnouncementDao; import com.example.jz.dao.GroupDao; import com.example.jz.dao.MessageDao; import com.example.jz.modle.entity.Announcement; import com.example.jz.modle.entity.Group; import com.example.jz.modle.entity.Message; import com.example.jz.modle.vo.GroupMessageVo; import com.example.jz.modle.vo.GroupUserVo; import com.example.jz.service.GroupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; /** * 群表 (Group)表服务实现类 * (Group)表服务实现类 * * @author makejava * @since 2022-07-11 16:35:57 */ @Service("groupService") public class GroupServiceImpl extends ServiceImpl<GroupDao, Group> implements GroupService { private MessageDao messageDao; private AnnouncementDao announcementDao; private GroupDao groupDao; @Autowired public void setMessageDao(MessageDao messageDao) { this.messageDao = messageDao; } @Autowired public void setAnnouncementDao(AnnouncementDao announcementDao) { this.announcementDao = announcementDao; } @Autowired public void setGroupDao(GroupDao groupDao) { this.groupDao = groupDao; } @Override public List<GroupMessageVo> getAllMessage(Integer id) { return messageDao.getAllMessageByGroup(id); } @Override public List<Announcement> getAllNotice(Integer id) { return announcementDao.selectList(new LambdaQueryWrapper<>(Announcement.class).eq(Announcement::getGroupId, id)); } @Override public Boolean sendMessage(Integer id, String text) { // todo 动态获取当前登录用户的id Message message = new Message().setUserId(1).setText(text).setGroupId(id).setCtime(new Date()); return messageDao.insert(message) > 0; } @Override public List<GroupUserVo> getAllUser(Integer id) { return groupDao.getAllUser(id); } } src/main/java/com/example/jz/service/impl/MessageServiceImpl.java
@@ -3,8 +3,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.jz.dao.MessageDao; import com.example.jz.modle.entity.Message; import com.example.jz.modle.vo.GroupMessageVo; import com.example.jz.service.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; /** * 消息表(Message)表服务实现类 @@ -14,5 +19,8 @@ */ @Service("messageService") public class MessageServiceImpl extends ServiceImpl<MessageDao, Message> implements MessageService { @Autowired private MessageDao messageDao; } src/main/java/com/example/jz/service/impl/ReportServiceImpl.java
@@ -1,10 +1,20 @@ package com.example.jz.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.jz.dao.CauseDao; import com.example.jz.dao.GroupDao; import com.example.jz.dao.GroupUserDao; import com.example.jz.dao.ReportDao; import com.example.jz.modle.entity.Group; import com.example.jz.modle.entity.GroupUser; import com.example.jz.modle.entity.Report; import com.example.jz.service.ReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; /** * 报案表(Report)表服务实现类 @@ -15,5 +25,31 @@ @Service("reportService") public class ReportServiceImpl extends ServiceImpl<ReportDao, Report> implements ReportService { @Autowired private ReportDao reportDao; @Autowired private GroupDao groupDao; @Autowired private GroupUserDao groupUserDao; /** * 审核报案 * * @param report * @return */ @Override @Transactional public Boolean audit(Report report) { // 1. 更新报案表 report.setStatus(1); reportDao.updateById(report); // 2. 更新群用户表 Group group = groupDao.selectOne(new LambdaQueryWrapper<>(Group.class) .eq(Group::getCauseId, report.getCauseId())); GroupUser groupUser = new GroupUser().setGroupId(group.getId()).setUserId(report.getUserId()).setCtime(new Date()).setBanSpeech(0); groupUserDao.insert(groupUser); return true; } } src/main/resources/application.yml
@@ -25,6 +25,9 @@ servlet: multipart: max-file-size: 50MB jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 # minio配置 minio: src/main/resources/banner.txt
New file @@ -0,0 +1,22 @@ //////////////////////////////////////////////////////////////////// // _ooOoo_ // // o8888888o // // 88" . "88 // // (| ^_^ |) // // O\ = /O // // ____/`---'\____ // // .' \\| |// `. // // / \\||| : |||// \ // // / _||||| -:- |||||- \ // // | | \\\ - /// | | // // | \_| ''\---/'' | | // // \ .-\__ `-` ___/-. / // // ___`. .' /--.--\ `. . ___ // // ."" '< `.___\_<|>_/___.' >'"". // // | | : `- \`.;`\ _ /`;.`/ - ` : | | // // \ \ `-. \_ __\ /__ _/ .-` / / // // ========`-.____`-.___\_____/___.-`____.-'======== // // `=---=' // // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // // 佛祖保佑 永不宕机 永无BUG // //////////////////////////////////////////////////////////////////// src/main/resources/mapper/AnnouncementDao.xml
New file @@ -0,0 +1,12 @@ <?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.example.jz.dao.AnnouncementDao"> <resultMap type="com.example.jz.modle.entity.Announcement" id="AnnouncementMap"> <result property="id" column="id" jdbcType="VARCHAR"/> <result property="text" column="text" jdbcType="VARCHAR"/> <result property="groupId" column="group_id" jdbcType="VARCHAR"/> <result property="ctime" column="ctime" jdbcType="TIMESTAMP"/> </resultMap> </mapper> src/main/resources/mapper/GroupDao.xml
New file @@ -0,0 +1,18 @@ <?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.example.jz.dao.GroupDao"> <resultMap id="GroupUserVoMap" type="com.example.jz.modle.vo.GroupUserVo"> <result property="userId" column="user_id" /> <result property="userName" column="real_name" /> <result property="banSpeech" column="ban_speech" /> </resultMap> <select id="getAllUser" resultType="com.example.jz.modle.vo.GroupUserVo"> select group_user.user_id,group_user.ban_speech,user.real_name from group_user join user on group_user.user_id = user.id where group_id = #{groupId} </select> </mapper> src/main/resources/mapper/MessageDao.xml
New file @@ -0,0 +1,20 @@ <?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.example.jz.dao.MessageDao"> <resultMap type="com.example.jz.modle.vo.GroupMessageVo" id="GroupMessageVoMap"> <result property="userName" column="real_name" jdbcType="VARCHAR"/> <result property="text" column="text" jdbcType="VARCHAR"/> <result property="ctime" column="ctime" jdbcType="TIMESTAMP"/> </resultMap> <select id="getAllMessageByGroup" resultMap="GroupMessageVoMap"> select u.real_name, m.text, m.ctime from message m join user u on m.user_id = u.id where m.group_id = #{groupId} order by m.ctime desc </select> </mapper> src/test/java/com/example/jz/JzApplicationTests.java
@@ -16,4 +16,10 @@ System.out.println(minIOService.getPreviewFileUrl("2fff006f3082f00e26d496dc0a47c624.png")); } @Test void test() { } } src/test/java/com/example/jz/dao/GroupDaoTest.java
New file @@ -0,0 +1,32 @@ package com.example.jz.dao; import com.example.jz.exception.BusinessException; import com.example.jz.modle.vo.GroupUserVo; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.util.List; import static org.junit.jupiter.api.Assertions.*; /** * @author 安瑾然 * @data 2022/7/14 - 1:49 PM * @description */ @SpringBootTest class GroupDaoTest { private GroupDao groupDao; @Autowired public void setGroupDao(GroupDao groupDao) { this.groupDao = groupDao; } @Test void getAllUser() { List<GroupUserVo> groupUserVos = groupDao.getAllUser(1); System.out.println(groupUserVos); } }