package com.goafanti.businessCard.controller;

import com.goafanti.businessCard.service.AdminBusinessCardService;
import com.goafanti.common.bo.Result;
import com.goafanti.common.controller.BaseController;
import com.goafanti.common.model.AdminBusinessCard;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户名片表(AdminBusinessCard)表控制层
 *
 * @author makejava
 * @since 2025-06-27 15:10:04
 */
@RestController
@RequestMapping("/api/admin/adminBusinessCard")
public class AdminBusinessCardController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private AdminBusinessCardService adminBusinessCardService;


    /**
     * 新增数据
     *
     * @param adminBusinessCard 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public Result add(AdminBusinessCard adminBusinessCard) {
        return new Result<>().data(this.adminBusinessCardService.insert(adminBusinessCard));
    }


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/get")
    public Result<AdminBusinessCard> queryById(Integer id) {
        return new Result<>().data(this.adminBusinessCardService.queryById(id));
    }


    /**
     * 编辑数据
     *
     * @param adminBusinessCard 实体
     * @return 编辑结果
     */
    @PostMapping("/update")
    public Result edit(AdminBusinessCard adminBusinessCard) {
        return new Result<>().data(this.adminBusinessCardService.update(adminBusinessCard));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/delete")
    public Result deleteById(Integer id) {
        return new Result<>().data(this.adminBusinessCardService.deleteById(id));
    }

    /**
     * 列表查询
     *
     * @param in 参数
     * @return
     */
    @GetMapping("/list")
    public Result<AdminBusinessCard> list(AdminBusinessCard in, Integer pageNo, Integer pageSize) {
        return new Result<>().data(this.adminBusinessCardService.list(in, pageNo, pageSize));
    }

}

