package ink.wgink.module.map.controller.app.api.grid;

import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.map.service.grid.IGridUserService;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: GridUserController
 * @Description: 网格用户
 * @Author: wanggeng
 * @Date: 2021/10/20 5:42 下午
 * @Version: 1.0
 */
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "网格用户接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/grid/user")
public class GridUserAppController extends DefaultBaseController {

    @Autowired
    private IGridUserService gridUserService;

    @ApiOperation(value = "新增我的网格", notes = "新增我的网格接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gridIdId", value = "网格ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PostMapping("save-of-mine/{gridId}")
    public SuccessResult saveOfMine(@RequestHeader() String token, @PathVariable("gridId") String gridId) throws Exception {
        gridUserService.saveOfMine(token, gridId);
        return new SuccessResult();
    }

    @ApiOperation(value = "删除我的网格", notes = "删除我的网格接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gridId", value = "网格ID", paramType = "path")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @DeleteMapping("delete-of-mine/{gridId}")
    public SuccessResult deleteOfMine(@RequestHeader("token") String token, @PathVariable("gridId") String gridId) {
        gridUserService.deleteOfMine(token, gridId);
        return new SuccessResult();
    }

}
