温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

springboot + mybatis plus实现多表联查分页

发布时间:2020-07-10 12:38:44 来源:网络 阅读:8221 作者:NopSmile 栏目:编程语言

1 配置分页插件

public class MybatisPlusConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
    @Bean
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        Properties properties = new Properties();
        properties.setProperty("format", "true");
        performanceInterceptor.setProperties(properties);
        return performanceInterceptor;
    }
}

2 创建返回实体VO

@ApiModel(value = "员工得分信息")
public class AgentOutVo {
    @ApiModelProperty(value = "所在单位")
    private String unit;
    略……
    @ApiModelProperty(value = "申诉状态")
    private String appealState;
}

3 service层
接口

public interface IAgentScoreService {
    List<AgentOutVo> queryAgentOutMapByPage(Map<String, Object> params);
}

实现

public class AgentScoreServiceImpl extends ServiceImpl<AgentScoreMapper, AgentScore> implements IAgentScoreService {
    @Autowired
    private AgentScoreMapper agentScoreMapper;
    @Override
    public List<AgentOutVo> queryAgentOutMapByPage(Map<String, Object> params) {
        return agentScoreMapper.selectAgentOutMap(new Query<AgentOutVo>(params).getPage(),params); 
    }
}

4 mapper

public interface AgentScoreMapper extends BaseMapper<AgentScore> {
    List<AgentOutVo> selectAgentOutMap(Page<AgentOutVo> pagination, @Param("params") Map<String, Object> params);//params 接收前端对象
}

5 resources/mapper/

<select id="selectAgentOutMap" resultType="com.itcc.qc.module.vo.AgentOutVo" parameterType="java.util.Map">
      select
      a.unit,a.dept,a.mission,a.workorder_pid,a.RECORD as recordtime,a.call, t.total_score,a.qer,t.appeal_state
      from
      t_qc_agentscore t,t_qc_agentscoreass a
      where
      t.workorder_pid=a.workorder_pid
      and 
t.appeal_state=#{params.appealState} <!—对应mapper @Param("params")-->
   </select>
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI