# TaAirlineConfigController.java

    package cloud.wconnect.finance.controller.ta;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.finance.entity.ta.TaAirline;
    import cloud.wconnect.finance.pojo.dto.ta.TaAirlineDTO;
    import cloud.wconnect.finance.service.ta.ITaAirlineService;
    import com.google.common.collect.ImmutableMap;
    import org.springframework.web.bind.annotation.*;

    import jakarta.annotation.Resource;
    import jakarta.validation.Valid;
    import java.util.Collections;
    import java.util.List;
    import java.util.Map;
    import java.util.Objects;

    /**
     * <p>
     * TA Airline 前端控制器
     * </p>
     *
     * @author zc
     * @since 2023-07-07
     */
    @RestController
    @RequestMapping("/ta/airline")
    public class TaAirlineConfigController {
        @Resource
        private ITaAirlineService taAirlineService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 获取 Airline 集合
         *
         * @param property 资产标识
         * @return TaAirlineDTO 集合
         * @author zc
         * @date 2023/7/8
         */
        @ApiId(433)
        @GetMapping
        public List<TaAirlineDTO> list(@RequestParam String property) {
            int propertyId = sessionContext.getPropertyId(property);

            return taAirlineService.list(propertyId);
        }

        /**
         * 保存 Airline
         *
         * @param property     资产标识
         * @param taAirlineDTO Airline 数据
         * @return id
         * @author zc
         * @date 2023/7/8
         */
        @ApiId(434)
        @PostMapping
        public Map<String, Integer> save(@RequestParam String property, @Valid @RequestBody TaAirlineDTO taAirlineDTO) {
            int propertyId = sessionContext.getPropertyId(property);

            if (Objects.isNull(taAirlineDTO.getId())) {
                // 新增数据
                return ImmutableMap.of("id", taAirlineService.insert(propertyId, taAirlineDTO));
            }

            // 校验是否存在
            TaAirline originTaAirline = taAirlineService.checkExist(taAirlineDTO.getId());

            // 校验数据归属
            taAirlineService.checkBelong(propertyId, originTaAirline);

            // 更新数据
            taAirlineService.update(propertyId, originTaAirline, taAirlineDTO);

            return ImmutableMap.of("id", taAirlineDTO.getId());
        }

        /**
         * 删除 Airline
         *
         * @param property 资产标识
         * @param id       Airline id
         * @return empty map
         * @author zc
         * @date 2023/7/8
         */
        @ApiId(435)
        @DeleteMapping("/{id:\\d+}")
        public Map<Object, Object> remove(@RequestParam String property, @PathVariable int id) {
            int propertyId = sessionContext.getPropertyId(property);

            // 校验是否存在
            TaAirline originTaAirline = taAirlineService.checkExist(id);

            // 校验数据归属
            taAirlineService.checkBelong(propertyId, originTaAirline);

            // 删除数据
            taAirlineService.removeById(id);

            return Collections.emptyMap();
        }
    }