|
@ -0,0 +1,215 @@
|
|
|
package com.yihu.iot.service.platform;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.iot.dao.company.IotCompanyDao;
|
|
|
import com.yihu.iot.dao.platform.*;
|
|
|
import com.yihu.jw.entity.iot.company.IotCompanyDO;
|
|
|
import com.yihu.jw.entity.iot.platform.*;
|
|
|
import com.yihu.jw.restmodel.iot.platform.IotInterfaceAuditVO;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.rm.iot.IotRequestMapping;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author HZY
|
|
|
* @vsrsion 1.0
|
|
|
* Created at 2020/5/6
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class IotInterfaceAuditService extends BaseJpaService<IotInterfaceAuditDO, IotInterfaceAuditDao> {
|
|
|
|
|
|
@Autowired
|
|
|
private IotInterfaceAuditDao iotInterfaceAuditDao;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private IotInterfaceAuditDetailDao iotInterfaceAuditDetailDao;
|
|
|
|
|
|
@Autowired
|
|
|
private IotShareInterfaceDao iotShareInterfaceDao;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private IotCompanyDao iotCompanyDao;
|
|
|
|
|
|
@Autowired
|
|
|
private IotCompanyAppInterfaceDao iotCompanyAppInterfaceDao;
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
/**
|
|
|
* 应用接口申请
|
|
|
* @param json
|
|
|
*/
|
|
|
public void addInterfaceApplyFor(String json, List<String> ids) {
|
|
|
IotInterfaceAuditDO iotInterfaceAuditDO = JSONObject.parseObject(json, IotInterfaceAuditDO.class);
|
|
|
iotInterfaceAuditDO.setTime(DateUtil.getNowDate());
|
|
|
iotInterfaceAuditDao.save(iotInterfaceAuditDO);
|
|
|
|
|
|
ids.forEach(one->{
|
|
|
|
|
|
IotInterfaceAuditDetailDO iotInterfaceAuditDetailDO = new IotInterfaceAuditDetailDO();
|
|
|
iotInterfaceAuditDetailDO.setInterfaceId(iotInterfaceAuditDO.getId());
|
|
|
iotInterfaceAuditDetailDO.setShareInterfaceId(one);
|
|
|
//获取共享接口信息,并存储到审核临时表中
|
|
|
IotShareInterfaceDO shareInterfaceDO = iotShareInterfaceDao.findById(one);
|
|
|
iotInterfaceAuditDetailDO.setInterfaceName(shareInterfaceDO.getInterfaceName());
|
|
|
iotInterfaceAuditDetailDO.setMethodName(shareInterfaceDO.getMethodName());
|
|
|
iotInterfaceAuditDetailDO.setExplanation(shareInterfaceDO.getExplanation());
|
|
|
iotInterfaceAuditDetailDO.setTypeName(shareInterfaceDO.getTypeName());
|
|
|
iotInterfaceAuditDetailDao.save(iotInterfaceAuditDetailDO);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看应用申请接口信息
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
public IotInterfaceAuditVO findInterfaceApplyFor(String id) {
|
|
|
|
|
|
IotInterfaceAuditVO iotInterfaceAuditVO = new IotInterfaceAuditVO();
|
|
|
|
|
|
IotInterfaceAuditDO auditDO = iotInterfaceAuditDao.findOne(id);
|
|
|
//获取联系人姓名与电话
|
|
|
IotCompanyDO company = iotCompanyDao.findOne(auditDO.getCompanyId());
|
|
|
auditDO.setContactsName(company.getContactsName());
|
|
|
auditDO.setContactsMobile(company.getContactsMobile());
|
|
|
List<IotInterfaceAuditDetailDO> list = iotInterfaceAuditDetailDao.findByInterfaceId(id);
|
|
|
iotInterfaceAuditVO.setIotInterfaceAuditDO(auditDO);
|
|
|
iotInterfaceAuditVO.setIotInterfaceAuditDetailDOList(list);
|
|
|
|
|
|
return iotInterfaceAuditVO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分页查找所有应用申请信息
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<IotInterfaceAuditDO, IotInterfaceAuditDO> findAllApplyFor(Integer page, Integer size) {
|
|
|
|
|
|
String sql="SELECT DISTINCT * FROM iot_interface_audit ORDER BY time DESC;";
|
|
|
|
|
|
List<IotInterfaceAuditDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(IotInterfaceAuditDO.class));
|
|
|
|
|
|
list.forEach(one->{
|
|
|
IotCompanyDO company = iotCompanyDao.findOne(one.getCompanyId());
|
|
|
one.setContactsName(company.getContactsName());
|
|
|
one.setContactsMobile(company.getContactsMobile());
|
|
|
});
|
|
|
|
|
|
//获取总数
|
|
|
long count = list.size();
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Platform.message_success_find,list,page, size,count);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 接口审核通过
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<IotInterfaceAuditDO, IotInterfaceAuditDO> auditPass(String id) {
|
|
|
|
|
|
IotInterfaceAuditDO auditDO = iotInterfaceAuditDao.findOne(id);
|
|
|
if (auditDO==null)
|
|
|
{
|
|
|
return MixEnvelop.getError("审核操作失败,无该应用");
|
|
|
}
|
|
|
|
|
|
//删除之前的所有应用接口 已审核通过的为最新接口
|
|
|
List<IotCompanyAppInterfaceDO> appInterfaceDOList = iotCompanyAppInterfaceDao.findByAppId(auditDO.getAppId());
|
|
|
appInterfaceDOList.forEach(one->{
|
|
|
iotCompanyAppInterfaceDao.delete(one.getId());
|
|
|
});
|
|
|
|
|
|
//获取共享接口数组并分配接口给应用
|
|
|
List<IotInterfaceAuditDetailDO> ids = iotInterfaceAuditDetailDao.findByInterfaceId(auditDO.getId());
|
|
|
ids.forEach(one->{
|
|
|
IotCompanyAppInterfaceDO appInterfaceDO = new IotCompanyAppInterfaceDO();
|
|
|
appInterfaceDO.setShareInterfaceId(one.getShareInterfaceId());
|
|
|
appInterfaceDO.setAppId(auditDO.getAppId());
|
|
|
appInterfaceDO.setAppName(auditDO.getAppName());
|
|
|
appInterfaceDO.setCompanyId(auditDO.getCompanyId());
|
|
|
appInterfaceDO.setCompanyName(auditDO.getCompanyName());
|
|
|
appInterfaceDO.setDel("0");
|
|
|
iotCompanyAppInterfaceDao.save(appInterfaceDO);
|
|
|
});
|
|
|
|
|
|
auditDO.setStatus("1");
|
|
|
auditDO.setAuditTime(DateUtil.getNowDate());
|
|
|
iotInterfaceAuditDao.save(auditDO);
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.InterfaceAudit.message_success_audit);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 接口审核不通过
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<IotInterfaceAuditDO, IotInterfaceAuditDO> auditNoPass(String id,String msg) {
|
|
|
IotInterfaceAuditDO auditDO = iotInterfaceAuditDao.findOne(id);
|
|
|
if (auditDO==null)
|
|
|
{
|
|
|
return MixEnvelop.getError("审核操作失败,无该应用");
|
|
|
}
|
|
|
auditDO.setStatus("0");
|
|
|
auditDO.setRefuseExplain(msg);
|
|
|
auditDO.setAuditTime(DateUtil.getNowDate());
|
|
|
iotInterfaceAuditDao.save(auditDO);
|
|
|
return MixEnvelop.getSuccess(IotRequestMapping.InterfaceAudit.message_success_audit);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 分页查询接口申请信息
|
|
|
* @param companyName
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<IotInterfaceAuditDO, IotInterfaceAuditDO> conditionQueryPage(String companyName, Integer page, Integer size) throws ParseException {
|
|
|
StringBuffer sql = new StringBuffer("SELECT DISTINCT * from iot_interface_audit ");
|
|
|
if (StringUtils.isNotBlank(companyName)){
|
|
|
sql.append("WHERE company_name like'%").append(companyName).append("%'");
|
|
|
}
|
|
|
|
|
|
sql.append("order by time desc limit ").append((page-1)*size).append(",").append(size);
|
|
|
|
|
|
List<IotInterfaceAuditDO> list = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(IotInterfaceAuditDO.class));
|
|
|
|
|
|
list.forEach(one->{
|
|
|
IotCompanyDO company = iotCompanyDao.findOne(one.getCompanyId());
|
|
|
one.setContactsName(company.getContactsName());
|
|
|
one.setContactsMobile(company.getContactsMobile());
|
|
|
});
|
|
|
|
|
|
//获取总数
|
|
|
long count = list.size();
|
|
|
|
|
|
return MixEnvelop.getSuccessListWithPage(IotRequestMapping.Platform.message_success_find,list,page, size,count);
|
|
|
}
|
|
|
}
|