package com.starry.admin.modules.personnel.controller;

import com.starry.admin.modules.personnel.module.entity.PlayBalanceDetailsInfoEntity;
import com.starry.admin.modules.personnel.module.vo.PlayBalanceDetailsQueryVo;
import com.starry.admin.modules.personnel.service.IPlayBalanceDetailsInfoService;
import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 余额明细Controller
 *
 * @author admin
 * @since 2024-04-30
 */
@Api(tags = "余额明细管理", description = "余额明细信息管理相关接口，包括查询、修改和删除等操作")
@RestController
@RequestMapping("/balance/details")
public class PlayBalanceDetailsInfoController {
    @Resource
    private IPlayBalanceDetailsInfoService playBalanceDetailsInfoService;

    /**
     * 查询余额明细列表
     */
    @ApiOperation(value = "分页查询明细列表", notes = "分页查询余额明细信息列表")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
    @PostMapping("/listByPage")
    public R list(@ApiParam(value = "查询条件", required = true) @Validated @RequestBody PlayBalanceDetailsQueryVo vo) {
        return R.ok(playBalanceDetailsInfoService.selectByPage(vo));
    }

    /**
     * 获取余额明细详细信息
     */
    @ApiOperation(value = "获取明细详情", notes = "根据ID获取余额明细详细信息")
    @ApiImplicitParam(name = "id", value = "明细ID", required = true, paramType = "path", dataType = "String", example = "1")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功", response = PlayBalanceDetailsInfoEntity.class)})
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") String id) {
        return R.ok(playBalanceDetailsInfoService.selectPlayBalanceDetailsInfoById(id));
    }

    /**
     * 修改余额明细
     */
    @ApiOperation(value = "修改明细信息", notes = "修改余额明细信息")
    @ApiImplicitParam(name = "id", value = "明细ID", required = true, paramType = "path", dataType = "String", example = "1")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功"), @ApiResponse(code = 500, message = "修改失败，包含详细错误信息")})
    // @PreAuthorize("@customSs.hasPermission('balance:details:update')")
    @Log(title = "余额明细", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/update/{id}")
    public R update(@PathVariable String id,
            @ApiParam(value = "明细信息", required = true) @RequestBody PlayBalanceDetailsInfoEntity playBalanceDetailsInfo) {
        playBalanceDetailsInfo.setId(id);
        boolean success = playBalanceDetailsInfoService.update(playBalanceDetailsInfo);
        if (success) {
            return R.ok();
        }
        return R.error("修改失败");
    }

    /**
     * 删除余额明细
     */
    @ApiOperation(value = "删除明细信息", notes = "根据ID批量删除余额明细信息")
    @ApiImplicitParam(name = "ids", value = "明细ID数组", required = true, paramType = "path", dataType = "String[]", example = "1,2,3")
    @ApiResponses({@ApiResponse(code = 200, message = "操作成功")})
    // @PreAuthorize("@customSs.hasPermission('balance:details:delete')")
    @Log(title = "余额明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids) {
        return R.ok(playBalanceDetailsInfoService.deletePlayBalanceDetailsInfoByIds(ids));
    }
}
