package io.renren.modules.business.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.business.entity.BusinessWorkerOrgEntity;
import io.renren.modules.business.service.BusinessWorkerOrgService;
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.Map;



/**
 * 组织机构表
 *
 * @author jiaqiao
 * @email jiaqiao@163.com
 * @date 2022-10-18 15:37:55
 */
@RestController
@RequestMapping("business/businessworkerorg")
public class BusinessWorkerOrgController {
    @Autowired
    private BusinessWorkerOrgService businessWorkerOrgService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:businessworkerorg:info")
    public R info(@PathVariable("id") Integer id){
		BusinessWorkerOrgEntity businessWorkerOrg = businessWorkerOrgService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:businessworkerorg:save")
    public R save(@RequestBody BusinessWorkerOrgEntity businessWorkerOrg){
		businessWorkerOrgService.save(businessWorkerOrg);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:businessworkerorg:update")
    public R update(@RequestBody BusinessWorkerOrgEntity businessWorkerOrg){
		businessWorkerOrgService.updateById(businessWorkerOrg);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:businessworkerorg:delete")
    public R delete(@RequestBody Integer[] ids){
		businessWorkerOrgService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
