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.model.TacSlbLawContent; import cn.com.goldenwater.dcproj.param.TacSlbLawContentParam; import cn.com.goldenwater.dcproj.service.TacSlbLawContentService; 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.web.bind.annotation.*; import java.util.List; /** * @author lune * @date 2019-9-25 */ @Api(value = "TAC 法律法规引用详情管理", tags = "TAC 法律法规引用详情管理") @RestController @RequestMapping("/tac/slb/law/content") public class TacSlbLawContentController extends BaseController { private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private TacSlbLawContentService tacSlbLawContentService; @ApiOperation(value = "添加/修改") @RequestMapping(value = "", method = RequestMethod.POST) public BaseResponse insert(@ApiParam(name = "tacSlbLawContent", value = "TacSlbLawContent", required = true) @RequestBody TacSlbLawContent tacSlbLawContent) { if (StringUtils.isBlank(tacSlbLawContent.getId())) { String uuid = UuidUtil.uuid(); // 生成uuid tacSlbLawContent.setId(uuid); tacSlbLawContentService.insert(tacSlbLawContent); } else { tacSlbLawContentService.update(tacSlbLawContent); } return buildSuccessResponse(tacSlbLawContent); } @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 = tacSlbLawContentService.delete(id); return buildSuccessResponse(); } @ApiOperation(value = "根据ID获取(单表)") @RequestMapping(value = "/{id}", method = RequestMethod.GET) public BaseResponse get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) { TacSlbLawContent tacSlbLawContent = tacSlbLawContentService.get(id); return buildSuccessResponse(tacSlbLawContent); } @ApiOperation(value = "获取(列表所有)") @RequestMapping(value = "/list", method = RequestMethod.POST) public BaseResponse> list(@ApiParam(name = "tacSlbLawContentParam", value = "tacSlbLawContentParam", required = true) @RequestBody TacSlbLawContentParam tacSlbLawContentParam) { List tacSlbLawContentList = tacSlbLawContentService.findList(tacSlbLawContentParam); return buildSuccessResponse(tacSlbLawContentList); } @ApiOperation(value = "获取(列表--分页)") @RequestMapping(value = "/page", method = RequestMethod.POST) public BaseResponse> page(@ApiParam(name = "tacSlbLawContentParam", value = "tacSlbLawContentParam", required = true) @RequestBody TacSlbLawContentParam tacSlbLawContentParam) { PageInfo tacSlbLawContentList = tacSlbLawContentService.findPageInfo(tacSlbLawContentParam); return buildSuccessResponse(tacSlbLawContentList); } @ApiOperation(value = "获取(根据目录id获取章节)") @RequestMapping(value = "/list/{indexId}", method = RequestMethod.GET) public BaseResponse> findChapters(@PathVariable(required = true) int indexId) { List tacSlbLawIndexList = tacSlbLawContentService.findChapters(indexId); return buildSuccessResponse(tacSlbLawIndexList); } @ApiOperation(value = "获取(根据目录id,章节id(sort)获取条目)") @RequestMapping(value = "/list/{indexId}/{sort}", method = RequestMethod.GET) public BaseResponse> findLine(@PathVariable(required = true) int indexId, @PathVariable(required = true) int sort) { TacSlbLawContentParam contentParam = new TacSlbLawContentParam(); contentParam.setSort(sort); contentParam.setIndexId(indexId); List tacSlbLawIndexList = tacSlbLawContentService.findList(contentParam); return buildSuccessResponse(tacSlbLawIndexList); } }