-
-
-
org.apache.shiro -
shiro-spring -
1.3.2 -
-
- package com.example.demo.pojo;
-
- import com.baomidou.mybatisplus.annotation.TableName;
- import com.baomidou.mybatisplus.annotation.IdType;
- import com.baomidou.mybatisplus.annotation.TableId;
- import java.time.LocalDateTime;
- import java.io.Serializable;
-
- import lombok.AllArgsConstructor;
- import lombok.Data;
- import lombok.EqualsAndHashCode;
- import lombok.NoArgsConstructor;
-
- /**
- *
- * 用户信息表
- *
- *
- * @author Pengke
- * @since 2022-09-21
- */
- @Data
- @NoArgsConstructor
- @AllArgsConstructor
- @EqualsAndHashCode(callSuper = false)
- @TableName("sys_user")
- public class SysUser implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * 用户ID
- */
- @TableId(value = "user_id", type = IdType.AUTO)
- private Long userId;
-
-
- /**
- * 用户账号
- */
- private String userName;
-
-
-
- /**
- * 手机号码
- */
- private String phonenumber;
-
-
- /**
- * 密码
- */
- private String password;
-
-
-
-
- }
- public interface SysUserService extends IService
{ -
- SysUser getUserByUserName(String userName);
- }
- @Service
- public class SysUserServiceImpl extends ServiceImpl
implements SysUserService { -
- @Override
- public SysUser getUserByUserName(String userName) {
- SysUser one = getOne(new LambdaQueryWrapper
() - .eq(SysUser::getUserName, userName)
- );
- return one;
- }
- }
- package com.example.demo.utils;
-
- import lombok.AllArgsConstructor;
- import lombok.Builder;
- import lombok.Data;
- import lombok.NoArgsConstructor;
-
- /**
- * @author Administrator
- */
- @Data
- @Builder
- @AllArgsConstructor
- @NoArgsConstructor
-
- public class Result
{ - /**
- * 成功
- */
-
- private boolean success;
-
-
- private String code;
-
- /**
- * 消息
- */
-
- private String message;
-
- /**
- * 结果数据
- */
-
- private T data;
-
- public static
Result success() { - return success(null);
- }
-
- public static
Result success(T data) { - return new Result<>(true, "200", "success", data);
- }
-
- public static
Result fail(String code, String message) { - return new Result<>(false, code, message, null);
- }
-
- }
- package com.example.demo.config.shiro;
-
- import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
- import org.apache.shiro.mgt.DefaultSubjectDAO;
- import org.