##### Coverage Report - com.ctrip.framework.apollo.biz.service.AuditService

Classes in this File | Line Coverage | Branch Coverage | Complexity
AuditService |
75% | 9/12
N/A | N/A
| 1.0;1

1 |  |
     package com.ctrip.framework.apollo.biz.service;
2 |  |
3 |  |
     import java.util.List;
4 |  |
5 |  |
     import org.springframework.beans.factory.annotation.Autowired;
6 |  |
     import org.springframework.stereotype.Service;
7 |  |
     import org.springframework.transaction.annotation.Transactional;
8 |  |
9 |  |
     import com.ctrip.framework.apollo.biz.entity.Audit;
10 |  |
     import com.ctrip.framework.apollo.biz.repository.AuditRepository;
11 |  |
12 |  |
     @Service
13 | 1 |
     public class AuditService {
14 |  |
15 |  |
       @Autowired
16 |  |
       private AuditRepository auditRepository;
17 |  |
18 |  |
       List<Audit> findByOwner(String owner) {
19 | 1 |
         return auditRepository.findByOwner(owner);
20 |  |
       }
21 |  |
22 |  |
       List<Audit> find(String owner, String entity, String op) {
23 | 0 |
         return auditRepository.findAudits(owner, entity, op);
24 |  |
       }
25 |  |
26 |  |
       @Transactional
27 |  |
       void audit(String entityName, Long entityId, Audit.OP op, String owner) {
28 | 25 |
         Audit audit = new Audit();
29 | 25 |
         audit.setEntityName(entityName);
30 | 25 |
         audit.setEntityId(entityId);
31 | 25 |
         audit.setOpName(op.name());
32 | 25 |
         audit.setDataChangeCreatedBy(owner);
33 | 25 |
         auditRepository.save(audit);
34 | 25 |
       }
35 |  |
36 |  |
       @Transactional
37 |  |
       void audit(Audit audit){
38 | 0 |
         auditRepository.save(audit);
39 | 0 |
       }
40 |  |
     }