MyBatisPlus

custom page sql

  • xml

    <select id="selectPages" resultType="com.example.domain.vo.UserVo">
    select u.user_name, u.real_real from user u
    ${ew.customSqlSegment}
    order by u.sort_num desc
    </select>
  • mapper


public interface UserMapper extends BaseMapper<User> {

    IPage<UserVo> selectPages(IPage<UserVo> page,@Param(Constants.WRAPPER) Wrapper<User> ex);

}
  • service
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Override
    public IPage<UserVo> pages(UserPageDto dto){

    QueryWrapper<User> query = new QueryWrapper<>();

    query.eq(StringUtils.hasText(dto.getUserName()), "u.user_name",dto.getUserName()); 

    query.like(StringUtils.hasText(dto.getRealName()), "u.real_name",dto.getRealName()); 

    Page<User> page = new Page(1,10);

    IPage<UserVo> result = this.getBaseMapper().selectPages(page, query);

    return result;

    }
}
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous