修改:
1.新增检查登录爬大哥客户端登录接口
This commit is contained in:
@@ -63,4 +63,35 @@ public class UserController {
|
|||||||
return ResultUtils.success(systemUsersVO);
|
return ResultUtils.success(systemUsersVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用户登陆接口
|
||||||
|
@PostMapping("bigbrother-doLogin")
|
||||||
|
public BaseResponse<SystemUsersVO> bigBrotherDoLogin(@RequestBody SystemUsersDTO usersDTO) {
|
||||||
|
SystemUsers user = usersService.getUserByUserName(usersDTO.getUsername(),usersDTO.getTenantId());
|
||||||
|
if (user == null) {
|
||||||
|
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||||
|
}
|
||||||
|
if (!usersService.isPasswordMatch(usersDTO.getPassword(), user.getPassword())) {
|
||||||
|
throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommonStatusEnum.isDisable(Integer.valueOf(user.getStatus()))) {
|
||||||
|
throw new BusinessException(ErrorCode.USER_DISABLE);
|
||||||
|
}
|
||||||
|
if (usersService.isExpired(usersDTO.getTenantId())){
|
||||||
|
throw new BusinessException(ErrorCode.PACKAGE_EXPIRED);
|
||||||
|
}
|
||||||
|
if (!usersService.checkbigBrotherlRole(user.getId())){
|
||||||
|
throw new BusinessException(ErrorCode.LOGIN_NOW_ALLOWED);
|
||||||
|
}
|
||||||
|
Long second = usersService.getTenantExpiredTime(usersDTO.getTenantId());
|
||||||
|
SystemUsersVO systemUsersVO = new SystemUsersVO();
|
||||||
|
BeanUtil.copyProperties(user, systemUsersVO);
|
||||||
|
// 赋予用户 Id
|
||||||
|
StpUtil.login(user.getId());
|
||||||
|
// 设置 token 有效期为当前日期和套餐有效期的差值
|
||||||
|
StpUtil.renewTimeout(second);
|
||||||
|
systemUsersVO.setTokenName(StpUtil.getTokenName());
|
||||||
|
systemUsersVO.setTokenValue(StpUtil.getTokenValue());
|
||||||
|
return ResultUtils.success(systemUsersVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.yupi.springbootinit.model.entity.SystemUsers;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @author: ziin
|
* @author: ziin
|
||||||
* @date: 2025/6/20 19:19
|
* @date: 2025/6/25 18:15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface SystemUsersMapper extends BaseMapper<SystemUsers> {
|
public interface SystemUsersMapper extends BaseMapper<SystemUsers> {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @author: ziin
|
* @author: ziin
|
||||||
* @date: 2025/6/20 19:19
|
* @date: 2025/6/25 18:15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,9 +162,16 @@ public class SystemUsers {
|
|||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 能否登录爬虫客户端
|
* 能否登录主播爬虫客户端
|
||||||
*/
|
*/
|
||||||
@TableField(value = "crawl")
|
@TableField(value = "crawl")
|
||||||
@ApiModelProperty(value = "能否登录爬虫客户端")
|
@ApiModelProperty(value = "能否登录主播爬虫客户端")
|
||||||
private Byte crawl;
|
private Byte crawl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 能否登录大哥爬虫客户端
|
||||||
|
*/
|
||||||
|
@TableField(value = "big_brother")
|
||||||
|
@ApiModelProperty(value = "能否登录大哥爬虫客户端")
|
||||||
|
private Byte bigBrother;
|
||||||
}
|
}
|
||||||
@@ -20,4 +20,7 @@ public interface SystemUsersService extends IService<SystemUsers> {
|
|||||||
|
|
||||||
boolean checkCrawlRole(Long userId);
|
boolean checkCrawlRole(Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
boolean checkbigBrotherlRole(Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,4 +69,12 @@ public class SystemUsersServiceImpl extends ServiceImpl<SystemUsersMapper,System
|
|||||||
SystemUsers systemUsers = baseMapper.selectById(userId);
|
SystemUsers systemUsers = baseMapper.selectById(userId);
|
||||||
return systemUsers.getCrawl() == 1;
|
return systemUsers.getCrawl() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkbigBrotherlRole(Long userId) {
|
||||||
|
SystemUsers systemUsers = baseMapper.selectById(userId);
|
||||||
|
return systemUsers.getBigBrother() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,12 +25,13 @@
|
|||||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||||
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
|
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
|
||||||
<result column="crawl" jdbcType="TINYINT" property="crawl" />
|
<result column="crawl" jdbcType="TINYINT" property="crawl" />
|
||||||
|
<result column="big_brother" jdbcType="TINYINT" property="bigBrother" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
id, username, `password`, nickname, remark, dept_id, post_ids, email, mobile, sex,
|
id, username, `password`, nickname, remark, dept_id, post_ids, email, mobile, sex,
|
||||||
avatar, `status`, login_ip, login_date, creator, create_time, updater, update_time,
|
avatar, `status`, login_ip, login_date, creator, create_time, updater, update_time,
|
||||||
deleted, tenant_id, crawl
|
deleted, tenant_id, crawl, big_brother
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectUsername" resultType="int">
|
<select id="selectUsername" resultType="int">
|
||||||
|
|||||||
Reference in New Issue
Block a user