package com.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.ssm.manage.dto.UseStoreDto;
import com.ssm.manage.entity.UseStore;
import com.ssm.manage.service.UseStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * (UseStore)表控制层
 *
 * @author makejava
 * @since 2022-06-11 15:00:25
 */
@RestController
@RequestMapping("useStore")
@Api(tags = "使用门店")
public class UseStoreController {
    /**
     * 服务对象
     */
    @Autowired
    private UseStoreService useStoreService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return
     */
    @GetMapping("{id}")
    @ApiOperation("通过主键查询单条数据")
//@RequiresPermissions("system:useStore:query")
    public UseStore get(@PathVariable Serializable id) {
        return this.useStoreService.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param dto
     * @return
     */
    @GetMapping
    @ApiOperation("分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", defaultValue = "1", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", defaultValue = "10", required = true)
    })
//@RequiresPermissions("system:useStore:query")
    public PageInfo<UseStore> listPage(@RequestBody UseStoreDto dto) {
        return this.useStoreService.queryByPage(dto);
    }

    /**
     * 新增
     *
     * @param useStore
     * @return
     */
    @PostMapping
    @ApiOperation("新增")
//@RequiresPermissions("system:useStore:add")
    public int add(@RequestBody UseStore useStore) {
        return this.useStoreService.add(useStore);
    }

    /**
     * 编辑
     *
     * @param useStore
     * @return
     */
    @PutMapping
    @ApiOperation("编辑")
//@RequiresPermissions("system:useStore:edit")
    public int edit(@RequestBody UseStore useStore) {
        return this.useStoreService.edit(useStore);
    }

    /**
     * 根据主键删除
     *
     * @param id 主键
     * @return
     */
    @DeleteMapping("{id}")
    @ApiOperation("根据主键删除")
//@RequiresPermissions("system:useStore:delete")
    public int delete(@PathVariable Serializable id) {
        return this.useStoreService.delete(id);
    }

}