不要用它自带的

selectPage方法,会有传参问题

controller


import java.util.Set;


@RestController
@RequiredArgsConstructor
@RequestMapping("/deviceInfo" )
public class DeviceInfoController {

    private final  DeviceInfoService deviceInfoService;


	/**
	 * 分页查询
	 * @param page 分页对象
	 * @param queryDto 设备信息查询对象
	 * @return
	 */
	@GetMapping("/page" )
	@PreAuthorize("@pms.hasPermission('proxy_deviceInfo_view')" )
	public R selectPage(Page page, @Validated(value = SelectVerify.class) DeviceInfoDTO queryDto) {
		return R.ok(deviceInfoService.selectForPage(page, queryDto));
	}
 
}

Mapper

public interface DeviceInfoMapper extends BaseMapper<DeviceInfo> {

    IPage<DeviceInfoVO> selectForPage(Page page, @Param("queryDto") DeviceInfoDTO queryDto);

    List<DeviceInfoVO> selectList(DeviceInfoDTO queryDto);
}

xml


<resultMap id="deviceInfoVoMap" type="xx.xx.vo.DeviceInfoVO">
        <id property="id" column="id"/>
        <id property="groupId" column="group_id"/>
        <id property="deviceNumber" column="device_number"/>
        <id property="deviceCategory" column="device_category"/>
        <id property="deviceType" column="device_type"/>
        <id property="manufacturer" column="manufacturer"/>
        <id property="deviceModel" column="device_model"/>
        <id property="remark" column="remark"/>
        <id property="createBy" column="create_by"/>
        <id property="createTime" column="create_time"/>
        <id property="updateBy" column="update_by"/>
        <id property="updateTime" column="update_time"/>
    </resultMap>




<select id="selectForPage" resultMap="deviceInfoVoMap">
		  SELECT
		  	di.*
		  FROM device_info di

		  <where>
			  <if test="queryDto.groupId != null">
				  AND di.group_id = #{queryDto.groupId}
			  </if>
			  <if test="queryDto.deviceNumber != null and queryDto.deviceNumber != ''">
				  AND di.device_number = #{queryDto.deviceNumber}
			  </if>
			  <if test="queryDto.deviceTypeCollection != null and queryDto.deviceTypeCollection.size > 0">
				  AND di.device_type IN
				  <foreach collection="queryDto.deviceTypeCollection" index="idx" item="item" separator="," open="(" close=")">
					  #{item}
				  </foreach>
			  </if>
		  </where>
		  ORDER BY di.device_number ASC
	  </select>

Server




public interface DeviceInfoService extends IService<DeviceInfo> {

  

    /**
     * 分页查询
     */
    IPage<DeviceInfoVO> selectForPage(Page page, DeviceInfoDTO queryDto);

   
}

impl


@Service
@RequiredArgsConstructor
public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceInfo> implements DeviceInfoService {

     

    public IPage<DeviceInfoVO> selectForPage(Page page, DeviceInfoDTO queryDto) {
        return baseMapper.selectForPage(page, queryDto);
    }

    
}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部