feat: add sip info
This commit is contained in:
parent
10315c6e0c
commit
d5043a3141
@ -12,6 +12,20 @@ import com.pudonghot.yo.dal.tenant.model.Tenant;
|
||||
*/
|
||||
public interface TenantDal extends BaseDal<Long, Tenant> {
|
||||
|
||||
/**
|
||||
* find by code
|
||||
*
|
||||
* @param code code
|
||||
* @return tenant
|
||||
*/
|
||||
Tenant findByCode(String code);
|
||||
|
||||
/**
|
||||
* find by realm
|
||||
*
|
||||
* @param realm
|
||||
* @return
|
||||
*/
|
||||
Tenant findByRealm(String realm);
|
||||
|
||||
List<Tenant> listAllActive();
|
||||
|
@ -28,6 +28,14 @@ public class TenantDalImpl
|
||||
extends BaseDalImpl<Long, Tenant, Tenant2Mapper>
|
||||
implements TenantDal {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Tenant findByCode(final String code) {
|
||||
return find(Search.of(Tenant.CODE, code).isTrue(Tenant.ACTIVE));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.pudonghot.yo.operation.dal.dept;
|
||||
|
||||
import java.util.List;
|
||||
import com.pudonghot.tigon.dal.BaseDal;
|
||||
import com.pudonghot.yo.operation.dal.dept.model.DeptDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调解组织结构
|
||||
*
|
||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import com.pudonghot.yo.operation.service.home.response.AgentListRespBO;
|
||||
import com.pudonghot.yo.operation.service.home.response.DeptListRespBO;
|
||||
import com.pudonghot.yo.operation.service.home.response.SmsTplListRespBO;
|
||||
import com.pudonghot.yo.operation.service.home.response.WebRtcAgentRespBO;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
@ -37,4 +38,12 @@ public interface HomeService {
|
||||
* @return dept list
|
||||
*/
|
||||
List<DeptListRespBO> deptList();
|
||||
|
||||
/**
|
||||
* WebRTC agent info
|
||||
*
|
||||
* @param account
|
||||
* @return web rtc agent info
|
||||
*/
|
||||
WebRtcAgentRespBO webRtcAgentInfo(String account);
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
package com.pudonghot.yo.operation.service.home.impl;
|
||||
|
||||
import lombok.val;
|
||||
import java.util.List;
|
||||
import com.pudonghot.yo.dal.agent.AgentDal;
|
||||
import com.pudonghot.tigon.dal.hook.AuthHook;
|
||||
import com.pudonghot.yo.dal.tenant.TenantDal;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.pudonghot.tigon.kit.bean.BeanService;
|
||||
import com.pudonghot.yo.operation.dal.dept.DeptDal;
|
||||
import com.pudonghot.yo.operation.dal.sms.SmsTemplateDal;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import com.pudonghot.yo.operation.service.home.HomeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.pudonghot.yo.operation.dal.loanimport.BatchNumberDal;
|
||||
import com.pudonghot.yo.operation.service.home.response.DeptListRespBO;
|
||||
import com.pudonghot.yo.operation.service.home.response.AgentListRespBO;
|
||||
import com.pudonghot.yo.operation.service.home.response.SmsTplListRespBO;
|
||||
import com.pudonghot.yo.operation.service.home.response.WebRtcAgentRespBO;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
@ -31,6 +36,15 @@ public class HomeServiceImpl implements HomeService {
|
||||
@Autowired
|
||||
private DeptDal deptDal;
|
||||
|
||||
@Value("${yo.sip.webrtc.endpoint:wss://cc.ideasfin.com:4443/ws}")
|
||||
private String webRtcEndpoint;
|
||||
@Autowired
|
||||
private AuthHook<Long> authHook;
|
||||
@Autowired
|
||||
private com.pudonghot.tigon.cms.dal.tenant.TenantDal tenantDal;
|
||||
@Autowired
|
||||
private TenantDal tenantDal2;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -62,4 +76,22 @@ public class HomeServiceImpl implements HomeService {
|
||||
public List<DeptListRespBO> deptList() {
|
||||
return beanService.convert(deptDal.listTop(), DeptListRespBO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WebRtcAgentRespBO webRtcAgentInfo(final String account) {
|
||||
val tenantId = authHook.getTenantId();
|
||||
val tenant = tenantDal.find(tenantId);
|
||||
val sipProfile = tenantDal2.findByCode(tenant.getCode());
|
||||
val realm = sipProfile.getRealm();
|
||||
|
||||
val agent = agentDal.findByDomainAndAccount(realm, account);
|
||||
val resp = beanService.convert(agent, WebRtcAgentRespBO.class);
|
||||
resp.setRealm(realm);
|
||||
resp.setEndpoint(webRtcEndpoint);
|
||||
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.pudonghot.yo.operation.service.home.response;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Oct 04, 2024 16:33:47
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class WebRtcAgentRespBO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String account;
|
||||
private String agent;
|
||||
private String password;
|
||||
|
||||
private String endpoint;
|
||||
private String realm;
|
||||
}
|
@ -4,12 +4,14 @@ import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import com.pudonghot.tigon.kit.bean.BeanService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import com.pudonghot.tigon.cms.auth.SessionAbility;
|
||||
import com.pudonghot.yo.operation.service.home.HomeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.pudonghot.yo.operation.controller.home.response.DeptListRespVO;
|
||||
import com.pudonghot.yo.operation.controller.home.response.AgentListRespVO;
|
||||
import com.pudonghot.yo.operation.controller.home.response.SmsTplListRespVO;
|
||||
import com.pudonghot.yo.operation.controller.home.response.WebRtcAgentRespVO;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
@ -17,13 +19,18 @@ import com.pudonghot.yo.operation.controller.home.response.SmsTplListRespVO;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/api/home")
|
||||
public class HomeController {
|
||||
public class HomeController implements SessionAbility {
|
||||
|
||||
@Autowired
|
||||
private HomeService homeService;
|
||||
@Autowired
|
||||
private BeanService beanService;
|
||||
|
||||
@RequestMapping("/sip-info")
|
||||
public WebRtcAgentRespVO sipInfo() {
|
||||
return beanService.convert(homeService.webRtcAgentInfo(getAccount()), WebRtcAgentRespVO.class);
|
||||
}
|
||||
|
||||
@RequestMapping("/agent-list")
|
||||
public List<AgentListRespVO> agentList() {
|
||||
return beanService.convert(homeService.agentList(), AgentListRespVO.class);
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.pudonghot.yo.operation.controller.home.response;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import java.io.Serializable;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Oct 04, 2024 16:33:47
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class WebRtcAgentRespVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String account;
|
||||
private String agent;
|
||||
private String password;
|
||||
|
||||
@JsonAlias("endpoint")
|
||||
private String sipAddr;
|
||||
@JsonAlias("realm")
|
||||
private String sipRealm;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user