EntmicroDepartmentController.java 5.32 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.model.response.DepartmentTreeResponse;
import cn.com.glsx.entmicro.model.response.EntmicroDepartmentResponse;
import cn.com.glsx.entmicro.request.department.DepartmentListRequest;
import cn.com.glsx.entmicro.request.department.DepartmentPageRequest;
import cn.com.glsx.entmicro.request.department.DepartmentTreeRequest;
import cn.com.glsx.entmicro.request.department.MerchantRequest;
import cn.com.glsx.entmicro.service.DepartmentService;
import cn.com.glsx.entmicro.utils.Pagination;
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;

import java.util.List;

/**
 * @author Lichongyuan
 * @Description: 部门服务
 * @date 2021/9/28 11:29
 */
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("部门服务")
@Slf4j
public class EntmicroDepartmentController {

    @Autowired
    private DepartmentService departmentService;

    /**
     * 查询组织树
     * @param departmentTreeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.department.listDepartmentTree", needInSession = NeedInSessionType.YES)
    @ApiOperation("查询组织树")
    public RopResponse<List<DepartmentTreeResponse>> listDepartmentTree(DepartmentTreeRequest departmentTreeRequest) {
        try {
            List<DepartmentTreeResponse> departmentTreeRopResponses = departmentService.listDepartmentTree(departmentTreeRequest);
            return RopResponse.success(departmentTreeRopResponses);
        } catch (RpcServiceException e) {
            log.info("=======EntmicroDepartmentController__invoke__listDepartmentTree__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 查询组织树(无session)
     * @param departmentTreeRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.department.listDepartmentTreeNoSession", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询组织树(无session)")
    public RopResponse<List<DepartmentTreeResponse>> listDepartmentTreeNoSession(DepartmentTreeRequest departmentTreeRequest) {
        try {
            List<DepartmentTreeResponse> departmentTreeRopResponses = departmentService.listDepartmentTree(departmentTreeRequest);
            return RopResponse.success(departmentTreeRopResponses);
        } catch (RpcServiceException e) {
            log.info("=======EntmicroDepartmentController__invoke__listDepartmentTree__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 根据父部门id查询子部门集合
     * @param departmentRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.department.listDepartment", needInSession = NeedInSessionType.YES)
    @ApiOperation("根据父部门id查询子部门集合")
    public RopResponse<List<EntmicroDepartmentResponse>> listDepartmentBySupId(DepartmentListRequest departmentRequest) {
        try {
            List<EntmicroDepartmentResponse> DepartmentResponses = departmentService.listDepartmentBySupId(departmentRequest);
            return RopResponse.success(DepartmentResponses);
        } catch (RpcServiceException e) {
            log.info("=======EntmicroDepartmentController__invoke__listDepartment__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 分页查询部门列表
     * @param departmentPageRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.department.findDepartmentListByPage", needInSession = NeedInSessionType.YES)
    @ApiOperation("分页查询部门列表")
    public RopResponse<Pagination<EntmicroDepartmentResponse>> findDepartmentListByPage(DepartmentPageRequest departmentPageRequest){
        try {
            Pagination<EntmicroDepartmentResponse> DepartmentResponses = departmentService.findDepartmentListByPage(departmentPageRequest);
            return RopResponse.success(DepartmentResponses);
        } catch (RpcServiceException e) {
            log.info("=======EntmicroDepartmentController__invoke__findDepartmentListByPage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }

    /**
     * 查询授权商户
     * @param merchantRequest
     * @return
     */
    @ServiceMethod(method = "entmicro.api.department.authorizeMerchant", needInSession = NeedInSessionType.NO)
    @ApiOperation("查询授权商户")
    public RopResponse<Integer> authorizeMerchant(MerchantRequest merchantRequest) {
        try {
            Integer departmentTreeRopResponses = departmentService.authorizeMerchant(merchantRequest);
            return RopResponse.success(departmentTreeRopResponses);
        } catch (RpcServiceException e) {
            log.info("=======EntmicroDepartmentController__invoke__listDepartmentTree__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(), e.getMessage());
        }
    }
}