发表于: 2019-12-09 23:07:11
1 1203
今天完成的事情:
不务正页,看了mybatis-plus,如果是单表的话,都不用写SQL了。感觉光秃秃的。
mapper的接口不用写
public interface StudyObjectMapper extends BaseMapper<StudyObject> {
}
server接口也不用写
public interface IStudyObjectService extends IService<StudyObject> {
}
实现类也不用
@Service
public class StudyObjectServiceImpl extends ServiceImpl<StudyObjectMapper, StudyObject> implements IStudyObjectService {
}
然后就可以在controller层直接用了。这个是主键查询
@Autowired
IStudyObjectService iStudyObjectService;
@GetMapping("/a/study")
public Map<String, StudyObject> select() {
Map<String, StudyObject> map = new HashMap<>(16);
StudyObject studyObject = iStudyObjectService.getById(1L);
map.put("data", studyObject);
return map;
}
还有查对象的。
@GetMapping("/a/list/study")
public Map<String, Object> selectList(){
Map<String, Object> map = new HashMap<>(16);
StudyObject studyObject=new StudyObject();
studyObject.setType(20);
QueryWrapper<StudyObject> wrapper=new QueryWrapper<StudyObject>();
wrapper.setEntity(studyObject);
PageHelper.startPage(1, 10, "create_at desc");
List<StudyObject> list=iStudyObjectService.list(wrapper);
map.put("data", list);
return map;
}
兼容pagehelper。…………因为他自带的不会用。
我去,真是太简单了,虽然不实用。因为正常下都是多表的。
早点demo,早点回家咯。
明天计划的事情:
遇到的问题:
收获:
评论