| | |
| | | import com.yeshi.fanli.entity.dynamic.ArticleOfficial;
|
| | | import com.yeshi.fanli.exception.dynamic.ArticleOfficialException;
|
| | | import com.yeshi.fanli.service.inter.dynamic.ArticleOfficialService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.vo.dynamic.ArticleVO;
|
| | |
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/article/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.article.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public void switchState(String id) throws ArticleOfficialException {
|
| | | if (StringUtil.isNullOrEmpty(id)) {
|
| | | throw new ArticleOfficialException(1, "请传递正确参数");
|
| | | }
|
| | | |
| | | ArticleOfficial resultObj = articleOfficialDao.getById(id);
|
| | | if (resultObj == null) {
|
| | | throw new ArticleOfficialException(1, "此内容已不存在");
|
| | | }
|
| | | |
| | | Integer state = resultObj.getState();
|
| | | if (state == null || state == 0) {
|
| | | state = 1;
|
| | | } else {
|
| | | state = 0;
|
| | | }
|
| | | articleOfficialDao.updateSatate(id, state);
|
| | | }
|
| | | |
| | | @Override
|
| | | public ArticleOfficial getById(String id) {
|
| | | return articleOfficialDao.getById(id);
|
| | | }
|