/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.base.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.base.entity.Portaluser;
import com.tofly.base.service.PortaluserService;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 地图资源用户表
 *
 * @author admin
 * @date Thu Oct 10 00:00:00 CST 2019
 */
@RestController
@AllArgsConstructor
@RequestMapping("/portaluser")
@Api(tags="地图资源用户表接口")
public class PortaluserController {

    private final  PortaluserService portaluserService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param portaluser 地图资源用户表
    * @return
    */
    @GetMapping("/page" )
    //@ApiOperation(value = "分页查询")
    public ResultRespone getPortaluserPage(Page page, @ModelAttribute Portaluser portaluser) {
      return ResultRespone.success(portaluserService.page(page, Wrappers.query(portaluser)));
    }


    /**
     * 通过id查询地图资源用户表
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    //@ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getById(@PathVariable("id" ) Long id) {
      return ResultRespone.success(portaluserService.getById(id));
    }

    /**
     * 新增地图资源用户表
     * @param portaluser 地图资源用户表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增地图资源用户表" )
    //@ApiOperation(value = "新增地图资源用户表")
    @PostMapping
    public ResultRespone save(@RequestBody Portaluser portaluser) {
      return ResultRespone.success(portaluserService.save(portaluser));
    }

    /**
     * 修改地图资源用户表
     * @param portaluser 地图资源用户表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改地图资源用户表" )
    //@ApiOperation(value = "修改地图资源用户表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Portaluser portaluser) {
      return ResultRespone.success(portaluserService.updateById(portaluser));
    }

    /**
     * 通过id删除地图资源用户表
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除地图资源用户表" )
    //@ApiOperation(value = "通过ID删除地图资源用户表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable Long id) {
      return ResultRespone.success(portaluserService.removeById(id));
    }
}
