package io.renren.modules.business.controller;

import io.renren.common.utils.R;
import io.renren.modules.business.entity.BusinessPlanTlEntity;
import io.renren.modules.business.service.BusinessPlanTlService;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.service.SysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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



/**
 * 明日计划-提料
 *
 * @author jiaqiao
 * @email jiaqiao@163.com
 * @date 2022-10-10 17:02:15
 */
@RestController
@RequestMapping("business/businessplantl")
public class BusinessPlanTlController {
    @Autowired
    private BusinessPlanTlService businessPlanTlService;
    @Autowired
    private SysUserService sysUserService;

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

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

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:businessplantl:list")
    public R list(@RequestParam Map<String, Object> params){
        List<BusinessPlanTlEntity> page = businessPlanTlService.queryList(params);
        return R.ok().put("page", page);
    }

    /**
     * 获取所有人List
     */
    @RequestMapping("/sysUserlist")
    @RequiresPermissions("business:businessplantl:list")
    public R sysUserlist(){
        List<SysUserEntity> page = sysUserService.sysUserlist();
        return R.ok().put("page", page);
    }
    /**
     * 获取完成人id 列表
     */
    @RequestMapping("/queryEndUserId")
    @RequiresPermissions("business:businessplantl:list")
    public R businessPlanTlService(){
        List<Integer> page = businessPlanTlService.queryEndUserId();
        return R.ok().put("page", page);
    }



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:businessplantl:info")
    public R info(@PathVariable("id") Integer id){
		BusinessPlanTlEntity businessPlanTl = businessPlanTlService.getById(id);

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


    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:businessplantl:save")
    public R save(@RequestBody BusinessPlanTlEntity businessPlanTl){
		businessPlanTlService.save(businessPlanTl);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:businessplantl:update")
    public R update(@RequestBody BusinessPlanTlEntity businessPlanTl){
		businessPlanTlService.updateById(businessPlanTl);

        return R.ok();
    }

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

        return R.ok();
    }

}
