package io.renren.modules.business.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.business.entity.BusinessMoneyEntity;
import io.renren.modules.business.service.BusinessMoneyService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author jiaqiao
 * @email jiaqiao@163.com
 * @date 2023-02-10 10:13:09
 */
@RestController
@RequestMapping("business/businessmoney")
public class BusinessMoneyController {
    @Autowired
    private BusinessMoneyService businessMoneyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:businessmoney:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = businessMoneyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{money}")
    @RequiresPermissions("business:businessmoney:info")
    public R info(@PathVariable("money") Double money){
		BusinessMoneyEntity businessMoney = businessMoneyService.getById(money);

        return R.ok().put("businessMoney", businessMoney);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:businessmoney:save")
    public R save(@RequestBody BusinessMoneyEntity businessMoney){
		businessMoneyService.save(businessMoney);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:businessmoney:update")
    public R update(@RequestBody BusinessMoneyEntity businessMoney){
		businessMoneyService.updateById(businessMoney);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:businessmoney:delete")
    public R delete(@RequestBody Double[] moneys){
		businessMoneyService.removeByIds(Arrays.asList(moneys));

        return R.ok();
    }

}
