Authored by csgyoho

synyohonow

package com.yoho.datasync.fullsync.dal.repository.yhcms;
import com.yoho.datasync.fullsync.dal.repository.yhcms.model.TblAttentionUser;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* Created by shengguo.cai on 2019/3/19.
*/
public interface ITblAttentionUserRepository extends JpaRepository<TblAttentionUser, Integer> {
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhcms;
import com.yoho.datasync.fullsync.dal.repository.yhcms.model.TblCommentInfo;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* Created by shengguo.cai on 2019/3/19.
*/
public interface ITblCommentInfoRepository extends JpaRepository<TblCommentInfo, Integer> {
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhcms.model;
import com.yoho.datasync.fullsync.dal.repository.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
* Created by shengguo.cai on 2019/3/19.
*/
@Data
@Entity
@Table(name = "tbl_attention_user")
public class TblAttentionUser extends BaseEntity implements Serializable {
private Integer uid;
@Column(name = "uid_attention")
private Integer uidAttention;
@Column(name = "create_time")
private Integer createTime;
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhcms.model;
import com.yoho.datasync.fullsync.dal.repository.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
* Created by shengguo.cai on 2019/3/19.
*/
@Data
@Entity
@Table(name = "tbl_comment_info")
public class TblCommentInfo extends BaseEntity implements Serializable {
private Integer id;
@Column(name = "forum_code")
private Integer forumCode;
@Column(name = "content_id")
private Integer contentId;
@Column(name = "to_comment_id")
private Integer toCommentId;
@Column(name = "parent_comment_id")
private Integer parentCommentId;
@Column(name = "floor_num")
private Integer floorNum;
private Integer uid;
@Column(name = "comment_text")
private String commentText;
@Column(name = "comment_image")
private String commentImage;
@Column(name = "check_status")
private Integer checkStatus;
@Column(name = "to_uid")
private Integer toUid;
private Integer status;
@Column(name = "create_time")
private Integer createTime;
@Column(name = "real_praise_num")
private Integer realPraiseNum;
@Column(name = "fake_praise_num")
private Integer fakePraiseNum;
@Column(name = "notice_uids")
private String noticeUids;
@Column(name = "author_uid")
private Integer authorUid;
@Column(name = "identify_info")
private String identifyInfo;
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhsocial;
/**
* Created by shengguo.cai on 2019/3/20.
*/
public interface ICommunityUserRepository {
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhsocial;
import com.yoho.datasync.fullsync.dal.repository.yhsocial.model.PostsPraise;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* Created by shengguo.cai on 2019/3/19.
*/
public interface IPostsPraiseRepository extends JpaRepository<PostsPraise, Integer> {
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhsocial.model;
import com.yoho.datasync.fullsync.dal.repository.BaseEntity;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
* Created by shengguo.cai on 2019/3/19.
*/
@Data
@Entity
@Table(name = "community_user")
public class CommunityUser extends BaseEntity implements Serializable {
private Integer uid;
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhsocial.model;
import com.yoho.datasync.fullsync.dal.repository.BaseEntity;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
* Created by shengguo.cai on 2019/3/20.
*/
@Data
@Entity
@Table(name = "posts")
public class Posts extends BaseEntity implements Serializable {
private Integer id;
private Integer authorId;
private Integer isOnlyImage;
private Integer status;
private Integer isHot;
private Integer isIndexTop;
private Integer isForumTop;
private Long createTime;
private Long revieweTime;
private Integer revieweState;
private String revieweUserName;
private Long updateTime;
private Long indexTopTime;
private Integer shareCommentId;
private Integer shareProductId;
private Integer appType;
private Integer postType;
private Integer voteType;
private Long voteDeadline;
private Integer userPraiseNum;
private Integer virtualPraiseNum;
private Integer commentsNum;//废弃
private Integer commentNum;
private Integer sendTime;
private String activityType;//活动帖类型,如果不是活动帖,则为null
private String topic;//活动贴的话题
private String defaultReply;//活动帖的官方默认回复
private Integer needCoins;//活动帖的参加活动需要消耗的有货币
private Integer joinNumLimit;//活动帖的最大参加次数,如果没有限制,则为null
private String activityBanner;//活动banner
private Long activityStartTime;//活动开始时间
private Long activityEndTime;//活动结束时间
private String noticeUids;
private String yohoProductSkns;
}
... ...
package com.yoho.datasync.fullsync.dal.repository.yhsocial.model;
import com.yoho.datasync.fullsync.dal.repository.BaseEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
* Created by shengguo.cai on 2019/3/19.
*/
@Data
@Entity
@Table(name = "posts_praise")
public class PostsPraise extends BaseEntity implements Serializable {
@Column(name = "posts_id")
private Integer postsId;
private Integer uid;
@Column(name = "create_time")
private Long createTime;
@Column(name = "author_id")
private Integer authorId;
@Column(name = "forum_code")
private Integer forumCode;
@Column(name = "is_virtual")
private Integer isVirtual = 0;
}
... ...
package com.yoho.datasync.fullsync.controller;
import com.yoho.datasync.fullsync.dal.repository.yhcms.ITblAttentionUserRepository;
import com.yoho.datasync.fullsync.dal.repository.yhcms.model.TblAttentionUser;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* Created by shengguo.cai on 2019/3/19.
*/
@RestController
public class YohoNowDataSynController {
@Resource
private ITblAttentionUserRepository tblAttentionUserRepository;
@RequestMapping("/test")
public TblAttentionUser test(){
TblAttentionUser user = tblAttentionUserRepository.getOne(99);
TblAttentionUser t = new TblAttentionUser();
BeanUtils.copyProperties(user,t);
return t;
}
}
... ...
... ... @@ -33,6 +33,24 @@ public class DataSourceConfig {
@Value("${spring.datasource.secondary.password}")
private String password2;
@Value("${spring.datasource.yhCms.url}")
private String yhCmsUrl;
@Value("${spring.datasource.yhCms.username}")
private String yhCmsUsername;
@Value("${spring.datasource.yhCms.password}")
private String yhCmsPassword;
@Value("${spring.datasource.yhSocial.url}")
private String yhSocialUrl;
@Value("${spring.datasource.yhSocial.username}")
private String yhSocialUsername;
@Value("${spring.datasource.yhSocial.password}")
private String yhSocialPassword;
public static final String text = "1qaz2wsx3edc4rfv";
@Bean(name = "primaryDataSource")
... ... @@ -48,6 +66,16 @@ public class DataSourceConfig {
return getDataSource(url2, username2, password2);
}
@Bean(name = "yhCmsDataSource")
public DataSource yhCmsDataSource() throws Exception {
return getDataSource(yhCmsUrl, yhCmsUsername, yhCmsPassword);
}
@Bean(name = "yhSocialDataSource")
public DataSource yhSocialDataSource() throws Exception {
return getDataSource(yhSocialUrl, yhSocialUsername, yhSocialPassword);
}
private DataSource getDataSource(String url, String userName, String passWord) throws Exception {
/*
// * 连接池配置
... ...
package com.yoho.datasync.fullsync.starter.config;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Properties;
/**
* Created by shengguo.cai on 2019/3/19.
*/
@Configuration
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactoryYhCms",
basePackages = "com.yoho.datasync.fullsync.dal.repository.yhcms")
public class YhCmsDataSourceConfig {
@Resource(name="yhCmsDataSource")
private DataSource dataSource;
@Resource
private Properties jpaProperties;
@Bean(name = "entityManagerYhCms")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) throws Exception {
return entityManagerFactorySecondary(builder).getObject().createEntityManager();
}
@Bean(name = "entityManagerFactoryYhCms")
public LocalContainerEntityManagerFactoryBean entityManagerFactorySecondary (EntityManagerFactoryBuilder builder) throws Exception {
LocalContainerEntityManagerFactoryBean entityManagerFactory
= builder
.dataSource(dataSource)
.packages("com.yoho.datasync.fullsync.dal.repository.yhcms.model")//设置实体类所在位置
.persistenceUnit("primaryPersistenceUnit")//持久化单元创建一个默认即可,多个便要分别命名
.build();
entityManagerFactory.setJpaProperties(jpaProperties);
return entityManagerFactory;
}
}
... ...
package com.yoho.datasync.fullsync.starter.config;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Properties;
/**
* Created by shengguo.cai on 2019/3/19.
*/
@Configuration
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactoryYhSocial",
basePackages = "com.yoho.datasync.fullsync.dal.repository.yhsocial")
public class YhSocialDataSourceConfig {
@Resource(name="yhSocialDataSource")
private DataSource dataSource;
@Resource
private Properties jpaProperties;
@Bean(name = "entityManagerYhSocial")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) throws Exception {
return entityManagerFactorySecondary(builder).getObject().createEntityManager();
}
@Bean(name = "entityManagerFactoryYhSocial")
public LocalContainerEntityManagerFactoryBean entityManagerFactorySecondary (EntityManagerFactoryBuilder builder) throws Exception {
LocalContainerEntityManagerFactoryBean entityManagerFactory
= builder
.dataSource(dataSource)
.packages("com.yoho.datasync.fullsync.dal.repository.yhsocial.model")//设置实体类所在位置
.persistenceUnit("primaryPersistenceUnit")//持久化单元创建一个默认即可,多个便要分别命名
.build();
entityManagerFactory.setJpaProperties(jpaProperties);
return entityManagerFactory;
}
}
... ...
... ... @@ -19,3 +19,15 @@ spring:
username: yh_test
password: 9nm0icOwt6bMHjMusIfMLw==
driver-class-name: com.mysql.jdbc.Driver
yhSocial:
url: jdbc:mysql://192.168.102.219:3306/yh_social?useUnicode=true&amp;characterEncoding=UTF-8
username: yh_test
password: 9nm0icOwt6bMHjMusIfMLw==
driver-class-name: com.mysql.jdbc.Driver
yhCms:
url: jdbc:mysql://192.168.102.17:3306/yh_cms?useUnicode=true&amp;characterEncoding=UTF-8
username: root
password: Z5BMngayHLUxyWLSv6+koA==
driver-class-name: com.mysql.jdbc.Driver
\ No newline at end of file
... ...
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
\ No newline at end of file
... ...
... ... @@ -19,3 +19,15 @@ spring:
username: yh_test
password: 9nm0icOwt6bMHjMusIfMLw==
driver-class-name: com.mysql.jdbc.Driver
yhSocial:
url: jdbc:mysql://192.168.102.219:3306/yh_social?useUnicode=true&amp;characterEncoding=UTF-8
username: yh_test
password: 9nm0icOwt6bMHjMusIfMLw==
driver-class-name: com.mysql.jdbc.Driver
yhCms:
url: jdbc:mysql://192.168.102.17:3306/yh_cms?useUnicode=true&amp;characterEncoding=UTF-8
username: root
password: Z5BMngayHLUxyWLSv6+koA==
driver-class-name: com.mysql.jdbc.Driver
\ No newline at end of file
... ...