package com.lz.modules.app.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 com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.lz.modules.app.service.DepartmentsStaffRelateService;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;



/**
 * 部门与员工关联表
 *
 * @author fumeiai
 * @email fumeiai@linzikg.com
 * @date 2020-04-29 20:59:20
 */
@RestController
@RequestMapping("generator/departmentsstaffrelate")
public class DepartmentsStaffRelateController {
    @Autowired
    private DepartmentsStaffRelateService departmentsStaffRelateService;

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

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


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:departmentsstaffrelate:info")
    public R info(@PathVariable("id") Long id){
		DepartmentsStaffRelateEntity departmentsStaffRelate = departmentsStaffRelateService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:departmentsstaffrelate:save")
    public R save(@RequestBody DepartmentsStaffRelateEntity departmentsStaffRelate){
		departmentsStaffRelateService.save(departmentsStaffRelate);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:departmentsstaffrelate:update")
    public R update(@RequestBody DepartmentsStaffRelateEntity departmentsStaffRelate){
		departmentsStaffRelateService.updateById(departmentsStaffRelate);

        return R.ok();
    }

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

        return R.ok();
    }

}
