1.目录结构
2.先修改表格名
3.单独运行PaginationPlugin,逆向生成
4.再建Service接口,接口实现类,Controller层
接口层:
package com.test.Service;
import com.test.entity.db.GradeDO;
import java.util.List;
public interface IGradeService {
/**
* 根据主键查询数据对象
*/
public GradeDO selectByPrimaryKey(GradeDO gradeDO);
}
接口实现类:
package com.test.Service.Impl;
import com.test.Service.IGradeService;
import com.test.entity.db.GradeDO;
import com.test.entity.db.GradeDOExample;
import com.test.mapper.GradeDOMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author Administrator
* @Description: TODO
* @Date in 2019/2/13 0013 17:01
* @Modify By:
*/
@Service
public class GradeServiceImpl implements IGradeService {
@Autowired
private GradeDOMapper gradeDOMapper;
/**
* 根据主键查询数据对象
*/
public GradeDO selectByPrimaryKey(GradeDO gradeDO){
try {
return gradeDOMapper.selectByPrimaryKey(gradeDO.getGradeId());
}catch (Exception e){
e.printStackTrace();
return null;
}
}
}
控制层:
package com.test.controller;
import com.test.Service.IGradeService;
import com.test.Service.Impl.GradeServiceImpl;
import com.test.entity.db.GradeDO;
import com.test.entity.db.GradeDOExample;
import com.test.mapper.GradeDOMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* @Author Administrator
* @Description: TODO
* @Date in 2019/2/13 0013 17:02
* @Modify By:
*/
@Controller
@RequestMapping(value = "/grade")
public class GradeController {
@Autowired
private IGradeService gradeService;
/**
* 根据主键查询数据对象
*/
@RequestMapping(value = "/selectByPrimaryKey",method = RequestMethod.POST)
@ResponseBody
public GradeDO selectByPrimaryKey(GradeDO gradeDO){
GradeDO gradeDO1 = new GradeDO();
gradeDO1.setGradeId(gradeDO.getGradeId());
return gradeService.selectByPrimaryKey(gradeDO1);
}
}
注意:controller主要是和前台进行交互,example这些业务逻辑都放在service