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.BusinessWorkerSalaryEntity;
import io.renren.modules.business.service.BusinessWorkerSalaryService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 工资账目
 *
 * @author jiaqiao
 * @email jiaqiao@163.com
 * @date 2022-09-19 09:13:54
 */
@RestController
@RequestMapping("business/businessworkersalary")
public class BusinessWorkerSalaryController {
    @Autowired
    private BusinessWorkerSalaryService businessWorkerSalaryService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:businessworkersalary:info")
    public R info(@PathVariable("id") Long id){
		BusinessWorkerSalaryEntity businessWorkerSalary = businessWorkerSalaryService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:businessworkersalary:save")
    public R save(@RequestBody BusinessWorkerSalaryEntity businessWorkerSalary){
		businessWorkerSalaryService.save(businessWorkerSalary);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:businessworkersalary:update")
    public R update(@RequestBody BusinessWorkerSalaryEntity businessWorkerSalary){
		businessWorkerSalaryService.updateById(businessWorkerSalary);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:businessworkersalary:delete")
    public R delete(@RequestBody Long[] ids){
		businessWorkerSalaryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
