Browse Source

cert 服务层实现

master
xyiege 4 years ago
parent
commit
66e34aba51
  1. 22
      src/main/java/cn/chjyj/szwh/service/CertService.java
  2. 23
      src/main/java/cn/chjyj/szwh/service/impl/CertServiceImpl.java
  3. 31
      src/test/java/cn/chjyj/szwh/mapper/CertMapperTest.java

22
src/main/java/cn/chjyj/szwh/service/CertService.java

@ -0,0 +1,22 @@
package cn.chjyj.szwh.service;
import cn.chjyj.szwh.bean.Cert;
/**
* 证书配置信息
*/
public interface CertService {
/**
* 根据编号查询
* @param id
* @return
*/
Cert getCertByid(Integer id);
/**
* 根据类型查询
* @param stype
* @return
*/
Cert getCertByType(String stype);
}

23
src/main/java/cn/chjyj/szwh/service/impl/CertServiceImpl.java

@ -0,0 +1,23 @@
package cn.chjyj.szwh.service.impl;
import cn.chjyj.szwh.bean.Cert;
import cn.chjyj.szwh.mapper.CertMapper;
import cn.chjyj.szwh.service.CertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CertServiceImpl implements CertService {
@Autowired
private CertMapper certMapper;
@Override
public Cert getCertByid(Integer id) {
return certMapper.getCertByid(id);
}
@Override
public Cert getCertByType(String stype) {
return certMapper.getCertByType(stype);
}
}

31
src/test/java/cn/chjyj/szwh/mapper/CertMapperTest.java

@ -0,0 +1,31 @@
package cn.chjyj.szwh.mapper;
import cn.chjyj.szwh.bean.Cert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
@SpringBootTest
@RunWith(SpringRunner.class)
public class CertMapperTest {
@Autowired
private CertMapper certMapper;
@Test
public void getCertByid() {
int id =1;
Cert cert = certMapper.getCertByid(id);
System.out.println(cert.getToken());
}
@Test
public void getCertByType() {
String stype ="entrust";
Cert cert = certMapper.getCertByType(stype);
System.out.println(cert.getToken());
}
}
Loading…
Cancel
Save