Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,23 @@ public enum ExceptionEnum implements IBaseError {
/**
* Cm 342 exception enum.
*/
CM342("CM342", "数字格式异常");
CM342("CM342", "数字格式异常"),


/**
* Cm 343 exception enum.
*/
CM343("CM343", "该用户名已被注册,请尝试其他名称"),

/**
* Cm 344 exception enum.
*/
CM344("CM344", "账户恢复代码无效"),

/**
* Cm 345 exception enum.
*/
CM345("CM345", "用户名不存在,请重新输入"),;
/**
* 错误码
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.tinyengine.it.common.context.LoginUserContext;
import com.tinyengine.it.dynamic.dao.ModelDataDao;
import com.tinyengine.it.dynamic.dto.*;
import com.tinyengine.it.model.entity.Model;
import com.tinyengine.it.service.material.ModelService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -112,7 +113,18 @@ public Map<String, Object> insert(DynamicInsert dto) {
Map<String, Object> params = new HashMap<>();
params.put("tableName", tableName);
params.put("data", dto.getParams());


String userId = loginUserContext.getLoginUserId();
if( userId == null || userId.trim().isEmpty()) {
List<Model> modelList = modelService.getModelByEnName(dto.getNameEn());
if( modelList.isEmpty()) {
throw new IllegalArgumentException("模型不存在: " + dto.getNameEn());
}else {
userId=modelList.get(0).getCreatedBy();
}
}

// 添加系统字段
dto.getParams().put("created_by", userId);
dto.getParams().put("updated_by", userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public void addInterceptors(InterceptorRegistry registry) {
"/app-center/api/ai/chat",
"/app-center/api/chat/completions",
// 图片文件资源下载
"/material-center/api/resource/download/*"
"/material-center/api/resource/download/*",
//模型驱动
"/platform-center/api/model-data/**"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public User createUser(User user) throws Exception {
userParam.setUsername(user.getUsername());
List<User> users = baseMapper.queryUserByCondition(userParam);
if (!users.isEmpty()) {
throw new ServiceException(ExceptionEnum.CM003.getResultCode(),
ExceptionEnum.CM003.getResultMsg());
throw new ServiceException(ExceptionEnum.CM343.getResultCode(),
ExceptionEnum.CM343.getResultMsg());
}
KeyPair keyPair = generateSM2KeyPair();
PublicKey publicKey = keyPair.getPublic();
Expand Down Expand Up @@ -98,14 +98,19 @@ public Result forgotPassword(User user) throws Exception {
userParam.setUsername(user.getUsername());
List<User> users = baseMapper.queryUserByCondition(userParam);
if (users.isEmpty()) {
return Result.failed(ExceptionEnum.CM002);
return Result.failed(ExceptionEnum.CM345);
}
User userResult = users.get(0);
PublicKey publicKey = getPublicKeyFromBase64(user.getPublicKey());
PublicKey publicKey;
try {
publicKey = getPublicKeyFromBase64(user.getPublicKey());
} catch (Exception e) {
return Result.failed(ExceptionEnum.CM344);
}
PrivateKey privateKey = getPrivateKeyFromBase64(userResult.getPrivateKey());
// 验证publickey
if (!validatorPublicKey(userResult.getSalt(), publicKey, privateKey)) {
return Result.failed(ExceptionEnum.CM335);
return Result.failed(ExceptionEnum.CM344);
}
String cipherText = encrypt(user.getSalt(), publicKey);
user.setSalt(cipherText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,20 @@ public Result<App> updateAppById(App app) {
appExtendConfig.remove("route");
app.getExtendConfig().putAll(appExtendConfig);
}
String tenantId = app.getTenantId();
if(tenantId == null) {
tenantId = loginUserContext.getTenantId();
app.setTenantId(tenantId);
}
App appselect = baseMapper.queryAppById(app.getId(), tenantId);
if(appselect == null) {
return Result.failed(ExceptionEnum.CM009);
}
int result = baseMapper.updateAppById(app);
if (result < 1) {
return Result.failed(ExceptionEnum.CM001);
}
App selectedApp = baseMapper.queryAppById(app.getId(), loginUserContext.getTenantId());
App selectedApp = baseMapper.queryAppById(app.getId(), tenantId);
return Result.success(selectedApp);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public interface ModelService extends IService<Model>{
*/
List<Model> getModelByName(String nameCn);

/**
* 根据name查询表t_model信息
*
* @return the model list
*/
List<Model> getModelByEnName(String nameEn);

/**
* 分页查询表t_model
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tinyengine.it.common.context.LoginUserContext;
import com.tinyengine.it.common.enums.Enums;
import com.tinyengine.it.common.exception.ExceptionEnum;
import com.tinyengine.it.common.exception.ServiceException;
Expand Down Expand Up @@ -44,6 +45,9 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper, Model> implements

@Autowired
private DynamicModelService dynamicModelService;

@Autowired
private LoginUserContext loginUserContext;
/**
* 查询表t_model信息
*
Expand All @@ -70,6 +74,19 @@ public List<Model> getModelByName(String nameCn) {
return this.baseMapper.selectList(queryWrapper);
}

/**
* 根据name查询表t_model信息
*
* @param nameEn
* @return the model list
*/
@Override
@SystemServiceLog(description = "根据名称查询model实现方法")
public List<Model> getModelByEnName(String nameEn) {
QueryWrapper<Model> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("name_en", nameEn);
return this.baseMapper.selectList(queryWrapper); }

/**
* 分页查询表t_model信息
*
Expand All @@ -94,7 +111,8 @@ public Page<Model> pageQuery(int currentPage, int pageSize, String nameCn, Strin
queryWrapper.like("name_en", nameEn);
}
}

queryWrapper.eq("created_by", loginUserContext.getLoginUserId());
queryWrapper.eq("tenant_id", loginUserContext.getTenantId());
page(page, queryWrapper);
return page;
}
Expand Down Expand Up @@ -124,6 +142,7 @@ public Model createModel(Model model) {
methodDtos.add(getMethodDto(Enums.methodName.QUERY.getValue(), Enums.methodName.QUERYAPI.getValue(), model));
methodDtos.add(getMethodDto(Enums.methodName.DELETE.getValue(), Enums.methodName.DELETEAPI.getValue(), model));
model.setMethod(methodDtos);
model.setTenantId(loginUserContext.getTenantId());
int result = this.baseMapper.createModel(model);
if (result != 1) {
throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
Expand Down
Loading