溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

springboot + mybatis plus實現(xiàn)多表聯(lián)查分頁

發(fā)布時間:2020-07-10 12:38:44 來源:網(wǎng)絡(luò) 閱讀: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 創(chuàng)建返回實體VO

@ApiModel(value = "員工得分信息")
public class AgentOutVo {
    @ApiModelProperty(value = "所在單位")
    private String unit;
    略……
    @ApiModelProperty(value = "申訴狀態(tài)")
    private String appealState;
}

3 service層
接口

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

實現(xiàn)

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} <!—對應(yīng)mapper @Param("params")-->
   </select>
向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI