Mybatisplus's generic query can simply discard DAO and mapper.xml.

Source: Internet
Author: User

/** * * @author shenjing * @date 2018/6/20 * * @Servicepublic class Localdispatchserviceimpl extends Serviceimpl<rep_disp     Atchdao, Rep_dispatch> implements Localdispatchservice {/** * based on the domain combination of various types of queries, the general query can be completed through this, DAO completely does not exist the meaning of        * * @param domain * @return */@Override public rep_dispatch findonebydomain (rep_dispatch domain) {        entitywrapper<rep_dispatch> ewrapper = new entitywrapper<> (domain);    Return SelectOne (Ewrapper); /** * Query According to paging parameters * * @param dispatchpageparam * @return */@Override public Page<rep_dis Patch> findlistbypage (Dispatchpageparam dispatchpageparam) {page<rep_dispatch> Page = new Page<> (di        Spatchpageparam.getstartindex (), dispatchpageparam.getpagesize ());        entitywrapper<rep_dispatch> ewrapper = new entitywrapper<> (Dispatchpageparam.getobj ());        page<rep_dispatch> ret = selectpage (page, ewrapper);    return ret; }}

Here, Serviceimpl, is a base class provided by Mybatisplus.

Dispatchpageparam is a package of query parameters written by himself

/** * Basic Paging parameters * @author shenjing * @date 2018/6/20 */public class Basepageparam<t> {    T obj;    int startIndex;    int pageSize;    Public T Getobj () {        return obj;    }    public void Setobj (T obj) {        this.obj = obj;    }    public int Getstartindex () {        return startIndex;    }    public void Setstartindex (int startIndex) {        this.startindex = StartIndex;    }    public int getpagesize () {        return pageSize;    }    public void setpagesize (int pageSize) {        this.pagesize = pageSize;    }}

Actually, there's nothing in this, just inherit the base class.

/** * Created by shenjing on 2018/6/20. */public class Dispatchpageparam extends Basepageparam<rep_dispatch> {}

  

Mybatisplus's generic query can simply discard DAO and mapper.xml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.