master
parent
a663474d8f
commit
243ea6668a
@ -0,0 +1,32 @@
|
|||||||
|
package com.bsd.cases.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.bsd.cases.model.CaseRecommend;
|
||||||
|
import com.bsd.cases.service.CaseRecommendService;
|
||||||
|
import com.bsd.cases.util.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/case-recommend")
|
||||||
|
public class CaseRecommendController {
|
||||||
|
@Resource
|
||||||
|
private CaseRecommendService caseRecommendService;
|
||||||
|
|
||||||
|
@RequestMapping("/get-case-recommend")
|
||||||
|
public AjaxResult getAllCategory(HttpServletRequest request) {
|
||||||
|
AjaxResult ajaxResult = new AjaxResult();
|
||||||
|
List<CaseRecommend> caseRecommendList = caseRecommendService.getCaseRecommend();
|
||||||
|
if (null!=caseRecommendList){
|
||||||
|
ajaxResult.setRetcode(AjaxResult.SUCCESS);
|
||||||
|
ajaxResult.setData(caseRecommendList);
|
||||||
|
}else {
|
||||||
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
||||||
|
}
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.bsd.cases.mapper;
|
||||||
|
|
||||||
|
import com.bsd.cases.model.CaseRecommend;
|
||||||
|
import com.bsd.cases.util.CommonMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CaseRecommendMapper extends CommonMapper<CaseRecommend> {
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.bsd.cases.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("case_recommend")
|
||||||
|
public class CaseRecommend extends BaseEntity{
|
||||||
|
|
||||||
|
private Long contentId;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.bsd.cases.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CaseRecommendService<CaseRecommend> extends BaseService<CaseRecommend> {
|
||||||
|
List<CaseRecommend> getCaseRecommend();
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.bsd.cases.service.impl;
|
||||||
|
|
||||||
|
import com.bsd.cases.constants.Constants;
|
||||||
|
import com.bsd.cases.mapper.CaseRecommendMapper;
|
||||||
|
import com.bsd.cases.model.CaseRecommend;
|
||||||
|
import com.bsd.cases.service.CaseRecommendService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import tk.mybatis.mapper.entity.Example;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service("caseRecommendService")
|
||||||
|
@Transactional
|
||||||
|
public class CaseRecommendServiceImpl extends BaseServiceImpl<CaseRecommendMapper, CaseRecommend>
|
||||||
|
implements CaseRecommendService<CaseRecommend> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseRecommendMapper caseRecommendMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页获取banner图
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<CaseRecommend> getCaseRecommend() {
|
||||||
|
Example example = new Example(CaseRecommend.class);
|
||||||
|
Example.Criteria criteria = example.createCriteria();
|
||||||
|
criteria.andEqualTo("state",Constants.STATE_VALID);
|
||||||
|
example.setOrderByClause("sort asc");
|
||||||
|
List<CaseRecommend> caseRecommendList = caseRecommendMapper.selectByExample(example);
|
||||||
|
return caseRecommendList;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue