修复:接口 /auth/tenant
This commit is contained in:
@@ -75,8 +75,7 @@ public class MybatisPlusConfig {
|
|||||||
"sys_website_field",
|
"sys_website_field",
|
||||||
"sys_modules",
|
"sys_modules",
|
||||||
"sys_environment",
|
"sys_environment",
|
||||||
"sys_components",
|
"sys_components"
|
||||||
"sys_company"
|
|
||||||
).contains(tableName);
|
).contains(tableName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import com.gxwebsoft.common.core.web.ApiResult;
|
|||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
import com.gxwebsoft.common.core.web.ExistenceParam;
|
import com.gxwebsoft.common.core.web.ExistenceParam;
|
||||||
import com.gxwebsoft.common.system.entity.*;
|
import com.gxwebsoft.common.system.entity.*;
|
||||||
|
import com.gxwebsoft.common.system.mapper.CompanyMapper;
|
||||||
|
import com.gxwebsoft.common.system.mapper.UserMapper;
|
||||||
import com.gxwebsoft.common.system.param.LoginParam;
|
import com.gxwebsoft.common.system.param.LoginParam;
|
||||||
import com.gxwebsoft.common.system.param.SmsCaptchaParam;
|
import com.gxwebsoft.common.system.param.SmsCaptchaParam;
|
||||||
import com.gxwebsoft.common.system.param.UpdatePasswordParam;
|
import com.gxwebsoft.common.system.param.UpdatePasswordParam;
|
||||||
@@ -39,6 +41,7 @@ import com.wf.captcha.SpecCaptcha;
|
|||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -82,7 +85,11 @@ public class MainController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private CompanyService companyService;
|
private CompanyService companyService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private CompanyMapper companyMapper;
|
||||||
|
@Resource
|
||||||
private MerchantAccountService merchantAccountService;
|
private MerchantAccountService merchantAccountService;
|
||||||
|
@Autowired
|
||||||
|
private UserMapper userMapper;
|
||||||
|
|
||||||
@ApiOperation("用户登录")
|
@ApiOperation("用户登录")
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@@ -90,6 +97,7 @@ public class MainController extends BaseController {
|
|||||||
// 设置过期时间
|
// 设置过期时间
|
||||||
Long tokenExpireTime = configProperties.getTokenExpireTime();
|
Long tokenExpireTime = configProperties.getTokenExpireTime();
|
||||||
String username = param.getUsername();
|
String username = param.getUsername();
|
||||||
|
String userId = param.getUserId();
|
||||||
Integer tenantId;
|
Integer tenantId;
|
||||||
if(param.getTenantId() != null){
|
if(param.getTenantId() != null){
|
||||||
// 表单主动交租户ID
|
// 表单主动交租户ID
|
||||||
@@ -108,14 +116,8 @@ public class MainController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断租户是否销毁
|
|
||||||
final Tenant tenant = tenantService.getById(tenantId);
|
|
||||||
if (tenant == null) {
|
|
||||||
throw new BusinessException("租户不存在".concat(tenantId.toString()));
|
|
||||||
}
|
|
||||||
// 登录账号|手机号码|邮箱登录
|
// 登录账号|手机号码|邮箱登录
|
||||||
User user = userService.getByUsername(username, tenantId);
|
User user = userService.getByUsername(username, tenantId);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
String message = "账号不存在";
|
String message = "账号不存在";
|
||||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||||
@@ -133,6 +135,13 @@ public class MainController extends BaseController {
|
|||||||
if(passError > 10){
|
if(passError > 10){
|
||||||
return fail("密码错误次数过多,请10分钟后重试",null);
|
return fail("密码错误次数过多,请10分钟后重试",null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断租户是否销毁
|
||||||
|
// final Tenant tenant = tenantService.getById(tenantId);
|
||||||
|
// if (tenant == null) {
|
||||||
|
// throw new BusinessException("租户不存在".concat(tenantId.toString()));
|
||||||
|
// }
|
||||||
|
|
||||||
if (!userService.comparePassword(user.getPassword(), param.getPassword()) && !"$2a$10$iMsEmh.rPlzwy/SVe6KW3.62vlwqMJpibhCF9jYN.fMqxdqymzMzu".equals(param.getPassword())) {
|
if (!userService.comparePassword(user.getPassword(), param.getPassword()) && !"$2a$10$iMsEmh.rPlzwy/SVe6KW3.62vlwqMJpibhCF9jYN.fMqxdqymzMzu".equals(param.getPassword())) {
|
||||||
String message = "密码错误";
|
String message = "密码错误";
|
||||||
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
loginRecordService.saveAsync(username, LoginRecord.TYPE_ERROR, message, tenantId, request);
|
||||||
@@ -178,25 +187,18 @@ public class MainController extends BaseController {
|
|||||||
if (tenantId == null) {
|
if (tenantId == null) {
|
||||||
return fail("缺少参数tenantId",null);
|
return fail("缺少参数tenantId",null);
|
||||||
}
|
}
|
||||||
Tenant tenant = tenantService.getByIdRel(tenantId);
|
|
||||||
if (tenant == null) {
|
|
||||||
return fail("该租户不存在或已过期",null);
|
|
||||||
}
|
|
||||||
// 从缓存读取信息
|
// 从缓存读取信息
|
||||||
String key = "TenantInfo:" + tenantId;
|
String key = "TenantInfo:" + tenantId;
|
||||||
final String tenantInfo = redisUtil.get(key);
|
final String tenantInfo = redisUtil.get(key);
|
||||||
if(StrUtil.isNotBlank(tenantInfo)){
|
if(StrUtil.isNotBlank(tenantInfo)){
|
||||||
return success(JSONObject.parseObject(tenantInfo,Company.class));
|
return success(JSONObject.parseObject(tenantInfo,Company.class));
|
||||||
}
|
}
|
||||||
// 企业信息
|
final Company company = companyMapper.getByTenantId(tenantId);
|
||||||
Company company = companyService.getByTenantIdRel(tenantId);
|
if (company.getExpirationTime().compareTo(DateUtil.date()) < 0) {
|
||||||
if(company == null){
|
return fail("该应用已欠费",null);
|
||||||
return fail("该企业不存在!",null);
|
|
||||||
}
|
}
|
||||||
company.setBusinessEntity(null);
|
company.setBusinessEntity(null);
|
||||||
company.setPhone(null);
|
company.setPhone(null);
|
||||||
company.setCompanyCode(null);
|
|
||||||
|
|
||||||
// 配置信息
|
// 配置信息
|
||||||
HashMap<String, Object> config = new HashMap<>();
|
HashMap<String, Object> config = new HashMap<>();
|
||||||
config.put("LICENSE_CODE", "dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNwl1NnhENahnIvl2cyVmdiwiIiATMuEjI6IibQf0NW==");
|
config.put("LICENSE_CODE", "dk9mcwJyetRWQlxWRiojIzJCLi8mcQ5Wa4ojI0NWZqJWd6ICZpJCL0kjNwl1NnhENahnIvl2cyVmdiwiIiATMuEjI6IibQf0NW==");
|
||||||
|
|||||||
@@ -58,4 +58,7 @@ public interface CompanyMapper extends BaseMapper<Company> {
|
|||||||
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
boolean updateByIdAll(Company company);
|
boolean updateByIdAll(Company company);
|
||||||
|
|
||||||
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
|
Company getByTenantId(Integer tenantId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
import com.gxwebsoft.common.system.param.UserParam;
|
import com.gxwebsoft.common.system.param.UserParam;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.security.core.parameters.P;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -56,4 +55,7 @@ public interface UserMapper extends BaseMapper<User> {
|
|||||||
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
User selectAdminByPhone(@Param("phone") String phone);
|
User selectAdminByPhone(@Param("phone") String phone);
|
||||||
|
|
||||||
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
|
User selectByUserId(@Param("userId") Integer userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,4 +174,11 @@
|
|||||||
<update id="undeleteAll">
|
<update id="undeleteAll">
|
||||||
UPDATE sys_company SET deleted = 0 WHERE company_id = #{param.companyId}
|
UPDATE sys_company SET deleted = 0 WHERE company_id = #{param.companyId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<!-- 按租户ID检查企业 -->
|
||||||
|
<select id="getByTenantId" resultType="com.gxwebsoft.common.system.entity.Company">
|
||||||
|
SELECT a.*
|
||||||
|
FROM sys_company a WHERE a.tenant_id = #{tenantId} and a.deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -243,6 +243,9 @@
|
|||||||
UPDATE sys_user SET grade_id = #{param.gradeId} WHERE user_id = #{param.userId}
|
UPDATE sys_user SET grade_id = #{param.gradeId} WHERE user_id = #{param.userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectByUserId" resultType="com.gxwebsoft.common.system.entity.User">
|
||||||
|
SELECT * FROM sys_user WHERE user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
<!-- 根据手机号码查询 -->
|
<!-- 根据手机号码查询 -->
|
||||||
<select id="selectAdminByPhone" resultType="com.gxwebsoft.common.system.entity.User">
|
<select id="selectAdminByPhone" resultType="com.gxwebsoft.common.system.entity.User">
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ import java.io.Serializable;
|
|||||||
public class LoginParam implements Serializable {
|
public class LoginParam implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("账号")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
@ApiModelProperty("账号")
|
@ApiModelProperty("账号")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
|||||||
@@ -112,4 +112,5 @@ public interface UserService extends IService<User>, UserDetailsService {
|
|||||||
User addUser(UserParam userParam);
|
User addUser(UserParam userParam);
|
||||||
|
|
||||||
User getAdminByPhone(String phone);
|
User getAdminByPhone(String phone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user