EntmicroMerchantController.java 1.92 KB
package cn.com.glsx.entmicro.controller;

import cn.com.glsx.entmicro.response.entmicromerchant.EntmicroMerchantBaseInfo;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.alibaba.fastjson.JSON;
import com.rop.AbstractRopRequest;
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.core.env.Environment;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author yelq
 * @Version 1.0
 * @Description:
 * @Date 2022/10/14 17:13
 */
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.YES)
@Api("门店号选择服务")
@Slf4j
public class EntmicroMerchantController {

    @Resource
    private Environment environment;

    /**
     * 获取配置文件中配置的门店列表
     * @return
     */
    @ServiceMethod(method = "entmicro.api.merchant.listDepartmentTree.select.merchant", needInSession = NeedInSessionType.YES)
    @ApiOperation("获取配置文件中配置的门店列表")
    public RopResponse<List<EntmicroMerchantBaseInfo>> getMerchantList(AbstractRopRequest request){
        List<EntmicroMerchantBaseInfo> response = new ArrayList<>();
        String merchantObjs = environment.getProperty("merchant.staff.tree.select.merchantId");
        try {
            if (merchantObjs!=null){
                List<EntmicroMerchantBaseInfo> baseInfos = JSON.parseArray(merchantObjs, EntmicroMerchantBaseInfo.class);
                response.addAll(baseInfos);
            }
        } catch (Exception e) {
            log.info("获取配置文件中配置的门店列表转换失败:{}",e);
            return RopResponse.error("获取门店列表失败!请联系管理员检查配置。");
        }
        return RopResponse.success(response);
    }
}