MerchantRoleController.java 4.85 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.role.*;
import cn.com.glsx.merchants.response.RoleResponse;
import cn.com.glsx.merchants.service.MerchantRoleService;
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: 角色管理接口
 * @date 2021/7/13 10:00
 */
@Slf4j
@Api("角色管理接口")
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
public class MerchantRoleController {

    @Autowired
    private MerchantRoleService roleService;

    /**
     * 角色管理获取列表接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "merchants.api.role.list", needInSession = NeedInSessionType.NO)
    @ApiOperation("角色管理获取列表接口")
    public RopResponse<List<RoleResponse>> getRoleList(RoleSearchRequest request) {
        try {
            return RopResponse.success(roleService.getRoleList(request));
        } catch (RpcServiceException e) {
            log.info("=======MerchantRoleController__invoke__getRoleList__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 角色管理获取分页数据接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "merchants.api.role.page", needInSession = NeedInSessionType.NO)
    @ApiOperation("角色管理获取分页数据接口")
    public RopResponse<Pagination<RoleResponse>> getRolePage(RoleListSearchRequest request) {
        try {
            return RopResponse.success(roleService.getRolePage(request));
        } catch (RpcServiceException e) {
            log.info("=======MerchantRoleController__invoke__getRolePage__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 根据id获取角色管理接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "merchants.api.role.getById", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据id获取角色管理接口")
    public RopResponse<RoleResponse> getById(RoleSearchRequest request) {
        try {
            return RopResponse.success(roleService.getById(request.getId()));
        } catch (RpcServiceException e) {
            log.info("=======MerchantRoleController__invoke__getById__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 根据id获取角色管理接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "merchants.api.role.deleteById", needInSession = NeedInSessionType.NO)
    @ApiOperation("根据id获取角色管理接口")
    public RopResponse<Boolean> deleteById(RoleDeleteRequest request) {
        try {
            return RopResponse.success(roleService.delete(request));
        } catch (RpcServiceException e) {
            log.info("=======MerchantRoleController__invoke__deleteById__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 角色管理新增接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "merchants.api.role.insert", needInSession = NeedInSessionType.NO)
    @ApiOperation("角色管理新增接口")
    public RopResponse<Boolean> insert(RoleInsertRequest request) {
        try {
            return RopResponse.success(roleService.insert(request));
        } catch (RpcServiceException e) {
            log.info("=======MerchantRoleController__invoke__insert__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

    /**
     * 角色管理更新接口
     *
     * @param request
     * @return
     */
    @ServiceMethod(method = "merchants.api.role.update", needInSession = NeedInSessionType.NO)
    @ApiOperation("角色管理更新接口")
    public RopResponse<Boolean> update(RoleUpdateRequest request) {
        try {
            return RopResponse.success(roleService.update(request));
        } catch (RpcServiceException e) {
            log.info("=======MerchantRoleController__invoke__update__exception:{}", e.getMessage());
            return RopResponse.error(e.getErrId(),e.getMessage());
        }
    }

}