提交 e09f7b98 编写于 作者: sq3536's avatar sq3536

提交uaa相关

上级 908d87fc
......@@ -17,7 +17,6 @@ import java.sql.Timestamp;
@JsonIgnoreProperties(ignoreUnknown = true)
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class IBZConfig {
......
......@@ -33,9 +33,15 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
if(ObjectUtils.isEmpty(userId) || ObjectUtils.isEmpty(cfgType) || ObjectUtils.isEmpty(targetType)) {
throw new BadRequestAlertException("获取配置失败,参数缺失","IBZConfig",cfgType);
}
IBZConfig config = this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()), false);
IBZConfig builder=new IBZConfig();
builder.setSystemId(systemId);
builder.setCfgType(cfgType);
builder.setTargetType(targetType);
builder.setUserId(userId);
IBZConfig config = this.getOne(Wrappers.query(builder), false);
if(config == null) {
config = this.getOne(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(adminuserid).build()), false);
builder.setUserId(adminuserid);
config = this.getOne(Wrappers.query(builder), false);
if(config == null) {
return new JSONObject();
}
......@@ -53,7 +59,15 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
if(config != null) {
cfg = JSONObject.toJSONString(config);
}
return this.saveOrUpdate(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).cfg(cfg).updateDate(DataObject.getNow()).build());
IBZConfig builder=new IBZConfig();
builder.setSystemId(systemId);
builder.setCfgType(cfgType);
builder.setTargetType(targetType);
builder.setUserId(userId);
builder.setCfg(cfg);
builder.setUpdateDate(DataObject.getNow());
builder.getCfgId();
return this.saveOrUpdate(builder);
}
@CacheEvict(value = "ibzrt_configs", key = "'cfgid:'+#p0+'||'+#p1+'||'+#p2")
......@@ -62,12 +76,17 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
if(ObjectUtils.isEmpty(userId) || ObjectUtils.isEmpty(cfgType) || ObjectUtils.isEmpty(targetType)) {
throw new BadRequestAlertException("重置配置失败,参数缺失","IBZConfig",cfgType);
}
this.remove(Wrappers.query(IBZConfig.builder().systemId(systemId).cfgType(cfgType).targetType(targetType).userId(userId).build()));
IBZConfig builder=new IBZConfig();
builder.setSystemId(systemId);
builder.setCfgType(cfgType);
builder.setTargetType(targetType);
builder.setUserId(userId);
this.remove(Wrappers.query(builder));
}
@Cacheable(value="ibzrt_shareconfigs",key = "'cfgid:'+#p0")
public JSONObject saveShareConfig(String id, String cfgType,String targetType,String userId){
return this.getConfig(cfgType, targetType, userId);
return this.getConfig(cfgType, targetType, adminuserid);
}
@Cacheable(value="ibzrt_shareconfigs",key = "'cfgid:'+#p0")
......
package cn.ibizlab.util.service;
import cn.ibizlab.util.domain.IBZUSER;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
public interface IBZUSERService extends IService<IBZUSER> {
}
\ No newline at end of file
package cn.ibizlab.util.service;
import cn.ibizlab.util.domain.IBZUSER;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.helper.CachedBeanCopier;
import cn.ibizlab.util.mapper.IBZUSERMapper;
import cn.ibizlab.util.security.AuthenticationUser;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
@Service("IBZUSERService")
@ConditionalOnExpression("(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:IBZUAAUserService}'.equals('IBZUSERService')")
public class IBZUSERServiceImpl extends ServiceImpl<IBZUSERMapper, IBZUSER> implements IBZUSERService, AuthenticationUserService {
@Value("${ibiz.auth.pwencrymode:0}")
private int pwencrymode;
@Override
public AuthenticationUser loadUserByUsername(String username) {
if(StringUtils.isEmpty(username)) {
throw new UsernameNotFoundException("用户名为空");
}
QueryWrapper<IBZUSER> conds = new QueryWrapper<IBZUSER>();
String[] data = username.split("[|]");
String loginname = "";
String domains = "";
if(data.length>0) {
loginname = data[0].trim();
}
if(data.length>1) {
domains = data[1].trim();
}
if(!StringUtils.isEmpty(loginname)) {
conds.eq("loginname",loginname);
}
if(!StringUtils.isEmpty(domains)) {
conds.eq("domains",domains);
}
IBZUSER user = this.getOne(conds);
if (user == null) {
throw new UsernameNotFoundException("用户" + username + "未找到");
}
else {
user.setUsername(username);
return createUserDetails(user);
}
}
@Override
public AuthenticationUser loadUserByLogin(String username, String password){
AuthenticationUser authuserdetail = loadUserByUsername(username);
if(pwencrymode == 1){
password = DigestUtils.md5DigestAsHex(password.getBytes());
}
else if(pwencrymode == 2){
password = DigestUtils.md5DigestAsHex(String.format("%1$s||%2$s", username, password).getBytes());
}
if(!authuserdetail.getPassword().equals(password)) {
throw new BadRequestAlertException("用户名密码错误","IBZUSER",username);
}
return authuserdetail;
}
public void resetByUsername(String username) {
}
public AuthenticationUser createUserDetails(IBZUSER user) {
AuthenticationUser userdatail = new AuthenticationUser();
CachedBeanCopier.copy(user,userdatail);
userdatail.setSuperuser(user.getSuperuser());
if(userdatail.getSuperuser() == 1){
userdatail.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_USERS","ROLE_SUPERADMIN"));
}
else {
userdatail.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_USERS"));
}
return userdatail;
}
}
\ No newline at end of file
......@@ -8,4 +8,4 @@ EXPOSE 8080
ADD ibizlab-gateway.jar /ibizlab-gateway.jar
#docker buildx build --platform linux/arm64,linux/amd64 -t ibiz4j/ibizlab-gateway:2.4.0.1 -t ibiz4j/ibizlab-gateway:latest --push .
\ No newline at end of file
#docker buildx build --platform linux/arm64,linux/amd64 -t ibiz4j/ibizlab-gateway:2.4.0.2 -t ibiz4j/ibizlab-gateway:latest --push .
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册