修改:

1.新增检查登录爬大哥客户端登录接口
This commit is contained in:
2025-06-25 18:17:23 +08:00
parent aada30a000
commit 6819b6c1d4
6 changed files with 55 additions and 5 deletions

View File

@@ -63,4 +63,35 @@ public class UserController {
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);
}
}

View File

@@ -5,7 +5,7 @@ import com.yupi.springbootinit.model.entity.SystemUsers;
/*
* @author: ziin
* @date: 2025/6/20 19:19
* @date: 2025/6/25 18:15
*/
public interface SystemUsersMapper extends BaseMapper<SystemUsers> {

View File

@@ -11,7 +11,7 @@ import lombok.Data;
/*
* @author: ziin
* @date: 2025/6/20 19:19
* @date: 2025/6/25 18:15
*/
/**
@@ -162,9 +162,16 @@ public class SystemUsers {
private Long tenantId;
/**
* 能否登录爬虫客户端
* 能否登录主播爬虫客户端
*/
@TableField(value = "crawl")
@ApiModelProperty(value = "能否登录爬虫客户端")
@ApiModelProperty(value = "能否登录主播爬虫客户端")
private Byte crawl;
/**
* 能否登录大哥爬虫客户端
*/
@TableField(value = "big_brother")
@ApiModelProperty(value = "能否登录大哥爬虫客户端")
private Byte bigBrother;
}

View File

@@ -20,4 +20,7 @@ public interface SystemUsersService extends IService<SystemUsers> {
boolean checkCrawlRole(Long userId);
boolean checkbigBrotherlRole(Long userId);
}

View File

@@ -69,4 +69,12 @@ public class SystemUsersServiceImpl extends ServiceImpl<SystemUsersMapper,System
SystemUsers systemUsers = baseMapper.selectById(userId);
return systemUsers.getCrawl() == 1;
}
@Override
public boolean checkbigBrotherlRole(Long userId) {
SystemUsers systemUsers = baseMapper.selectById(userId);
return systemUsers.getBigBrother() == 1;
}
}

View File

@@ -25,12 +25,13 @@
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="crawl" jdbcType="TINYINT" property="crawl" />
<result column="big_brother" jdbcType="TINYINT" property="bigBrother" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, username, `password`, nickname, remark, dept_id, post_ids, email, mobile, sex,
avatar, `status`, login_ip, login_date, creator, create_time, updater, update_time,
deleted, tenant_id, crawl
deleted, tenant_id, crawl, big_brother
</sql>
<select id="selectUsername" resultType="int">