use of com.baomidou.mybatisplus.extension.service.IService in project jeecg-boot by jeecgboot.
the class ImportExcelUtil method importDateSaveOne.
public static List<String> importDateSaveOne(Object obj, Class serviceClass, List<String> errorMessage, int i, String errorFlag) {
IService bean = (IService) SpringContextUtils.getBean(serviceClass);
try {
boolean save = bean.save(obj);
if (!save) {
throw new Exception(errorFlag);
}
} catch (Exception e) {
String message = e.getMessage().toLowerCase();
int lineNumber = i + 1;
// 通过索引名判断出错信息
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE)) {
errorMessage.add("第 " + lineNumber + " 行:角色编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
errorMessage.add("第 " + lineNumber + " 行:任务类名已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
errorMessage.add("第 " + lineNumber + " 行:职务编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
errorMessage.add("第 " + lineNumber + " 行:部门编码已经存在,忽略导入。");
} else {
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
log.error(e.getMessage(), e);
}
}
return errorMessage;
}
use of com.baomidou.mybatisplus.extension.service.IService in project kykms by mahonelau.
the class ImportExcelUtil method importDateSaveOne.
public static List<String> importDateSaveOne(Object obj, Class serviceClass, List<String> errorMessage, int i, String errorFlag) {
IService bean = (IService) SpringContextUtils.getBean(serviceClass);
try {
boolean save = bean.save(obj);
if (!save) {
throw new Exception(errorFlag);
}
} catch (Exception e) {
String message = e.getMessage().toLowerCase();
int lineNumber = i + 1;
// 通过索引名判断出错信息
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE)) {
errorMessage.add("第 " + lineNumber + " 行:角色编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
errorMessage.add("第 " + lineNumber + " 行:任务类名已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
errorMessage.add("第 " + lineNumber + " 行:职务编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
errorMessage.add("第 " + lineNumber + " 行:部门编码已经存在,忽略导入。");
} else {
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
log.error(e.getMessage(), e);
}
}
return errorMessage;
}
use of com.baomidou.mybatisplus.extension.service.IService in project springboot-learning by lyb-geek.
the class UpdateWapperAspect method updateEntity.
/**
*重写update(Wrapper<T> updateWrapper), 更新时自动填充不生效问题
* @param pjp
* @return
*/
private Object updateEntity(ProceedingJoinPoint pjp) {
Object[] args = pjp.getArgs();
if (args != null && args.length == 1) {
Object arg = args[0];
if (arg instanceof Wrapper) {
Wrapper updateWrapper = (Wrapper) arg;
Object entity = updateWrapper.getEntity();
IService service = (IService) applicationContext.getBean(pjp.getTarget().getClass());
if (ObjectUtils.isEmpty(entity)) {
entity = entityMap.get(pjp.getTarget().getClass().getName());
if (ObjectUtils.isEmpty(entity)) {
Class entityClz = ReflectionKit.getSuperClassGenericType(pjp.getTarget().getClass(), 1);
try {
entity = entityClz.newInstance();
} catch (InstantiationException e) {
log.warn("Entity instantiating exception!");
} catch (IllegalAccessException e) {
log.warn("Entity illegal access exception!");
}
entityMap.put(pjp.getTarget().getClass().getName(), entity);
}
}
return service.update(entity, updateWrapper);
}
}
return null;
}
Aggregations