-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
191 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/com/featureprobe/api/base/enums/OperationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.featureprobe.api.base.enums; | ||
|
||
public enum OperationType { | ||
LOGIN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/featureprobe/api/entity/OperationLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.featureprobe.api.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.hibernate.annotations.DynamicInsert; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
import java.util.Date; | ||
|
||
@EqualsAndHashCode | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Data | ||
@Entity | ||
@Table(name = "operation_logs") | ||
@DynamicInsert | ||
@ToString(callSuper = true) | ||
public class OperationLog { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(name = "res_param") | ||
private String response; | ||
|
||
@Column(name = "req_param") | ||
private String request; | ||
|
||
private String type; | ||
|
||
private String account; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
@Column(name = "created_time") | ||
private Date createdTime; | ||
|
||
public OperationLog(String type, String account) { | ||
this.type = type; | ||
this.account = account; | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/featureprobe/api/repository/OperationLogRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.featureprobe.api.repository; | ||
|
||
import com.featureprobe.api.entity.OperationLog; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface OperationLogRepository extends JpaRepository<OperationLog, Long>, | ||
JpaSpecificationExecutor<OperationLog> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/featureprobe/api/service/OperationLogService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.featureprobe.api.service; | ||
|
||
import com.featureprobe.api.entity.OperationLog; | ||
import com.featureprobe.api.repository.OperationLogRepository; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@Service | ||
@AllArgsConstructor | ||
public class OperationLogService { | ||
|
||
private OperationLogRepository operationLogRepository; | ||
|
||
public void save(OperationLog log) { | ||
operationLogRepository.save(log); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/resources/db/migration/V29__add_member_source_fields.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
alter table member add source VARCHAR(256) default '' not null after deleted; | ||
|
||
create table operation_logs | ||
( | ||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, | ||
`res_param` text, | ||
`req_param` text, | ||
`type` varchar(64) NOT NULL DEFAULT '', | ||
`account` varchar(128) NOT NULL DEFAULT '', | ||
`created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY (`id`) | ||
)ENGINE=InnoDB collate = utf8mb4_unicode_ci; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/test/groovy/com/featureprobe/api/service/OperationLogServiceSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.featureprobe.api.service | ||
|
||
import com.featureprobe.api.entity.OperationLog | ||
import com.featureprobe.api.repository.OperationLogRepository | ||
import spock.lang.Specification | ||
|
||
class OperationLogServiceSpec extends Specification{ | ||
|
||
OperationLogRepository operationLogRepository | ||
|
||
OperationLogService operationLogService | ||
|
||
def setup() { | ||
operationLogRepository = Mock(OperationLogRepository) | ||
operationLogService = new OperationLogService(operationLogRepository) | ||
} | ||
|
||
def "saved operation log"() { | ||
when: | ||
operationLogService.save(new OperationLog("test", "Admin")) | ||
then: | ||
1 * operationLogRepository.save(_) | ||
} | ||
} | ||
|
Oops, something went wrong.