package com.younike.store.controller;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import com.younike.common.bean.APIResult;
import com.younike.common.bean.ResultGenerator;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import com.younike.common.core.page.PageParam;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.younike.common.annotation.OpLog;
import com.younike.common.core.controller.BaseController;
import com.younike.common.core.dto.AjaxResult;
import com.younike.common.constant.BusinessType;
import com.younike.service.pojo.StoreStaffRole;
import com.younike.service.service.IStoreStaffRoleService;
import com.younike.common.core.page.TableResult;

/**
 * 门店员工角色				Controller
 *
 * @author dail
 * @date 2022-05-24
 */
@RestController
@RequestMapping("/storeStaffRole")
public class StoreStaffRoleController extends BaseController {
    @Autowired
    private IStoreStaffRoleService storeStaffRoleService;

    /**
     * 查询门店员工角色				列表
     */
    @RequiresPermissions("role:list")
    @PostMapping("/list")
    public Page list(@RequestBody PageParam<StoreStaffRole> page) {

        return storeStaffRoleService.page(page);
    }


    /**
     * 获取门店员工角色				详细信息
     */
    @RequiresPermissions("role:query")
    @GetMapping(value = "/{staffRoleId}")
    public APIResult getInfo(@PathVariable("staffRoleId") String staffRoleId) {
        return ResultGenerator.getSuccessResult(storeStaffRoleService.getById(staffRoleId));
    }

    /**
     * 新增门店员工角色				
     */
    @RequiresPermissions("role:add")
    @OpLog(title = "门店员工角色				", type = BusinessType.INSERT)
    @PostMapping
    public APIResult add(@RequestBody StoreStaffRole storeStaffRole) {
        return ResultGenerator.getSuccessResult(storeStaffRoleService.save(storeStaffRole));
    }

    /**
     * 修改门店员工角色				
     */
    @RequiresPermissions("role:edit")
    @OpLog(title = "门店员工角色				", type = BusinessType.UPDATE)
    @PutMapping
    public APIResult edit(@RequestBody StoreStaffRole storeStaffRole) {
        return ResultGenerator.getSuccessResult(storeStaffRoleService.updateById(storeStaffRole));
    }

    /**
     * 删除门店员工角色				
     */
    @RequiresPermissions("role:remove")
    @OpLog(title = "门店员工角色				", type = BusinessType.DELETE)
    @DeleteMapping("/{staffRoleIds}")
    public APIResult remove(@PathVariable List<String> staffRoleIds) {
        return ResultGenerator.getSuccessResult(storeStaffRoleService.removeByIds(staffRoleIds));
    }
}
