package com.fdkankan.feign;

import com.fdkankan.common.user.SSOUser;
import com.fdkankan.goods.entity.Camera;
import com.fdkankan.goods.entity.CameraDetail;
import com.fdkankan.goods.entity.Company;
import com.fdkankan.goods.service.ICameraDetailService;
import com.fdkankan.goods.service.ICameraService;
import com.fdkankan.goods.service.ICompanyService;
import com.fdkankan.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 提供场景调用
 */
@RestController
@RequestMapping("/feign")
public class SceneFeign {

    @Autowired
    private ICameraService cameraService;
    @Autowired
    private ICameraDetailService cameraDetailService;
    @Autowired
    private IUserService userService;
    @Autowired
    private ICompanyService companyService;

    @PostMapping("/getCameraByChildName")
    public Camera getCameraByChildName(@RequestParam(value = "childName", required = false) String childName) {
        return cameraService.getByChildName(childName);
    }

    @PostMapping("/getCameraDetailByCameraId")
    public CameraDetail getCameraDetailByCameraId(@RequestParam(value = "cameraId", required = false) Long cameraId) {
        return cameraDetailService.getByCameraId(cameraId);
    }

    @PostMapping("/updateCameraDetailByCameraIdAndSpace")
    public String updateCameraDetailByCameraIdAndSpace(@RequestParam(value = "cameraId", required = false) Long cameraId,
                                                           @RequestParam(value = "space", required = false) Long space) {
        return cameraDetailService.updateCameraDetailByCameraIdAndSpace(cameraId,space);
    }

    @PostMapping("/getCameraBySnCode")
    public Camera getCameraBySnCode(@RequestParam(value = "snCode", required = false) String snCode) {
        return cameraService.getBySnCode(snCode);
    }
    @PostMapping("/getSSOUserByUserId")
    public SSOUser getSSOUserByUserId(@RequestParam(value = "userId", required = false) Long userId) {
        return userService.getSSOUserByUserId(userId);
    }
    @PostMapping("/getCompanyById")
    public Company getCompanyById(@RequestParam(value = "companyId", required = false) Long companyId) {
        return companyService.getById(companyId);
    }

}
