Search in sources :

Example 1 with ResourceService

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);
}
Also used : ResourceService(com.cas.sim.tis.services.ResourceService)

Example 2 with ResourceService

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);
    }
}
Also used : Resource(com.cas.sim.tis.entity.Resource) ResourceService(com.cas.sim.tis.services.ResourceService) ShellLinkException(mslinks.ShellLinkException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 3 with ResourceService

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);
}
Also used : UserService(com.cas.sim.tis.services.UserService) ResourceService(com.cas.sim.tis.services.ResourceService) ElecCompService(com.cas.sim.tis.services.ElecCompService) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

ResourceService (com.cas.sim.tis.services.ResourceService)3 Resource (com.cas.sim.tis.entity.Resource)1 ElecCompService (com.cas.sim.tis.services.ElecCompService)1 UserService (com.cas.sim.tis.services.UserService)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ShellLinkException (mslinks.ShellLinkException)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1