package com.zksy.park.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zksy.common.annotation.Log;
import com.zksy.common.core.domain.Result;
import com.zksy.common.enums.BusinessType;
import com.zksy.common.utils.SearchUtil;
import com.zksy.park.domain.SecurityPersonnel;
import com.zksy.park.service.SecurityPersonnelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator
 * @version 1.0
 * @project dh-server-micro
 * @description 安保人员信息
 * @date 2025/04/14 09:42:12
 */
@RestController
@RequestMapping("/securityPersonnel")
@Api(tags = "安保人员信息", description = "安保人员信息")
public class SecurityPersonnelController {

    @Autowired
    private SecurityPersonnelService service;

    @GetMapping("/getById/{borrowId}")
    @ApiOperation(value = "安保人员搜索getById")
    public Result getById(@PathVariable String borrowId) {
        return Result.ok(service.getById(borrowId));
    }

    @GetMapping("/findByPage")
    @ApiOperation(value = "安保人员分页")
    public Page findByPage(long pageNum, long pageSize, String conditionJson) throws Exception {
        return service.page(new Page<>(pageNum, pageSize), SearchUtil.parseWhereSql(conditionJson));
    }

    @GetMapping("/getList")
    @ApiOperation(value = "安保人员查询所有")
    public Result getList(String conditionJson) throws Exception {
        return Result.ok(service.list(SearchUtil.parseWhereSql(conditionJson)));
    }

    /**
     * 新增安保人员
     */
    @PostMapping("/save")
    @ApiOperation(value = "安保人员新增")
    @Log(title = "安保人员", businessType = BusinessType.INSERT)
    public Result save(@RequestBody SecurityPersonnel securityPersonnel) {
        return Result.ok(service.save(securityPersonnel));
    }

    /**
     * 修改安保人员
     */
    @PostMapping("/updateById")
    @ApiOperation(value = "安保人员修改")
    @Log(title = "安保人员", businessType = BusinessType.UPDATE)
    public Result updateById(@RequestBody SecurityPersonnel securityPersonnel) {
        return Result.ok(service.updateById(securityPersonnel));
    }

    @Log(title = "安保人员", businessType = BusinessType.DELETE)
    @PostMapping("/delete")
    @ApiOperation(value = "删除安保人员", notes = "删除安保人员")
    public Result delete(@RequestBody List<String> ids)
    {
        return Result.ok(service.removeByIds(ids));
    }
}
