| 1 | |
package com.ctrip.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.apollo.biz.entity.Audit; |
| 10 | |
import com.ctrip.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 | 21 | Audit audit = new Audit(); |
| 29 | 21 | audit.setEntityName(entityName); |
| 30 | 21 | audit.setEntityId(entityId); |
| 31 | 21 | audit.setOpName(op.name()); |
| 32 | 21 | audit.setDataChangeCreatedBy(owner); |
| 33 | 21 | auditRepository.save(audit); |
| 34 | 21 | } |
| 35 | |
|
| 36 | |
@Transactional |
| 37 | |
void audit(Audit audit){ |
| 38 | 0 | auditRepository.save(audit); |
| 39 | 0 | } |
| 40 | |
} |