|
@@ -572,6 +572,7 @@ public class TBUserController {
|
|
|
@Transactional
|
|
|
public Result save(@ApiJsonObject(name = "userSave", value = {
|
|
|
@ApiJsonProperty(key = "id", type = "long", example = "1", description = "新增不需要主键"),
|
|
|
+ @ApiJsonProperty(key = "orgId", example = "1", description = "机构id"),
|
|
|
@ApiJsonProperty(key = "loginName", description = "登录名,新增必须"),
|
|
|
@ApiJsonProperty(key = "name", description = "姓名,新增必须"),
|
|
|
@ApiJsonProperty(key = "password", description = "密码,新增必须"),
|
|
@@ -582,22 +583,21 @@ public class TBUserController {
|
|
|
if (Objects.isNull(mapParameter)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.USER_INFO_IS_NULL);
|
|
|
}
|
|
|
- TBUser tbUser = null;
|
|
|
+ if (Objects.isNull(mapParameter.get("orgId"))) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ Long orgId = Long.parseLong(String.valueOf(mapParameter.get("orgId")));
|
|
|
try {
|
|
|
Gson gson = new Gson();
|
|
|
- tbUser = gson.fromJson(gson.toJson(mapParameter), TBUser.class);
|
|
|
+ TBUser tbUser = gson.fromJson(gson.toJson(mapParameter), TBUser.class);
|
|
|
List<String> roleList = (List<String>) mapParameter.get("roles");
|
|
|
Set<String> roleSet = null;
|
|
|
if (Objects.nonNull(roleList) && roleList.size() > 0) {
|
|
|
roleSet = new HashSet<>(roleList);
|
|
|
}
|
|
|
if (Objects.isNull(tbUser.getId())) {
|
|
|
- TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
|
|
|
- if (Objects.isNull(tbOrg) || Objects.isNull(tbOrg.getId())) {
|
|
|
- throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
|
|
|
- }
|
|
|
tbUser.setId(Constants.idGen.next());
|
|
|
- tbUser.setOrgId(tbOrg.getId());
|
|
|
+ tbUser.setOrgId(orgId);
|
|
|
tbUser.setCreateId(tbUser.getId());
|
|
|
if (Objects.nonNull(roleSet) && roleSet.size() > 0) {
|
|
|
TBUser finalTbUser = tbUser;
|
|
@@ -626,7 +626,7 @@ public class TBUserController {
|
|
|
if (e instanceof DuplicateKeyException) {
|
|
|
String errorColumn = e.getCause().toString();
|
|
|
String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
|
|
|
- throw new BusinessException("机构id[" + tbUser.getLoginName() + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
|
|
|
+ throw new BusinessException("机构id[" + orgId + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
|
|
|
} else if (e instanceof BusinessException) {
|
|
|
throw new BusinessException(e.getMessage());
|
|
|
} else {
|