|
@ -22,26 +22,19 @@ import com.epmet.commons.tools.annotation.RequirePermission; |
|
|
import com.epmet.commons.tools.enums.RequirePermissionEnum; |
|
|
import com.epmet.commons.tools.enums.RequirePermissionEnum; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.validator.AssertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
|
|
import com.epmet.dto.ArticleDTO; |
|
|
|
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.excel.ArticleExcel; |
|
|
|
|
|
import com.epmet.service.ArticleOperateRecordService; |
|
|
import com.epmet.service.ArticleOperateRecordService; |
|
|
import com.epmet.service.ArticleService; |
|
|
import com.epmet.service.ArticleService; |
|
|
import com.epmet.service.DraftService; |
|
|
import com.epmet.service.DraftService; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -61,48 +54,6 @@ public class ArticleController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private DraftService draftService; |
|
|
private DraftService draftService; |
|
|
|
|
|
|
|
|
@GetMapping("page") |
|
|
|
|
|
public Result<PageData<ArticleDTO>> page(@RequestParam Map<String, Object> params){ |
|
|
|
|
|
PageData<ArticleDTO> page = articleService.page(params); |
|
|
|
|
|
return new Result<PageData<ArticleDTO>>().ok(page); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("{id}") |
|
|
|
|
|
public Result<ArticleDTO> get(@PathVariable("id") String id){ |
|
|
|
|
|
ArticleDTO data = articleService.get(id); |
|
|
|
|
|
return new Result<ArticleDTO>().ok(data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping |
|
|
|
|
|
public Result save(@RequestBody ArticleDTO dto){ |
|
|
|
|
|
//效验数据
|
|
|
|
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|
|
|
|
|
articleService.save(dto); |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PutMapping |
|
|
|
|
|
public Result update(@RequestBody ArticleDTO dto){ |
|
|
|
|
|
//效验数据
|
|
|
|
|
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|
|
|
|
|
articleService.update(dto); |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping |
|
|
|
|
|
public Result delete(@RequestBody String[] ids){ |
|
|
|
|
|
//效验数据
|
|
|
|
|
|
AssertUtils.isArrayEmpty(ids, "id"); |
|
|
|
|
|
articleService.delete(ids); |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("export") |
|
|
|
|
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|
|
|
|
|
List<ArticleDTO> list = articleService.list(params); |
|
|
|
|
|
ExcelUtils.exportExcelToTarget(response, null, list, ArticleExcel.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param tokenDTO |
|
|
* @param tokenDTO |
|
|
* @return |
|
|
* @return |
|
@ -222,9 +173,6 @@ public class ArticleController { |
|
|
public Result<Boolean> saveDraftAttr(@LoginUser TokenDto tokenDto,@RequestBody DraftAttrFromDTO fromDTO) throws Exception { |
|
|
public Result<Boolean> saveDraftAttr(@LoginUser TokenDto tokenDto,@RequestBody DraftAttrFromDTO fromDTO) throws Exception { |
|
|
ValidatorUtils.validateEntity(fromDTO, DefaultGroup.class); |
|
|
ValidatorUtils.validateEntity(fromDTO, DefaultGroup.class); |
|
|
Boolean isSuccess = articleService.saveDraftAttr(tokenDto, fromDTO); |
|
|
Boolean isSuccess = articleService.saveDraftAttr(tokenDto, fromDTO); |
|
|
if (isSuccess){ |
|
|
|
|
|
//TODO 异步校验内容
|
|
|
|
|
|
} |
|
|
|
|
|
return new Result<Boolean>().ok(isSuccess); |
|
|
return new Result<Boolean>().ok(isSuccess); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -250,9 +198,19 @@ public class ArticleController { |
|
|
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH) |
|
|
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISH) |
|
|
public Result<Boolean> publishArticle(@LoginUser TokenDto tokenDto, String draftId) throws Exception { |
|
|
public Result<Boolean> publishArticle(@LoginUser TokenDto tokenDto, String draftId) throws Exception { |
|
|
Boolean isSuccess = articleService.publish(tokenDto, draftId); |
|
|
Boolean isSuccess = articleService.publish(tokenDto, draftId); |
|
|
|
|
|
if (isSuccess){ |
|
|
|
|
|
//TODO 异步校验内容
|
|
|
|
|
|
scanContent(draftId); |
|
|
|
|
|
} |
|
|
return new Result<Boolean>().ok(isSuccess); |
|
|
return new Result<Boolean>().ok(isSuccess); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Async |
|
|
|
|
|
public void scanContent(String draftId){ |
|
|
|
|
|
articleService.scanContent(draftId); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 已发布文章列表 |
|
|
* 已发布文章列表 |
|
@ -363,4 +321,5 @@ public class ArticleController { |
|
|
DraftDetailResultDTO draftDetailResultDTO = draftService.queryDraftDetail(formDTO); |
|
|
DraftDetailResultDTO draftDetailResultDTO = draftService.queryDraftDetail(formDTO); |
|
|
return new Result<DraftDetailResultDTO>().ok(draftDetailResultDTO); |
|
|
return new Result<DraftDetailResultDTO>().ok(draftDetailResultDTO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |