@ -1,7 +1,13 @@
package com.haiwei.manage.service.impl ;
import java.io.File ;
import java.util.List ;
import com.haiwei.common.config.Global ;
import com.haiwei.common.constant.Constants ;
import com.haiwei.common.utils.DateUtils ;
import com.haiwei.common.utils.StringUtils ;
import com.haiwei.common.utils.file.FileUtils ;
import com.haiwei.framework.util.ShiroUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
@ -83,7 +89,13 @@ public class BsaeFileServiceImpl implements IBsaeFileService
@Override
public int deleteBsaeFileByIds ( String ids )
{
return bsaeFileMapper . deleteBsaeFileByIds ( Convert . toStrArray ( ids ) ) ;
String [ ] objids = Convert . toStrArray ( ids ) ;
for ( int i = 0 ; i < objids . length ; i + + ) {
delectFile ( Long . valueOf ( objids [ i ] ) ) ;
}
return bsaeFileMapper . deleteBsaeFileByIds ( objids ) ;
}
/ * *
@ -95,6 +107,24 @@ public class BsaeFileServiceImpl implements IBsaeFileService
@Override
public int deleteBsaeFileById ( Long objid )
{
return bsaeFileMapper . deleteBsaeFileById ( objid ) ;
}
private void delectFile ( Long id ) {
try {
BsaeFile bsaeFile = bsaeFileMapper . selectBsaeFileById ( id ) ;
// 本地资源路径
String localPath = Global . getProfile ( ) ;
// 数据库资源地址
String downloadPath = localPath + StringUtils . substringAfter ( bsaeFile . getFilePath ( ) , Constants . RESOURCE_PREFIX ) ;
System . out . println ( downloadPath ) ;
FileUtils . deleteFile ( downloadPath ) ;
} catch ( Exception e ) {
}
}
}