diff --git a/pom.xml b/pom.xml index aaf996921f41d8fec888ffc9ddde021611959550..5a0a738b8b5f13c6b1b3efbe8a137162a2f74e34 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 0000000000000000000000000000000000000000..92e816e6a744732aa60399193f5b23d1dfc67d08 --- /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 d7e16fad7c0b69fb55222afe1a88f77c176e240b..afe94e2ef08bb53cfc0f877935dd1141b2839cd9 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 6835f7a5e4f93994fba61f91a78b49fcbda9d31c..49b6ac8ba760917726ce7018e9c10c459491381e 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 b0b491370f84929bbaa4a00ac4382903ab0b7b8c..149fd107d89cee3f7fe5a66b9d3e81065a390d2b 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 4edf651a65d06060c7c6e59bdae36f730149693c..11f60c872767a826430dead0605ec862f94bc416 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 dbac89fe86dce3a6202830b34b41535319fff06f..68590d26dbbf3c202fb2170c99c8033e7fa9ff64 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 e1e1744c794e2a1f6c695becf8612d6acd945cbf..8291fadec2d5705e34f75559536c66a40a03ad85 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 d53be70865b3aed153ed67cb07e274c76dd8e028..33a0105c6bb05e7320b55d523a7f4a3ef0cf7e5e 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 6ed43347f4b113700dfa48ef925ad87e4cfd7171..e587ee4b8f47707bffab094bb216c2c014d23c78 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 2e28e5b9a55ae0e8df9eef89f4a40a67269114d3..0000000000000000000000000000000000000000 --- 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 38244cc28e7715ffc4178bbf74351cf0311329be..dd9178fd4c87413ed052f634277e33ae84e6d275 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 a9cbac050e3c1d6633779224a15b4f42bee83296..99b3a54312f2836c3bc0fe32273b6f4098517148 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 0000000000000000000000000000000000000000..7434ff6ee49b8178654a1e0f92f342e02a14b4eb --- /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 ad175b994dfbf8e2d26b33f0a3ea11dc7647861b..71f665534e4e2f66ca4616586ef87dfd2f9587e8 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 f816b55d3b24a5dcb93ae7beea44ba6a7648de07..28ad277bc7f4f0ff5a0e7bb9301e1525aff8f175 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 1df6185b32a8908e34f152bddf0f5a8f2d727de1..dc1c9b368d9ae72f2cd017d21dd38257df27e824 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 abf8821abc372f4c23b459ceabbc66064862e15d..0754a269395328cc328dc8d43b22a1e79ab7446c 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 17999ff77966261115f55591d2d5eac8f60f257a..a5aa1e0931930723093814fdd70f6e334a991f85 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 337a67002e5825598662b8f1f3f1d93418f5e55c..2e2a96aa72ac50591fcc4f4e61a059dd7c752396 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 70c68263b317e06ddeb1611225513aefaee2f326..3b04bb091476c3bb8705c08c23ade16047e3a84b 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}