java论坛数据以及搜索接口实现
数据来源,以及存储,都python写的
http://t.csdnimg.cn/NOsGD
package com.ca.controller;
import com.ca.dao.FormListMapper;
import com.ca.dao.UsersMapper;
import com.ca.entity.Users;
import com.ca.vo.ResultVO;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.session.RowBounds;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
@RestController
@RequestMapping("/form")
// value是详细说明,tags是标签
@Api(value = "论坛接口",tags = "论坛接口")
// 允许跨域
@CrossOrigin
public class FormList {
@Resource
private FormListMapper formListMapper;
@ApiOperation("论坛列表数据")
@RequestMapping(value = "/list",method = RequestMethod.GET)
public ResultVO getList(String type,int pageNum,int pageSize){
// 实体类,需要写好
Example example = new Example(com.ca.entity.FormList.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("type", type);
// // 分页处理
// PageHelper.startPage(pageNum, pageSize);
int start = (pageNum - 1)*pageSize;
RowBounds rowBounds = new RowBounds(start,pageSize);
List<com.ca.entity.FormList> formLists= formListMapper.selectByExampleAndRowBounds(example,rowBounds);
return new ResultVO(10000,"查询成功!",formLists);
}
@ApiOperation("论坛搜索接口")
@RequestMapping(value = "/search",method = RequestMethod.GET)
public ResultVO searchList(String word,int pageNum,int pageSize){
// 实体类,需要写好
Example example = new Example(com.ca.entity.FormList.class);
Example.Criteria criteria = example.createCriteria();
criteria.andLike("title", "%" + word + "%");
// // 分页处理
// PageHelper.startPage(pageNum, pageSize);
int start = (pageNum - 1)*pageSize;
RowBounds rowBounds = new RowBounds(start,pageSize);
List<com.ca.entity.FormList> formLists= formListMapper.selectByExampleAndRowBounds(example,rowBounds);
return new ResultVO(10000,"查询成功!",formLists);
}
}
更多【java-java论坛数据以及搜索接口实现】相关视频教程:www.yxfzedu.com