Merge commit '2beebbe4697356016295740ea01df1c99b26adc7'
This commit is contained in:
@@ -73,7 +73,7 @@ public class AuthInterceptor implements HandlerInterceptor {
|
||||
.orElseThrow(() -> new UnauthorizedException("未登录或登录已过期"));
|
||||
|
||||
SysUser user = sysUserMapper.findByIdAndCompanyId(loginUser.userId(), loginUser.companyId());
|
||||
SysCompany company = sysCompanyMapper.findById(loginUser.companyId());
|
||||
SysCompany company = sysCompanyMapper.selectById(loginUser.companyId());
|
||||
if (user == null || company == null || user.getStatus() != UserStatus.ENABLED || company.getStatus() != CompanyStatus.ENABLED) {
|
||||
throw new UnauthorizedException("未登录或登录已过期");
|
||||
}
|
||||
|
||||
@@ -8,17 +8,11 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface SysCompanyMapper extends BaseMapper<SysCompany> {
|
||||
|
||||
int insert(SysCompany company);
|
||||
|
||||
SysCompany findById(@Param("id") Long id);
|
||||
|
||||
SysCompany findByCompanyCode(@Param("companyCode") String companyCode);
|
||||
|
||||
List<SysCompany> findEnabledCompaniesByPhone(@Param("phone") String phone);
|
||||
|
||||
List<SysCompany> listAll();
|
||||
|
||||
int updateStatus(@Param("id") Long id, @Param("status") CompanyStatus status);
|
||||
|
||||
void deleteAll();
|
||||
}
|
||||
}
|
||||
@@ -10,35 +10,21 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
int insert(SysUser user);
|
||||
|
||||
SysUser findById(@Param("id") Long id);
|
||||
|
||||
SysUser findByIdAndCompanyId(@Param("id") Long id, @Param("companyId") Long companyId);
|
||||
|
||||
SysUser findByCompanyIdAndPhone(@Param("companyId") Long companyId, @Param("phone") String phone);
|
||||
|
||||
List<SysUser> listByCompanyId(@Param("companyId") Long companyId);
|
||||
|
||||
List<SysUser> listCompanyAdmins(@Param("companyId") Long companyId);
|
||||
|
||||
int updatePassword(
|
||||
@Param("id") Long id,
|
||||
@Param("companyId") Long companyId,
|
||||
@Param("passwordHash") String passwordHash,
|
||||
@Param("mustChangePassword") boolean mustChangePassword
|
||||
);
|
||||
int updatePassword(@Param("id") Long id, @Param("companyId") Long companyId,
|
||||
@Param("passwordHash") String passwordHash, @Param("mustChangePassword") boolean mustChangePassword);
|
||||
|
||||
int updateAssignment(
|
||||
@Param("id") Long id,
|
||||
@Param("companyId") Long companyId,
|
||||
@Param("role") UserRole role,
|
||||
@Param("position") UserPosition position
|
||||
);
|
||||
int updateAssignment(@Param("id") Long id, @Param("companyId") Long companyId, @Param("role") UserRole role,
|
||||
@Param("position") UserPosition position);
|
||||
|
||||
int updateStatus(@Param("id") Long id, @Param("companyId") Long companyId, @Param("status") UserStatus status);
|
||||
|
||||
int bumpSessionVersion(@Param("id") Long id, @Param("companyId") Long companyId);
|
||||
|
||||
void deleteAll();
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class CompanyService {
|
||||
|
||||
public List<SysCompany> listCompanies(LoginUser currentUser) {
|
||||
assertPlatformAdmin(currentUser);
|
||||
return sysCompanyMapper.listAll();
|
||||
return sysCompanyMapper.selectList(null);
|
||||
}
|
||||
|
||||
public SysCompany createCompany(LoginUser currentUser, CreateCompanyRequest request) {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package com.labelsys.backend.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.labelsys.backend.common.ResultCode;
|
||||
import com.labelsys.backend.common.exception.BusinessException;
|
||||
import com.labelsys.backend.common.exception.ForbiddenException;
|
||||
@@ -18,11 +25,8 @@ import com.labelsys.backend.mapper.SysCompanyMapper;
|
||||
import com.labelsys.backend.mapper.SysUserMapper;
|
||||
import com.labelsys.backend.service.session.TokenSessionRepository;
|
||||
import com.labelsys.backend.util.IdGenerator;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -37,7 +41,9 @@ public class UserService {
|
||||
|
||||
public List<SysUser> listCompanyUsers(LoginUser currentUser) {
|
||||
assertCompanyAdmin(currentUser);
|
||||
return sysUserMapper.listByCompanyId(currentUser.companyId());
|
||||
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getCompanyId, currentUser.companyId()).orderByAsc(SysUser::getId);
|
||||
return sysUserMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
public List<SysUser> listCompanyAdmins(LoginUser currentUser, Long companyId) {
|
||||
@@ -114,7 +120,7 @@ public class UserService {
|
||||
}
|
||||
|
||||
private void ensureEnabledCompany(Long companyId) {
|
||||
SysCompany company = sysCompanyMapper.findById(companyId);
|
||||
SysCompany company = sysCompanyMapper.selectById(companyId);
|
||||
if (company == null || company.getStatus() != CompanyStatus.ENABLED) {
|
||||
throw new BusinessException(ResultCode.NOT_FOUND, "公司不存在或已禁用");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user