|
8 | 8 | import com.zhazhapan.efo.entity.File; |
9 | 9 | import com.zhazhapan.efo.entity.User; |
10 | 10 | import com.zhazhapan.efo.model.AuthRecord; |
| 11 | +import com.zhazhapan.efo.model.BaseAuthRecord; |
11 | 12 | import com.zhazhapan.efo.model.FileBasicRecord; |
12 | 13 | import com.zhazhapan.efo.model.FileRecord; |
13 | 14 | import com.zhazhapan.efo.modules.constant.ConfigConsts; |
14 | 15 | import com.zhazhapan.efo.modules.constant.DefaultValues; |
15 | 16 | import com.zhazhapan.efo.service.IAuthService; |
16 | 17 | import com.zhazhapan.efo.service.ICategoryService; |
17 | 18 | import com.zhazhapan.efo.service.IFileService; |
| 19 | +import com.zhazhapan.efo.util.BeanUtils; |
18 | 20 | import com.zhazhapan.efo.util.ServiceUtils; |
19 | 21 | import com.zhazhapan.modules.constant.ValueConsts; |
20 | 22 | import com.zhazhapan.util.*; |
@@ -79,6 +81,51 @@ public FileServiceImpl(FileDAO fileDAO, ICategoryService categoryService, IAuthS |
79 | 81 | this.downloadDAO = downloadDAO; |
80 | 82 | } |
81 | 83 |
|
| 84 | + @Override |
| 85 | + public boolean updateAuth(long id, String auth) { |
| 86 | + int[] au = BeanUtils.getAuth(auth); |
| 87 | + return fileDAO.updateAuthById(id, au[0], au[1], au[2], au[3], au[4]); |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public BaseAuthRecord getAuth(long id) { |
| 92 | + return fileDAO.getAuth(id); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = |
| 97 | + Exception.class) |
| 98 | + public boolean deleteFiles(String ids) { |
| 99 | + if (Checker.isNotEmpty(ids)) { |
| 100 | + String[] id = ids.split(ValueConsts.COMMA_SIGN); |
| 101 | + for (String s : id) { |
| 102 | + long fileId = Formatter.stringToLong(s); |
| 103 | + String localUrl = fileDAO.getLocalUrlById(fileId); |
| 104 | + FileExecutor.deleteFile(localUrl); |
| 105 | + removeById(fileId); |
| 106 | + } |
| 107 | + return true; |
| 108 | + } |
| 109 | + return false; |
| 110 | + } |
| 111 | + |
| 112 | + @Override |
| 113 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = |
| 114 | + Exception.class) |
| 115 | + public boolean[] updateUrl(int id, String oldLocalUrl, String localUrl, String visitUrl) { |
| 116 | + boolean[] b = new boolean[]{false, false}; |
| 117 | + if (Checker.isNotEmpty(localUrl) && Checker.isNotExists(localUrl) && !localUrlExists(localUrl)) { |
| 118 | + FileExecutor.renameTo(oldLocalUrl, localUrl); |
| 119 | + fileDAO.updateLocalUrlById(id, localUrl); |
| 120 | + b[0] = true; |
| 121 | + } |
| 122 | + if (Checker.isNotEmpty(visitUrl) && !visitUrlExists(visitUrl)) { |
| 123 | + fileDAO.updateVisitUrlById(id, visitUrl); |
| 124 | + b[1] = true; |
| 125 | + } |
| 126 | + return b; |
| 127 | + } |
| 128 | + |
82 | 129 | @Override |
83 | 130 | @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = |
84 | 131 | Exception.class) |
|
0 commit comments