package com.lz.modules.app.controller;

import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;
import com.lz.modules.app.dto.DepartmentsDto;
import com.lz.modules.app.entity.DepartmentsEntity;
import com.lz.modules.app.entity.StaffOccupationEntity;
import com.lz.modules.app.service.DepartmentsService;
import com.lz.modules.app.service.StaffOccupationService;
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 fumeiai
 * @email fumeiai@linzikg.com
 * @date 2020-04-29 20:59:20
 */
@RestController
@RequestMapping("generator/staffoccupation")
public class StaffOccupationController {
    @Autowired
    private StaffOccupationService staffOccupationService;

    @Autowired
    private DepartmentsService departmentsService;

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

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

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:staffoccupation:info")
    public R info(@PathVariable("id") Long id) {
        StaffOccupationEntity staffOccupation = staffOccupationService.getById(id);

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

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:staffoccupation:save")
    public R save(@RequestBody StaffOccupationEntity staffOccupation) {
        staffOccupationService.save(staffOccupation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:staffoccupation:update")
    public R update(@RequestBody StaffOccupationEntity staffOccupation) {
        staffOccupationService.updateById(staffOccupation);

        return R.ok();
    }

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

        return R.ok();
    }

}
