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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 余额明细Controller
 *
 * @author admin
 * @since 2024-04-30
 */
@RestController
@RequestMapping("/balance/details")
public class PlayBalanceDetailsInfoController {
    @Resource
    private IPlayBalanceDetailsInfoService playBalanceDetailsInfoService;


    /**
     * 查询余额明细列表
     */
    @PostMapping("/listByPage")
    public R list(@Validated @RequestBody PlayBalanceDetailsQueryVo vo) {
        return R.ok(playBalanceDetailsInfoService.selectByPage(vo));
    }

    /**
     * 获取余额明细详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") String id) {
        return R.ok(playBalanceDetailsInfoService.selectPlayBalanceDetailsInfoById(id));
    }


    /**
     * 修改余额明细
     */
    //@PreAuthorize("@customSs.hasPermission('balance:details:update')")
    @Log(title = "余额明细", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/update/{id}")
    public R update(@PathVariable String id, @RequestBody PlayBalanceDetailsInfoEntity playBalanceDetailsInfo) {
        playBalanceDetailsInfo.setId(id);
        boolean success = playBalanceDetailsInfoService.update(playBalanceDetailsInfo);
        if (success) {
            return R.ok();
        }
        return R.error("修改失败");
    }

    /**
     * 删除余额明细
     */
    //@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));
    }
}
