Commit af6443eb by wqc Committed by 王健飞

共享平台接口

parent c0f37581
......@@ -47,7 +47,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: select 1
validation-query: SELECT 1 FROM DUAL
# 配置监控统计
webStatFilter:
enabled: true
......
......@@ -60,7 +60,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: SELECT 1
validation-query: SELECT 1 FROM DUAL
filters: stat
stat:
merge-sql: true
......
package com.zq.open.controller.api;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.ResultVo;
import com.zq.open.entity.ShareData;
import com.zq.open.service.ShareService;
import com.zq.open.vo.CustomVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@Api(tags = "数据共享相关接口")
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/open/api/share")
public class ShareApi {
private final ShareService shareService;
@ApiOperation("数据共享接口")
@PostMapping(value = "/shareData")
public ResultVo destituteInfo(@RequestBody CustomVo vo) {
return ResultVo.success(shareService.shareData(vo));
}
}
package com.zq.open.dao;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zq.common.constant.DBName;
import com.zq.open.entity.ShareData;
import org.springframework.stereotype.Repository;
@DS(DBName.GXSHJZ)
@Repository
public interface ShareDataDao extends BaseMapper<ShareData> {
}
package com.zq.open.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName(value = "share_data")
public class ShareData {
/**
* 服务号
*/
private String serviceid;
/**
* 总数
*/
private BigDecimal datacount;
}
\ No newline at end of file
package com.zq.open.service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zq.common.vo.ResultVo;
import com.zq.open.dao.ShareDataDao;
import com.zq.open.entity.ShareData;
import com.zq.open.vo.CustomVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@RequiredArgsConstructor
public class ShareService {
private final ShareDataDao shareDataDao;
public ResultVo shareData(CustomVo vo) {
if (vo.getServiceid().equals("") || vo.getServiceid()==null) {
Map<String, Object> map = new HashMap<>();
List<ShareData> share = new ArrayList<>();
List<ShareData> dataList = shareDataDao.selectList(Wrappers.lambdaQuery(ShareData.builder().serviceid("").build()));
for (ShareData list:dataList) {
share.add(list);
}
map.put("code",1);
map.put("text","获取成功");
map.put("dataList",share);
return ResultVo.success(map);
}else if(vo.getServiceid()!=null){
Map<String, Object> custom = new HashMap<>();
List<ShareData> share = new ArrayList<>();
ShareData shareData = shareDataDao.selectOne(Wrappers.lambdaQuery(ShareData.builder().serviceid(vo.getServiceid()).build()));
if (shareData != null) {
share.add(shareData);
custom.put("code",1);
custom.put("text","获取成功");
custom.put("dataList",share);
}else{
return ResultVo.fail("抱歉,您传的服务号不对");
}
return ResultVo.success(custom);
}else{
return ResultVo.fail("抱歉,您传的服务号不对");
}
}
}
package com.zq.open.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CustomVo {
/**
* 服务号
*/
private String serviceid;
/**
* 总数
*/
private BigDecimal datacount;
}
......@@ -47,6 +47,12 @@ spring:
username: ${jdbc.username}
password: ${jdbc.password}
url: ${jdbc.gxhy.url}
gxshjz:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: ${jdbc.driver-class-name}
username: ${jdbc.username}
password: ${jdbc.password}
url: ${jdbc.gxshjz.url}
ozt:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: ${ojdbc.driver-class-name}
......@@ -72,7 +78,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: SELECT 1
validation-query: SELECT 1 FROM DUAL
filters: stat
stat:
merge-sql: true
......
......@@ -110,7 +110,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: select 1
validation-query: SELECT 1 FROM DUAL
filters: stat
stat:
merge-sql: true
......
......@@ -60,7 +60,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: SELECT 1
validation-query: SELECT 1 FROM DUAL
filters: stat
stat:
merge-sql: true
......
......@@ -42,7 +42,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: SELECT 1
validation-query: SELECT 1 FROM DUAL
filters: stat
stat:
merge-sql: true
......
......@@ -58,7 +58,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: select 1
validation-query: SELECT 1 FROM DUAL
filters: stat
stat:
merge-sql: true
......
......@@ -52,7 +52,7 @@ spring:
test-on-borrow: false
test-on-return: false
# 检测连接是否有效
validation-query: select 1
validation-query: SELECT 1 FROM DUAL
filters: stat
stat:
merge-sql: true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment