MerchantStaffController.java 4.95 KB
package cn.com.glsx.busassistant.controller;

import cn.com.glsx.busassistant.request.serviceCenter.CreateMerchantStaffRopRequest;
import cn.com.glsx.busassistant.request.serviceCenter.SearchStaffPageRopRequest;
import cn.com.glsx.busassistant.request.serviceCenter.UpdateStaffRopRequest;
import cn.com.glsx.busassistant.request.staff.StaffAuditPageRopRequest;
import cn.com.glsx.busassistant.request.staff.StaffResponse;
import cn.com.glsx.busassistant.request.staff.TechnicianPageRequest;
import cn.com.glsx.busassistant.response.ServiceStaffRopResponse;
import cn.com.glsx.busassistant.service.BusinessStaffService;
import cn.com.glsx.busassistant.util.Pagination;
import cn.com.glsx.dj.smartcarlife.response.staff.StaffAuditResponse;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("个人中心-员工管理")
public class MerchantStaffController {


    @Autowired
    private BusinessStaffService staffService;

    @ServiceMethod(method = "scrm.api.busassistant.staff.createStaff", needInSession = NeedInSessionType.YES)
    @ApiOperation("服务中心-创建员工")
    public RopResponse<Boolean> createStaff(CreateMerchantStaffRopRequest ropRequest) {
        try {
            return staffService.createStaff(ropRequest);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__serviceCenterCreateStaff__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    @ServiceMethod(method = "scrm.api.busassistant.staff.updateStaff", needInSession = NeedInSessionType.YES)
    @ApiOperation("服务中心-更新员工")
    public RopResponse<Boolean> updateStaff(UpdateStaffRopRequest ropRequest) {
        try {
            return staffService.updateStaff(ropRequest);
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__serviceCenterupdateStaff__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }


    @ServiceMethod(method = "scrm.api.busassistant.staff.searchStaffPage", needInSession = NeedInSessionType.YES)
    @ApiOperation("服务中心-查询员工分页")
    public RopResponse<Pagination<ServiceStaffRopResponse>> searchStaffPage(SearchStaffPageRopRequest ropRequest) {
        try {
            return RopResponse.success(staffService.searchStaffPage(ropRequest));
        } catch (RpcServiceException e) {
            log.info("=======OpenController__invoke__serviceCenterSearchStaffPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
    /**
     * 查询员工分页列表
     *
     * @param staffPageRequest 入参
     * @return
     */
    @ServiceMethod(method = "scrm.api.busassistant.staff.findStaffByPage", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询员工分页列表")
    public RopResponse<Pagination<StaffResponse>> getMerchantStaffPage(TechnicianPageRequest staffPageRequest) {
        try {
            Pagination<StaffResponse> list = staffService.getMerchantStaffPage(staffPageRequest);
            return RopResponse.success(list);
        } catch (RpcServiceException e) {
            log.info("=======MerchantMenuController__invoke__findStaffByPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 新增/更新/删除员工-提交审核
     */
    @ServiceMethod(method = "scrm.api.busassistant.staff.audit.add", needInSession = NeedInSessionType.NO)
    @ApiOperation("新增/更新/删除员工-提交审核")
    public RopResponse<Boolean> addStaffAudit(CreateMerchantStaffRopRequest ropRequest) {
        try {
            return RopResponse.success(staffService.addStaffAudit(ropRequest));
        } catch (RpcServiceException e) {
            log.error("提交审核失败 ",e);
            return RopResponse.error(e.getMessage());
        }
    }

    @ServiceMethod(method = "scrm.api.busassistant.staff.audit.page", needInSession = NeedInSessionType.NO)
    @ApiOperation("员工审核列表")
    public RopResponse<RpcPagination<StaffAuditResponse>> addStaffAudit(StaffAuditPageRopRequest ropRequest) {
        try {
            return RopResponse.success(staffService.staffAuditPage(ropRequest));
        } catch (RpcServiceException e) {
            log.error("查询员工审核列表失败 ",e);
            return RopResponse.error("查询员工审核列表失败");
        }
    }

}