package com.zcxk.controller;

import com.zcxk.model.AjaxMessage;
import com.zcxk.model.LoginUser;
import com.zcxk.model.ResultStatus;
import com.zcxk.util.UserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import com.zcxk.entity.ComdisplayMapLocationEntity;
import com.zcxk.service.ComdisplayMapLocationService;

/**
 * 地图坐标页面控制器
 * @author WYY
 * @date 2021-02-24 09:58
 */
@RestController
@RequestMapping("/comdislocation")
@Api(tags = "综合展示--图片坐标")
public class ComdisplayMapLocationController {
    @Autowired
    private ComdisplayMapLocationService comdisplayMapLocationService;
    /**
     * 新增
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "保存或修改")
    public AjaxMessage<Integer> save(@ApiParam(value = "地图坐标信息", required = true) @RequestBody ComdisplayMapLocationEntity comdisplayMapLocation){
        LoginUser currentUser = UserUtil.getCurrentUser();
        comdisplayMapLocation.setStatus(1);
        comdisplayMapLocation.setTenantId(currentUser.getTenantId());
        int result= comdisplayMapLocationService.saveOrUpdate(comdisplayMapLocation) ? 1 : 0;
        return new AjaxMessage<>(ResultStatus.OK, result);
    }
    /**
     * 新增
     */
    @RequestMapping(value = "/findMapLocation", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询地图坐标")
    public AjaxMessage<List<ComdisplayMapLocationEntity>> findMapLocation() {
        LoginUser currentUser = UserUtil.getCurrentUser();
        ComdisplayMapLocationEntity comdisplayMap = new ComdisplayMapLocationEntity();
        comdisplayMap.setTenantId(currentUser.getTenantId());
        List<ComdisplayMapLocationEntity> result = comdisplayMapLocationService.findList(comdisplayMap);
        return new AjaxMessage<>(ResultStatus.OK, result);
    }
    /**
     * 修改保存地图坐标
     */
    @ApiOperation(value = "单个编辑")
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    public  AjaxMessage<Integer> editComdisplayMapLocation(@ApiParam(value = "地图坐标信息", required = true) @RequestBody ComdisplayMapLocationEntity comdisplayMapLocation) {
        int result = comdisplayMapLocationService.updateComdisplayMapLocationById(comdisplayMapLocation) ? 1 : 0;
        return new AjaxMessage<>(ResultStatus.OK, result);
    }

    /**
     * 删除
     */
    @ApiOperation(value = "批量删除")
    @RequestMapping(value = "/deleteByIds", method = RequestMethod.POST)
    @ResponseBody
    public AjaxMessage<Integer> del(@ApiParam(value = "IDS", required = true) @RequestBody Long[] ids) {
        int result = comdisplayMapLocationService.delComdisplayMapLocationByIds(ids) ? 1 : 0;
        return new AjaxMessage<>(ResultStatus.OK, result);
    }
}
