mirror of
				https://github.com/suyiiyii/SIMS.git
				synced 2025-11-04 15:54:52 +08:00 
			
		
		
		
	模糊查询
This commit is contained in:
		
							parent
							
								
									4a72ee2e53
								
							
						
					
					
						commit
						cc053a6834
					
				@ -13,7 +13,7 @@ Super Invincible Management System
 | 
			
		||||
8. require review: 请求reviewpush
 | 
			
		||||
9. merge: 合并 PR
 | 
			
		||||
10. delete: 删除分支
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
1. 基础rbac的五张表: user, role, permission, user_role, role_permission
 | 
			
		||||
2. 然后奖惩记录这张表,通过用户id来查到,里面有相应的记录, 有一个 奖惩类别ID是对应到奖惩类型去的
 | 
			
		||||
3. 有一个上下级关系表,想着是用户明确查上下级就可以用查,
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ import top.suyiiyii.sims.dto.CommonResponse;
 | 
			
		||||
import top.suyiiyii.sims.dto.RecordDto;
 | 
			
		||||
import top.suyiiyii.sims.entity.Record;
 | 
			
		||||
import top.suyiiyii.sims.entity.Role;
 | 
			
		||||
import top.suyiiyii.sims.entity.User;
 | 
			
		||||
 | 
			
		||||
import top.suyiiyii.sims.entity.UserRole;
 | 
			
		||||
import top.suyiiyii.sims.mapper.CategoryMapper;
 | 
			
		||||
import top.suyiiyii.sims.mapper.UserMapper;
 | 
			
		||||
 | 
			
		||||
@ -74,11 +74,12 @@ public class UserController {
 | 
			
		||||
            throw new ServiceException("密码长度不能小于3位");
 | 
			
		||||
        }
 | 
			
		||||
        User user = new User();
 | 
			
		||||
 | 
			
		||||
        user.setUsername(request.getUsername());
 | 
			
		||||
        user.setPassword(request.getPassword());
 | 
			
		||||
        user.setEmail(request.getEmail());
 | 
			
		||||
        user.setGrade(request.getGrade());
 | 
			
		||||
        user.setUserGroup(request.getGroup());
 | 
			
		||||
        user.setUserGroup(request.getUserGroup());
 | 
			
		||||
        userService.register(user);
 | 
			
		||||
 | 
			
		||||
        return Result.success(CommonResponse.factory("注册成功"));
 | 
			
		||||
@ -118,10 +119,11 @@ public class UserController {
 | 
			
		||||
    @Data
 | 
			
		||||
    public static class RegisterRequest {
 | 
			
		||||
        private String username;
 | 
			
		||||
        private Integer studentId;
 | 
			
		||||
        private String password;
 | 
			
		||||
        private String email;
 | 
			
		||||
        private String grade;
 | 
			
		||||
        private String group;
 | 
			
		||||
        private String userGroup;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Data
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class Attachment {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private Integer recordId;
 | 
			
		||||
    // 文件路径
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class HierarchyRelation {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
 | 
			
		||||
    // 上级用户ID
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
package top.suyiiyii.sims.entity;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.IdType;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableId;
 | 
			
		||||
import com.tangzc.mpe.autotable.annotation.Table;
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
@ -21,7 +22,7 @@ import java.time.LocalDateTime;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class Notification {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private String title;
 | 
			
		||||
    private String content;
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ import java.util.Objects;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class Permissions {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    //权限id
 | 
			
		||||
    private Integer permissionId;
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
package top.suyiiyii.sims.entity;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.IdType;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableId;
 | 
			
		||||
import com.tangzc.mpe.autotable.annotation.Table;
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
@ -21,7 +22,7 @@ import java.time.LocalDateTime;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class RevokeRequest {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private Integer recordId;
 | 
			
		||||
    private Integer userId;
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
package top.suyiiyii.sims.entity;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.IdType;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableId;
 | 
			
		||||
import com.tangzc.mpe.autotable.annotation.Table;
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
@ -21,7 +22,7 @@ import java.time.LocalDateTime;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class RevokedRecord {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    // 被撤销的奖惩记录ID
 | 
			
		||||
    private Integer recordId;
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class RewardPunishmentCategory {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
 | 
			
		||||
    private Integer categoryId;
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class Role {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private Integer roleId;
 | 
			
		||||
    //管理员,普通用户,组员,组长,队长
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@ import java.security.Permission;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class RolePermission {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private Integer roleId;
 | 
			
		||||
    private Integer permissionId;
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,6 @@
 | 
			
		||||
package top.suyiiyii.sims.entity;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.IdType;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableId;
 | 
			
		||||
import com.tangzc.mpe.autotable.annotation.Table;
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
@ -19,7 +20,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class User {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private Integer studentId;
 | 
			
		||||
    private String username;
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ import lombok.NoArgsConstructor;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@NoArgsConstructor
 | 
			
		||||
public class UserRole {
 | 
			
		||||
    @TableId("id")
 | 
			
		||||
    @TableId(type= IdType.AUTO)
 | 
			
		||||
    private Integer id;
 | 
			
		||||
    private Integer userId;
 | 
			
		||||
    private Integer roleId;
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ public interface RecordMapper {
 | 
			
		||||
    List<Record> getAllRecords(Integer page, Integer size);
 | 
			
		||||
//根据学号分页查询所以信息
 | 
			
		||||
    @Select("select * from record where student_id = #{id} limit #{page},#{size}")
 | 
			
		||||
    List<Record> getMyAllRecords(Integer page, Integer size, String id);
 | 
			
		||||
    List<Record> getMyAllRecords(Integer page, Integer size, Integer id);
 | 
			
		||||
    //根据id,更新对应信息
 | 
			
		||||
    @Update("UPDATE record SET "
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ public interface UserMapper extends BaseMapper<User> {
 | 
			
		||||
     * @param user 新用户对象
 | 
			
		||||
     * @return 影响的行数
 | 
			
		||||
     */
 | 
			
		||||
    @Insert("insert INTO user (id,student_id, username, password, name, email, userGroup) VALUES (#{id},#{studentId}, #{username}, #{password}, #{name}, #{email}, #{userGroup})")
 | 
			
		||||
    @Insert("insert INTO user (student_id, username, password,  email, user_group) VALUES (#{studentId}, #{username}, #{password},  #{email}, #{userGroup})")
 | 
			
		||||
    int addUser(User user);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -41,7 +41,7 @@ public interface UserMapper extends BaseMapper<User> {
 | 
			
		||||
    @Update("UPDATE user SET " +
 | 
			
		||||
            "student_id = #{userId}, " +
 | 
			
		||||
            "username = #{username}, " +
 | 
			
		||||
            "name = #{name}, " +
 | 
			
		||||
 | 
			
		||||
            "email = #{email}, " +
 | 
			
		||||
            "grade = #{grade}, " +
 | 
			
		||||
            "userGroup = #{group} " +
 | 
			
		||||
@ -53,7 +53,7 @@ public interface UserMapper extends BaseMapper<User> {
 | 
			
		||||
     * @param
 | 
			
		||||
     * @return 用户对象
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT id, student_id, username, password, name, email,grade,user_group from user WHERE student_id = #{id}")
 | 
			
		||||
    @Select("SELECT id, student_id, username, password, email,grade,user_group from user WHERE student_id = #{id}")
 | 
			
		||||
    User selectByUserId(Integer id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -61,13 +61,13 @@ public interface UserMapper extends BaseMapper<User> {
 | 
			
		||||
     * @param
 | 
			
		||||
     * @return 用户对象
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT id, student_id, username, password, name, email,grade, user_group from user WHERE id = #{id}")
 | 
			
		||||
    @Select("SELECT id, student_id, username, password,  email,grade, user_group from user WHERE id = #{id}")
 | 
			
		||||
    User selectById(Integer id);
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询所有用户信息
 | 
			
		||||
     * @return 用户列表
 | 
			
		||||
     */
 | 
			
		||||
    @Select("SELECT id, student_id, username, password, name, email, grade, user_group FROM user")
 | 
			
		||||
    @Select("SELECT id, student_id, username, password,  email, grade, user_group FROM user")
 | 
			
		||||
    List<User> selectAll();
 | 
			
		||||
 | 
			
		||||
  @Select("select * from user where username = #{username}")
 | 
			
		||||
@ -75,7 +75,7 @@ public interface UserMapper extends BaseMapper<User> {
 | 
			
		||||
@Update("update user set password = #{password} where username = #{username}")
 | 
			
		||||
    void updatePassword(User user);
 | 
			
		||||
@Select("select student_id from user where id = #{userId}")
 | 
			
		||||
    String getStudentIdById(String userId);
 | 
			
		||||
Integer getStudentIdById(Integer userId);
 | 
			
		||||
    @Select("SELECT student_id from user WHERE id = #{id}")
 | 
			
		||||
    Integer selectStudentIdByUserId(Integer id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ public class RecordService {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public List<Record> getMyAllRecords(Integer page, Integer size, String userId) {
 | 
			
		||||
        String studentId = userMapper.getStudentIdById(userId);
 | 
			
		||||
        Integer studentId = userMapper.getStudentIdById(Integer.valueOf(userId));
 | 
			
		||||
        return recordMapper.getMyAllRecords(page, size, studentId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -84,7 +84,7 @@ public class UserService {
 | 
			
		||||
 | 
			
		||||
    public User register(User user) {
 | 
			
		||||
 | 
			
		||||
        User dbUser = userMapper.selectByUserId(user.getStudentId());
 | 
			
		||||
        User dbUser = userMapper.selectById(user.getId());
 | 
			
		||||
 | 
			
		||||
        if (user.getUsername() == null || user.getUsername().equals("")) {
 | 
			
		||||
        throw new ServiceException("用户名不能为空");
 | 
			
		||||
@ -92,9 +92,7 @@ public class UserService {
 | 
			
		||||
        if (dbUser != null) {
 | 
			
		||||
            throw new ServiceException("账号已经存在");
 | 
			
		||||
        }
 | 
			
		||||
        if (user.getStudentId() == null || user.getStudentId().equals("")) {
 | 
			
		||||
            throw new ServiceException("用户id不能为空");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if( user.getPassword() == null || user.getPassword().equals("")) {
 | 
			
		||||
            throw new ServiceException("密码不能为空");
 | 
			
		||||
        }
 | 
			
		||||
@ -160,9 +158,7 @@ public class UserService {
 | 
			
		||||
        return UserDto;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public User selectByUserId(Integer studentId) {
 | 
			
		||||
        return userMapper.selectByUserId(studentId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public List<Role> selectRolesById(Integer studentId) {
 | 
			
		||||
        return roleMapper.selectRolesById(studentId);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user