| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- package cn.com.goldenwater.dcproj.controller.tac;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.dto.TacSlbLawIndexDto;
- import cn.com.goldenwater.dcproj.model.TacSlbLawIndex;
- import cn.com.goldenwater.dcproj.param.TacSlbLawIndexParam;
- import cn.com.goldenwater.dcproj.service.GwComFileService;
- import cn.com.goldenwater.dcproj.service.TacSlbLawIndexService;
- import cn.com.goldenwater.dcproj.utils.WorldExoprtWithPicUtils;
- import cn.com.goldenwater.id.util.UuidUtil;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.*;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * @author lune
- * @date 2019-9-25
- */
- @Api(value = "TAC 法律法规目录索引管理", tags = "TAC 法律法规目录索引管理")
- @RestController
- @RequestMapping("/tac/slb/law/index")
- public class TacSlbLawIndexController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Value("${export.basePath.docx}")
- private String docxPath;
- @Value("${web.upload-path}")
- private String uploadPath;
- @Value("${export.basePath.docx.path}")
- private String baseDocxPath;
- @Value("${getFile.prefix}")
- private String filePreFix;
- @Autowired
- private TacSlbLawIndexService tacSlbLawIndexService;
- @Autowired
- private GwComFileService comFileService;
- @ApiOperation(value = "添加/修改")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<TacSlbLawIndex> insert(@ApiParam(name = "tacSlbLawIndex", value = "TacSlbLawIndex", required = true) @RequestBody TacSlbLawIndex tacSlbLawIndex) {
- tacSlbLawIndex.setFlagValid("1");
- if (StringUtils.isNotBlank(tacSlbLawIndex.getDocId() + "")) {
- List<TacSlbLawIndex> slbLawIndices = tacSlbLawIndexService.findDocs(1, Integer.parseInt(tacSlbLawIndex.getDocId()));
- if (slbLawIndices != null && slbLawIndices.size() == 1) {
- String title = slbLawIndices.get(0).getLawTitle();
- tacSlbLawIndex.setLawTitle(title);
- }
- }
- if (StringUtils.isBlank(tacSlbLawIndex.getId())) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- tacSlbLawIndex.setId(uuid);
- tacSlbLawIndex.setFileId(uuid);
- tacSlbLawIndexService.insert(tacSlbLawIndex);
- } else {
- tacSlbLawIndexService.update(tacSlbLawIndex);
- }
- return buildSuccessResponse(tacSlbLawIndex);
- }
- @ApiOperation(value = "根据ID删除")
- @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = tacSlbLawIndexService.deleteInFlag(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<TacSlbLawIndex> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- TacSlbLawIndex tacSlbLawIndex = tacSlbLawIndexService.get(id);
- if (tacSlbLawIndex != null && StringUtils.isBlank(tacSlbLawIndex.getBookContent())) {
- tacSlbLawIndex.setGwComFile(comFileService.findFileByBiz(tacSlbLawIndex.getFileId()));
- }
- return buildSuccessResponse(tacSlbLawIndex);
- }
- @ApiOperation(value = "获取(列表所有)")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<TacSlbLawIndex>> list(@ApiParam(name = "tacSlbLawIndexParam", value = "tacSlbLawIndexParam", required = true) @RequestBody TacSlbLawIndexParam tacSlbLawIndexParam) {
- List<TacSlbLawIndex> tacSlbLawIndexList = tacSlbLawIndexService.findList(tacSlbLawIndexParam);
- return buildSuccessResponse(tacSlbLawIndexList);
- }
- @ApiOperation(value = "获取(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacSlbLawIndex>> page(@ApiParam(name = "tacSlbLawIndexParam", value = "tacSlbLawIndexParam", required = true) @RequestBody TacSlbLawIndexParam tacSlbLawIndexParam) {
- if (tacSlbLawIndexParam.getLawKeyword().contains("*")) {
- return buildFailResponse("异常请求!");
- }
- PageInfo<TacSlbLawIndex> tacSlbLawIndexList = tacSlbLawIndexService.findPageInfo(tacSlbLawIndexParam);
- return buildSuccessResponse(tacSlbLawIndexList);
- }
- @ApiOperation(value = "获取(法规的所有篇幅,默认输入1)")
- @RequestMapping(value = "/list/{bookId}", method = RequestMethod.GET)
- public BaseResponse<List<TacSlbLawIndexDto>> listDocs(@PathVariable(required = true) int bookId) {
- List<TacSlbLawIndexDto> tacSlbLawIndexList = tacSlbLawIndexService.findDocs(bookId);
- return buildSuccessResponse(tacSlbLawIndexList);
- }
- @ApiOperation(value = "获取(法规的所有篇幅,默认输入1)")
- @RequestMapping(value = "/tree", method = RequestMethod.GET)
- public BaseResponse<List<TacSlbLawIndexDto>> tree() {
- List<TacSlbLawIndexDto> tacSlbLawIndexList = tacSlbLawIndexService.findDocs(1);
- for (TacSlbLawIndexDto lawIndex : tacSlbLawIndexList) {
- TacSlbLawIndexParam lawIndexParam = new TacSlbLawIndexParam();
- lawIndexParam.setDocId(lawIndex.getDocId() + "");
- List<TacSlbLawIndex> lawIndexList = tacSlbLawIndexService.findList(lawIndexParam);
- lawIndex.setChildren(lawIndexList);
- }
- return buildSuccessResponse(tacSlbLawIndexList);
- }
- @ApiOperation(value = "下载稽察法规")
- @RequestMapping(value = "/doc/{id}", method = RequestMethod.GET)
- public BaseResponse doc(@PathVariable String id) {
- TacSlbLawIndex slbLawIndex = tacSlbLawIndexService.get(id);
- StringBuffer buffer = new StringBuffer();
- String content = slbLawIndex.getBookContent().replace(slbLawIndex.getLawKeyword(), "").replace(slbLawIndex.getLawModify(), "");
- content = content.replace("\n", "<p/><p>");
- buffer.append("<h3>").append(slbLawIndex.getLawKeyword()).append("</h3>").append("<h4>")
- .append(slbLawIndex.getLawModify()).append("</h4>").append("<p>").append(content).append("</p>");
- try {
- uploadPath = uploadPath.replace(filePreFix, "");
- String filename = WorldExoprtWithPicUtils.createWord("tac_" + id, buffer.toString(), docxPath, uploadPath, "8");
- Map<String, String> params = new HashMap<>();
- params.put("downloadPath", baseDocxPath + filename);
- return buildSuccessResponse(params);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return buildFailResponse();
- }
- }
|