Commit af4f2cc8 authored by wuwz's avatar wuwz

im

parent 3847d31f
......@@ -47,6 +47,7 @@
<module>xx-vehicle</module>
<module>xx-universal</module>
<module>xx-tour</module>
<module>xx-im</module>
</modules>
<packaging>pom</packaging>
<developers>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ace-security</artifactId>
<groupId>com.github.wxiaoqi</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>xx-im</artifactId>
<packaging>pom</packaging>
<modules>
<module>xx-im-api</module>
<module>xx-im-server</module>
</modules>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>xx-im-api</artifactId>
</project>
\ No newline at end of file
package com.xxfc.platform.im.feign;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* ${DESCRIPTION}
*
* @author wanghaobin
* @create 2017-06-21 8:11
*/
@FeignClient(value = "xx-im")
public interface ImFeign {
/**
* 注册
* @param map
* @return
*/
@RequestMapping(value = "/user/app/unauth/register", method = RequestMethod.POST)
public BaseResponse register(@RequestBody Map<String,Object> map);
/**
* 登录
* @param map
* @return
*/
@RequestMapping(value = "/user/app/unauth/login", method = RequestMethod.POST)
public BaseResponse login(@RequestBody Map<String,Object> map);
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>xx-common-platform</artifactId>
<groupId>com.xxfc.common</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>xx-im-server</artifactId>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
<!-- MyBatis Generator -->
<!-- Java接口和实体类 -->
<targetJavaProject>${basedir}/src/main/java</targetJavaProject>
<targetMapperPackage>com.xxfc.platform.order.mapper
</targetMapperPackage>
<targetModelPackage>com.xxfc.platform.order.entity
</targetModelPackage>
<!-- XML生成路径 -->
<targetResourcesProject>${basedir}/src/main/resources
</targetResourcesProject>
<targetXMLPackage>mapper</targetXMLPackage>
<!-- 依赖版本 -->
<!-- <mapper.version>3.4.0</mapper.version>-->
<mybatis.version>3.3.1</mybatis.version>
<mybatis.spring.version>1.2.4</mybatis.spring.version>
<poi.version>3.15</poi.version>
</properties>
<dependencies>
<!-- spring -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<!-- 缓存 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--nacos相关配置-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>0.2.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<!--引入开源后台项目的公共包-->
<dependency>
<groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-auth-client</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<!-- 引用缓存开源项目 -->
<dependency>
<groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-cache</artifactId>
<version>0.0.2</version>
</dependency>
<!-- 其他 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb.morphia</groupId>
<artifactId>morphia</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>7.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.xxfc.platform.im;
import com.ace.cache.EnableAceCache;
import com.github.wxiaoqi.security.auth.client.EnableAceAuthClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableDiscoveryClient
@EnableScheduling
@EnableAceAuthClient
@EnableFeignClients({"com.github.wxiaoqi.security.auth.client.feign", "com.xxfc.platform"})
@EnableAceCache
@EnableCaching
public class ImApplication {
public static void main(String[] args) {
SpringApplication.run(ImApplication.class, args);
}
}
package com.xxfc.platform.im.biz;
import com.mongodb.DB;
import com.mongodb.Mongo;
public class MGDBCollection {
private static final String HOST = "10.5.52.3";
private static final int PORT = 28018;
private static final String DB_NAME = "imapi";
private static Mongo mongo;
private static DB db;
static {
// 连接到MongoDB
mongo = new Mongo(HOST, PORT);
// 打开数据库 testDB
db = mongo.getDB(DB_NAME);
}
public static DB getDB(){
return db;
}
}
package com.xxfc.platform.im.biz;
import com.mongodb.DB;
import com.mongodb.Mongo;
public class TigaseCollection {
private static final String HOST = "10.5.52.3";
private static final int PORT = 28018;
private static final String DB_NAME = "tigase";
private static Mongo mongo;
private static DB db;
static {
// 连接到MongoDB
mongo = new Mongo(HOST, PORT);
// 打开数据库 testDB
db = mongo.getDB(DB_NAME);
}
public static DB getDB(){
return db;
}
}
package com.xxfc.platform.im.biz;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.xxfc.platform.im.model.User;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@Component
public class UserBiz {
@Autowired
private MongoTemplate mongoTemplate;
/**
* 注册
* @param map
* @return
*/
public BaseResponse register(Map<String, Object> map){
BaseResponse baseResponse = new BaseResponse();
String str = "";
if(map.get("telephone") != null && !("").equals(map.get("telephone"))){
str += "telephone="+map.get("telephone").toString()+"&";
}
if(map.get("password") != null && !("").equals(map.get("password"))){
str += "password="+map.get("password").toString()+"&";
}
if(map.get("nickname") != null && !("").equals(map.get("nickname"))){
str += "nickname="+map.get("nickname").toString();
}
String result = this.doPost("http://10.5.52.3:6688/xxfcim/user/register",str) ;
JSONObject json = JSONObject.parseObject(result);
//如果已经注册过,查询出手机号对应用户信息执行登录返回
if(0 == json.getInteger("resultCode")){
String phone = map.get("telephone").toString();
Query query = new Query(Criteria.where("phone").is(phone));
User mgt = mongoTemplate.findOne(query, User.class);
if(mgt == null){
result = "系统错误";
}else{
Map<String,Object>params = new HashMap<String,Object>();
params.put("userId",mgt.getUserId());
params.put("telephone",mgt.getPhone());
params.put("password",mgt.getPassword());
result = this.login(params);
}
}
baseResponse.setStatus(200);
baseResponse.setMessage(result);
return baseResponse;
}
/**
* 登录
* @param map
* @return
*/
public String login(Map<String, Object> map) {
String str = "";
if(map.get("userId") != null && !("").equals(map.get("userId"))){
str += "userId="+map.get("userId").toString()+"&";
}
if(map.get("telephone") != null && !("").equals(map.get("telephone"))){
str += "telephone="+DigestUtils.md5Hex(map.get("telephone").toString())+"&";
}
if(map.get("password") != null && !("").equals(map.get("password"))){
str += "password="+map.get("password").toString();
}
str += "&areaCode=86";
String result = this.doPost("http://10.5.52.3:6688/xxfcim/user/login",str) ;
JSONObject json = JSONObject.parseObject(result);
json.put("password",map.get("password").toString());
return json.toJSONString();
}
/**
* 远程请求
* @param path
* @param params
* @return
*/
private String doPost(String path,String params){
HttpURLConnection connection = null;
InputStream is = null;
OutputStream os = null;
BufferedReader br = null;
String result = null;
try {
URL url = new URL(path);
// 通过远程url连接对象打开连接
connection = (HttpURLConnection) url.openConnection();
// 设置连接请求方式
connection.setRequestMethod("POST");
// 设置连接主机服务器超时时间:15000毫秒
connection.setConnectTimeout(15000);
// 设置读取主机服务器返回数据超时时间:60000毫秒
connection.setReadTimeout(60000);
// 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
connection.setDoOutput(true);
// 默认值为:true,当前向远程服务读取数据时,设置为true,该参数可有可无
connection.setDoInput(true);
// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// 通过连接对象获取一个输出流
os = connection.getOutputStream();
// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
os.write(params.getBytes());
// 通过连接对象获取一个输入流,向远程读取
if (connection.getResponseCode() == 200) {
is = connection.getInputStream();
// 对输入流对象进行包装:charset根据工作项目组的要求来设置
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer sbf = new StringBuffer();
String temp = null;
// 循环遍历一行一行读取数据
while ((temp = br.readLine()) != null) {
sbf.append(temp);
sbf.append("\r\n");
}
result = sbf.toString();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 关闭资源
if (null != br) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != os) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != is) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
// 断开与远程地址url的连接
connection.disconnect();
}
return result;
}
}
package com.xxfc.platform.im.model;
public class BaseExample {
protected String apiVersion;// 客户端使用的接口版本号
protected String model;// 客户端设备型号
protected String osVersion;// 客户端设备操作系统版本号
protected String serial;// 客户端设备序列号
protected Integer areaId;// 区县Id
protected Integer cityId;// 城市Id
protected String cityName;// 城市名称
protected Integer countryId;// 国家Id
protected Integer provinceId;// 省份Id
protected String address;// 详细地址
protected String location;// 位置描述
protected double latitude;// 纬度
protected double longitude;// 经度
public String getApiVersion() {
return apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getOsVersion() {
return osVersion;
}
public void setOsVersion(String osVersion) {
this.osVersion = osVersion;
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public Integer getAreaId() {
return areaId;
}
public void setAreaId(Integer areaId) {
this.areaId = areaId;
}
public Integer getCityId() {
return cityId;
}
public void setCityId(Integer cityId) {
this.cityId = cityId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public Integer getCountryId() {
return countryId;
}
public void setCountryId(Integer countryId) {
this.countryId = countryId;
}
public Integer getProvinceId() {
return provinceId;
}
public void setProvinceId(Integer provinceId) {
this.provinceId = provinceId;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
}
package com.xxfc.platform.im.model;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Indexed;
import org.mongodb.morphia.annotations.NotSaved;
import java.util.List;
@Entity(value = "company", noClassnameStored = true)
public class Company {
private @Id
ObjectId id; //公司id
private @Indexed String companyName;// 公司名称
private @Indexed int createUserId;//创建者的用户id
private @Indexed int deleteUserId; //删除者id,默认0 注:当用户执行删除公司操作后,将userId存入,隐藏相关信息。
private @Indexed List<ObjectId> rootDpartId; //根部门Id,可能有多个
private @Indexed long createTime; //创建时间
private long deleteTime; //删除时间
private @Indexed String noticeContent;// 公司公告(通知)
private long noticeTime; //公告时间
private @Indexed int empNum; //公司员工总数
private @Indexed int type = 0; //类型值 5:默认加入的公司
private @NotSaved List<Department> departments; //公司的部门列表
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public List<Department> getDepartments() {
return departments;
}
public void setDepartments(List<Department> departments) {
this.departments = departments;
}
public ObjectId getId() {
return id;
}
public void setId(ObjectId id) {
this.id = id;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public int getCreateUserId() {
return createUserId;
}
public void setCreateUserId(int createUserId) {
this.createUserId = createUserId;
}
public int getDeleteUserId() {
return deleteUserId;
}
public void setDeleteUserId(int deleteUserId) {
this.deleteUserId = deleteUserId;
}
public List<ObjectId> getRootDpartId() {
return rootDpartId;
}
public void setRootDpartId(List<ObjectId> rootDpartId) {
this.rootDpartId = rootDpartId;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public long getDeleteTime() {
return deleteTime;
}
public void setDeleteTime(long deleteTime) {
this.deleteTime = deleteTime;
}
public String getNoticeContent() {
return noticeContent;
}
public void setNoticeContent(String noticeContent) {
this.noticeContent = noticeContent;
}
public long getNoticeTime() {
return noticeTime;
}
public void setNoticeTime(long noticeTime) {
this.noticeTime = noticeTime;
}
public int getEmpNum() {
return empNum;
}
public void setEmpNum(int empNum) {
this.empNum = empNum;
}
}
\ No newline at end of file
package com.xxfc.platform.im.model;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
@Getter
@Setter
@Entity(value="config",noClassnameStored=true)
public class Config {
/**
*
*/
private @Id long id=10000;
public int XMPPTimeout=15;// xmpp超时时间 秒
// private String apiUrl;
// private String downloadAvatarUrl;
// private String downloadUrl;
// private String uploadUrl;
// private String liveUrl;
//private String freeswitch;
// private String jitsiServer;
//private String meetingHost;
//聊天内容的 文件有效期 默认 -1
private int fileValidTime=-1;
//聊天记录// 过期销毁时长 -1、0:永久 0.04:一小时 1:1天 7:一周 30:一个月 120:一季 365:一年
private int chatRecordTimeOut=-1;
private int telephoneSearchUser = 1; //手机号搜索用户 0 :关闭 1:精确搜索 2:模糊搜索 默认精准搜索
private int nicknameSearchUser = 2; //昵称搜索用户 0 :关闭 1:精确搜索 2:模糊搜索 默认模糊搜索
private int isTelephoneLogin=1; //手机号登陆 1 开启 0 关闭
private int isUserIdLogin=1; //用户ID登陆 1 开启 0 关闭
private String helpUrl;
private String videoLen;
private String audioLen;
private String shareUrl;
private String softUrl;
private int distance;
private int isAuthApi=1;//检验api 权限
private int isKeyWord; // 是否开启关键词过滤 1:开启 0:关闭
private int isSaveMsg=1; // 是否保存单聊聊天记录 1:开启 0:关闭
private int isSaveMucMsg=1; // 是否保存群聊聊天记录 1:是 0:否
private int isMsgSendTime; // 是否强制同步消息发送时间 1:是 0:否
private int regeditPhoneOrName = 0;// 0:使用手机号注册,1:使用用户名注册
private int registerInviteCode; // 注册邀请码
private int isSaveRequestLogs; // 是否保存接口请求日志
/** 用户隐私设置参数 **/
private double roamingTime=-2;// 漫游时长 -2:不漫游 -1、0:永久 0.04:一小时 1:1天 7:一周 30:一个月 120:一季 365:一年
private double outTimeDestroy=-1;// 过期销毁时长 -1、0:永久 0.04:一小时 1:1天 7:一周 30:一个月 120:一季 365:一年
private String language="zh";// 客户端默认语种
private int isFriendsVerify = 1;// 是否需要好友验证 1:开启 0:关闭
private int isEncrypt;// 是否开启加密传输 1:开启 0:关闭
private int isMultiLogin=1;// 是否开启多点登录 1:开启 0:关闭
private int isVibration; // 是否振动 1:开启 0:关闭
private int isTyping; // 让对方知道我正在输入 1:开启 0:关闭
private int isUseGoogleMap;// 使用google地图 1:开启 0:关闭
private Integer isKeepalive = 1;// 是否安卓后台常驻保活app 0:取消保活 1:保活
private Integer phoneSearch = 1;// 允许手机号搜索 1 允许 0 不允许
private Integer nameSearch = 1;// 允许昵称搜索 1 允许 0 不允许
private Integer showLastLoginTime = 1;// 显示上次上线时间 -1 所有人不显示 1所有人显示 2 所有好友显示 3 手机联系人显示
private Integer showTelephone = 1;// 显示我的手机号码 -1 所有人不显示 1所有人显示 2 所有好友显示 3 手机联系人显示
/** 建立群组默认参数设置 **/
private int maxUserSize=1000;// 群成员人数上限
private int isAttritionNotice=1;// 群组减员发送通知(踢人,退出) 1:开启 0:关闭
private Integer isLook=1;// 群组是否可见 0为可见 1为不可见
private int showRead=0;// 群主设置 群内消息是否发送已读 回执 显示数量 1:是 0:否
private Integer isNeedVerify=0; // 加群是否需要通过验证 0:不要 1:要
private int showMember=1;// 显示群成员给 普通用户 1 显示 0 不显示
private int allowSendCard=1;// 允许发送名片 好友 1 允许 0 不允许
private int allowInviteFriend=1;// 允许普通成员邀请好友 1:允许 0:不允许
private int allowUploadFile=1;// 允许群成员上传群共享文件 1:允许 0:不允许
private int allowConference=1;// 允许成员 召开会议 1:允许 0:不允许
private int allowSpeakCourse=1;// 允许群成员 开启 讲课 1:允许 0:不允许
private String iosPushServer="apns";// apns 推送
private String SMSType = "aliyun";// 短信服务支持
private int isAutoAddressBook;// 是否自动添加通讯录好友
private double giftRatio = 0.50;// 直播礼物分成比例
private String promotionUrl;// 客服推广链接
private String defaultTelephones;// 注册默认自动添加为好友 的用户手机号
private byte isOpenSMSCode = 1; //是否开启短信验证码
private byte isOpenReceipt=1;//是否启用 消息回执
private byte isOpenCluster;// 是否开启集群
private byte isOpenVoip;// 是否打开ios voip推送
//以下为版本更新的字段
private int androidVersion; //Android 版本号
private int iosVersion; //ios版本号
private String androidAppUrl; //Android App的下载地址
private String iosAppUrl; // IOS App 的下载地址
private String androidExplain; //Android 说明
private String iosExplain; // ios 说明
public Config() {
}
//需要返回给客户端
public Config(Config config) {
super();
this.id = config.id;
this.fileValidTime = config.getFileValidTime();
this.chatRecordTimeOut = config.getChatRecordTimeOut();
this.telephoneSearchUser = config.getTelephoneSearchUser();
this.isTelephoneLogin = config.getIsTelephoneLogin();
this.isUserIdLogin = config.getIsUserIdLogin();
this.registerInviteCode = config.getRegisterInviteCode();
this.helpUrl = config.getHelpUrl();
this.videoLen = config.getVideoLen();
this.audioLen = config.getAudioLen();
this.shareUrl = config.getShareUrl();
this.softUrl = config.getSoftUrl();
this.distance = config.getDistance();
this.androidVersion = config.getAndroidVersion();
this.iosVersion = config.getIosVersion();
this.androidAppUrl = config.getAndroidAppUrl();
this.iosAppUrl = config.getIosAppUrl();
this.androidExplain = config.getAndroidExplain();
this.iosExplain = config.getIosExplain();
this.isOpenSMSCode = config.getIsOpenSMSCode();
this.isOpenReceipt = config.getIsOpenReceipt();
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
}
package com.xxfc.platform.im.model;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Indexed;
import org.mongodb.morphia.annotations.NotSaved;
import java.util.List;
@Entity(value = "department", noClassnameStored = true)
public class Department {
private @Id
ObjectId id; //部门id
private @Indexed
ObjectId companyId; //公司id,表示该部门所属的公司
private @Indexed
ObjectId parentId; //parentId 表示上一级的部门ID
private @Indexed String departName; //部门名称
private @Indexed int createUserId; //创建者userId
private long createTime; //创建时间
private int empNum = -1; //部门总人数
private @Indexed int type = 0; //类型值 0:普通部门 1:根部门 2:分公司 5:默认加入的部门 6.客服部门
//此属性用于封装部门员工列表
private @NotSaved List<Employee> employees; //部门员工列表
//此属性用于封装该部门的子部门
private @NotSaved List<Department> childDepartment; //子部门
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public ObjectId getId() {
return id;
}
public void setId(ObjectId id) {
this.id = id;
}
public List<Employee> getEmployees() {
return employees;
}
public void setEmployees(List<Employee> employees) {
this.employees = employees;
}
public ObjectId getCompanyId() {
return companyId;
}
public void setCompanyId(ObjectId companyId) {
this.companyId = companyId;
}
public ObjectId getParentId() {
return parentId;
}
public void setParentId(ObjectId parentId) {
this.parentId = parentId;
}
public String getDepartName() {
return departName;
}
public void setDepartName(String departName) {
this.departName = departName;
}
public int getCreateUserId() {
return createUserId;
}
public void setCreateUserId(int createUserId) {
this.createUserId = createUserId;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public int getEmpNum() {
return empNum;
}
public void setEmpNum(int empNum) {
this.empNum = empNum;
}
public List<Department> getChildDepartment() {
return childDepartment;
}
public void setChildDepartment(List<Department> childDepartment) {
this.childDepartment = childDepartment;
}
}
package com.xxfc.platform.im.model;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.*;
@Entity(value = "employee", noClassnameStored = true)
@Indexes(value = {@Index(fields = {@Field("userId"),@Field("departmentId"),@Field("companyId"),@Field("role") }) })
public class Employee {
private @Id
ObjectId id; //员工id
private @Indexed int userId; //用户id,用于和用户表关联
private @Indexed
ObjectId departmentId; //部门Id,表示员工所属部门
private @Indexed
ObjectId companyId; //公司id,表示员工所属公司
private @Indexed int role; //员工角色:0:普通员工 1:部门管理者 2:管理员 3:公司创建者(超管)
private String position = "员工"; //职位(头衔),如:经理、总监等
private @NotSaved String nickname; //用户昵称,和用户表一致
//客服模块所需字段
private int chatNum;//当前会话的人数
private int isPause;//是否暂停 0:暂停,1:正常
private @NotSaved int operationType;//操作类型 1.建立会话操作 2.结束回话操作
private @NotSaved int isCustomer;//是否为客服 0:不是 1:是
public int getIsCustomer() {
return isCustomer;
}
public void setIsCustomer(int isCustomer) {
this.isCustomer = isCustomer;
}
public int getOperationType() {
return operationType;
}
public void setOperationType(int operationType) {
this.operationType = operationType;
}
public int getIsPause() {
return isPause;
}
public void setIsPause(int isPause) {
this.isPause = isPause;
}
public int getChatNum() {
return chatNum;
}
public void setChatNum(int chatNum) {
this.chatNum = chatNum;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public ObjectId getId() {
return id;
}
public void setId(ObjectId id) {
this.id = id;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public ObjectId getDepartmentId() {
return departmentId;
}
public void setDepartmentId(ObjectId departmentId) {
this.departmentId = departmentId;
}
public ObjectId getCompanyId() {
return companyId;
}
public void setCompanyId(ObjectId companyId) {
this.companyId = companyId;
}
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
}
package com.xxfc.platform.im.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.xxfc.platform.im.utils.DateUtil;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Index;
import org.mongodb.morphia.annotations.Indexes;
@Entity(value = "u_fans", noClassnameStored = true)
@Indexes(@Index("userId,toUserId"))
public class Fans {
private @JSONField(serialize = false) @Id
ObjectId id;// 粉丝关系Id
private long time;// 关注世间
private String toNickname;// 粉丝用户昵称
private int toUserId;// 粉丝用户Id
private int userId;// 用户Id
public Fans() {
super();
}
public Fans(int userId, int toUserId) {
super();
this.userId = userId;
this.toUserId = toUserId;
this.time = DateUtil.currentTimeSeconds();
}
public ObjectId getId() {
return id;
}
public long getTime() {
return time;
}
public String getToNickname() {
return toNickname;
}
public int getToUserId() {
return toUserId;
}
public int getUserId() {
return userId;
}
public void setId(ObjectId id) {
this.id = id;
}
public void setTime(long time) {
this.time = time;
}
public void setToNickname(String toNickname) {
this.toNickname = toNickname;
}
public void setToUserId(int toUserId) {
this.toUserId = toUserId;
}
public void setUserId(int userId) {
this.userId = userId;
}
}
package com.xxfc.platform.im.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.xxfc.platform.im.utils.DateUtil;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.*;
import java.util.List;
@Entity(value = "u_friends", noClassnameStored = true)
@Indexes(@Index("userId,toUserId"))
public class Friends {
public static class Blacklist {
public static final int No = 0;
public static final int Yes = 1;
}
public static class Status {
/** 关注 */
public static final int Attention = 1;
/** 好友 */
public static final int Friends = 2;
/** 陌生人 */
public static final int Stranger = 0;
}
private Integer blacklist=0;// 是否拉黑(1=是;0=否)
private Integer isBeenBlack=0; //是否被拉黑(1=是;0=否)
private Integer offlineNoPushMsg=0;//消息免打扰(1=是;0=否)
private long createTime;// 建立关系时间
@Id
@JSONField(serialize = false)
private ObjectId id;// 关系Id
private long modifyTime;// 修改时间
private long lastTalkTime; //最后沟通时间
private long msgNum;//未读消息数量
private String remarkName;// 备注
private Integer status;// 状态(1=关注;2=好友;0=陌生人 ;-1=黑名单)
private String toNickname;// 好友昵称
private int toUserId;// 好友Id
private int toUserType;// 好友的user type
private List<Integer> toFriendsRole;// 好友的角色信息
private int userId;// 用户Id
@NotSaved
private String nickname;// 自己的昵称
//聊天记录过期时间 -1 为永久 数值 为天数
private double chatRecordTimeOut=-1;
/*private ObjectId groupId;//分组ID
private String groupName;//分组名称
*/
private String describe;// 描述
private Integer fromAddType = 0;// 通过什么方式添加 0 : 系统添加好友 1:二维码 2:名片 3:群组 4: 手机号搜索 5:昵称搜索
public Friends() {
super();
}
public Friends(int userId) {
super();
this.userId = userId;
}
public Friends(int userId, int toUserId) {
super();
this.userId = userId;
this.toUserId = toUserId;
this.createTime = DateUtil.currentTimeSeconds();
}
public Friends(int userId, int toUserId, String toNickname, Integer status) {
super();
this.userId = userId;
this.toUserId = toUserId;
this.toNickname=toNickname;
this.status = status;
this.createTime = DateUtil.currentTimeSeconds();
}
public Friends(int userId, int toUserId, String toNickname, Integer status, Integer toUserType, List<Integer> toFriendsRole) {
super();
this.userId = userId;
this.toUserId = toUserId;
this.toNickname=toNickname;
this.status = status;
this.createTime = DateUtil.currentTimeSeconds();
this.toUserType = toUserType;
this.toFriendsRole = toFriendsRole;
}
public Friends(int userId, int toUserId, String toNickname, Integer status, Integer blacklist, Integer isBeenBlack) {
super();
this.userId = userId;
this.toUserId = toUserId;
this.toNickname=toNickname;
this.status = status;
this.blacklist = blacklist;
this.isBeenBlack=isBeenBlack;
this.createTime = DateUtil.currentTimeSeconds();
}
public Friends(int userId, int toUserId, String toNickname, Integer status, Integer blacklist, Integer isBeenBlack, List<Integer> toUserRole, int toUserType, Integer fromAddType) {
super();
this.userId = userId;
this.toUserId = toUserId;
this.toNickname=toNickname;
this.status = status;
this.blacklist = blacklist;
this.isBeenBlack=isBeenBlack;
this.toFriendsRole=toUserRole;
this.createTime = DateUtil.currentTimeSeconds();
this.toUserType=toUserType;
this.fromAddType=fromAddType;
}
public Friends(int userId, int toUserId, String toNickname, Integer status, Integer blacklist, Integer isBeenBlack, List<Integer> toUserRole, String toRemarkName, int toUserType) {
super();
this.userId = userId;
this.toUserId = toUserId;
this.toNickname=toNickname;
this.status = status;
this.blacklist = blacklist;
this.isBeenBlack=isBeenBlack;
this.toFriendsRole=toUserRole;
this.createTime = DateUtil.currentTimeSeconds();
this.remarkName = toRemarkName;
this.toUserType=toUserType;
}
public Integer getBlacklist() {
return blacklist;
}
public Integer getIsBeenBlack() {
return isBeenBlack;
}
public void setIsBeenBlack(Integer isBeenBlack) {
this.isBeenBlack = isBeenBlack;
}
public Integer getOfflineNoPushMsg() {
return offlineNoPushMsg;
}
public void setOfflineNoPushMsg(Integer offlineNoPushMsg) {
this.offlineNoPushMsg = offlineNoPushMsg;
}
public long getCreateTime() {
return createTime;
}
public ObjectId getId() {
return id;
}
public long getModifyTime() {
return modifyTime;
}
public String getRemarkName() {
return remarkName;
}
public Integer getStatus() {
return status;
}
public String getToNickname() {
return toNickname;
}
public int getToUserId() {
return toUserId;
}
public int getUserId() {
return userId;
}
public void setBlacklist(Integer blacklist) {
this.blacklist = blacklist;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public void setId(ObjectId id) {
this.id = id;
}
public void setModifyTime(long modifyTime) {
this.modifyTime = modifyTime;
}
public void setRemarkName(String remarkName) {
this.remarkName = remarkName;
}
public void setStatus(Integer status) {
this.status = status;
}
public void setToNickname(String toNickname) {
this.toNickname = toNickname;
}
public void setToUserId(int toUserId) {
this.toUserId = toUserId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public long getLastTalkTime() {
return lastTalkTime;
}
public void setLastTalkTime(long lastTalkTime) {
this.lastTalkTime = lastTalkTime;
}
public long getMsgNum() {
return msgNum;
}
public void setMsgNum(long msgNum) {
this.msgNum = msgNum;
}
public double getChatRecordTimeOut() {
return chatRecordTimeOut;
}
public void setChatRecordTimeOut(double chatRecordTimeOut) {
this.chatRecordTimeOut = chatRecordTimeOut;
}
public List<Integer> getToFriendsRole() {
return toFriendsRole;
}
public void setToFriendsRole(List<Integer> toFriendsRole) {
this.toFriendsRole = toFriendsRole;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public int getToUserType() {
return toUserType;
}
public void setToUserType(int toUserType) {
this.toUserType = toUserType;
}
public String getDescribe() {
return describe;
}
public void setDescribe(String describe) {
this.describe = describe;
}
public Integer getFromAddType() {
return fromAddType;
}
public void setFromAddType(Integer fromAddType) {
this.fromAddType = fromAddType;
}
}
\ No newline at end of file
package com.xxfc.platform.im.model;
import com.alibaba.fastjson.JSON;
public class KSession {
private String telephone;
private Integer userId;
private int deviceId;
private String channelId;
private String language="zh";
public KSession() {
super();
}
public KSession(String telephone, Integer userId, String language) {
super();
this.telephone = telephone;
this.userId = userId;
this.language=language;
}
public KSession(String telephone, Integer userId) {
super();
this.telephone = telephone;
this.userId = userId;
}
public KSession(String telephone, Integer userId, int deviceId, String channelId, String language) {
super();
this.telephone = telephone;
this.userId = userId;
this.channelId=channelId;
this.language=language;
}
public String getTelephone() {
return telephone;
}
public Integer getUserId() {
return userId;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
public String getChannelId() {
return channelId;
}
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public int getDeviceId() {
return deviceId;
}
public void setDeviceId(int deviceId) {
this.deviceId = deviceId;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
}
package com.xxfc.platform.im.model;
import java.util.List;
import java.util.Map;
import com.xxfc.platform.im.utils.DateUtil;
import org.mongodb.morphia.annotations.Embedded;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import org.mongodb.morphia.annotations.Index;
import org.mongodb.morphia.annotations.Indexed;
import org.mongodb.morphia.annotations.Indexes;
import org.mongodb.morphia.annotations.NotSaved;
import org.mongodb.morphia.utils.IndexDirection;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Entity(value = "user", noClassnameStored = true)
@Indexes({ @Index("status,birthday,sex,cityId") })
public class User {
@Id
private Integer userId;// 用户Id
//@JSONField(serialize = false)
@Indexed(unique=true)
private String userKey;// 用户唯一标识
/**
* 账号 唯一
*/
private String account;
/**
* 修改账号次数
*/
private int setAccountCount;
@JSONField(serialize = false)
private String username; //用户名
//@JSONField(serialize = false)
private String password;
private String appId; //ios 需要判断的包名
// 用户类型:1=普通用户; 2=公众号 ;
private Integer userType=1;
//消息免打扰
private Integer offlineNoPushMsg=0;//1为开启 0为关闭
@Setter
@Getter
private String openid;// 微信openId
@Getter
@Setter
private String aliUserId; // 支付宝用户Id
@Indexed
private String areaCode;
@Indexed(unique=true)
private String telephone;
@Indexed
private String phone;
private String name;// 姓名
@Indexed(value = IndexDirection.ASC)
private String nickname;// 昵称
@Indexed(value = IndexDirection.ASC)
private Long birthday;// 生日
@Indexed(value = IndexDirection.ASC)
private Integer sex;// 性别 0 女 1:男
@Indexed(value = IndexDirection.ASC)
private long active=0;// 最后出现时间
@Indexed(value = IndexDirection.GEO2D)
private Loc loc;// 地理位置
private String description;// 签名、说说、备注
private Integer countryId;// 国家Id
private Integer provinceId;// 省份Id
private Integer cityId;// 城市
private Integer areaId;// 地区Id
private Integer level;// 等级
private Integer vip; // VIP级别
private Double balance=0.0; //用户余额
private Integer msgNum=0;//未读消息数量
private Double totalRecharge=0.0;//充值总金额
private Double totalConsume=0.0;//消费总金额
private Integer friendsCount = 0;// 好友数
private Integer fansCount = 0;// 粉丝数
private Integer attCount = 0;// 关注数
private Long createTime;// 注册时间
private Long modifyTime;// 更新时间
private String idcard;// 身份证号码
private String idcardUrl;// 身份证图片地址
private String msgBackGroundUrl;// 朋友圈背景URL
private Integer isAuth = 0;// 是否认证 0:否 1:是 (该字段目前用于标示用户是否使用短信验证码注册--2018-10-11)
private Integer status = 1;// 状态:1=正常, -1=禁用
private @Indexed Integer onlinestate=0; //在线状态,默认离线0 在线 1
private String payPassword;// 用户支付密码
private String regInviteCode; //注册时填写的邀请码
//********************引用字段********************
@NotSaved
private String model;// 登录设备
@NotSaved
private long showLastLoginTime;// 最后上线时间
private @NotSaved LoginLog loginLog;// 登录日志
private UserSettings settings;// 用户设置
private @NotSaved Company company;// 所属公司
private @NotSaved Friends friends;// 好友关系
private @NotSaved List<Integer> role;// 角色
private @NotSaved String myInviteCode;//我的邀请码
// 第三方帐号列表
private @NotSaved List<ThridPartyAccount> accounts;
// 关注列表
private @NotSaved List<Friends> attList;
// 粉丝列表
private @NotSaved List<Fans> fansList;
// 好友列表
private @NotSaved List<Friends> friendsList;
//创建房间次数
private int num=0;
//是否暂停 0:正常 1:暂停
private int isPasuse;
// 用户的地理位置
private String area;
// ********************引用字段********************
public Integer getUserId() {
return userId;
}
public int getIsPasuse() {
return isPasuse;
}
public void setIsPasuse(int isPasuse) {
this.isPasuse = isPasuse;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserKey() {
return userKey;
}
public void setUserKey(String userKey) {
this.userKey = userKey;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Integer getOfflineNoPushMsg() {
return offlineNoPushMsg;
}
public void setOfflineNoPushMsg(Integer offlineNoPushMsg) {
this.offlineNoPushMsg = offlineNoPushMsg;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getUserType() {
return userType;
}
public void setUserType(Integer userType) {
this.userType = userType;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public Long getBirthday() {
return birthday;
}
public void setBirthday(Long birthday) {
this.birthday = birthday;
}
public Integer getSex() {
return sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
public long getActive() {
return active;
}
public void setActive(long active) {
this.active = active;
}
public Loc getLoc() {
return loc;
}
public void setLoc(Loc loc) {
this.loc = loc;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getCountryId() {
return countryId;
}
public void setCountryId(Integer countryId) {
this.countryId = countryId;
}
public Integer getProvinceId() {
return provinceId;
}
public void setProvinceId(Integer provinceId) {
this.provinceId = provinceId;
}
public Integer getCityId() {
return cityId;
}
public void setCityId(Integer cityId) {
this.cityId = cityId;
}
public Integer getAreaId() {
return areaId;
}
public void setAreaId(Integer areaId) {
this.areaId = areaId;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getVip() {
return vip;
}
public void setVip(Integer vip) {
this.vip = vip;
}
public Integer getFriendsCount() {
return friendsCount;
}
public void setFriendsCount(Integer friendsCount) {
this.friendsCount = friendsCount;
}
public Integer getFansCount() {
return fansCount;
}
public void setFansCount(Integer fansCount) {
this.fansCount = fansCount;
}
public Integer getAttCount() {
return attCount;
}
public void setAttCount(Integer attCount) {
this.attCount = attCount;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getModifyTime() {
return modifyTime;
}
public void setModifyTime(Long modifyTime) {
this.modifyTime = modifyTime;
}
public String getIdcard() {
return idcard;
}
public void setIdcard(String idcard) {
this.idcard = idcard;
}
public String getIdcardUrl() {
return idcardUrl;
}
public void setIdcardUrl(String idcardUrl) {
this.idcardUrl = idcardUrl;
}
public Integer getIsAuth() {
return isAuth;
}
public void setIsAuth(Integer isAuth) {
this.isAuth = isAuth;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public UserSettings getSettings() {
return settings;
}
public void setSettings(UserSettings settings) {
this.settings = settings;
}
public Company getCompany() {
return company;
}
public void setCompany(Company company) {
this.company = company;
}
public Friends getFriends() {
return friends;
}
public void setFriends(Friends friends) {
this.friends = friends;
}
public List<ThridPartyAccount> getAccounts() {
return accounts;
}
public void setAccounts(List<ThridPartyAccount> accounts) {
this.accounts = accounts;
}
public List<Friends> getAttList() {
return attList;
}
public void setAttList(List<Friends> attList) {
this.attList = attList;
}
public List<Fans> getFansList() {
return fansList;
}
public void setFansList(List<Fans> fansList) {
this.fansList = fansList;
}
public List<Friends> getFriendsList() {
return friendsList;
}
public void setFriendsList(List<Friends> friendsList) {
this.friendsList = friendsList;
}
public Integer getOnlinestate() {
return onlinestate;
}
public void setOnlinestate(Integer onlinestate) {
this.onlinestate = onlinestate;
}
public Double getTotalConsume() {
return totalConsume;
}
public void setTotalConsume(Double totalConsume) {
this.totalConsume = totalConsume;
}
public Double getTotalRecharge() {
return totalRecharge;
}
public void setTotalRecharge(Double totalRecharge) {
this.totalRecharge = totalRecharge;
}
public Double getBalance() {
return balance;
}
public void setBalance(Double balance) {
this.balance = balance;
}
// public static String buildUserKey(String telephone) {
// return DigestUtils.md5Hex(DigestUtils.md5Hex(telephone));
// }
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getMsgNum() {
return msgNum;
}
public void setMsgNum(Integer msgNum) {
this.msgNum = msgNum;
}
public LoginLog getLoginLog() {
return loginLog;
}
public void setLoginLog(LoginLog loginLog) {
this.loginLog = loginLog;
}
public String getPayPassword() {
return payPassword;
}
public void setPayPassword(String payPassword) {
this.payPassword = payPassword;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public List<Integer> getRole() {
return role;
}
public void setRole(List<Integer> role) {
this.role = role;
}
public String getRegInviteCode() {
return regInviteCode;
}
public void setRegInviteCode(String regInviteCode) {
this.regInviteCode = regInviteCode;
}
public String getMyInviteCode() {
return myInviteCode;
}
public void setMyInviteCode(String myInviteCode) {
this.myInviteCode = myInviteCode;
}
public String getMsgBackGroundUrl() {
return msgBackGroundUrl;
}
public void setMsgBackGroundUrl(String msgBackGroundUrl) {
this.msgBackGroundUrl = msgBackGroundUrl;
}
public long getShowLastLoginTime() {
return showLastLoginTime;
}
public void setShowLastLoginTime(long showLastLoginTime) {
this.showLastLoginTime = showLastLoginTime;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public int getSetAccountCount() {
return setAccountCount;
}
public void setSetAccountCount(int setAccountCount) {
this.setAccountCount = setAccountCount;
}
public static class LoginLog{
private int isFirstLogin;
private long loginTime;
private String apiVersion;
private String osVersion;
private String model;
private String serial;
private double latitude;
private double longitude;
private String location;
private String address;
private long offlineTime;
public int getIsFirstLogin() {
return isFirstLogin;
}
public void setIsFirstLogin(int isFirstLogin) {
this.isFirstLogin = isFirstLogin;
}
public long getLoginTime() {
return loginTime;
}
public void setLoginTime(long loginTime) {
this.loginTime = loginTime;
}
public String getApiVersion() {
return apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
public String getOsVersion() {
return osVersion;
}
public void setOsVersion(String osVersion) {
this.osVersion = osVersion;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public long getOfflineTime() {
return offlineTime;
}
public void setOfflineTime(long offlineTime) {
this.offlineTime = offlineTime;
}
}
public static class DeviceInfo{
private long loginTime;
/**
* 设备号 android ios web
*/
private String deviceKey;
private String adress;// 地区标识 例 CN HK
private int online;//在线状态
//ios 推送 用到的 appId
private String appId;
/**
* 推送平台厂商
* 华为 huawei
* 小米 xiaomi
* 百度 baidu
* apns ios
*/
private String pushServer;
/**
* 推送平台的 token
*/
private String pushToken;
/**
* VOip 推送 token
*/
private String voipToken;
/**
* 同时使用多个推送平台的
*/
//private Map<String,String> pushMap;
/**
* 下线时间
*/
private long offlineTime;
public long getLoginTime() {
return loginTime;
}
public void setLoginTime(long loginTime) {
this.loginTime = loginTime;
}
public String getPushServer() {
return pushServer;
}
public void setPushServer(String pushServer) {
this.pushServer = pushServer;
}
public String getPushToken() {
return pushToken;
}
public void setPushToken(String pushToken) {
this.pushToken = pushToken;
}
public long getOfflineTime() {
return offlineTime;
}
public void setOfflineTime(long offlineTime) {
this.offlineTime = offlineTime;
}
@Override
public String toString() {
return JSON.toJSONString(this);
}
public String getDeviceKey() {
return deviceKey;
}
public void setDeviceKey(String deviceKey) {
this.deviceKey = deviceKey;
}
public int getOnline() {
return online;
}
public void setOnline(int online) {
this.online = online;
}
public String getVoipToken() {
return voipToken;
}
public void setVoipToken(String voipToken) {
this.voipToken = voipToken;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAdress() {
return adress;
}
public void setAdress(String adress) {
this.adress = adress;
}
}
@Entity(value="userLoginLog",noClassnameStored=true)
public static class UserLoginLog {
@Id
private Integer userId;
/**
*
* @Description: TODO(登陆日志信息)
* @author lidaye
* @date 2018年8月18日
*/
@Embedded
private LoginLog loginLog;
/**
* 登陆设备列表
* web DeviceInfo
* android DeviceInfo
* ios DeviceInfo
*/
private Map<String,DeviceInfo> deviceMap;
public UserLoginLog() {
super();
}
public static LoginLog init(UserExample example, boolean isFirst) {
LoginLog info = new LoginLog();
info.setIsFirstLogin(isFirst ? 1 : 0);
info.setLoginTime(DateUtil.currentTimeSeconds());
info.setApiVersion(example.getApiVersion());
info.setOsVersion(example.getOsVersion());
info.setModel(example.getModel());
info.setSerial(example.getSerial());
info.setLatitude(example.getLatitude());
info.setLongitude(example.getLongitude());
info.setLocation(example.getLocation());
info.setAddress(example.getAddress());
info.setOfflineTime(0);
return info;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Map<String,DeviceInfo> getDeviceMap() {
return deviceMap;
}
public void setDeviceMap(Map<String,DeviceInfo> deviceMap) {
this.deviceMap = deviceMap;
}
public LoginLog getLoginLog() {
return loginLog;
}
public void setLoginLog(LoginLog loginLog) {
this.loginLog = loginLog;
}
}
@Data
public static class UserSettings {
private int allowAtt=1;// 允许关注
private int allowGreet=1;// 允许打招呼
private int friendsVerify=1;// 加好友需验证
private int openService=-1;//是否开启客服模式
private int isVibration=1;// 是否振动 1:开启 0:关闭
private int isTyping=1;// 让对方知道我正在输入 1:开启 0:关闭
private int isUseGoogleMap=1;// 使用google地图 1:开启 0:关闭
private int isEncrypt=1;// 是否开启加密传输 1:开启 0:关闭
private int multipleDevices=1;// 是否开启多点登录 1:开启 0:关闭
/**
* 关闭手机号搜索用户
关闭次选项 不用使用手机号搜索用户
0 开启 1 关闭
默认开启
*/
private int closeTelephoneFind=0;
//聊天记录 销毁 时间 -1 0 永久 1 一天
private String chatRecordTimeOut="0";
private double chatSyncTimeLen=-1;// 聊天记录 最大 漫游时长 -1 永久 -2 不同步
private Integer isKeepalive = 1;// 是否安卓后台常驻保活app 0:取消保活 1:保活
private Integer showLastLoginTime = -1;// 显示上次上线时间 -1 所有人不显示 1所有人显示 2 所有好友显示 3 手机联系人显示
private Integer showTelephone = -1;// 显示我的手机号码 -1 所有人不显示 1所有人显示 2 所有好友显示 3 手机联系人显示
private Integer phoneSearch = 1;// 允许手机号搜索 1 允许 0 不允许
private Integer nameSearch = 1;// 允许昵称搜索 1 允许 0 不允许
private String friendFromList = "1,2,3,4,5";// 通过什么方式添加我 0:系统添加好友 1:二维码 2:名片 3:群组 4: 手机号搜索 5: 昵称搜索
/*sync*/
public UserSettings() {
super();
}
public UserSettings(int allowAtt, int allowGreet, int friendsVerify, int openService, int isVibration,
int isTyping, int isUseGoogleMap, int isEncrypt, int multipleDevices,
int closeTelephoneFind, String chatRecordTimeOut, double chatSyncTimeLen) {
super();
this.allowAtt = allowAtt;
this.allowGreet = allowGreet;
this.friendsVerify = friendsVerify;
this.openService = openService;
this.isVibration = isVibration;
this.isTyping = isTyping;
this.isUseGoogleMap = isUseGoogleMap;
this.isEncrypt = isEncrypt;
this.multipleDevices = multipleDevices;
this.closeTelephoneFind = closeTelephoneFind;
this.chatRecordTimeOut = chatRecordTimeOut;
this.chatSyncTimeLen = chatSyncTimeLen;
}
public UserSettings(int openService) {
super();
this.openService = openService;
}
public static DBObject getDefault() {
//Config config = SKBeanUtils.getAdminManager().getConfig();
DBObject dbObj = new BasicDBObject();
dbObj.put("allowAtt", 1);// 允许关注
dbObj.put("isVibration",1);// 是否开启振动
dbObj.put("isTyping",1);// 让对方知道正在输入
dbObj.put("isUseGoogleMap",0); // 使用Google地图
dbObj.put("allowGreet", 1);// 允许打招呼
dbObj.put("friendsVerify", 1);// 加好友需要验证
dbObj.put("openService", 0); // 是否开启客服模式
dbObj.put("closeTelephoneFind",2);// 手机号搜索用户
dbObj.put("chatRecordTimeOut",-1);// 聊天记录销毁时长
dbObj.put("chatSyncTimeLen", -2);// 漫游时长
dbObj.put("isEncrypt",1);// 加密传输
dbObj.put("multipleDevices", 0);// 支持多点登录
dbObj.put("isKeepalive",1);// 安卓保活
dbObj.put("phoneSearch", 1);// 是否允许手机号搜索
dbObj.put("nameSearch", 1);// 是否允许昵称号搜索
dbObj.put("showLastLoginTime", 1);// 显示上次上线时间 -1 所有人不显示 1所有人显示 2 所有好友显示 3 手机联系人显示
dbObj.put("showTelephone",-1);// 显示我的手机号码 -1 所有人不显示 1所有人显示 2 所有好友显示 3 手机联系人显示
dbObj.put("friendFromList", "1,2,3,4,5");// 通过什么方式添加我 0:系统添加好友 1:二维码 2:名片 3:群组 4: 手机号搜索 5: 昵称搜索
return dbObj;
}
}
public static class Count {
private int att;
private int fans;
private int friends;
public int getAtt() {
return att;
}
public int getFans() {
return fans;
}
public int getFriends() {
return friends;
}
public void setAtt(int att) {
this.att = att;
}
public void setFans(int fans) {
this.fans = fans;
}
public void setFriends(int friends) {
this.friends = friends;
}
}
/**
* 坐标
*
* @author luorc@www.youjob.co
*
*/
public static class Loc {
public Loc() {
super();
}
public Loc(double lng, double lat) {
super();
this.lng = lng;
this.lat = lat;
}
private double lng;// longitude 经度
private double lat;// latitude 纬度
public double getLng() {
return lng;
}
public void setLng(double lng) {
this.lng = lng;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
}
public static class ThridPartyAccount {
private long createTime;
private long modifyTime;
private int status;// 状态(0:解绑;1:绑定)
private String tpAccount;// 账号
private String tpName;// 帐号所属平台名字或代码
private String tpUserId;// 账号唯一标识
public long getCreateTime() {
return createTime;
}
public long getModifyTime() {
return modifyTime;
}
public int getStatus() {
return status;
}
public String getTpAccount() {
return tpAccount;
}
public String getTpName() {
return tpName;
}
public String getTpUserId() {
return tpUserId;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
public void setModifyTime(long modifyTime) {
this.modifyTime = modifyTime;
}
public void setStatus(int status) {
this.status = status;
}
public void setTpAccount(String tpAccount) {
this.tpAccount = tpAccount;
}
public void setTpName(String tpName) {
this.tpName = tpName;
}
public void setTpUserId(String tpUserId) {
this.tpUserId = tpUserId;
}
}
}
package com.xxfc.platform.im.model;
public class UserExample extends BaseExample {
private Long birthday;
private String description;
private String idcard;
private String idcardUrl;
private String name;
private String nickname;
private String password;
private Integer sex; //0:男 1:女
private String telephone;
/**
* 账号
*/
private String account;
private int userId=0;
private String areaCode="86";
private String randcode;
private String phone;
private Integer userType;
private String appId;//ios 当前包名
private int xmppVersion; //xmpp 心跳包的时候用到
private Integer d = 0;
private Integer w = 0;
private String email;
private String payPassWord; //支付密码
private int multipleDevices=-1; //多设备登陆
private byte isSmsRegister = 0; //是否使用短信验证码注册 0:不是 1:是
private String area;// 用户地理位置
private String myInviteCode; //我的邀请码
private String inviteCode; //注册时填写的邀请码
private String msgBackGroundUrl;// 朋友圈背景URL
private int isSdkLogin;// 第三方登录标识 0 不是 1 是
private int loginType;// 登录类型 0:账号密码登录,1:短信验证码登录
private String verificationCode;// 短信验证码
//当前登陆设备
private String deviceKey;
public Long getBirthday() {
return birthday;
}
public void setBirthday(Long birthday) {
this.birthday = birthday;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getIdcard() {
return idcard;
}
public void setIdcard(String idcard) {
this.idcard = idcard;
}
public String getIdcardUrl() {
return idcardUrl;
}
public void setIdcardUrl(String idcardUrl) {
this.idcardUrl = idcardUrl;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getSex() {
return sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public Integer getUserType() {
return userType;
}
public void setUserType(Integer userType) {
this.userType = userType;
}
public Integer getD() {
return d;
}
public void setD(Integer d) {
this.d = d;
}
public Integer getW() {
return w;
}
public void setW(Integer w) {
this.w = w;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getRandcode() {
return randcode;
}
public void setRandcode(String randcode) {
this.randcode = randcode;
}
public int getXmppVersion() {
return xmppVersion;
}
public void setXmppVersion(int xmppVersion) {
this.xmppVersion = xmppVersion;
}
public int getMultipleDevices() {
return multipleDevices;
}
public void setMultipleDevices(int multipleDevices) {
this.multipleDevices = multipleDevices;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getDeviceKey() {
return deviceKey;
}
public void setDeviceKey(String deviceKey) {
this.deviceKey = deviceKey;
}
public String getInviteCode() {
return inviteCode;
}
public void setInviteCode(String inviteCode) {
this.inviteCode = inviteCode;
}
public String getPayPassWord() {
return payPassWord;
}
public void setPayPassWord(String payPassWord) {
this.payPassWord = payPassWord;
}
public byte getIsSmsRegister() {
return isSmsRegister;
}
public void setIsSmsRegister(byte isSmsRegister) {
this.isSmsRegister = isSmsRegister;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getMyInviteCode() {
return myInviteCode;
}
public void setMyInviteCode(String myInviteCode) {
this.myInviteCode = myInviteCode;
}
public String getMsgBackGroundUrl() {
return msgBackGroundUrl;
}
public void setMsgBackGroundUrl(String msgBackGroundUrl) {
this.msgBackGroundUrl = msgBackGroundUrl;
}
public int getIsSdkLogin() {
return isSdkLogin;
}
public void setIsSdkLogin(int isSdkLogin) {
this.isSdkLogin = isSdkLogin;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public int getLoginType() {
return loginType;
}
public void setLoginType(int loginType) {
this.loginType = loginType;
}
public String getVerificationCode() {
return verificationCode;
}
public void setVerificationCode(String verificationCode) {
this.verificationCode = verificationCode;
}
}
package com.xxfc.platform.im.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.mapping.Language;
import java.util.List;
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix="im")
public class KApplicationProperties {
// ,locations="classpath:application-test.properties" //外网测试环境
// ,locations="classpath:application-local.properties" //本地测试环境
//// application
public KApplicationProperties() {
// TODO Auto-generated constructor stub
}
private MongoConfig mongoConfig;
private RedisConfig redisConfig;
private XMPPConfig xmppConfig;
private AppConfig appConfig;
private SmsConfig smsConfig;
private PushConfig pushConfig;
private WXConfig wxConfig;
private AliPayConfig aliPayConfig;
private MQConfig mqConfig;
@Setter
@Getter
public static class MongoConfig {
/**
* 数据库链接 127.0.0.1:27017,127.0.0.2:28018
*/
private String uri;
private String dbName;
private String roomDbName;
//配置是否使用集群模式 读写分离 0 单机 模式 1:集群模式
private int cluster = 0;
private String username;
private String password;
private int connectTimeout=20000;
private int socketTimeout=20000;
private int maxWaitTime=20000;
}
@Setter
@Getter
public static class XMPPConfig {
private String host;
private int port;
private String serverName;
private String username;
private String password;
/**
* 数据库链接 127.0.0.1:27017,127.0.0.2:28018
*/
private String dbUri;
private String dbName;
private String dbUsername;
private String dbPassword;
}
@Setter
@Getter
public static class RedisConfig {
private String address;
private int database = 0;
private String password;
private int connectionMinimumIdleSize=32;
private int connectionPoolSize=64;
private int connectTimeout=10000;
private int pingConnectionInterval=500;
private int pingTimeout=10000;
private int timeout=10000;
private String host;
private int port;
private short isCluster=0; //是否开启集群 0 关闭 1开启
}
@Getter
@Setter
public static class AppConfig {
private String uploadDomain = "http://upload.server.com";//上传服务器域名
private String apiKey;
private List<Language> languages; //语言
/**
* ip 数据库目录
*/
private String qqzengPath;
private int openTask = 1;//是否开启定时任务
private int distance = 20;
private byte isBeta=0;//是否测试版本 测试版本 附近的人和 所有房间不返回值
private byte isDebug=1;//是否开启调试 打印日志用到
private String wxChatUrl;// 微信公众号群聊网页路径
}
@Getter
@Setter
public static class PushConfig{
// 企业版 app 包名
protected String betaAppId;
//appStore 版本 App 包名
protected String appStoreAppId;
}
@Getter
@Setter
public static class SmsConfig {
private int openSMS = 1;// 是否发送短信验证码
// 天天国际短信服务
private String host;
private int port;
private String api;
private String username;// 短信平台用户名
private String password;// 短信平台密码
private String templateChineseSMS;// 中文短信模板
private String templateEnglishSMS;// 英文短信模板
// 阿里云短信服务
private String product;// 云通信短信API产品,无需替换
private String domain;// 产品域名,无需替换
private String accesskeyid;// AK key
private String accesskeysecret;// AK value
private String signname;// 短信签名
private String chinase_templetecode;// 中文短信模板标识
private String english_templetecode;// 英文短信模板标识
}
@Getter
@Setter
public static class WXConfig {
// 微信认证的自己应用ID
private String appid;
// 商户ID
private String mchid;
// App secret
private String secret;
// api API密钥
private String apiKey;
//
/**
* 微信支付 回调 通知 url
* 默认 http://imapi.server.com/user/recharge/wxPayCallBack
*
*/
private String callBackUrl;
//证书文件 名称
private String pkPath;
}
@Getter
@Setter
public static class AliPayConfig{
// 支付宝认证应用Id
private String appid;
// 应用私钥
private String app_private_key;
// 字符编码格式
private String charset;
// 支付宝公钥
private String alipay_public_key;
// 支付宝回调地址
private String callBackUrl;
}
/**
* rocketmq 的 配置
*
* @author lidaye
*
*/
@Getter
@Setter
public static class MQConfig {
protected String nameAddr="localhost:9876";
protected int threadMin=Runtime.getRuntime().availableProcessors();
protected int threadMax=Runtime.getRuntime().availableProcessors()*2;
protected int batchMaxSize=20;
private byte isConsumerUserStatus=1;
}
}
package com.xxfc.platform.im.rest;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.xxfc.platform.im.biz.UserBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("user")
public class UserController {
@Autowired
private UserBiz mtBiz;
/**
* 注册
* @param map
* @return
*/
@RequestMapping(value = "/app/unauth/register", method = RequestMethod.POST)
@ResponseBody
@IgnoreClientToken
public BaseResponse register(@RequestBody Map<String, Object> map) {
return mtBiz.register(map);
}
/**
* 登录
* @param map
* @return
*/
@RequestMapping(value = "/app/unauth/login", method = RequestMethod.POST)
@ResponseBody
@IgnoreClientToken
public BaseResponse login(@RequestBody Map<String, Object> map) {
BaseResponse baseResponse = new BaseResponse();
String result = mtBiz.login(map);
baseResponse.setStatus(200);
baseResponse.setMessage(result);
return baseResponse;
}
}
package com.xxfc.platform.im.utils;
public interface Callback {
void execute(Object obj);
}
\ No newline at end of file
package com.xxfc.platform.im.utils;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Pattern;
public final class DateUtil {
public static final SimpleDateFormat FORMAT_YYYY_MM;
public static final SimpleDateFormat FORMAT_YYYY_MM_DD;
public static final SimpleDateFormat FORMAT_YMDHMS;
public static final Pattern PATTERN_YYYY_MM;
public static final Pattern PATTERN_YYYY_MM_DD;
public static final Pattern PATTERN_YYYY_MM_DD_HH_MM_SS;
static {
FORMAT_YMDHMS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
FORMAT_YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");
FORMAT_YYYY_MM = new SimpleDateFormat("yyyy-MM");
PATTERN_YYYY_MM_DD_HH_MM_SS = Pattern.compile("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}");
PATTERN_YYYY_MM_DD = Pattern.compile("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}");
PATTERN_YYYY_MM = Pattern.compile("[0-9]{4}-[0-9]{1,2}");
}
/**
* 精确到秒
*/
public static long currentTimeSeconds() {
return System.currentTimeMillis() / 1000;
}
/**
* 精确到毫秒 Millisecond
**/
public static long currentTimeMilliSeconds() {
return System.currentTimeMillis();
}
public static String getFullString() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
}
public static String getYMDString() {
return new SimpleDateFormat("yyyyMMdd").format(new Date());
}
public static String getYMString() {
return new SimpleDateFormat("yyyyMM").format(new Date());
}
public static String getTimeString(long millis) {
return FORMAT_YMDHMS.format(new Date(millis));
}
public static Date toDate(String strDate) {
strDate = strDate.replaceAll("/", "-");
try {
if (PATTERN_YYYY_MM_DD_HH_MM_SS.matcher(strDate).find())
return FORMAT_YMDHMS.parse(strDate);
else if (PATTERN_YYYY_MM_DD.matcher(strDate).find())
return FORMAT_YYYY_MM_DD.parse(strDate);
else if (PATTERN_YYYY_MM.matcher(strDate).find())
return FORMAT_YYYY_MM.parse(strDate);
else
throw new RuntimeException("未知的日期格式化字符串");
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
public static long toTimestamp(String strDate) {
return toDate(strDate).getTime();
}
public static long toSeconds(String strDate) {
return toTimestamp(strDate) / 1000;
}
public static long s2s(String s) {
s = StringUtil.trim(s);
if ("至今".equals(s)) {
return 0;
}
return toSeconds(s);
}
/**
* 比较两个时间的年月日是否相同
* @param d1 时间1
* @param d2 时间2
* @return
*/
public static boolean compareDayTime(Calendar d1,Calendar d2){
int d1_year=d1.get(Calendar.YEAR);
int d1_month=d1.get(Calendar.MONTH);
int d1_day=d1.get(Calendar.DAY_OF_MONTH);
int d2_year=d2.get(Calendar.YEAR);
int d2_month=d2.get(Calendar.MONTH);
int d2_day=d2.get(Calendar.DAY_OF_MONTH);
if(d1_year==d2_year&&d1_month==d2_month&&d1_day==d2_day)return true;
return false;
}
/**
* 比较两个时间的年月是否相同
* @param d1 时间1
* @param d2 时间2
* @return
*/
public static boolean compareMonthTime(Calendar d1,Calendar d2){
int d1_year=d1.get(Calendar.YEAR);
int d1_month=d1.get(Calendar.MONTH);
int d2_year=d2.get(Calendar.YEAR);
int d2_month=d2.get(Calendar.MONTH);
if(d1_year==d2_year&&d1_month==d2_month)return true;
return false;
}
/**
* 获取上传路径的前缀
* @return
*/
/*public static String getUploadPathPrefix(){
ResourceBundle bundle = ResourceBundle.getBundle("application");
return bundle.getString("upload.path.prefix");
}*/
public static Date getNextDay(Date currentDay){
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDay);
calendar.add(Calendar.DATE, 1);
Date nextDay = calendar.getTime();
return nextDay;
}
/**
* 获得当天0点时间
* @return
*/
public static Date getTodayMorning() {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());//把当前时间赋给cal
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获得当天24点时间
* @return
*/
public static Date getTodayNight() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 24);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/** @Description:(获得第n后的当前时间)
* @param times 当前时间
* @param days 第n天
* @param type 0:后n天 , 1:前n天
* @return
**/
public static long getOnedayNextDay(long times,int days,int type){
final long ruleTimes = 86400;// 基数
return (0 == type ? times+(ruleTimes*days) : times-(ruleTimes*days));
}
/**
* 获得昨天0点时间
* @return
*/
public static Date getYesterdayMorning() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获得昨天23.59点时间
* @return
*/
public static Date getYesterdayLastTime() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.MILLISECOND,00);
return cal.getTime();
}
/**
* 获得昨天24点时间
* @return
*/
public static Date getYesterdayNight() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
cal.set(Calendar.HOUR_OF_DAY, 24);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获得明天0点时间
* @return
*/
public static Date getTomorrowMorning() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获得明天23.59点时间
* @return
*/
public static Date getTomorrowLastTime() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.MILLISECOND,00);
return cal.getTime();
}
/**
* 获得明天24点时间
* @return
*/
public static Date getTomorrowNight() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
cal.set(Calendar.HOUR_OF_DAY, 24);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获得本周一0点时间
* @return
*/
public static Date getWeekMorning() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
return cal.getTime();
}
/**
* 获得本周日24点时间
* @return
*/
public static Date getWeekNight() {
Calendar cal = Calendar.getInstance();
cal.setTime(getWeekMorning());
cal.add(Calendar.DAY_OF_WEEK, 7);
return cal.getTime();
}
/**
* 获得本月第一天0点时间
* @return
*/
public static Date getMonthMorning() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
return cal.getTime();
}
/**
* 获得本月最后一天24点时间
* @return
*/
public static Date getMonthNight() {
Calendar cal = Calendar.getInstance();
cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, 24);
return cal.getTime();
}
/**
* 获得上月第一天0点时间
* @return
*/
public static Date getLastMonthMorning(){
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());//把当前时间赋给cal
cal.add(Calendar.MONTH, -1);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY,00);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获取上周一0点
* @return
*/
public static Date getPreviousWeekday(){
Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.add(Calendar.DATE, -7);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获取当前时间的前一年的0点
*/
public static Date getLastYear(){
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.YEAR, -1);
cal.set(Calendar.HOUR_OF_DAY,00);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获取当前时间的下一年的0点
*/
public static Date getNextYear(){
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.YEAR, +1);
return cal.getTime();
}
/**
* 获得当前时间一个月前的时间
* @return
*/
public static Date getLastMonth(){
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());//把当前时间赋给cal
cal.add(Calendar.MONTH, -1);
cal.set(Calendar.HOUR_OF_DAY,00);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
/**
* 获得当前时间的三个月前的时间
* @return
*/
public static Date getLast3Month(){
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());//把当前时间赋给cal
cal.add(Calendar.MONTH, -3); //设置为前3月
return cal.getTime();
}
/**
* 获取上周日23点59分
* @return
*/
public static Date getPreviousWeekSunday(){
Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.add(Calendar.DATE, -7);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.MILLISECOND,00);
return cal.getTime();
}
/**
* 时间戳转年月日
* @author dingyongli
* @param long strDateTime:日期时间的字符串形式
* @return timestamp
* @throws
*/
public static String strToDateTime(long strDateTime){
String timestamp;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(strDateTime*1000);
timestamp = simpleDateFormat.format(date);
return ("1970-01-01 08:00:00".equals(timestamp)?null:timestamp);
}
public static String TimeToStr(Date date){//可以用
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return format.format(date);
}
public static Date strYYMMDDToDate(String strYYMMDD) {
SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd");
try {
return format.parse(strYYMMDD);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 将字符串装换为Date类型
* @param time 字符串时间
* @param pattern 匹配格式
* @return 返回Date格式时间
* @throws ParseException 转换异常
*/
public static Date getDate(String time,String pattern) throws ParseException{
SimpleDateFormat sdf=new SimpleDateFormat(pattern);
if(!StringUtils.isEmpty(time))
return sdf.parse(time);
return null;
}
/**
* 将Date类型装换为字符串
* @param date 时间
* @param pattern 匹配格式
* @return 返回字符串格式时间
*/
public static String getDateStr(Date date,String pattern){
SimpleDateFormat sdf=new SimpleDateFormat(pattern);
return sdf.format(date);
}
// public static String getDiff(long start, long end) {
// long diff = end - start;
// long day = diff / 86400;
// long hour = diff % 86400 / 3600;
// long minute = (diff % 86400 % 3600) / 60;
// return MessageFormat.format("{0}天{1}时{2}分", diff / 86400, diff % 86400 /
// 3600, (diff % 86400 % 3600) / 60);
// }
//
// public static void main(String... args) {
// long a = System.currentTimeMillis() + 86400 * 7;
// System.out.println(a + 121);
// System.out.println(getDiff(System.currentTimeMillis(), a + 79504));
// System.out.println(getDiff(System.currentTimeMillis(), a + 121));
// System.out.println(getDiff(System.currentTimeMillis(),
// System.currentTimeMillis() + 121));
//
// long b = 1420788389937L;
// System.out.println(b % 86400);
// System.out.println(b % 86400 % 3600);
// System.out.println((b % 86400) % 3600);
// }
}
package com.xxfc.platform.im.utils;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class StringUtil {
public static String trim(String s) {
StringBuilder sb = new StringBuilder();
for (char ch : s.toCharArray())
if (' ' != ch)
sb.append(ch);
s = sb.toString();
return s.replaceAll("&nbsp;", "").replaceAll(" ", "").replaceAll(" ", "").replaceAll("\t", "").replaceAll("\n", "");
}
private static final char[] charArray = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
public static String getExt(String filename) {
return filename.substring(filename.lastIndexOf('.'));
}
/**
* 是否是数字
* @param str
* @return
*/
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(str);
if( !isNum.matches() ){
return false;
}
return true;
}
public static boolean isEmpty(String s) {
return isNullOrEmpty(s);
}
public static boolean isNullOrEmpty(String s) {
return null == s || 0 == s.trim().length();
}
public static String randomCode() {
return "" + (new Random().nextInt(899999) + 100000);
}
public static String randomPassword() {
return randomString(6);
}
public static String getOutTradeNo() {
int r1 = (int) (Math.random() * (10));// 产生2个0-9的随机数
int r2 = (int) (Math.random() * (10));
long now = System.currentTimeMillis();// 一个13位的时间戳
String id = String.valueOf(r1) + String.valueOf(r2)
+ String.valueOf(now);// 订单ID
return id;
}
public static String randomString(int length) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int index = new Random().nextInt(36);
sb.append(charArray[index]);
}
return sb.toString();
}
public static String randomUUID() {
UUID uuid = UUID.randomUUID();
String uuidStr = uuid.toString().replace("-", "");
return uuidStr;
}
public static String getFormatName(String fileName) {
int index = fileName.lastIndexOf('.');
return -1 == index ? "jpg" : fileName.substring(index + 1);
}
public static String getFormatName(MultipartFile file) {
return getFormatName(file.getName());
}
public static String randomFileName(MultipartFile file) {
return randomUUID() + "." + getFormatName(file.getName());
}
/**默认的文本分隔符 */
public static final String Default_Split= "#";
public static String[] getStringList(String str) {
str = trim(str);
if (str.endsWith(",")) {
str = str.substring(0, str.length() - 1);
}
String sep = ",";
if (str.indexOf(':') >= 0) {
sep = ":";
}
return str.split(sep);
}
public static String[] getStringList(String str, String sep) {
str = trim(str);
return str.split(sep);
}
public static int[] getIntArray(String str, String sep) {
String[] prop = getStringList(str, sep);
List<Integer> tmp = new ArrayList<Integer>();
for (int i = 0; i < prop.length; i++) {
try {
int r = Integer.parseInt(prop[i]);
tmp.add(r);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
int[] ints = new int[tmp.size()];
for (int i = 0; i < tmp.size(); i++) {
ints[i] = tmp.get(i);
}
return ints;
}
public static List<Integer> getIntList(String str, String sep) {
List<Integer> tmp = new ArrayList<Integer>();
if (str == null || str.trim().equals("")) {
return tmp;
}
String[] prop = getStringList(str, sep);
for (int i = 0; i < prop.length; i++) {
try {
int r = Integer.parseInt(prop[i]);
tmp.add(r);
} catch (Exception e) {
e.printStackTrace();
}
}
return tmp;
}
public static String join(String[] strs, String sep) {
StringBuffer buffer = new StringBuffer();
buffer.append(strs[0]);
for (int i = 1; i < strs.length; i++) {
buffer.append(sep).append(strs[i]);
}
return buffer.toString();
}
public static String join(List<Integer> ints, String sep) {
StringBuffer sb = new StringBuffer();
sb.append(ints.get(0));
for (int i = 1; i < ints.size(); i++) {
sb.append(sep).append(ints.get(i));
}
return sb.toString();
}
public static String getStringByList(List<String> ints, String sep) {
StringBuffer sb = new StringBuffer();
sb.append(ints.get(0));
for (int i = 1; i < ints.size(); i++) {
sb.append(sep).append(ints.get(i));
}
return sb.toString();
}
public static double[] getDoubleList(String str) {
String[] prop = getStringList(str);
double[] ds = new double[prop.length];
for (int i = 0; i < ds.length; i++) {
ds[i] = Double.parseDouble(prop[i]);
}
return ds;
}
public static List<String> getListBySplit(String str, String split) {
List<String> list = new ArrayList<String>();
//|| str.trim().equalsIgnoreCase("")
if (str == null )
return list;
String[] strs = str.split(split);
for (String temp : strs) {
//&& !temp.trim().equalsIgnoreCase("")
if (temp != null ) {
list.add(temp);
}
}
return list;
}
public static int[] getIntList(String str) {
String[] prop = getStringList(str);
List<Integer> tmp = new ArrayList<Integer>();
for (int i = 0; i < prop.length; i++) {
try {
String sInt = prop[i].trim();
if (sInt.length() < 20) {
int r = Integer.parseInt(prop[i].trim());
tmp.add(r);
}
} catch (Exception e) {
}
}
int[] ints = new int[tmp.size()];
for (int i = 0; i < tmp.size(); i++) {
ints[i] = tmp.get(i);
}
return ints;
}
public static String toWrapString(Object obj, String content) {
if (obj == null) {
return "null";
} else {
return obj.getClass().getName() + "@" + obj.hashCode() + "[\r\n"
+ content + "\r\n]";
}
}
// 将1,2,3和{1,2,3}格式的字符串转化为JDK的bitset
// 考虑了两边是否有{},数字两边是否有空格,是否合法数字
public static BitSet bitSetFromString(String str) {
if (str == null) {
return new BitSet();
}
if (str.startsWith("{")) {
str = str.substring(1);
}
if (str.endsWith("}")) {
str = str.substring(0, str.length() - 1);
}
int[] ints = getIntList(str);
BitSet bs = new BitSet();
for (int i : ints) {
bs.set(i);
}
return bs;
}
public static boolean hasExcludeChar(String str) {
if (str != null) {
char[] chs = str.toCharArray();
for (int i = 0; i < chs.length; i++) {
if (Character.getType(chs[i]) == Character.PRIVATE_USE) {
return true;
}
}
}
return false;
}
public static String replaceSql(String str) {
if (str != null) {
return str.replaceAll("'", "’").replaceAll("<", "&lt;").replaceAll(
">", "&gt;").replaceAll("\"", "&quot;");
}
return "";
}
/**
* 判断两个字符串是否相等
*
* @param s1
* @param s2
* @return true,字符串相等;false,字符串不相等
*/
public static boolean isEquals(String s1, String s2) {
if (s1 != null) {
return s1.equals(s2);
}
if (s2 != null) {
return false;
}
// 两个字符串都是null
return true;
}
/**
* 判断字符串是否时数字
*
* @param text
* @return
*/
public static boolean isDigit(String text) {
String reg = "[-]*[\\d]+[\\.\\d+]*";
Pattern pat = Pattern.compile(reg);
Matcher mat = pat.matcher(text);
return mat.matches();
}
/**
* 判断一句话是否是汉语
*
* @param text
* @return
*/
public static boolean isChiness(String text) {
String reg = "[\\w]*[\\u4e00-\\u9fa5]+[\\w]*";
Pattern pat = Pattern.compile(reg);
Matcher mat = pat.matcher(text);
boolean result = mat.matches();
return result;
}
/**
* 判断单个字符是否是汉语
*
* @param cha
* @return
*/
public static boolean isChineseChar(char cha) {
String reg = "[\\u4e00-\\u9fa5]";
Pattern pat = Pattern.compile(reg);
String text = Character.toString(cha);
Matcher mat = pat.matcher(text);
boolean result = mat.matches();
return result;
}
/**
* 判断字符是否是字母(包括大小写)或者数字
*
* @param cha
* @return
*/
public static boolean isLetterAndDigit(String cha) {
String reg = "[\\w]+";
Pattern pat = Pattern.compile(reg);
Matcher mat = pat.matcher(cha);
boolean result = mat.matches();
return result;
}
/**
* 返回字符串中汉字的数量
*
* @param test
* @return
*/
public static int getChineseCount(String test) {
int count = 0;
boolean tempResult = false;
for (int i = 0; i < test.length(); i++) {
char cha = test.charAt(i);
tempResult = isChineseChar(cha);
if (tempResult) {
count++;
}
}
return count;
}
/**
* 返回字符串中字母和数字的个数,其中字母包括大小写
*
* @param text
* @return
*/
public static int getLetterAndDigitCount(String text) {
int count = 0;
boolean tempResult = false;
for (int i = 0; i < text.length(); i++) {
tempResult = isLetterAndDigit(text);
if (tempResult) {
count++;
}
}
return count;
}
/**
* 将字符串首字母大写
*
* @param s
* @return
*/
public static String upperCaseFirstCharOnly(String s) {
if (s == null || s.length() < 1) {
return s;
}
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
}
/**
* 数组转化为String
* @param s
* @param sep
* @return
*/
public static String arrayToString(String[] s, char sep) {
if (s == null || s.length == 0){
return "";
}
StringBuffer buf = new StringBuffer();
if (s != null) {
for (int i = 0; i < s.length; i++) {
if (i > 0)
buf.append(sep);
buf.append(s[i]);
}
}
return buf.toString();
}
/**
* 获取拼起来的key
* @param splitString
* @param strings
* @return
*/
public static String getString(String splitString, String... strings){
StringBuffer stringBuffer = new StringBuffer();
for(int i = 0; i < strings.length; i++){
stringBuffer.append(strings[i]);
if(i == strings.length - 1){
break;
}
stringBuffer.append(splitString);
}
return stringBuffer.toString();
}
/**
* 获取拼起来的key
* @param splitString
* @param strings
* @return
*/
public static String getString(String splitString, int start, Serializable... strings){
StringBuffer stringBuffer = new StringBuffer();
for(int i = start; i < strings.length; i++){
stringBuffer.append(strings[i]);
if(i == strings.length - 1){
break;
}
stringBuffer.append(splitString);
}
return stringBuffer.toString();
}
//首字母转小写
public static String toLowerCaseFirstOne(String s){
if(Character.isLowerCase(s.charAt(0)))
return s;
else
return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
}
}
package com.xxfc.platform.im.utils;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class ThreadUtil {
public static final ScheduledExecutorService mThreadPool = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors()*2);
/**
* @Description: TODO(立即执行 线程)
* @param @param callback 参数
*/
public static void executeInThread(Callback callback){
mThreadPool.execute(new Runnable() {
@Override
public void run() {
callback.execute(Thread.currentThread().getName());
}
});
}
public static void executeInThread(Callback callback,Object obj){
mThreadPool.execute(new Runnable() {
@Override
public void run() {
callback.execute(obj);
}
});
}
/**
* @Description: TODO(延时执行线程)
* @param @param callback 延时 秒钟
*/
public static void executeInThread(Callback callback,long delay){
mThreadPool.schedule(new Runnable() {
@Override
public void run() {
callback.execute(Thread.currentThread().getName());
}
}, delay, TimeUnit.SECONDS);
}
}
package com.xxfc.platform.im.utils;
public class ValueUtil {
public static Integer parse(Integer value) {
return null == value ? 0 : value;
}
public static Long parse(Long value) {
return null == value ? 0 : value;
}
public static String parse(String value) {
return null == value || "".equals(value.trim()) ? "" : value;
}
}
#spring:
# application:
# name: vehicle
# cloud:
# nacos:
# config:
# server-addr: 127.0.0.1:8848
# file-extension: yaml
# profiles:
# active: dev
spring:
profiles:
active: dev
application:
name: xx-im
cloud:
nacos:
config:
file-extension: yaml
---
spring:
profiles: dev
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
---
spring:
profiles: pro
cloud:
nacos:
config:
server-addr: 10.5.52.2:8848
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--<properties resource="dev.properties"/>-->
<context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<property name="mergeable" value="false"></property>
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/vehicle?useUnicode=true&amp;characterEncoding=UTF8"
userId="root"
password="xx2019fc">
</jdbcConnection>
<javaModelGenerator targetPackage="${targetModelPackage}" targetProject="${targetJavaProject}"/>
<sqlMapGenerator targetPackage="${targetXMLPackage}" targetProject="${targetResourcesProject}"/>
<javaClientGenerator targetPackage="${targetMapperPackage}" targetProject="${targetJavaProject}"
type="XMLMAPPER"/>
<!-- <table tableName="vehicle" domainObjectName="Vehicle">-->
<!-- </table>-->
<!-- <table tableName="vehicle_book_info" domainObjectName="VehicleBookInfo">-->
<!-- </table>-->
<!-- <table tableName="vehicle_book_record" domainObjectName="VehicleBookRecord">-->
<!-- </table>-->
<!-- <table tableName="branch_company" domainObjectName="BranchCompany">-->
<!-- </table>-->
<!-- <table tableName="branch_company_stock_info" domainObjectName="BranchCompanyStockInfo"></table>-->
<!-- <table tableName="branch_company_stock_apply_info" domainObjectName="BranchCompanyStockApplyInfo"></table>-->
<table tableName="vehicle_upkeep_item" domainObjectName="VehicleUpkeepItem"></table>
<table tableName="vehicle_upkeep_log" domainObjectName="VehicleUpkeepLog"></table>
</context>
</generatorConfiguration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment