@@ -5,6 +5,7 @@ import com.tuoheng.until.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
@@ -23,7 +24,12 @@ public class PlatformController { | |||
* @return | |||
*/ | |||
@GetMapping("/list") | |||
public JsonResult list(){ | |||
return platformService.findAll(); | |||
// public JsonResult list(){ | |||
// return platformService.findAll(); | |||
// } | |||
public JsonResult listWithAirportOption(@RequestParam boolean includeAirport) { | |||
return platformService.findAllWithAirportOption(includeAirport); | |||
} | |||
} |
@@ -4,15 +4,17 @@ import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import lombok.Data; | |||
/** | |||
* 平台表 | |||
* | |||
* @TableName platform | |||
*/ | |||
@TableName(value ="platform") | |||
@TableName(value = "platform") | |||
@Data | |||
public class Platform implements Serializable { | |||
/** | |||
@@ -63,4 +65,10 @@ public class Platform implements Serializable { | |||
@TableField(exist = false) | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
*是否包含机场平台 | |||
*/ | |||
@TableField("is_airport") | |||
private Boolean isAirport; | |||
} |
@@ -14,5 +14,7 @@ public interface PlatformService extends IService<Platform> { | |||
* 查询各平台名称 | |||
* @return | |||
*/ | |||
JsonResult findAll(); | |||
//JsonResult findAll(); | |||
JsonResult findAllWithAirportOption(boolean includeAirport); | |||
} |
@@ -1,10 +1,11 @@ | |||
package com.tuoheng.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.mapper.PlatformMapper; | |||
import com.tuoheng.model.dto.Platform; | |||
import com.tuoheng.service.PlatformService; | |||
import com.tuoheng.mapper.PlatformMapper; | |||
import com.tuoheng.until.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -28,14 +29,29 @@ public class PlatformServiceImpl extends ServiceImpl<PlatformMapper, Platform> | |||
* | |||
* @return | |||
*/ | |||
// @Override | |||
// public JsonResult findAll() { | |||
// | |||
// List<Platform> platforms = platformMapper.selectList(Wrappers.<Platform>lambdaQuery() | |||
// .eq(Platform::getMark, 1)); | |||
// | |||
// return JsonResult.success(platforms); | |||
// } | |||
//通过机场条件进行查询 | |||
@Override | |||
public JsonResult findAll() { | |||
List<Platform> platforms = platformMapper.selectList(Wrappers.<Platform>lambdaQuery() | |||
.eq(Platform::getMark, 1)); | |||
public JsonResult findAllWithAirportOption(boolean includeAirport) { | |||
LambdaQueryWrapper<Platform> queryWrapper = Wrappers.<Platform>lambdaQuery() | |||
.eq(Platform::getMark, 1); | |||
// 筛选是否含机场平台 | |||
if (!includeAirport) { | |||
queryWrapper.eq(Platform::getIsAirport, false); // 只筛选非机场平台 | |||
} | |||
List<Platform> platforms = platformMapper.selectList(queryWrapper); | |||
return JsonResult.success(platforms); | |||
} | |||
} | |||