package com.ssm.controller;


import com.github.pagehelper.PageInfo;
import com.ssm.manage.dto.UseProjectDto;
import com.ssm.manage.entity.UseProject;
import com.ssm.manage.service.UseProjectService;
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;

/**
 * (UseProject)表控制层
 *
 * @author makejava
 * @since 2022-06-11 15:00:41
 */
@RestController
@RequestMapping("useProject")
@Api(tags = "使用项目")
public class UseProjectController {
    /**
     * 服务对象
     */
    @Autowired
    private UseProjectService useProjectService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return
     */
    @GetMapping("{id}")
    @ApiOperation("通过主键查询单条数据")
//@RequiresPermissions("system:useProject:query")
    public UseProject get(@PathVariable Serializable id) {
        return this.useProjectService.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:useProject:query")
    public PageInfo<UseProject> listPage(UseProjectDto dto) {
        return this.useProjectService.queryByPage(dto);
    }

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

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

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

}