use of com.cas.sim.tis.services.ResourceService in project TeachingInSimulation by ScOrPiOzzy.
the class ResourceAction method addResource.
public Integer addResource(Resource resource) {
ResourceService service = getService();
resource.setCreator(Session.get(Session.KEY_LOGIN_ID));
return service.addResource(resource);
}
use of com.cas.sim.tis.services.ResourceService in project TeachingInSimulation by ScOrPiOzzy.
the class LnkParser2 method upload.
private void upload(File uploadFile, String fileName, String keyword) {
String filePath = uploadFile.getAbsolutePath();
String ext = FileUtil.getFileExt(filePath);
// 重命名
String rename = UUID.randomUUID() + "." + ext;
// 上传文件到FTP
ftpUtils.uploadFile(ResourceConsts.FTP_RES_PATH, uploadFile, rename);
// 封装资源记录
int type = ResourceType.parseType(ext);
Resource resource = new Resource();
resource.setPath(rename);
resource.setName(fileName);
resource.setCreator(1);
resource.setKeyword(keyword);
try {
resource.setType(type);
} catch (Exception e) {
LOG.warn("解析文件后缀名出现错误", e);
throw e;
}
// 记录到数据库
ResourceService service = (ResourceService) resourceServiceFactory.getObject();
Integer id = service.addResource(resource);
if (id != null) {
LOG.info("{}录入数据库成功!", filePath);
} else {
LOG.error("{}录入数据库失败!", filePath);
}
}
use of com.cas.sim.tis.services.ResourceService in project TeachingInSimulation by ScOrPiOzzy.
the class RMITest method testGetObject.
@Test
public void testGetObject() throws Exception {
UserService userService = (UserService) userServiceFactory.getObject();
Assert.assertNotNull(userService);
userService.findAll().forEach(System.out::println);
ResourceService resourceService = (ResourceService) resourceServiceFactory.getObject();
Assert.assertNotNull(resourceService);
resourceService.findAll().forEach(System.out::println);
ElecCompService elecCompService = (ElecCompService) elecCompServiceFactory.getObject();
Assert.assertNotNull(elecCompService);
elecCompService.findAll().forEach(System.out::println);
}
Aggregations