StaffController.java 5.49 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.merchant.MerchantSaveRequest;
import cn.com.glsx.merchants.request.merchant.MerchantSearchResquest;
import cn.com.glsx.merchants.request.staff.*;
import cn.com.glsx.merchants.response.MerchantRopResponse;
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.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;

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 = "cn.com.glsx.merchants.merchant.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 = "cn.com.glsx.merchants.merchant.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 staffDeleteRequest 入参
     * @return
     */
    @ServiceMethod(method = "cn.com.glsx.merchants.merchant.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 = "cn.com.glsx.merchants.merchant.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 = "cn.com.glsx.merchants.merchant.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 = "cn.com.glsx.merchants.menu.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());
        }
    }
}