jpa相关的配置更改和字段默认值设置

master
土豆兄弟 4 years ago
parent e4b738e2b8
commit 423ba08061

@ -1,3 +1,14 @@
USE ; CREATE TABLE ab_message (
id bigint(20) NOT NULL AUTO_INCREMENT,
DROP TABLE IF EXISTS ``; gmt_create datetime DEFAULT NULL,
gmt_modified datetime DEFAULT NULL,
rec_id bigint(20) DEFAULT NULL COMMENT '记录id',
pnum varchar(255) DEFAULT NULL COMMENT 'pnum',
act_name varchar(255) DEFAULT NULL COMMENT '业务名',
start_time datetime DEFAULT NULL COMMENT '业务开始时间',
client_type tinyint(1) DEFAULT NULL COMMENT '业务类别(1:A,2:B,3:C,4:D,5:E,6:F)',
app_id varchar(255) DEFAULT NULL COMMENT '上游推送用户id',
push_time datetime DEFAULT NULL COMMENT '上游推送时间',
send_status tinyint(1) DEFAULT 0 COMMENT '下游推送状态',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

@ -2,10 +2,12 @@ package com.yuyou.openapi.openapi;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication @SpringBootApplication
@EnableAsync @EnableAsync
@EnableJpaAuditing
public class OpenapiApplication { public class OpenapiApplication {
public static void main(String[] args) { public static void main(String[] args) {

@ -82,6 +82,12 @@ public class ABMessageConverter {
BeanUtils.copyProperties(abMessageDTO, abMessageDO); BeanUtils.copyProperties(abMessageDTO, abMessageDO);
abMessageDO.setPushTime(DateUtil.date(abMessageDTO.getTimestamp() * 1000)); abMessageDO.setPushTime(DateUtil.date(abMessageDTO.getTimestamp() * 1000));
abMessageDO.setStartTime(DateUtil.date(abMessageDTO.getStartTime() * 1000)); abMessageDO.setStartTime(DateUtil.date(abMessageDTO.getStartTime() * 1000));
try{
abMessageDO.setRecId(Long.valueOf(abMessageDTO.getRecId()));
}catch (Exception e){
log.error("String convert Long type Error.");
}
// AES加密 // AES加密
try { try {
SecurityService.encrypt(abMessageDTO.getMobile(), SecurityConstants.PHONE); SecurityService.encrypt(abMessageDTO.getMobile(), SecurityConstants.PHONE);

@ -1,10 +1,11 @@
package com.yuyou.openapi.openapi.model.dataobject; package com.yuyou.openapi.openapi.model.dataobject;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column; import javax.persistence.*;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date; import java.util.Date;
/** /**
@ -14,15 +15,20 @@ import java.util.Date;
*/ */
@Data @Data
@Table(name = "ab_message") @Table(name = "ab_message")
@Entity
@EntityListeners(AuditingEntityListener.class)
public class ABMessageDO { public class ABMessageDO {
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id; private Long id;
@Column(name = "gmt_create") @Column(name = "gmt_create")
@CreatedDate
private Date gmtCreate; private Date gmtCreate;
@Column(name = "gmt_modified") @Column(name = "gmt_modified")
@LastModifiedDate
private Date gmtModified; private Date gmtModified;
/** /**
@ -67,6 +73,9 @@ public class ABMessageDO {
@Column(name = "push_time") @Column(name = "push_time")
private Date pushTime; private Date pushTime;
/**
* 0 0 - 1 -
*/
@Column(name = "send_status") @Column(name = "send_status")
private Integer sendStatus; private Integer sendStatus = 0;
} }

@ -1,11 +1,11 @@
package com.yuyou.openapi.openapi.model.dataobject; package com.yuyou.openapi.openapi.model.dataobject;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column; import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date; import java.util.Date;
/** /**
@ -16,21 +16,25 @@ import java.util.Date;
@Data @Data
@Entity @Entity
@Table(name = "app_user") @Table(name = "app_user")
@EntityListeners(AuditingEntityListener.class)
public class AppUserDO { public class AppUserDO {
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id; private Long id;
/** /**
* *
*/ */
@Column(name = "gmt_create") @Column(name = "gmt_create")
@CreatedDate
private Date gmtCreate; private Date gmtCreate;
/** /**
* *
*/ */
@Column(name = "gmt_modified") @Column(name = "gmt_modified")
@LastModifiedDate
private Date gmtModified; private Date gmtModified;
/** /**

@ -1,10 +1,11 @@
package com.yuyou.openapi.openapi.model.dataobject; package com.yuyou.openapi.openapi.model.dataobject;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column; import javax.persistence.*;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date; import java.util.Date;
/** /**
@ -14,18 +15,23 @@ import java.util.Date;
*/ */
@Data @Data
@Table(name = "zhangmen_message") @Table(name = "zhangmen_message")
@Entity
@EntityListeners(AuditingEntityListener.class)
public class ZhangmenMessageDO { public class ZhangmenMessageDO {
/** /**
* id * id
*/ */
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id; private Long id;
@Column(name = "gmt_create") @Column(name = "gmt_create")
@CreatedDate
private Date gmtCreate; private Date gmtCreate;
@Column(name = "gmt_modified") @Column(name = "gmt_modified")
@LastModifiedDate
private Date gmtModified; private Date gmtModified;
/** /**

@ -12,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**

@ -4,7 +4,9 @@ spring:
# 序列化忽略null的k-v配置 # 序列化忽略null的k-v配置
jackson: jackson:
default-property-inclusion: non_null default-property-inclusion: non_null
# JPA数据层相关配置
jpa:
show-sql: true
--- ---
# 端口 # 端口
server: server:

Loading…
Cancel
Save