From 8ea221596617586d09bd85152831612378fb6181 Mon Sep 17 00:00:00 2001 From: yxyc-137 Date: Tue, 16 Apr 2024 15:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=B1=BB=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=92=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E5=BC=95=E5=85=A5knife4j=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 207 +++++++++--------- .../configuration/SwaggerConfig.java | 67 ++++++ .../newgroupshell/controller/FileCtrl.java | 2 +- .../newgroupshell/controller/GroupCtrl.java | 34 ++- .../newgroupshell/controller/UserCtrl.java | 8 +- .../{MGCtrl.java => UserGroupCtrl.java} | 40 ++-- .../mapper/MemberGroupMapper.java | 14 +- .../newgroupshell/mapper/TaskMapper.java | 26 +-- .../newgroupshell/mapper/UserMapper.java | 37 ++-- .../com/example/newgroupshell/pojo/Group.java | 17 +- .../newgroupshell/pojo/Member_Group.java | 42 ---- .../com/example/newgroupshell/pojo/Task.java | 112 +++++----- .../com/example/newgroupshell/pojo/User.java | 16 +- .../example/newgroupshell/pojo/UserGroup.java | 23 ++ .../newgroupshell/result/PageResult.java | 2 +- .../{MGService.java => UserGroupService.java} | 11 +- .../newgroupshell/service/UserService.java | 32 +-- ...iceImpl.java => UserGroupServiceImpl.java} | 49 ++--- .../service/impl/UserServiceImpl.java | 6 +- src/main/resources/application.properties | 7 +- src/main/resources/mapper/TaskMapper.xml | 17 +- 21 files changed, 412 insertions(+), 357 deletions(-) create mode 100644 src/main/java/com/example/newgroupshell/configuration/SwaggerConfig.java rename src/main/java/com/example/newgroupshell/controller/{MGCtrl.java => UserGroupCtrl.java} (68%) delete mode 100644 src/main/java/com/example/newgroupshell/pojo/Member_Group.java create mode 100644 src/main/java/com/example/newgroupshell/pojo/UserGroup.java rename src/main/java/com/example/newgroupshell/service/{MGService.java => UserGroupService.java} (40%) rename src/main/java/com/example/newgroupshell/service/impl/{MGServiceImpl.java => UserGroupServiceImpl.java} (34%) diff --git a/pom.xml b/pom.xml index aaf9969..5a0a738 100644 --- a/pom.xml +++ b/pom.xml @@ -1,107 +1,116 @@ - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.2.4 - - - com.example - newgroupshell - 0.0.1-SNAPSHOT - newgroupshell - newgroupshell - - 17 - - - - org.springframework.boot - spring-boot-starter-jdbc - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-web-services - - - com.baomidou - mybatis-plus-spring-boot3-starter - 3.5.5 - + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.4 + + + com.example + newgroupshell + 0.0.1-SNAPSHOT + newgroupshell + newgroupshell + + 17 + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-web-services + + + com.baomidou + mybatis-plus-spring-boot3-starter + 3.5.5 + - - org.springframework.boot - spring-boot-devtools - runtime - true - - - com.mysql - mysql-connector-j - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - org.mybatis.spring.boot - mybatis-spring-boot-starter-test - 3.0.3 - test - - - com.alibaba - fastjson - 2.0.27 - - - org.projectlombok - lombok - provided - + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + 3.0.3 + test + + + com.alibaba + fastjson + 2.0.27 + + + org.projectlombok + lombok + provided + - - com.aliyun.oss - aliyun-sdk-oss - 3.15.1 - + + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter + 4.4.0 + + + cn.hutool + hutool-all + 5.8.10 + + + com.aliyun.oss + aliyun-sdk-oss + 3.15.1 + - - javax.xml.bind - jaxb-api - 2.3.1 - - - javax.activation - activation - 1.1.1 - - - - org.glassfish.jaxb - jaxb-runtime - 2.3.3 - + + javax.xml.bind + jaxb-api + 2.3.1 + + + javax.activation + activation + 1.1.1 + + + + org.glassfish.jaxb + jaxb-runtime + 2.3.3 + + - - - - - - org.springframework.boot - spring-boot-maven-plugin - 3.2.4 - - - + + + + org.springframework.boot + spring-boot-maven-plugin + 3.2.4 + + + diff --git a/src/main/java/com/example/newgroupshell/configuration/SwaggerConfig.java b/src/main/java/com/example/newgroupshell/configuration/SwaggerConfig.java new file mode 100644 index 0000000..92e816e --- /dev/null +++ b/src/main/java/com/example/newgroupshell/configuration/SwaggerConfig.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD. + * All rights reserved. + * Official Web Site: http://www.xiaominfo.com. + * Developer Web Site: http://open.xiaominfo.com. + */ +package com.example.newgroupshell.configuration; + +import cn.hutool.core.util.RandomUtil; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import org.springdoc.core.customizers.GlobalOpenApiCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.Map; + +/*** + * 创建Swagger配置 + * @since:knife4j-springdoc-openapi-demo 1.0 + * @author xiaoymin@foxmail.com + * 2020/03/15 20:40 + */ +@Configuration +public class SwaggerConfig +{ + /** + * 根据@Tag 上的排序,写入x-order + * + * @return the global open api customizer + */ + @Bean + public GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() + { + return openApi-> + { + if(openApi.getTags()!=null) + { + openApi.getTags() + .forEach(tag-> + { + Map map=new HashMap<>(); + map.put("x-order",RandomUtil.randomInt(0,100)); + tag.setExtensions(map); + }); + } + if(openApi.getPaths()!=null) + { + openApi.addExtension("x-test123","333"); + openApi.getPaths() + .addExtension("x-abb",RandomUtil.randomInt(1,100)); + } + }; + } + @Bean + public OpenAPI customOpenAPI() + { + return new OpenAPI().info(new Info().title("GroupShell接口文档") + .version("1.0") + .description("GroupShell接口文档") + .termsOfService("http://doc.xiaominfo.com") + .license(new License().name("Apache 2.0") + .url("http://doc.xiaominfo.com"))); + } +} diff --git a/src/main/java/com/example/newgroupshell/controller/FileCtrl.java b/src/main/java/com/example/newgroupshell/controller/FileCtrl.java index d7e16fa..afe94e2 100644 --- a/src/main/java/com/example/newgroupshell/controller/FileCtrl.java +++ b/src/main/java/com/example/newgroupshell/controller/FileCtrl.java @@ -23,7 +23,7 @@ public class FileCtrl */ @CrossOrigin @RequestMapping(method=RequestMethod.POST) - public File upload(@RequestBody File file) + public File uploadOne(@RequestBody File file) { return fileService.upload(file); } diff --git a/src/main/java/com/example/newgroupshell/controller/GroupCtrl.java b/src/main/java/com/example/newgroupshell/controller/GroupCtrl.java index 6835f7a..49b6ac8 100644 --- a/src/main/java/com/example/newgroupshell/controller/GroupCtrl.java +++ b/src/main/java/com/example/newgroupshell/controller/GroupCtrl.java @@ -4,12 +4,10 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.example.newgroupshell.pojo.Group; -import com.example.newgroupshell.pojo.Member_Group; -import com.example.newgroupshell.pojo.User; +import com.example.newgroupshell.pojo.UserGroup; import com.example.newgroupshell.service.GroupService; -import com.example.newgroupshell.service.MGService; +import com.example.newgroupshell.service.UserGroupService; import com.example.newgroupshell.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; @@ -23,12 +21,12 @@ import java.util.List; public class GroupCtrl { private final GroupService groupService; - private final MGService mgService; + private final UserGroupService userGroupService; private final UserService userService; - public GroupCtrl(GroupService groupService,MGService mgService,UserService userService) + public GroupCtrl(GroupService groupService,UserGroupService userGroupService,UserService userService) { this.groupService=groupService; - this.mgService=mgService; + this.userGroupService=userGroupService; this.userService=userService; } //根据用户id查找用户创建的团队 @@ -59,9 +57,9 @@ public class GroupCtrl System.out.println(grouptocreate.toString()); JSONObject data=new JSONObject(); // 获取注册用户的用户名 - String groupname=grouptocreate.getGroupname(); + String groupname=grouptocreate.getName(); groupname=HtmlUtils.htmlEscape(groupname); - String username=userService.getNameById(grouptocreate.getLeaderid()); + String username=userService.getNameById(grouptocreate.getLeaderId()); if(!"".equals(groupname)) { Group temp=groupService.findgoupbyGroupname(groupname);//查找用户名是否被占用 @@ -69,13 +67,11 @@ public class GroupCtrl { //可以进行建组 int res=groupService.createnewgroup(grouptocreate); - Member_Group memberGroup=new Member_Group(); + UserGroup userGroup=new UserGroup(); Group temp2=groupService.findgoupbyGroupname(groupname); - memberGroup.setGroupname(groupname); - memberGroup.setGid(temp2.getGid()); - memberGroup.setUid(temp2.getLeaderid()); - memberGroup.setUsername(username); - mgService.userjoingroup(memberGroup); + userGroup.setGroupId(temp2.getId()); + userGroup.setUserId(temp2.getLeaderId()); + userGroupService.userjoingroup(userGroup); if(res>0) // 新建组成功 {data.put("msg","success");} else // 新建组失败 @@ -97,10 +93,10 @@ public class GroupCtrl { JSONObject json=new JSONObject(); JSONObject res=new JSONObject(); - Integer userid=Userwantedtofindhisgroup.getInteger("userid"); + Long userid=Userwantedtofindhisgroup.getLong("userid"); //获取输入的用户名 System.out.println(userid); - List groups=mgService.findgroupbyuid(userid); + List groups=userGroupService.findgroupbyuid(userid); System.out.println(JSON.toJSONString(groups)); //把结果json化 JSONArray groupList=JSONArray.parseArray(JSON.toJSONString(groups)); @@ -116,10 +112,10 @@ public class GroupCtrl { JSONObject json=new JSONObject(); JSONObject res=new JSONObject(); - Integer userid=Userwantedtomanagehisgroup.getInteger("groupid"); + Long userid=Userwantedtomanagehisgroup.getLong("groupid"); //获取输入的用户名 System.out.println(userid); - List groups=mgService.findgroupbyuid(userid); + List groups=userGroupService.findgroupbyuid(userid); System.out.println(JSON.toJSONString(groups)); //把结果json化 JSONArray groupList=JSONArray.parseArray(JSON.toJSONString(groups)); diff --git a/src/main/java/com/example/newgroupshell/controller/UserCtrl.java b/src/main/java/com/example/newgroupshell/controller/UserCtrl.java index b0b4913..149fd10 100644 --- a/src/main/java/com/example/newgroupshell/controller/UserCtrl.java +++ b/src/main/java/com/example/newgroupshell/controller/UserCtrl.java @@ -92,7 +92,7 @@ public class UserCtrl //登录成功 res.put("msg","success"); // 把登录用户的id和name传过去 - int id=curUser.getUid(); + Long id=curUser.getId(); String name=curUser.getUsername(); System.out.println(curUser.toString()); System.out.println(name); @@ -166,7 +166,7 @@ public class UserCtrl public JSONObject getName(@RequestBody User user) { JSONObject json=new JSONObject(); - int id=user.getUid(); + Long id=user.getId(); String username=userService.getNameById(id); if(username!=null && !"".equals(username)) {json.put("username",username);} else {json.put("username","error");} @@ -179,7 +179,7 @@ public class UserCtrl public JSONObject getUserInfo(@RequestBody User curUser) { JSONObject json=new JSONObject(); - int id=curUser.getUid(); + Long id=curUser.getId(); //根据id获取当前用户信息 User user=userService.findUserById(id); //将结果json化 @@ -262,7 +262,7 @@ public class UserCtrl public JSONObject setUsername(@RequestBody User user) { JSONObject json=new JSONObject(); - int id=user.getUid();//获取用户的id + Long id=user.getId();//获取用户的id String username=user.getUsername(); if(!"".equals(username) && username!=null) { diff --git a/src/main/java/com/example/newgroupshell/controller/MGCtrl.java b/src/main/java/com/example/newgroupshell/controller/UserGroupCtrl.java similarity index 68% rename from src/main/java/com/example/newgroupshell/controller/MGCtrl.java rename to src/main/java/com/example/newgroupshell/controller/UserGroupCtrl.java index 4edf651..11f60c8 100644 --- a/src/main/java/com/example/newgroupshell/controller/MGCtrl.java +++ b/src/main/java/com/example/newgroupshell/controller/UserGroupCtrl.java @@ -1,15 +1,11 @@ package com.example.newgroupshell.controller; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.example.newgroupshell.pojo.Group; -import com.example.newgroupshell.pojo.Member_Group; -import com.example.newgroupshell.pojo.User; +import com.example.newgroupshell.pojo.UserGroup; import com.example.newgroupshell.service.GroupService; -import com.example.newgroupshell.service.MGService; +import com.example.newgroupshell.service.UserGroupService; import com.example.newgroupshell.service.UserService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; @@ -20,14 +16,14 @@ import org.springframework.web.util.HtmlUtils; import java.util.List; @Controller -public class MGCtrl +public class UserGroupCtrl { - private final MGService mgService; + private final UserGroupService userGroupService; private final GroupService groupService; private final UserService userService; - public MGCtrl(MGService mgService,GroupService groupService,UserService userService) + public UserGroupCtrl(UserGroupService userGroupService,GroupService groupService,UserService userService) { - this.mgService=mgService; + this.userGroupService=userGroupService; this.groupService=groupService; this.userService=userService; } @@ -38,7 +34,7 @@ public class MGCtrl public JSONObject joingroup(@RequestBody JSONObject membergroup_to_join) { JSONObject res=new JSONObject(); - Integer userid=membergroup_to_join.getInteger("userid"); + Long userid=membergroup_to_join.getLong("userid"); String username=userService.getNameById(userid); //获取输入的用户名 String groupname=membergroup_to_join.getString("groupname"); @@ -57,10 +53,10 @@ public class MGCtrl else { int flag=1; - List mygroups=mgService.findgroupbyuid(userid); + List mygroups=userGroupService.findgroupbyuid(userid); for(Group e: mygroups) { - if(e.getGroupname() + if(e.getName() .equals(groupname)) { flag=0; @@ -77,15 +73,13 @@ public class MGCtrl //登录成功 res.put("msg","success"); // 把登录用户的id和name传过去 - int groupid=curGroup.getGid(); - Member_Group memberGroup=new Member_Group(); - memberGroup.setGid(groupid); - memberGroup.setUid(userid); - memberGroup.setGroupname(groupname); - memberGroup.setUsername(username); - mgService.userjoingroup(memberGroup); - int Gid=curGroup.getGid(); - String Gname=curGroup.getGroupname(); + Long groupid=curGroup.getId(); + UserGroup userGroup=new UserGroup(); + userGroup.setGroupId(groupid); + userGroup.setUserId(userid); + userGroupService.userjoingroup(userGroup); + Long Gid=curGroup.getId(); + String Gname=curGroup.getName(); System.out.println(curGroup.toString()); System.out.println(Gname); res.put("Gid",Gid); @@ -95,3 +89,5 @@ public class MGCtrl return res; } } + + diff --git a/src/main/java/com/example/newgroupshell/mapper/MemberGroupMapper.java b/src/main/java/com/example/newgroupshell/mapper/MemberGroupMapper.java index dbac89f..68590d2 100644 --- a/src/main/java/com/example/newgroupshell/mapper/MemberGroupMapper.java +++ b/src/main/java/com/example/newgroupshell/mapper/MemberGroupMapper.java @@ -1,8 +1,8 @@ package com.example.newgroupshell.mapper; import com.example.newgroupshell.pojo.Group; -import com.example.newgroupshell.pojo.Member_Group; import com.example.newgroupshell.pojo.User; +import com.example.newgroupshell.pojo.UserGroup; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; @@ -12,12 +12,12 @@ import java.util.List; @Mapper public interface MemberGroupMapper { - @Select("select * from member_group where uid=#{0}") - List selectgroupbyuid(int uid); + @Select("select * from user_group where user_id=#{0}") + List selectgroupbyuid(Long uid); - @Insert("insert into member_group(username,groupname,Gid,uid) values(#{username},#{groupname},#{Gid},#{uid})") - int memberjoingroup(Member_Group menberGroup); + @Insert("insert into user_group(group_id, user_id, authority) values(#{groupId},#{userId},#{authority})") + int memberjoingroup(UserGroup userGroup); - @Select("select * from member_group where Gid=#{0}") - List selectuserbyGid(int Gid); + @Select("select * from user_group where group_id=#{0}") + List selectuserbyGid(Long Gid); } diff --git a/src/main/java/com/example/newgroupshell/mapper/TaskMapper.java b/src/main/java/com/example/newgroupshell/mapper/TaskMapper.java index e1e1744..8291fad 100644 --- a/src/main/java/com/example/newgroupshell/mapper/TaskMapper.java +++ b/src/main/java/com/example/newgroupshell/mapper/TaskMapper.java @@ -1,6 +1,5 @@ package com.example.newgroupshell.mapper; - import com.example.newgroupshell.common.enums.TaskStatusEnum; import com.example.newgroupshell.pojo.Task; import org.apache.ibatis.annotations.*; @@ -8,16 +7,17 @@ import org.apache.ibatis.annotations.*; import java.util.List; @Mapper -public interface TaskMapper { - int insertTask(Task task); - - int updateTaskById(Task task); - - int deleteTaskById(@Param("tid") Integer tid); - - List findTasksByAssigneeId(@Param("assigneeId") Integer assigneeId); - - List findTasksByCreatorId(@Param("creatorId") Integer creatorId); - - List findTasksByStatus(@Param("status") TaskStatusEnum status); +public interface TaskMapper +{ + int insertTask(Task task); + + int updateTaskById(Task task); + + int deleteTaskById(@Param("tid") Integer tid); + + List findTasksByAssigneeId(@Param("assigneeId") Integer assigneeId); + + List findTasksByCreatorId(@Param("creatorId") Integer creatorId); + + List findTasksByStatus(@Param("status") TaskStatusEnum status); } \ No newline at end of file diff --git a/src/main/java/com/example/newgroupshell/mapper/UserMapper.java b/src/main/java/com/example/newgroupshell/mapper/UserMapper.java index d53be70..33a0105 100644 --- a/src/main/java/com/example/newgroupshell/mapper/UserMapper.java +++ b/src/main/java/com/example/newgroupshell/mapper/UserMapper.java @@ -5,44 +5,39 @@ import org.apache.ibatis.annotations.*; import java.util.List; import com.example.newgroupshell.pojo.User; -import org.apache.ibatis.annotations.*; - -import java.util.List; @Mapper public interface UserMapper { //获取所有用户 - @Select("select * from users") + @Select("select * from user") List selectAllUsers(); // 获取特定用户 - @Select("select * from users where username=#{username} and password=#{password}") + @Select("select * from user where username=#{username} and password=#{password}") User findUser(@Param("username") String username,@Param("password") String password); // 根据username获取用户 - @Select("select * from users where username = #{0}") + @Select("select * from user where username = #{0}") User findUserByName(String username); //添加用户 - @Insert("insert into users(username,password) values(#{username},#{password})") + @Insert("insert into user(username,password) values(#{username},#{password})") int addUser(User registerUser); //根据id获取用户 - @Select("select * from users where uid = #{0}") - User findUserById(int uid); + @Select("select * from user where id = #{0}") + User findUserById(Long uid); //修改当前用户的用户名 - @Update("update users set username = #{username} where uid = #{uid}") - int setUsername(@Param("uid") int uid,@Param("username") String username); - + @Update("update user set username = #{username} where id = #{uid}") + int setUsername(@Param("uid") Long uid,@Param("username") String username); // 根据telephone获取用户 // @Select("select * from users where telephone=#{0}") // User getUserByPhone(String phone); //修改当前用户的手机号 - @Update("update users set telephone=#{telephone} where uid=#{uid}") - int setPhone(@Param("uid") int uid,@Param("telephone") String phone); - +// @Update("update user set telephone=#{telephone} where id=#{uid}") +// int setPhone(@Param("uid") int uid,@Param("telephone") String phone); //获取当前用户的手机号 // @Select("select telephone from users where id=#{0}") // String getBeforePhone(int id); @@ -56,13 +51,13 @@ public interface UserMapper // @Select("select birthdate from users where id=#{0}") // String getBeforeDate(int id); //修改当前用户的出生日期 - @Update("update users set birthdate=#{birthdate} where id=#{id}") - int setDate(@Param("id") int id,@Param("birthdate") String date); +// @Update("update user set birthdate=#{birthdate} where id=#{id}") +// int setDate(@Param("id") int id,@Param("birthdate") String date); - @Select("select username from users where uid=#{0}") - String getNameById(int id); + @Select("select username from user where id=#{0}") + String getNameById(Long id); //重置密码 - @Update("update users set password=#{password} where id=#{id}") - int resetPass(@Param("id") int id,@Param("password") String password); + @Update("update user set password=#{password} where id=#{id}") + int resetPass(@Param("id") Long id,@Param("password") String password); } diff --git a/src/main/java/com/example/newgroupshell/pojo/Group.java b/src/main/java/com/example/newgroupshell/pojo/Group.java index 6ed4334..e587ee4 100644 --- a/src/main/java/com/example/newgroupshell/pojo/Group.java +++ b/src/main/java/com/example/newgroupshell/pojo/Group.java @@ -1,16 +1,23 @@ package com.example.newgroupshell.pojo; -import lombok.Data; -import lombok.ToString; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; import java.io.Serializable; @Data @ToString +@NoArgsConstructor +@AllArgsConstructor +@Builder +@TableName("group") public class Group implements Serializable { - private Integer Gid; - private String groupname; - private Integer leaderid; + @TableId(value="id",type=IdType.AUTO) + private Long id; + private Long leaderId; + private String name; private String password; } diff --git a/src/main/java/com/example/newgroupshell/pojo/Member_Group.java b/src/main/java/com/example/newgroupshell/pojo/Member_Group.java deleted file mode 100644 index 2e28e5b..0000000 --- a/src/main/java/com/example/newgroupshell/pojo/Member_Group.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.example.newgroupshell.pojo; - -public class Member_Group { - - private String username; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - private String groupname; - public String getGroupname() { - return groupname; - } - public void setGroupname(String groupname) { - this.groupname = groupname; - } - private Integer uid; - - public Integer getUid() { - return uid; - } - - public void setUid(Integer uid) { - this.uid = uid; - } - - public Integer getGid() { - return Gid; - } - - public void setGid(Integer gid) { - Gid = gid; - } - - private Integer Gid; - -} diff --git a/src/main/java/com/example/newgroupshell/pojo/Task.java b/src/main/java/com/example/newgroupshell/pojo/Task.java index 38244cc..dd9178f 100644 --- a/src/main/java/com/example/newgroupshell/pojo/Task.java +++ b/src/main/java/com/example/newgroupshell/pojo/Task.java @@ -1,10 +1,10 @@ package com.example.newgroupshell.pojo; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.example.newgroupshell.common.enums.TaskStatusEnum; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.ToString; +import lombok.*; import java.time.LocalDateTime; @@ -18,59 +18,53 @@ import java.time.LocalDateTime; @ToString @NoArgsConstructor @AllArgsConstructor -public class Task { - /** - * The unique identifier of the task. - */ - private Integer tid; - - /** - * The title of the task. - */ - private String title; - - /** - * The description of the task. - */ - private String description; - - /** - * The time when the task was created. - */ - private LocalDateTime createdTime; - - /** - * The time when the task was last updated. - */ - private LocalDateTime updatedTime; - - /** - * The time when the task is scheduled to start. - */ - private LocalDateTime startTime; - - /** - * The deadline for the task. - */ - private LocalDateTime deadline; //TODO:deadline必须比startTime迟 - - /** - * The ID of the assignee responsible for the task. - */ - private Integer assigneeId; - - /** - * The ID of the creator of the task. - */ - private Integer creatorId; - - /** - * The priority level of the task. - */ - private Integer priority; - - /** - * The status of the task. - */ - private TaskStatusEnum status; +@Builder +@TableName("task") +public class Task +{ + /** + * The unique identifier of the task. + */ + @TableId(value="id", type=IdType.AUTO) + private Long id; + /** + * The title of the task. + */ + private String title; + /** + * The description of the task. + */ + private String description; + /** + * The time when the task was created. + */ + private LocalDateTime createdTime; + /** + * The time when the task was last updated. + */ + private LocalDateTime updatedTime; + /** + * The time when the task is scheduled to start. + */ + private LocalDateTime startTime; + /** + * The deadline for the task. + */ + private LocalDateTime deadline; //TODO:deadline必须比startTime迟 + /** + * The ID of the assignee responsible for the task. + */ + private Integer assigneeId; + /** + * The ID of the creator of the task. + */ + private Integer creatorId; + /** + * The priority level of the task. + */ + private Integer priority; + /** + * The status of the task. + */ + private TaskStatusEnum status; } \ No newline at end of file diff --git a/src/main/java/com/example/newgroupshell/pojo/User.java b/src/main/java/com/example/newgroupshell/pojo/User.java index a9cbac0..99b3a54 100644 --- a/src/main/java/com/example/newgroupshell/pojo/User.java +++ b/src/main/java/com/example/newgroupshell/pojo/User.java @@ -1,15 +1,25 @@ package com.example.newgroupshell.pojo; -import lombok.Data; -import lombok.ToString; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; import java.io.Serializable; +import java.time.LocalDateTime; @Data +@NoArgsConstructor +@AllArgsConstructor +@Builder @ToString +@TableName("user") public class User implements Serializable { - private Integer uid; + @TableId(value="id", type=IdType.AUTO) + private Long id; private String username; private String password; + private LocalDateTime createTime; + private LocalDateTime updateTime; } diff --git a/src/main/java/com/example/newgroupshell/pojo/UserGroup.java b/src/main/java/com/example/newgroupshell/pojo/UserGroup.java new file mode 100644 index 0000000..7434ff6 --- /dev/null +++ b/src/main/java/com/example/newgroupshell/pojo/UserGroup.java @@ -0,0 +1,23 @@ +package com.example.newgroupshell.pojo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +@TableName("user_group") +public class UserGroup +{ + @TableId(value="id", type=IdType.AUTO) + private Long id; + private Long userId; + private Long groupId; + private Integer authority; +} diff --git a/src/main/java/com/example/newgroupshell/result/PageResult.java b/src/main/java/com/example/newgroupshell/result/PageResult.java index ad175b9..71f6655 100644 --- a/src/main/java/com/example/newgroupshell/result/PageResult.java +++ b/src/main/java/com/example/newgroupshell/result/PageResult.java @@ -16,5 +16,5 @@ import java.util.List; public class PageResult implements Serializable { private long total; //总记录数 - private List records; //当前页数据集合 + private List records; //当前页数据集合 } diff --git a/src/main/java/com/example/newgroupshell/service/MGService.java b/src/main/java/com/example/newgroupshell/service/UserGroupService.java similarity index 40% rename from src/main/java/com/example/newgroupshell/service/MGService.java rename to src/main/java/com/example/newgroupshell/service/UserGroupService.java index f816b55..28ad277 100644 --- a/src/main/java/com/example/newgroupshell/service/MGService.java +++ b/src/main/java/com/example/newgroupshell/service/UserGroupService.java @@ -1,17 +1,16 @@ package com.example.newgroupshell.service; import com.example.newgroupshell.pojo.Group; -import com.example.newgroupshell.pojo.Member_Group; import com.example.newgroupshell.pojo.User; -import org.apache.ibatis.annotations.Param; +import com.example.newgroupshell.pojo.UserGroup; import java.util.List; -public interface MGService +public interface UserGroupService { - List findgroupbyuid(Integer uid); + List findgroupbyuid(Long uid); - int userjoingroup(Member_Group menberGroup); + int userjoingroup(UserGroup userGroup); - List selectuserbyGid(int Gid); + List selectuserbyGid(Long Gid); } diff --git a/src/main/java/com/example/newgroupshell/service/UserService.java b/src/main/java/com/example/newgroupshell/service/UserService.java index 1df6185..dc1c9b3 100644 --- a/src/main/java/com/example/newgroupshell/service/UserService.java +++ b/src/main/java/com/example/newgroupshell/service/UserService.java @@ -4,21 +4,21 @@ import com.example.newgroupshell.pojo.User; import java.util.List; -public interface UserService { - - List selectAllUsers(); - - User findUser(String username, String password); - - User findUserByName(String username); - - int addUser(User registerUser); - - User findUserById(int id); - - int setUsername(int id, String username); - - // User getUserByPhone(String phone); +public interface UserService +{ + List selectAllUsers(); + + User findUser(String username,String password); + + User findUserByName(String username); + + int addUser(User registerUser); + + User findUserById(Long id); + + int setUsername(Long id,String username); + + // User getUserByPhone(String phone); // // int setPhone(int id, String phone); // @@ -32,7 +32,7 @@ public interface UserService { // // int setDate(int id, String date); // - String getNameById(int id); + String getNameById(Long id); // // int resetPass(int id, String password); } diff --git a/src/main/java/com/example/newgroupshell/service/impl/MGServiceImpl.java b/src/main/java/com/example/newgroupshell/service/impl/UserGroupServiceImpl.java similarity index 34% rename from src/main/java/com/example/newgroupshell/service/impl/MGServiceImpl.java rename to src/main/java/com/example/newgroupshell/service/impl/UserGroupServiceImpl.java index abf8821..0754a26 100644 --- a/src/main/java/com/example/newgroupshell/service/impl/MGServiceImpl.java +++ b/src/main/java/com/example/newgroupshell/service/impl/UserGroupServiceImpl.java @@ -2,35 +2,34 @@ package com.example.newgroupshell.service.impl; import com.example.newgroupshell.mapper.MemberGroupMapper; import com.example.newgroupshell.pojo.Group; -import com.example.newgroupshell.pojo.Member_Group; import com.example.newgroupshell.pojo.User; -import com.example.newgroupshell.service.MGService; -import org.apache.ibatis.annotations.Param; +import com.example.newgroupshell.pojo.UserGroup; +import com.example.newgroupshell.service.UserGroupService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; -@Service -public class MGServiceImpl implements MGService { - - - @Autowired - private MemberGroupMapper memberGroupMapper; - - @Override - public List findgroupbyuid(Integer uid){ -return memberGroupMapper.selectgroupbyuid(uid); - - }; - @Override - public int userjoingroup(Member_Group menberGroup){ -return memberGroupMapper.memberjoingroup(menberGroup); - }; - -@Override - public List selectuserbyGid(int Gid) - { - return memberGroupMapper.selectuserbyGid(Gid); - } +@Service +public class UserGroupServiceImpl implements UserGroupService +{ + @Autowired + private MemberGroupMapper memberGroupMapper; + @Override + public List findgroupbyuid(Long uid) + { + return memberGroupMapper.selectgroupbyuid(uid); + } + ; + @Override + public int userjoingroup(UserGroup userGroup) + { + return memberGroupMapper.memberjoingroup(userGroup); + } + ; + @Override + public List selectuserbyGid(Long Gid) + { + return memberGroupMapper.selectuserbyGid(Gid); + } } diff --git a/src/main/java/com/example/newgroupshell/service/impl/UserServiceImpl.java b/src/main/java/com/example/newgroupshell/service/impl/UserServiceImpl.java index 17999ff..a5aa1e0 100644 --- a/src/main/java/com/example/newgroupshell/service/impl/UserServiceImpl.java +++ b/src/main/java/com/example/newgroupshell/service/impl/UserServiceImpl.java @@ -34,12 +34,12 @@ public class UserServiceImpl implements UserService { } @Override - public User findUserById(int id) { + public User findUserById(Long id) { return userMapper.findUserById(id); } @Override - public int setUsername(int id, String username) { + public int setUsername(Long id, String username) { return userMapper.setUsername(id,username); } @@ -79,7 +79,7 @@ public class UserServiceImpl implements UserService { // } // @Override - public String getNameById(int id) { + public String getNameById(Long id) { return userMapper.getNameById(id); } // diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 337a670..2e2a96a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,6 +4,7 @@ spring.datasource.url=jdbc:mysql://rm-cn-27a3ougjg0001sso.rwlb.rds.aliyuncs.com: spring.datasource.username=cahdsicd spring.datasource.password=xsU513Gnxjs -#spring.datasource.url=jdbc:mysql://rm-cn-27a3ougjg0001sso.rwlb.rds.aliyuncs.com:3306/groupshell -#spring.datasource.username=cahdsicd -#spring.datasource.password=xsU513Gnxjs \ No newline at end of file +server.port=8080 +mybatis-plus.configuration.map-underscore-to-camel-case=true +spring.mvc.pathmatch.matching-strategy=ant_path_matcher + diff --git a/src/main/resources/mapper/TaskMapper.xml b/src/main/resources/mapper/TaskMapper.xml index 70c6826..3b04bb0 100644 --- a/src/main/resources/mapper/TaskMapper.xml +++ b/src/main/resources/mapper/TaskMapper.xml @@ -8,7 +8,7 @@ - INSERT INTO tasks + INSERT INTO task tid, title, @@ -39,7 +39,7 @@ - UPDATE tasks + UPDATE task title = #{title}, @@ -57,6 +57,7 @@ start_time = #{startTime}, + deadline = #{deadline}, @@ -72,34 +73,34 @@ status = #{status}, - WHERE tid = #{tid} + WHERE id = #{tid} DELETE - FROM tasks - WHERE tid = #{tid} + FROM task + WHERE id = #{tid} -- Gitee