Commit 6608df00 by 周海宝

Merge branch 'dev' into 'master'

Dev

See merge request !5
2 parents ca1b1cdb 5263c796
package cn.com.glsx.modules.controller;
import cn.com.glsx.modules.model.param.DeviceInfo;
import cn.com.glsx.modules.model.param.Function;
import cn.com.glsx.modules.service.DeviceService;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......
package cn.com.glsx.modules.controller;
import cn.com.glsx.modules.model.param.UserBo;
import cn.com.glsx.modules.model.param.UserInfo;
import cn.com.glsx.modules.service.UserService;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
......
package cn.com.glsx.modules.factory;
/**
* @author fengzhi
* @date 2021/3/9 17:05
* @description 平台信息枚举
*/
public enum PlatForm implements PlatformConstants{
TUYA {
@Override
public Integer getCode() {
return 0;
}
@Override
public String getValue() {
return "涂鸦";
}
@Override
public String getBeanName(){
return "oneselfStrategy";
}
},
XIAOMI {
@Override
public Integer getCode() {
return 1;
}
@Override
public String getValue() {
return "小米";
}
@Override
public String getBeanName(){
return "oneselfStrategy";
}
},;
public static String getValueByCode(Integer code) {
for (PlatForm platForm : PlatForm.values()) {
if (platForm.getCode().equals(code)) {
return platForm.getValue();
}
}
return null;
}
public static String getBeanNameByCode(Integer code) {
for (PlatForm platForm : PlatForm.values()) {
if (platForm.getCode().equals(code)) {
return platForm.getBeanName();
}
}
return null;
}
}
package cn.com.glsx.modules.factory;
/**
* @author fengzhi
* @date 2021/3/9 17:05
* @description 平台信息接口
*/
public interface PlatformConstants {
Integer getCode();
String getValue();
String getBeanName();
}
package cn.com.glsx.modules.factory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author fengzhi
* @date 2021/3/9 17:05
* @description 平台接口工厂类
*/
@Service
public class PlatformFactory {
@Autowired
Map<String, PlatformStrategy> strategys = new ConcurrentHashMap<>(3);
public PlatformStrategy getStrategy(Integer platformCode) throws Exception{
PlatformStrategy strategy = strategys.get(PlatForm.getBeanNameByCode(platformCode));
if(strategy == null) {
throw new RuntimeException("no strategy defined");
}
return strategy;
}
}
package cn.com.glsx.modules.factory;
/**
* @author fengzhi
* @date 2021/3/9 17:05
* @description 平台统一对外接口
*/
public interface PlatformStrategy {
}
package cn.com.glsx.modules.factory.strategy;
import cn.com.glsx.modules.factory.PlatformStrategy;
import org.springframework.stereotype.Service;
@Service
public class TuyaStrategy implements PlatformStrategy {
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!