StaffController.java 8.76 KB
package cn.com.glsx.merchants.controller;

import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.merchants.request.staff.*;
import cn.com.glsx.merchants.response.StaffResponse;
import cn.com.glsx.merchants.service.StaffService;
import cn.com.glsx.merchants.util.Pagination;
import com.rop.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author zhouhaibao
 * @version 1.0
 * @description: TODO
 * @date 2021/7/22 13:45
 */
@Slf4j
@Api("员工接口")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class StaffController {

    @Autowired
    private StaffService staffService;

    /**
     * 保存员工
     *
     * @param staffSaveRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.saveStaff", needInSession = NeedInSessionType.NO)
    @ApiOperation("保存员工")
    public RopResponse<Boolean> saveStaff(StaffSaveRequest staffSaveRequest) {
        try {
            staffService.saveStaff(staffSaveRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__saveStaff__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 更新员工
     *
     * @param staffUpdateRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.updateStaff", needInSession = NeedInSessionType.NO)
    @ApiOperation("更新员工")
    public RopResponse<Boolean> updateStaff(StaffUpdateRequest staffUpdateRequest) {
        try {
            staffService.updateStaff(staffUpdateRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__updateStaff__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 更新员工状态
     *
     * @param staffUpdateStatusRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.updateStatus", needInSession = NeedInSessionType.NO)
    @ApiOperation("更新员工状态")
    public RopResponse<Boolean> updateStatus(StaffUpdateStatusRequest staffUpdateStatusRequest) {
        try {
            staffService.updateStatus(staffUpdateStatusRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__updateStaff__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 批量更新员工状态
     *
     * @param staffUpdateStatusBatchRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.updateStatusBatch", needInSession = NeedInSessionType.NO)
    @ApiOperation("批量更新员工状态")
    public RopResponse<Boolean> updateStatusBatch(StaffUpdateStatusBatchRequest staffUpdateStatusBatchRequest) {
        try {
            staffService.updateStatusBatch(staffUpdateStatusBatchRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__updateStatusBatch__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 批量分配员工角色
     *
     * @param staffRoleInsertBatchRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.addStaffRoleBatch", needInSession = NeedInSessionType.NO)
    @ApiOperation("批量分配员工角色")
    public RopResponse<Boolean> addStaffRoleBatch(StaffRoleInsertBatchRequest staffRoleInsertBatchRequest) {
        try {
            staffService.addRoleBatch(staffRoleInsertBatchRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__addStaffRoleBatch__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 删除员工
     *
     * @param staffDeleteRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.deleteStaff", needInSession = NeedInSessionType.NO)
    @ApiOperation("删除员工")
    public RopResponse<Boolean> deleteStaff(StaffDeleteRequest staffDeleteRequest) {
        try {
            staffService.deleteStaff(staffDeleteRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__deleteStaff__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 查询员工详情
     *
     * @param staffSearchRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.staffSearchRequest", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询员工详情")
    public RopResponse<StaffResponse> findMerchantStaffDetail(StaffSearchRequest staffSearchRequest) {
        try {
            StaffResponse staffResponse = staffService.findMerchantStaffDetail(staffSearchRequest);
            return RopResponse.success(staffResponse);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__findMerchantStaffDetail__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 查询员工列表
     *
     * @param staffListRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.findMerchantStaffList", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询员工列表")
    public RopResponse<List<StaffResponse>> findMerchantStaffList(StaffListRequest staffListRequest) {
        try {
            List<StaffResponse> staffResponse = staffService.findMerchantStaffList(staffListRequest);
            return RopResponse.success(staffResponse);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__findMerchantStaffList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    /**
     * 查询员工分页列表
     *
     * @param staffPageRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.findStaffByPage", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询员工分页列表")
    public RopResponse<Pagination<StaffResponse>> findStaffByPage(StaffPageRequest staffPageRequest) {
        try {
            Pagination<StaffResponse> list = staffService.findStaffByPage(staffPageRequest);
            return RopResponse.success(list);
        } catch (RpcServiceException e) {
            log.info("=======MerchantMenuController__invoke__findStaffByPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 查询员工分页列表
     *
     * @param staffExportRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.exportData", needInSession = NeedInSessionType.NO)
    @ApiOperation("员工导出")
    public RopResponse<String> exportData(StaffExportRequest staffExportRequest) {
        try {
            String url = staffService.exportData(staffExportRequest);
            return RopResponse.success(url);
        } catch (RpcServiceException e) {
            log.info("=======MerchantMenuController__invoke__exportData__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());

        }
    }

    /**
     * 更新员工的有效期
     *
     * @param staffUpdateValRequest 入参
     * @return
     */
    @ServiceMethod(method = "merchants.api.staff.updateValPerByStaffId", needInSession = NeedInSessionType.NO)
    @ApiOperation("更新员工的有效期")
    public RopResponse<Boolean> updateValPerByStaffId(StaffUpdateValRequest staffUpdateValRequest) {
        try {
            staffService.updateValPerByStaffId(staffUpdateValRequest);
            return RopResponse.success(true);
        } catch (RpcServiceException e) {
            log.info("=======StaffController__invoke__updateValPerByStaffId__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}