package com.elephant.framework.galaxy.aroad.module.emergency.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog;
import com.elephant.framework.galaxy.aroad.module.common.controller.BaseController;
import com.elephant.framework.galaxy.aroad.module.emergency.entity.EmergencyEquipment;
import com.elephant.framework.galaxy.aroad.module.emergency.service.EmergencyEquipmentService;
import com.elephant.framework.galaxy.aroad.response.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 应急处置装备
 *
 * @author songwenjie
 * @date 2019-03-21 14:50:19
 */
@RestController
@AllArgsConstructor
@RequestMapping("/emergencyequipment")
public class EmergencyEquipmentController extends BaseController {

    private final EmergencyEquipmentService emergencyEquipmentService;

    /**
     * 分页查询
     *
     * @param page 分页对象
     * @param text 模糊查询
     * @return
     */
    @GetMapping("/page")
    public R getEmergencyEquipmentPage(Page page, String text) {
        return new R<>(emergencyEquipmentService.getEmergencyEquipmentPage(page, text));
    }

    /**
     * @Description: 获取队伍装备坐标信息
     * @auther: XingYuyang
     * @date: 2019-4-9 14:20:33
     * @param: []
     * @return: com.elephant.framework.galaxy.aroad.response.R
     */
    @GetMapping("/coordinates/{teamids}")
    public R getCoordinates(@PathVariable("teamids") String teamIds) {
        return new R<>(emergencyEquipmentService.getCoordinates(teamIds));
    }

    /**
     * 通过id查询应急处置装备
     *
     * @param rowId id
     * @return R
     */
    @GetMapping("/{rowId}")
    public R getById(@PathVariable("rowId") Integer rowId) {
        return new R<>(emergencyEquipmentService.getById(rowId));
    }

    /**
     * @Description: 获取队伍列表
     * @Param:
     * @return:
     * @Author: XingYuyang
     * @Date: 2019-04-15 10:08:18
     */
    @GetMapping("/getteams")
    public R getTeams() {
        return new R<>(emergencyEquipmentService.getTeams());
    }

    /**
     * 新增应急处置装备
     *
     * @param emergencyEquipment 应急处置装备
     * @return R
     */
    @SysLog("新增应急处置装备")
    @PostMapping
    public R save(@RequestBody EmergencyEquipment emergencyEquipment) {
        return new R<>(emergencyEquipmentService.save(emergencyEquipment));
    }

    /**
     * 修改应急处置装备
     *
     * @param emergencyEquipment 应急处置装备
     * @return R
     */
    @SysLog("修改应急处置装备")
    @PutMapping
    public R updateById(@RequestBody EmergencyEquipment emergencyEquipment) {
        return new R<>(emergencyEquipmentService.updateById(emergencyEquipment));
    }

    /**
     * 通过id删除应急处置装备
     *
     * @param rowId id
     * @return R
     */
    @SysLog("删除应急处置装备")
    @DeleteMapping("/{rowId}")
    public R removeById(@PathVariable Integer rowId) {
        return new R<>(emergencyEquipmentService.removeById(rowId));
    }

}
