对外只有一个接口,统一的情况下,内部系统使用完全没必要,多写几个control就可以了
通过常量和枚举控制
常量类
public class CommentConstant {
public static final Integer worker = 0;
public static final Integer student = 1;
}
枚举
public enum CommentEatEmun {
WORKER(CommentConstant.worker),
Student(CommentConstant.student);
private Integer type;
CommentEatEmun(Integer type) {
this.type=type;
}
public static CommentEatEmun getCommentEatEmun(Integer type){
for (CommentEatEmun commentEatEmun:CommentEatEmun.values()){
if (type.equals(commentEatEmun.type)){
return commentEatEmun;
}
}
return null;
}
}
建服务接口
public interface UserService {
CommentEatEmun getServiceType();
String eat();
}
建对应枚举的实现类