forked from p85126437/datagear
EntityService的add方法返回值由boolean改为void
This commit is contained in:
parent
76a82ff006
commit
73d2dbc980
|
@ -102,7 +102,7 @@ public interface DataPermissionEntityService<ID, T extends DataPermissionEntity<
|
|||
* @return
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
boolean add(User user, T entity) throws PermissionDeniedException;
|
||||
void add(User user, T entity) throws PermissionDeniedException;
|
||||
|
||||
/**
|
||||
* 授权更新。
|
||||
|
|
|
@ -29,7 +29,7 @@ public interface EntityService<ID, T extends Entity<ID>>
|
|||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
boolean add(T entity);
|
||||
void add(T entity);
|
||||
|
||||
/**
|
||||
* 更新。
|
||||
|
|
|
@ -102,9 +102,9 @@ public abstract class AbstractMybatisDataPermissionEntityService<ID, T extends D
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean add(User user, T entity) throws PermissionDeniedException
|
||||
public void add(User user, T entity) throws PermissionDeniedException
|
||||
{
|
||||
return super.add(entity);
|
||||
super.add(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,9 +82,9 @@ public abstract class AbstractMybatisEntityService<ID, T extends Entity<ID>> ext
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean add(T entity)
|
||||
public void add(T entity)
|
||||
{
|
||||
return super.add(entity);
|
||||
super.add(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -108,9 +108,9 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
*
|
||||
* @param entity
|
||||
*/
|
||||
protected boolean add(T entity)
|
||||
protected void add(T entity)
|
||||
{
|
||||
return add(entity, buildParamMap());
|
||||
add(entity, buildParamMap());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,15 +119,13 @@ public abstract class AbstractMybatisService<T> extends SqlSessionDaoSupport
|
|||
* @param entity
|
||||
* @param params
|
||||
*/
|
||||
protected boolean add(T entity, Map<String, Object> params)
|
||||
protected void add(T entity, Map<String, Object> params)
|
||||
{
|
||||
checkAddInput(entity);
|
||||
|
||||
params.put("entity", entity);
|
||||
|
||||
insertMybatis("insert", params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,14 +63,10 @@ public class AuthorizationServiceImpl extends AbstractMybatisEntityService<Strin
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean add(Authorization entity)
|
||||
public void add(Authorization entity)
|
||||
{
|
||||
boolean re = super.add(entity);
|
||||
|
||||
if (re)
|
||||
permissionUpdated(entity.getResourceType(), entity.getResource());
|
||||
|
||||
return re;
|
||||
super.add(entity);
|
||||
permissionUpdated(entity.getResourceType(), entity.getResource());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -186,35 +186,29 @@ public class DataSetEntityServiceImpl extends AbstractMybatisDataPermissionEntit
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean add(DataSetEntity entity, Map<String, Object> params)
|
||||
protected void add(DataSetEntity entity, Map<String, Object> params)
|
||||
{
|
||||
if (entity instanceof SummaryDataSetEntity)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
boolean success = super.add(entity, params);
|
||||
super.add(entity, params);
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (entity instanceof SqlDataSetEntity)
|
||||
success = addSqlDataSetEntity((SqlDataSetEntity) entity);
|
||||
else if (entity instanceof JsonValueDataSetEntity)
|
||||
success = addJsonValueDataSetEntity((JsonValueDataSetEntity) entity);
|
||||
else if (entity instanceof JsonFileDataSetEntity)
|
||||
success = addJsonFileDataSetEntity((JsonFileDataSetEntity) entity);
|
||||
else if (entity instanceof ExcelDataSetEntity)
|
||||
success = addExcelDataSetEntity((ExcelDataSetEntity) entity);
|
||||
else if (entity instanceof CsvValueDataSetEntity)
|
||||
success = addCsvValueDataSetEntity((CsvValueDataSetEntity) entity);
|
||||
else if (entity instanceof CsvFileDataSetEntity)
|
||||
success = addCsvFileDataSetEntity((CsvFileDataSetEntity) entity);
|
||||
else if (entity instanceof HttpDataSetEntity)
|
||||
success = addHttpDataSetEntity((HttpDataSetEntity) entity);
|
||||
}
|
||||
if (entity instanceof SqlDataSetEntity)
|
||||
addSqlDataSetEntity((SqlDataSetEntity) entity);
|
||||
else if (entity instanceof JsonValueDataSetEntity)
|
||||
addJsonValueDataSetEntity((JsonValueDataSetEntity) entity);
|
||||
else if (entity instanceof JsonFileDataSetEntity)
|
||||
addJsonFileDataSetEntity((JsonFileDataSetEntity) entity);
|
||||
else if (entity instanceof ExcelDataSetEntity)
|
||||
addExcelDataSetEntity((ExcelDataSetEntity) entity);
|
||||
else if (entity instanceof CsvValueDataSetEntity)
|
||||
addCsvValueDataSetEntity((CsvValueDataSetEntity) entity);
|
||||
else if (entity instanceof CsvFileDataSetEntity)
|
||||
addCsvFileDataSetEntity((CsvFileDataSetEntity) entity);
|
||||
else if (entity instanceof HttpDataSetEntity)
|
||||
addHttpDataSetEntity((HttpDataSetEntity) entity);
|
||||
|
||||
if (success)
|
||||
saveDataSetChildren(entity);
|
||||
|
||||
return success;
|
||||
saveDataSetChildren(entity);
|
||||
}
|
||||
|
||||
protected boolean addSqlDataSetEntity(SqlDataSetEntity entity)
|
||||
|
|
|
@ -177,14 +177,10 @@ public class HtmlChartWidgetEntityServiceImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean add(HtmlChartWidgetEntity entity, Map<String, Object> params)
|
||||
protected void add(HtmlChartWidgetEntity entity, Map<String, Object> params)
|
||||
{
|
||||
boolean success = super.add(entity, params);
|
||||
|
||||
if (success)
|
||||
saveWidgetDataSetRelations(entity);
|
||||
|
||||
return success;
|
||||
super.add(entity, params);
|
||||
saveWidgetDataSetRelations(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -71,11 +71,10 @@ public class SchemaServiceImpl extends AbstractMybatisDataPermissionEntityServic
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean add(User user, Schema entity) throws PermissionDeniedException
|
||||
public void add(User user, Schema entity) throws PermissionDeniedException
|
||||
{
|
||||
checkSaveUrlPermission(user, entity.getUrl());
|
||||
|
||||
return super.add(user, entity);
|
||||
super.add(user, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -90,36 +90,31 @@ public class UserServiceImpl extends AbstractMybatisEntityService<String, User>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean add(User entity, Map<String, Object> params)
|
||||
protected void add(User entity, Map<String, Object> params)
|
||||
{
|
||||
String password = entity.getPassword();
|
||||
|
||||
if (password != null && !password.isEmpty() && this.userPasswordEncoder != null)
|
||||
entity.setPassword(this.userPasswordEncoder.encode(password));
|
||||
|
||||
boolean add = super.add(entity, params);
|
||||
super.add(entity, params);
|
||||
|
||||
if (add)
|
||||
RoleUser roleUser = new RoleUser(IDUtil.randomIdOnTime20(), new Role(Role.ROLE_REGISTRY, ""), entity);
|
||||
this.roleUserService.add(roleUser);
|
||||
|
||||
Set<Role> roles = entity.getRoles();
|
||||
|
||||
if (roles != null && !roles.isEmpty())
|
||||
{
|
||||
RoleUser roleUser = new RoleUser(IDUtil.randomIdOnTime20(), new Role(Role.ROLE_REGISTRY, ""), entity);
|
||||
this.roleUserService.add(roleUser);
|
||||
|
||||
Set<Role> roles = entity.getRoles();
|
||||
|
||||
if (roles != null && !roles.isEmpty())
|
||||
for (Role role : roles)
|
||||
{
|
||||
for (Role role : roles)
|
||||
{
|
||||
if (Role.ROLE_REGISTRY.equals(role.getId()))
|
||||
continue;
|
||||
if (Role.ROLE_REGISTRY.equals(role.getId()))
|
||||
continue;
|
||||
|
||||
RoleUser ru = new RoleUser(IDUtil.randomIdOnTime20(), role, entity);
|
||||
this.roleUserService.add(ru);
|
||||
}
|
||||
RoleUser ru = new RoleUser(IDUtil.randomIdOnTime20(), role, entity);
|
||||
this.roleUserService.add(ru);
|
||||
}
|
||||
}
|
||||
|
||||
return add;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -326,13 +326,11 @@ public class DashboardController extends AbstractDataAnalysisController implemen
|
|||
if (firstTemplateIndex > -1)
|
||||
dashboard.setTemplateEncoding(resolveTemplateEncoding(resourceContents[firstTemplateIndex]));
|
||||
|
||||
boolean save = false;
|
||||
|
||||
if (isSaveAdd)
|
||||
{
|
||||
dashboard.setId(IDUtil.randomIdOnTime20());
|
||||
dashboard.setCreateUser(user);
|
||||
save = this.htmlTplDashboardWidgetEntityService.add(user, dashboard);
|
||||
this.htmlTplDashboardWidgetEntityService.add(user, dashboard);
|
||||
|
||||
if (form.hasCopySourceId())
|
||||
{
|
||||
|
@ -344,14 +342,11 @@ public class DashboardController extends AbstractDataAnalysisController implemen
|
|||
}
|
||||
else
|
||||
{
|
||||
save = this.htmlTplDashboardWidgetEntityService.update(user, dashboard);
|
||||
this.htmlTplDashboardWidgetEntityService.update(user, dashboard);
|
||||
}
|
||||
|
||||
if (save)
|
||||
{
|
||||
for (int i = 0; i < resourceNames.length; i++)
|
||||
saveResourceContent(dashboard, resourceNames[i], resourceContents[i]);
|
||||
}
|
||||
for (int i = 0; i < resourceNames.length; i++)
|
||||
saveResourceContent(dashboard, resourceNames[i], resourceContents[i]);
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("id", dashboard.getId());
|
||||
|
|
|
@ -184,6 +184,7 @@ public class UserController extends AbstractController
|
|||
this.userService.deleteByIds(ids);
|
||||
|
||||
this.schemaService.deleteByUserId(ids);
|
||||
// TODO 应该删除所有其他用户创建的数据
|
||||
|
||||
return buildOperationMessageDeleteSuccessResponseEntity(request);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue