attachment
parent
2696c3f309
commit
2a96ff4b67
@ -0,0 +1,49 @@
|
|||||||
|
package com.bsd.cases.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bsd.cases.service.CaseContentAttachmentService;
|
||||||
|
import com.bsd.cases.util.AjaxRequest;
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/case-content-attachment")
|
||||||
|
public class CaseContentAttachmentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseContentAttachmentService caseContentAttachmentService;
|
||||||
|
|
||||||
|
@RequestMapping("/get-attachment-by-content-id")
|
||||||
|
public AjaxResult getCaseContentAttachment(@RequestBody AjaxRequest ajaxRequest, HttpServletRequest request) {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
JSONObject data = ajaxRequest.getData();
|
||||||
|
if (null == data){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("data missing");
|
||||||
|
}else {
|
||||||
|
Integer pageNum = data.getInteger("pageNum");
|
||||||
|
Integer pageSize = data.getInteger("pageSize");
|
||||||
|
if (null==pageNum|| null == pageSize){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("分页参数不可为空");
|
||||||
|
}else {
|
||||||
|
Long contentId = data.getLong("contentId");
|
||||||
|
if (null == contentId){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
ajaxResult.setRetmsg("文章id不可为空");
|
||||||
|
}else {
|
||||||
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
||||||
|
ajaxResult.setData(caseContentAttachmentService.getCaseContentAttachment(contentId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,7 @@
|
|||||||
package com.bsd.cases.service;
|
package com.bsd.cases.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface CaseContentAttachmentService<CaseContentAttachment> extends BaseService<CaseContentAttachment> {
|
public interface CaseContentAttachmentService<CaseContentAttachment> extends BaseService<CaseContentAttachment> {
|
||||||
|
List<CaseContentAttachment> getCaseContentAttachment(Long contentId);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,29 @@
|
|||||||
package com.bsd.cases.service.impl;
|
package com.bsd.cases.service.impl;
|
||||||
|
|
||||||
|
import com.bsd.cases.constants.Constants;
|
||||||
import com.bsd.cases.mapper.CaseContentAttachmentMapper;
|
import com.bsd.cases.mapper.CaseContentAttachmentMapper;
|
||||||
import com.bsd.cases.model.CaseContentAttachment;
|
import com.bsd.cases.model.CaseContentAttachment;
|
||||||
import com.bsd.cases.service.CaseContentAttachmentService;
|
import com.bsd.cases.service.CaseContentAttachmentService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service("caseContentAttachmentService")
|
@Service("caseContentAttachmentService")
|
||||||
@Transactional
|
@Transactional
|
||||||
public class CaseContentAttachmentServiceImpl extends BaseServiceImpl<CaseContentAttachmentMapper, CaseContentAttachment>
|
public class CaseContentAttachmentServiceImpl extends BaseServiceImpl<CaseContentAttachmentMapper, CaseContentAttachment>
|
||||||
implements CaseContentAttachmentService<CaseContentAttachment> {
|
implements CaseContentAttachmentService<CaseContentAttachment> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseContentAttachmentMapper caseContentAttachmentMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CaseContentAttachment> getCaseContentAttachment(Long contentId) {
|
||||||
|
CaseContentAttachment findCaseContentAttachment = new CaseContentAttachment();
|
||||||
|
findCaseContentAttachment.setContentId(contentId);
|
||||||
|
findCaseContentAttachment.setState(Constants.STATE_VALID);
|
||||||
|
List<CaseContentAttachment> caseContentAttachmentList = caseContentAttachmentMapper.select(findCaseContentAttachment);
|
||||||
|
return caseContentAttachmentList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue