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



/**
 * 工作计划的负责工长和施工人
 *
 * @author jiaqiao
 * @email jiaqiao@163.com
 * @date 2023-03-04 13:17:18
 */
@RestController
@RequestMapping("business/businessplanworker")
public class BusinessPlanWorkerController {
    @Autowired
    private BusinessPlanWorkerService businessPlanWorkerService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:businessplanworker:info")
    public R info(@PathVariable("id") Integer id){
		BusinessPlanWorkerEntity businessPlanWorker = businessPlanWorkerService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:businessplanworker:save")
    public R save(@RequestBody BusinessPlanWorkerEntity businessPlanWorker){
		businessPlanWorkerService.save(businessPlanWorker);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:businessplanworker:update")
    public R update(@RequestBody BusinessPlanWorkerEntity businessPlanWorker){
		businessPlanWorkerService.updateById(businessPlanWorker);

        return R.ok();
    }

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

        return R.ok();
    }

}
