package com.foreverwin.mesnac.common.controller;

import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.model.MobileWorkStationData;
import com.foreverwin.mesnac.common.service.MobileWorkStationService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.R;
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.RestController;

import java.util.List;

/**
 *
 * @author Syngna
 * @since 2020-01-04
 */
@RestController
@RequestMapping("/mobileWorkStations")
public class MobileWorkStationController {

    @Autowired
    public MobileWorkStationService mobileWorkStationService;

    @GetMapping("listMobileWorkStationApplication")
    public R listMobileWorkStationApplication(String workStation) {

        List<MobileWorkStationData> result;
        try {
            String site = CommonMethods.getSite();
            String user = CommonMethods.getUser();
            String userBo = HandleEnum.USER.getHandle(site, user);
            result = mobileWorkStationService.listMobileWorkStationApplication(site, userBo, workStation);
        }
        catch (Exception e) {
            return R.failed(e.getMessage());
        }
        return R.ok(result);
    }
}