1、添加注册接口;

2、添加行为积分接口;
3、请求白名单修改为配置文件的方式;
4、升级swagger文档;
5、添加微信小程序、家医接口配置;
This commit is contained in:
mengkuiliang 2023-09-25 18:05:41 +08:00
parent a0c8077935
commit ac687bc8a3
33 changed files with 2729 additions and 34 deletions

View File

@ -33,6 +33,7 @@
<velocity.version>2.3</velocity.version>
<jwt.version>0.9.1</jwt.version>
<lombok.version>1.18.4</lombok.version>
<knife4j.version>3.0.3</knife4j.version>
</properties>
<!-- 依赖声明 -->

View File

@ -72,6 +72,10 @@
<groupId>com.xinelu</groupId>
<artifactId>xinelu-nurse-applet</artifactId>
</dependency>
<dependency>
<groupId>com.xinelu</groupId>
<artifactId>xinelu-familydoctor</artifactId>
</dependency>
</dependencies>
<build>
@ -91,17 +95,17 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
</project>
</project>

View File

@ -0,0 +1,109 @@
package com.xinelu.web.controller.applet;
import com.xinelu.familydoctor.applet.pojo.body.PatientInfoBody;
import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo;
import com.xinelu.familydoctor.applet.service.IPatientInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.BusinessType;
/**
* @Author mengkuiliang
* @Description 小程序注册控制器
* @Date 2023-09-25 025 10:24
* @Param
* @return
**/
@RestController
@RequestMapping("/applet/register")
@Api(tags = "小程序注册控制器")
public class PatientInfoController extends BaseController {
@Autowired
private IPatientInfoService patientInfoService;
@ApiOperation("获取OpenId")
@GetMapping("/getOpenId/{code}")
public AjaxResult getOpenId(@PathVariable String code) {
try {
return AjaxResult.success(patientInfoService.getOpenId(code));
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@ApiOperation("注册")
@Log(title = "居民小程序注册", businessType = BusinessType.INSERT)
@PostMapping("/")
public AjaxResult register(@Validated @RequestBody PatientInfoBody body) {
try {
patientInfoService.register(body);
return AjaxResult.success();
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@ApiOperation("修改注册信息")
@Log(title = "修改注册信息", businessType = BusinessType.UPDATE)
@PostMapping("/update")
public AjaxResult update(@Validated @RequestBody PatientInfo body) {
try {
patientInfoService.updatePatientInfo(body);
return AjaxResult.success();
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@ApiOperation("解绑")
@Log(title = "居民小程序解绑", businessType = BusinessType.UPDATE)
@GetMapping("/unbinding/{patientCode}")
public AjaxResult unbinding(@PathVariable String patientCode) {
patientInfoService.unbinding(patientCode);
return AjaxResult.success();
}
@ApiOperation("获取已注册列表")
@GetMapping("/getList/{openid}/{cityCode}")
public AjaxResult getList(@PathVariable String openid, @PathVariable String cityCode) {
return AjaxResult.success(patientInfoService.getList(openid, cityCode));
}
@ApiOperation("切换账号")
@GetMapping("/switchResident/{openid}/{patientCode}")
public AjaxResult switchResident(@PathVariable String openid, @PathVariable String patientCode) {
try {
return AjaxResult.success(patientInfoService.switchResident(openid, patientCode));
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
@ApiOperation("获取注册详细信息")
@GetMapping(value = "/getInfo/{patientCode}")
public AjaxResult getInfo(@PathVariable("patientCode") String patientCode) {
return AjaxResult.success(patientInfoService.selectPatientInfoByCode(patientCode));
}
@ApiOperation("获取当前注册居民")
@GetMapping(value = "/getCurrentResident/{openid}/{cityCode}")
public AjaxResult getCurrentResident(@PathVariable("openid") String openid, @PathVariable("cityCode") String cityCode) {
if(StringUtils.isBlank(cityCode) || cityCode.equals("null")) {
AjaxResult.error("绑定城市编码不能为空");
}
return AjaxResult.success(patientInfoService.getCurrentResident(openid, cityCode));
}
}

View File

@ -0,0 +1,99 @@
package com.xinelu.web.controller.applet;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageInfo;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.utils.http.HttpUtils;
import com.xinelu.common.utils.spring.SpringUtils;
import com.xinelu.familydoctor.applet.pojo.query.DictHealthActQuery;
import com.xinelu.familydoctor.applet.pojo.query.PatientScoreQuery;
import com.xinelu.familydoctor.applet.pojo.vo.DictHealthActVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
/**
* @Author mengkuiliang
* @Description 健康行为积分控制器
* @Date 2023-09-21 021 17:50
* @Param
* @return
**/
@Api(tags = "健康行为积分控制器")
@RestController
@RequestMapping("/score")
public class PatientScoreController {
@ApiOperation(value = "获取居民总积分", notes = "region: (1: 德州 2东营)")
@GetMapping("/total/{cardNo}")
public AjaxResult schemaList(@PathVariable String cardNo, @RequestHeader("region") String region) {
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/patient/score/record/total/" + cardNo);
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
return AjaxResult.success(jsonObject.getString("data"));
}
@ApiOperation("获取居民积分列表")
@GetMapping("/list")
public AjaxResult schemaList(PatientScoreQuery query, @RequestHeader("region") String region) {
StringBuffer params = new StringBuffer();
params.append("?identity=").append(query.getIdentity());
params.append("&pageSize=").append(query.getPageSize() != null && query.getPageSize() > 0 ? query.getPageSize() : 15);
params.append("&pageNum=").append(query.getPageNum() != null && query.getPageNum() > 0 ? query.getPageNum() : 1);
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/patient/score/record/list" + params.toString());
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
PageInfo pageInfo = new PageInfo();
if (jsonObject.get("data") != null) {
JSONObject jsonObject1 = (JSONObject) jsonObject.get("data");
pageInfo.setTotal(jsonObject1.getInteger("total"));
pageInfo.setList(jsonObject1.getJSONArray("list"));
}
return AjaxResult.success(pageInfo);
}
@GetMapping("/healthAct/list")
@ApiOperation("健康行为列表")
public AjaxResult healthActList(DictHealthActQuery query, @RequestHeader("region") String region) {
StringBuffer params = new StringBuffer();
params.append("?pageNum=").append(query.getPageNum() != null && query.getPageNum() > 0 ? query.getPageNum() : 1);
params.append("&pageSize=").append(query.getPageSize() != null && query.getPageSize() > 0 ? query.getPageSize() : 15);
params.append("&actId=").append(!StringUtils.isBlank(query.getActId()) ? query.getActId() : "");
params.append("&targetGroups=").append(!StringUtils.isBlank(query.getTargetGroups()) ? query.getTargetGroups() : "");
params.append("&actName=").append(!StringUtils.isBlank(query.getActName()) ? query.getActName() : "");
params.append("&period=").append(!StringUtils.isBlank(query.getPeriod()) ? query.getPeriod() : "");
params.append("&identity=").append(!StringUtils.isBlank(query.getIdentity()) ? query.getIdentity() : "");
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/patient/score/list" + params.toString());
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
PageInfo pageInfo = new PageInfo();
if (jsonObject.get("data") != null) {
JSONObject jsonObject1 = (JSONObject) jsonObject.get("data");
pageInfo.setTotal(jsonObject1.getInteger("total"));
pageInfo.setList(jsonObject1.getJSONArray("list"));
}
return AjaxResult.success(pageInfo);
}
@GetMapping("/healthAct/detail/{actId}")
@ApiOperation("健康行为明细")
public AjaxResult healthActDetail(@PathVariable String actId, @RequestHeader("region") String region) {
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/patient/score/detail/" + actId);
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
if (jsonObject.get("data") != null) {
return AjaxResult.success(JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), DictHealthActVo.class));
}
return AjaxResult.success();
}
}

View File

@ -0,0 +1,74 @@
package com.xinelu.web.controller.applet;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageInfo;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.utils.http.HttpUtils;
import com.xinelu.common.utils.spring.SpringUtils;
import com.xinelu.familydoctor.applet.pojo.query.PrizeQuery;
import com.xinelu.familydoctor.applet.pojo.vo.PrizeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
/**
* @Author mengkuiliang
* @Description 健康行为积分商城奖品控制器
* @Date 2023-09-21 021 17:50
* @Param
* @return
**/
@Api(tags = "健康行为积分商城奖品控制器")
@RestController
@RequestMapping("/score/prize")
public class PrizeController {
@ApiOperation("获取奖品列表")
@GetMapping("/list")
public AjaxResult getPrizeList(PrizeQuery query, @RequestHeader("region") String region) {
StringBuffer params = new StringBuffer();
params.append("?identity=").append(query.getIdentity());
params.append("&pageSize=").append(query.getPageSize() != null && query.getPageSize() > 0 ? query.getPageSize() : 15);
params.append("&pageNum=").append(query.getPageNum() != null && query.getPageNum() > 0 ? query.getPageNum() : 1);
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/prize/list" + params);
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
PageInfo pageInfo = new PageInfo();
if (jsonObject.get("data") != null) {
JSONObject jsonObject1 = (JSONObject) jsonObject.get("data");
pageInfo.setTotal(jsonObject1.getInteger("total"));
pageInfo.setList(jsonObject1.getJSONArray("list"));
}
return AjaxResult.success(pageInfo);
}
@GetMapping("/getByPrizeId/{prizeId}")
@ApiOperation("奖品详情")
public AjaxResult getByPrizeId(@PathVariable String prizeId, @RequestHeader("region") String region) {
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/prize/getByPrizeId/" + prizeId);
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
if (jsonObject.get("data") != null) {
return AjaxResult.success(JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), PrizeVo.class));
}
return AjaxResult.success();
}
@GetMapping("/getImgById/{prizeId}")
@ApiOperation("奖品图片查询")
public AjaxResult getImgById(@PathVariable String prizeId, @RequestHeader("region") String region) {
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/prize/getImgById/" + prizeId);
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
if (jsonObject.get("data") != null) {
return AjaxResult.success(jsonObject.getString("data"));
}
return AjaxResult.success();
}
}

View File

@ -0,0 +1,84 @@
package com.xinelu.web.controller.applet;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageInfo;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.utils.http.HttpService;
import com.xinelu.common.utils.http.HttpUtils;
import com.xinelu.common.utils.spring.SpringUtils;
import com.xinelu.familydoctor.applet.pojo.body.PrizeExchangeBody;
import com.xinelu.familydoctor.applet.pojo.query.PrizeQuery;
import com.xinelu.familydoctor.applet.pojo.vo.PrizeExchangeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @Author mengkuiliang
* @Description 积分兑换记录控制器
* @Date 2023-09-21 021 17:50
* @Param
* @return
**/
@Api(tags = "积分兑换记录控制器")
@RestController
@RequestMapping("/score/prizeExchange")
public class PrizeExchangeController {
@Resource
private HttpService httpService;
@ApiOperation("兑换奖品")
@PostMapping("/save")
public AjaxResult save(@RequestBody PrizeExchangeBody body, @RequestHeader("region") String region) {
if (StringUtils.isBlank(body.getIdentity())) {
return AjaxResult.error("请求参数异常");
}
JSONObject params = new JSONObject();
params.put("identity", body.getIdentity());
params.put("prizeId", body.getPrizeId());
JSONObject jsonObject = httpService.post(SpringUtils.getFdUrl(region) + "/prizeExchange/insert", null, params);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
return AjaxResult.success();
}
@ApiOperation("查询兑换记录列表")
@GetMapping("/list")
public AjaxResult getList(PrizeQuery query, @RequestHeader("region") String region) {
StringBuffer params = new StringBuffer();
params.append("?identity=").append(query.getIdentity());
params.append("&status=").append(query.getStatus());
params.append("&pageSize=").append(query.getPageSize() != null && query.getPageSize() > 0 ? query.getPageSize() : 15);
params.append("&pageNum=").append(query.getPageNum() != null && query.getPageNum() > 0 ? query.getPageNum() : 1);
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/prizeExchange/list" + params);
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
PageInfo pageInfo = new PageInfo();
if (jsonObject.get("data") != null) {
JSONObject jsonObject1 = (JSONObject) jsonObject.get("data");
pageInfo.setTotal(jsonObject1.getInteger("total"));
pageInfo.setList(jsonObject1.getJSONArray("list"));
}
return AjaxResult.success(pageInfo);
}
@GetMapping("/getById/{exchangeId}")
@ApiOperation("兑换记录详情")
public AjaxResult getById(@PathVariable String exchangeId, @RequestHeader("region") String region) {
String result = HttpUtils.sendGet(SpringUtils.getFdUrl(region) + "/prizeExchange/getById/" + exchangeId);
JSONObject jsonObject = JSONObject.parseObject(result);
if (!jsonObject.get("code").toString().equals("1")) {
return AjaxResult.error(jsonObject.get("msg").toString());
}
if (jsonObject.get("data") != null) {
return AjaxResult.success(JSONObject.parseObject(jsonObject.getJSONObject("data").toJSONString(), PrizeExchangeVo.class));
}
return AjaxResult.success();
}
}

View File

@ -46,27 +46,27 @@ public class SwaggerConfig {
/**
* 创建API
*/
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.OAS_30)
// 是否启用Swagger
.enable(enabled)
// 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
.apiInfo(apiInfo())
// 设置哪些接口暴露给Swagger展示
.select()
// 扫描所有有注解的api用这种方式更灵活
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// 扫描指定包中的swagger注解
// .apis(RequestHandlerSelectors.basePackage("com.xinelu.project.tool.swagger"))
// 扫描所有 .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
/* 设置安全模式swagger可以设置访问token */
.securitySchemes(securitySchemes())
.securityContexts(securityContexts())
.pathMapping(pathMapping);
}
// @Bean
// public Docket createRestApi() {
// return new Docket(DocumentationType.OAS_30)
// // 是否启用Swagger
// .enable(enabled)
// // 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
// .apiInfo(apiInfo())
// // 设置哪些接口暴露给Swagger展示
// .select()
// // 扫描所有有注解的api用这种方式更灵活
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// // 扫描指定包中的swagger注解
// // .apis(RequestHandlerSelectors.basePackage("com.xinelu.project.tool.swagger"))
// // 扫描所有 .apis(RequestHandlerSelectors.any())
// .paths(PathSelectors.any())
// .build()
// /* 设置安全模式swagger可以设置访问token */
// .securitySchemes(securitySchemes())
// .securityContexts(securityContexts())
// .pathMapping(pathMapping);
// }
/**
* 安全模式这里指定token通过Authorization头请求头传递

View File

@ -89,7 +89,9 @@ token:
# 令牌密钥
secret: eaGoBFyEl31MGE3u1mt4teZFbk
# 令牌有效期默认30分钟
expireTime: 30
expireTime: 1440
#拦截白名单地址
ant-matchers: /applet/test/**,/nurseApplet/**,/nurseApp/**,/applet/register/**
# MyBatis-Plus配置
mybatis-plus:
@ -161,6 +163,9 @@ swagger:
# 请求前缀
pathMapping: /dev-api
swagger-ui:
base-url: com.xinelu.web
# 防止XSS攻击
xss:
# 过滤开关
@ -169,3 +174,17 @@ xss:
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 微信小程序配置
applet:
wxAppid: wxccb16a452ab5e4b4
wxSecret: 72e11a5757e578c47ee935c00f49e8bf
grantType: authorization_code
openIDUrl: https://api.weixin.qq.com/sns/jscode2session
# 附近机构,多少公里内
distance: 100.00
# 家医请求地址
fd:
dy: http://192.168.124.10:8001/fd/mp
dz: http://192.168.124.10:8002/fd/mp

View File

@ -55,9 +55,7 @@ public class AjaxResult extends HashMap<String, Object> {
public AjaxResult(int code, String msg, Object data) {
super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
if (StringUtils.isNotNull(data)) {
super.put(DATA_TAG, data);
}
super.put(DATA_TAG, data);
}
/**

View File

@ -0,0 +1,39 @@
package com.xinelu.common.enums;
import lombok.Getter;
/**
* @Author mengkuiliang
* @Description 家医配置枚举 对应 application.yml中的 fd模块的配置
* @Date 2023-09-21 021 17:31
* @Param
* @return
**/
@Getter
public enum RegionKeyType {
/**
* 德州 ${fd.dz}
*/
DZ("1", "dz"),
/**
* 东营 ${fd.dy}
*/
DY("2", "dy");
private final String code;
private final String name;
RegionKeyType(String code, String name) {
this.code = code;
this.name = name;
}
public static RegionKeyType getRegionKeyByCode(String code) {
for (RegionKeyType uploadType : RegionKeyType.values()) {
if (uploadType.getCode().equals(code)) {
return uploadType;
}
}
return null;
}
}

View File

@ -0,0 +1,100 @@
package com.xinelu.common.utils.http;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* @Author mengkuiliang
* @Description Http请求Service
* @Date 2023-09-22 022 11:40
* @Param
* @return
**/
@Service
@Slf4j
public class HttpService {
@Resource
private RestTemplate restTemplate;
/**
* @return java.lang.Object
* @Author mengkuiliang
* @Description get请求
* @Date 2022-10-09 16:48
* @Param [url, headerMap, resp]
**/
public Object get(String url, Map<String, Object> headerMap, Class<?> resp) {
log.info("get请求{}", url);
HttpHeaders httpHeaders = new HttpHeaders();
if (headerMap != null) {
for (Map.Entry<String, Object> stringStringEntry : headerMap.entrySet()) {
httpHeaders.add(stringStringEntry.getKey(), String.valueOf(stringStringEntry.getValue()));
}
}
HttpEntity httpEntity = new HttpEntity(httpHeaders);
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
ResponseEntity<?> result = restTemplate.exchange(url, HttpMethod.GET, httpEntity, resp);
return result.getBody();
}
/**
* @return com.alibaba.fastjson.JSONObject
* @Author mengkuiliang
* @Description post请求
* @Date 2022-10-09 16:50
* @Param [url, headerMap, jsonObject]
**/
public JSONObject post(String url, Map<String, Object> headerMap, JSONObject jsonObject) {
if (headerMap != null) {
log.info("post请求{} 请求头:{} 参数:{}", url, new JSONObject(headerMap).toJSONString(), jsonObject.toJSONString());
} else {
log.info("post请求{} 参数:{}", url, jsonObject.toJSONString());
}
HttpHeaders httpHeaders = new HttpHeaders();
if (headerMap != null) {
for (Map.Entry<String, Object> stringStringEntry : headerMap.entrySet()) {
httpHeaders.add(stringStringEntry.getKey(), String.valueOf(stringStringEntry.getValue()));
}
}
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
HttpEntity httpEntity = new HttpEntity(jsonObject, httpHeaders);
return restTemplate.postForObject(url, httpEntity, JSONObject.class);
}
/**
* @return com.alibaba.fastjson.JSONObject
* @Author mengkuiliang
* @Description post请求
* @Date 2022-10-09 16:50
* @Param [url, headerMap, jsonObject]
**/
public JSONObject post(String url, Map<String, Object> headerMap, String paramStr) {
if (headerMap != null) {
log.info("post请求{} 请求头:{} 参数:{}", url, new JSONObject(headerMap).toJSONString(), paramStr);
} else {
log.info("post请求{} 参数:{}", url, paramStr);
}
HttpHeaders httpHeaders = new HttpHeaders();
if (headerMap != null) {
for (Map.Entry<String, Object> stringStringEntry : headerMap.entrySet()) {
httpHeaders.add(stringStringEntry.getKey(), String.valueOf(stringStringEntry.getValue()));
}
}
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
HttpEntity httpEntity = new HttpEntity(JSONObject.parseObject(paramStr), httpHeaders);
return restTemplate.postForObject(url, httpEntity, JSONObject.class);
}
}

View File

@ -207,4 +207,4 @@ public class HttpUtils {
return true;
}
}
}
}

View File

@ -0,0 +1,58 @@
package com.xinelu.common.utils.http;
import javax.net.ssl.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public class SslUtils {
private static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[1];
TrustManager tm = new miTM();
trustAllCerts[0] = tm;
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
static class miTM implements TrustManager, X509TrustManager {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public boolean isServerTrusted(X509Certificate[] certs) {
return true;
}
public boolean isClientTrusted(X509Certificate[] certs) {
return true;
}
public void checkServerTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
public void checkClientTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
}
/**
* 忽略HTTPS请求的SSL证书必须在openConnection之前调用
*
* @throws Exception
*/
public static void ignoreSsl() throws Exception {
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
};
trustAllHttpsCertificates();
HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
}

View File

@ -1,5 +1,6 @@
package com.xinelu.common.utils.spring;
import com.xinelu.common.enums.RegionKeyType;
import com.xinelu.common.utils.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeansException;
@ -138,4 +139,11 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
public static String getRequiredProperty(String key) {
return applicationContext.getEnvironment().getRequiredProperty(key);
}
/**
* 获取家医请求地址
*/
public static String getFdUrl(String key) {
return applicationContext.getEnvironment().getProperty("fd." + RegionKeyType.getRegionKeyByCode(key).getName());
}
}

View File

@ -0,0 +1,90 @@
package com.xinelu.familydoctor.applet.mapper;
import com.xinelu.familydoctor.applet.pojo.body.PatientInfoBody;
import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo;
import com.xinelu.familydoctor.applet.pojo.query.PatientInfoQuery;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 被护理人基本信息Mapper接口
*
* @author xinelu
* @date 2023-09-25
*/
public interface PatientInfoMapper {
/**
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
* @Author mengkuiliang
* @Description 获取注册详细信息
* @Date 2023-09-21 021 9:44
* @Param [registerCode]
**/
public PatientInfo selectPatientInfoByCode(String patientCode);
/**
* @return java.util.List<com.xinelu.familydoctor.applet.pojo.entity.PatientInfo>
* @Author mengkuiliang
* @Description 获取注册列表
* @Date 2023-09-21 021 9:40
* @Param [query]
**/
public List<PatientInfo> selectPatientInfoList(PatientInfoQuery query);
/**
* @return int
* @Author mengkuiliang
* @Description 新增
* @Date 2023-09-21 021 14:20
* @Param [patientInfo]
**/
public int insertPatientInfo(PatientInfo patientInfo);
/**
* @return int
* @Author mengkuiliang
* @Description 修改
* @Date 2023-09-21 021 14:20
* @Param [patientInfo]
**/
public int updatePatientInfo(PatientInfo body);
/**
* @return void
* @Author mengkuiliang
* @Description 身份证号是否已注册
* @Date 2023-09-21 021 10:35
* @Param [cardNo]
**/
PatientInfo isRegisterByCardNo(String cardNo);
/**
* @return java.lang.String
* @Author mengkuiliang
* @Description 获取已注册列表
* @Date 2023-09-21 021 14:53
* @Param [openid]
**/
List<PatientInfo> getList(@Param("openid") String openid, @Param("cityCode") String cityCode);
/**
* @return void
* @Author mengkuiliang
* @Description 切换账号
* @Date 2023-09-21 021 15:19
* @Param [registerCode]
**/
void switchResident(@Param("openid") String openid, @Param("patientCode") String patientCode);
/**
* @return void
* @Author mengkuiliang
* @Description 更新选中标识
* @Date 2023-09-25 021 15:53
* @Param [registerCode]
**/
void updateChecked(@Param("patientCode") String patientCode, @Param("isChecked") String isChecked);
}

View File

@ -0,0 +1,242 @@
package com.xinelu.familydoctor.applet.pojo.body;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xinelu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Author mengkuiliang
* @Description 居民注册请求对象
* @Date 2023-09-25 025 10:02
* @Param
* @return
**/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "居民注册请求对象")
public class PatientInfoBody extends BaseEntity {
/**
* 所属区域编码
*/
@ApiModelProperty(value = "所属区域编码")
private String areaCode;
/**
* 居住小区编码
*/
@ApiModelProperty(value = "居住小区编码")
private String communityCode;
/**
* 用户编号
*/
@ApiModelProperty(value = "用户编号")
private String patientCode;
/**
* 用户姓名
*/
@NotNull(message = "用户姓名不能为空")
@NotBlank(message = "用户姓名不能为空")
@ApiModelProperty(value = "用户姓名")
private String patientName;
/**
* 身份证号
*/
@NotNull(message = "身份证号不能为空")
@NotBlank(message = "身份证号不能为空")
@ApiModelProperty(value = "身份证号")
private String cardNo;
/**
* sys_user表id
*/
@ApiModelProperty(value = "sys_user表id")
private Long userId;
/**
* 用户微信unionid
*/
@ApiModelProperty(value = "用户微信unionid")
private String unionid;
/**
* 用户微信openid
*/
@NotNull(message = "用户微信openid不能为空")
@NotBlank(message = "用户微信openid不能为空")
@ApiModelProperty(value = "用户微信openid")
private String openid;
/**
* 手机号码
*/
@NotNull(message = "手机号码不能为空")
@NotBlank(message = "手机号码不能为空")
@ApiModelProperty(value = "手机号码")
private String phone;
/**
* 居住地址
*/
@ApiModelProperty(value = "居住地址")
private String address;
/**
* 紧急联系人名称
*/
@ApiModelProperty(value = "紧急联系人名称")
private String urgentContactName;
/**
* 紧急联系人电话
*/
@ApiModelProperty(value = "紧急联系人电话")
private String urgentContactPhone;
/**
* 小区名称
*/
@ApiModelProperty(value = "小区名称")
private String communityAliasName;
/**
* 住址经度
*/
@ApiModelProperty(value = "住址经度")
private String homeLongitude;
/**
* 住址纬度
*/
@ApiModelProperty(value = "住址纬度")
private String homeLatitude;
/**
* 个人头像地址
*/
@ApiModelProperty(value = "个人头像地址")
private String headPictureUrl;
/**
* 登录密码
*/
@ApiModelProperty(value = "登录密码")
private String password;
/**
* 会员账户积分
*/
@ApiModelProperty(value = "会员账户积分")
private Long integral;
/**
* 完善标识记录当前用户是否第一次完善信息
*/
@ApiModelProperty(value = "完善标识,记录当前用户是否第一次完善信息")
private Long loginFlag;
/**
* 主账号标识0标识主账号1子账号
*/
@ApiModelProperty(value = "主账号标识0标识主账号1子账号")
private Integer primaryAccountFlag;
/**
* 所选服务id多个用逗号隔开
*/
@ApiModelProperty(value = "所选服务id多个用逗号隔开")
private String serviceIds;
/**
* 所在位置名称手机App和微信小程序所在位置名称
*/
@ApiModelProperty(value = "所在位置名称手机App和微信小程序所在位置名称")
private String locationName;
/**
* 会员注册来源好友邀请FRIEND_INVITATION自己搜索注册REGISTER_YOURSELF
*/
@ApiModelProperty(value = "会员注册来源好友邀请FRIEND_INVITATION自己搜索注册REGISTER_YOURSELF ")
private String source;
/**
* 邀请人id
*/
@ApiModelProperty(value = "邀请人id")
private Long invitationPatientId;
/**
* 会员累计签到天数
*/
@ApiModelProperty(value = "会员累计签到天数")
private Integer totalSignInDays;
/**
* 性别MALEFEMALE
*/
@ApiModelProperty(value = "性别MALEFEMALE")
private String sex;
/**
* 出生日期
*/
@ApiModelProperty(value = "出生日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthDate;
/**
* 是否删除标识01
*/
private Integer delFlag;
/**
* 小程序个人微信二维码图片存放地址
*/
@ApiModelProperty(value = "小程序个人微信二维码图片存放地址")
private String personalWechatCodeUrl;
/**
* 失能情况NOT_DISABLED未失能DISABLED已失能
*/
@ApiModelProperty(value = "失能情况NOT_DISABLED未失能DISABLED已失能")
private String disablingCondition;
/**
* 失能原因
*/
@ApiModelProperty(value = "失能原因")
private String disablingReason;
/**
* 绑定城市(1德州 2东营)
*/
@NotNull(message = "绑定城市不能为空")
@NotBlank(message = "绑定城市不能为空")
@ApiModelProperty(value = "绑定城市(1德州 2东营)")
private String cityCode;
/**
* 小程序绑定时间
*/
@ApiModelProperty(value = "小程序绑定时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date bindingTime;
/**
* 当前是否选中(0 1)
*/
@ApiModelProperty(value = "当前是否选中(0 否 1是)")
private String isChecked;
}

View File

@ -0,0 +1,23 @@
package com.xinelu.familydoctor.applet.pojo.body;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 积分兑换对象
* @Date 2023-09-21 021 17:53
* @Param
* @return
**/
@ApiModel("积分兑换传输对象")
@Data
public class PrizeExchangeBody {
@ApiModelProperty("居民身份证号")
private String identity;
@ApiModelProperty("奖品业务主键")
private String prizeId;
}

View File

@ -0,0 +1,321 @@
package com.xinelu.familydoctor.applet.pojo.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xinelu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import com.xinelu.common.annotation.Excel;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @Author mengkuiliang
* @Description 居民注册表
* @Date 2023-09-25 025 10:02
* @Param
* @return
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "居民注册表", description = "patient_info")
public class PatientInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private Long id;
/**
* 所属区域编码
*/
@ApiModelProperty(value = "所属区域编码")
@Excel(name = "所属区域编码")
private String areaCode;
/**
* 居住小区编码
*/
@ApiModelProperty(value = "居住小区编码")
@Excel(name = "居住小区编码")
private String communityCode;
/**
* 用户编号
*/
@ApiModelProperty(value = "用户编号")
@Excel(name = "用户编号")
private String patientCode;
/**
* 用户姓名
*/
@ApiModelProperty(value = "用户姓名")
@Excel(name = "用户姓名")
private String patientName;
/**
* 身份证号
*/
@ApiModelProperty(value = "身份证号")
@Excel(name = "身份证号")
private String cardNo;
/**
* sys_user表id
*/
@ApiModelProperty(value = "sys_user表id")
@Excel(name = "sys_user表id")
private Long userId;
/**
* 用户微信unionid
*/
@ApiModelProperty(value = "用户微信unionid")
@Excel(name = "用户微信unionid")
private String unionid;
/**
* 用户微信openid
*/
@ApiModelProperty(value = "用户微信openid")
@Excel(name = "用户微信openid")
private String openid;
/**
* 手机号码
*/
@ApiModelProperty(value = "手机号码")
@Excel(name = "手机号码")
private String phone;
/**
* 居住地址
*/
@ApiModelProperty(value = "居住地址")
@Excel(name = "居住地址")
private String address;
/**
* 紧急联系人名称
*/
@ApiModelProperty(value = "紧急联系人名称")
@Excel(name = "紧急联系人名称")
private String urgentContactName;
/**
* 紧急联系人电话
*/
@ApiModelProperty(value = "紧急联系人电话")
@Excel(name = "紧急联系人电话")
private String urgentContactPhone;
/**
* 小区名称
*/
@ApiModelProperty(value = "小区名称")
@Excel(name = "小区名称")
private String communityAliasName;
/**
* 住址经度
*/
@ApiModelProperty(value = "住址经度")
@Excel(name = "住址经度")
private String homeLongitude;
/**
* 住址纬度
*/
@ApiModelProperty(value = "住址纬度")
@Excel(name = "住址纬度")
private String homeLatitude;
/**
* 个人头像地址
*/
@ApiModelProperty(value = "个人头像地址")
@Excel(name = "个人头像地址")
private String headPictureUrl;
/**
* 登录密码
*/
@ApiModelProperty(value = "登录密码")
@Excel(name = "登录密码")
private String password;
/**
* 会员账户积分
*/
@ApiModelProperty(value = "会员账户积分")
@Excel(name = "会员账户积分")
private Long integral;
/**
* 完善标识记录当前用户是否第一次完善信息
*/
@ApiModelProperty(value = "完善标识,记录当前用户是否第一次完善信息")
@Excel(name = "完善标识,记录当前用户是否第一次完善信息")
private Long loginFlag;
/**
* 主账号标识0标识主账号1子账号
*/
@ApiModelProperty(value = "主账号标识0标识主账号1子账号")
@Excel(name = "主账号标识0标识主账号1子账号")
private Integer primaryAccountFlag;
/**
* 所选服务id多个用逗号隔开
*/
@ApiModelProperty(value = "所选服务id多个用逗号隔开")
@Excel(name = "所选服务id多个用逗号隔开")
private String serviceIds;
/**
* 所在位置名称手机App和微信小程序所在位置名称
*/
@ApiModelProperty(value = "所在位置名称手机App和微信小程序所在位置名称")
@Excel(name = "所在位置名称手机App和微信小程序所在位置名称")
private String locationName;
/**
* 会员注册来源好友邀请FRIEND_INVITATION自己搜索注册REGISTER_YOURSELF
*/
@ApiModelProperty(value = "会员注册来源好友邀请FRIEND_INVITATION自己搜索注册REGISTER_YOURSELF ")
@Excel(name = "会员注册来源好友邀请FRIEND_INVITATION自己搜索注册REGISTER_YOURSELF ")
private String source;
/**
* 邀请人id
*/
@ApiModelProperty(value = "邀请人id")
@Excel(name = "邀请人id")
private Long invitationPatientId;
/**
* 会员累计签到天数
*/
@ApiModelProperty(value = "会员累计签到天数")
@Excel(name = "会员累计签到天数")
private Integer totalSignInDays;
/**
* 性别MALEFEMALE
*/
@ApiModelProperty(value = "性别MALEFEMALE")
@Excel(name = "性别MALEFEMALE")
private String sex;
/**
* 出生日期
*/
@ApiModelProperty(value = "出生日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出生日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date birthDate;
/**
* 是否删除标识01
*/
private Integer delFlag;
/**
* 小程序个人微信二维码图片存放地址
*/
@ApiModelProperty(value = "小程序个人微信二维码图片存放地址")
@Excel(name = "小程序个人微信二维码图片存放地址")
private String personalWechatCodeUrl;
/**
* 失能情况NOT_DISABLED未失能DISABLED已失能
*/
@ApiModelProperty(value = "失能情况NOT_DISABLED未失能DISABLED已失能")
@Excel(name = "失能情况NOT_DISABLED未失能DISABLED已失能")
private String disablingCondition;
/**
* 失能原因
*/
@ApiModelProperty(value = "失能原因")
@Excel(name = "失能原因")
private String disablingReason;
/**
* 绑定城市(1德州 2东营)
*/
@ApiModelProperty(value = "绑定城市(1德州 2东营)")
@Excel(name = "绑定城市(1德州 2东营)")
private String cityCode;
/**
* 小程序绑定时间
*/
@ApiModelProperty(value = "小程序绑定时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "小程序绑定时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date bindingTime;
/**
* 当前是否选中(0 1)
*/
@ApiModelProperty(value = "当前是否选中(0 否 1是)")
@Excel(name = "当前是否选中(0 否 1是)")
private String isChecked;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("areaCode", getAreaCode())
.append("communityCode", getCommunityCode())
.append("patientCode", getPatientCode())
.append("patientName", getPatientName())
.append("cardNo", getCardNo())
.append("userId", getUserId())
.append("unionid", getUnionid())
.append("openid", getOpenid())
.append("phone", getPhone())
.append("address", getAddress())
.append("urgentContactName", getUrgentContactName())
.append("urgentContactPhone", getUrgentContactPhone())
.append("communityAliasName", getCommunityAliasName())
.append("homeLongitude", getHomeLongitude())
.append("homeLatitude", getHomeLatitude())
.append("headPictureUrl", getHeadPictureUrl())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("password", getPassword())
.append("integral", getIntegral())
.append("loginFlag", getLoginFlag())
.append("primaryAccountFlag", getPrimaryAccountFlag())
.append("serviceIds", getServiceIds())
.append("locationName", getLocationName())
.append("source", getSource())
.append("invitationPatientId", getInvitationPatientId())
.append("totalSignInDays", getTotalSignInDays())
.append("sex", getSex())
.append("birthDate", getBirthDate())
.append("delFlag", getDelFlag())
.append("personalWechatCodeUrl", getPersonalWechatCodeUrl())
.append("disablingCondition", getDisablingCondition())
.append("disablingReason", getDisablingReason())
.append("cityCode", getCityCode())
.append("bindingTime", getBindingTime())
.append("isChecked", getIsChecked())
.toString();
}
}

View File

@ -0,0 +1,54 @@
package com.xinelu.familydoctor.applet.pojo.query;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 居民健康行为查询类
* @Date 2023-09-21 17:36
* @Param
* @return
**/
@ApiModel("居民健康行为查询类")
@Data
public class DictHealthActQuery {
/**
* 行为序号
*/
@ApiModelProperty("行为序号")
private String actId;
@ApiModelProperty("适用人群")
private String targetGroups;
/**
* 行为名称
*/
@ApiModelProperty("行为名称")
private String actName;
/**
* 积分周期1月度2季度3年度
*/
@ApiModelProperty("积分周期1月度2季度3年度")
private String period;
@ApiModelProperty("居民身份证号")
private String identity;
/**
* 页码
*/
@ApiModelProperty("页码")
private Integer pageNum;
/**
* 页面大小
*/
@ApiModelProperty("页面大小")
private Integer pageSize;
}

View File

@ -0,0 +1,74 @@
package com.xinelu.familydoctor.applet.pojo.query;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xinelu.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @Author mengkuiliang
* @Description 居民注册查询对象
* @Date 2023-09-25 025 10:02
* @Param
* @return
**/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "居民注册查询对象")
public class PatientInfoQuery extends BaseEntity {
/**
* 用户姓名
*/
@ApiModelProperty(value = "用户姓名")
private String patientName;
/**
* 身份证号
*/
@ApiModelProperty(value = "身份证号")
private String cardNo;
/**
* 用户微信openid
*/
@ApiModelProperty(value = "用户微信openid")
private String openid;
/**
* 手机号码
*/
@ApiModelProperty(value = "手机号码")
private String phone;
/**
* 居住地址
*/
@ApiModelProperty(value = "居住地址")
private String address;
/**
* 绑定城市(1德州 2东营)
*/
@ApiModelProperty(value = "绑定城市(1德州 2东营)")
private String cityCode;
/**
* 小程序绑定时间
*/
@ApiModelProperty(value = "小程序绑定时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date bindingTime;
/**
* 当前是否选中(0 1)
*/
@ApiModelProperty(value = "当前是否选中(0 否 1是)")
private String isChecked;
}

View File

@ -0,0 +1,33 @@
package com.xinelu.familydoctor.applet.pojo.query;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description: 健康行为积分查询类
* @author: mengkuiliang
* @createDate: 2023-09-21 17:36
*/
@Api("健康行为积分查询类")
@Data
public class PatientScoreQuery {
/**
* 居民身份证号
*/
@ApiModelProperty("居民身份证号")
private String identity;
/**
* 页码
*/
@ApiModelProperty("页码")
private Integer pageNum;
/**
* 页面大小
*/
@ApiModelProperty("页面大小")
private Integer pageSize;
}

View File

@ -0,0 +1,32 @@
package com.xinelu.familydoctor.applet.pojo.query;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @description: 奖品查询传输实体类
* @author: mengkuiliang
* @create: 2023-09-21 17:36
**/
@ApiModel("奖品查询传输实体类")
@Data
public class PrizeQuery {
@ApiModelProperty("居民身份证号")
private String identity;
@ApiModelProperty("使用状态0未使用1已使用")
private String status;
/**
* 页码
*/
@ApiModelProperty("页码")
private Integer pageNum;
/**
* 页面大小
*/
@ApiModelProperty("页面大小")
private Integer pageSize;
}

View File

@ -0,0 +1,61 @@
package com.xinelu.familydoctor.applet.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 居民健康行为积分对象
* @Date 2023-09-21 021 17:37
* @Param
* @return
**/
@Data
public class DictHealthActVo {
/**
* 行为序号
*/
@ApiModelProperty("行为序号")
private String actId;
@ApiModelProperty("适用人群")
private String targetGroups;
/**
* 行为名称
*/
@ApiModelProperty("行为名称")
private String actName;
/**
* 具体内容
*/
@ApiModelProperty("具体内容")
private String actContent;
/**
* 积分分值
*/
@ApiModelProperty("积分分值")
private Integer score;
/**
* 积分周期1月度2季度3年度
*/
@ApiModelProperty("积分周期1月度2季度3年度")
private String period;
/**
* 年度总分
*/
@ApiModelProperty("年度总分")
private Integer totalScore;
/**
* 删除标志0未删除 1删除
*/
@ApiModelProperty(value = "删除标志0未删除 1删除", hidden = true)
private String delFlag;
}

View File

@ -0,0 +1,105 @@
package com.xinelu.familydoctor.applet.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @Author mengkuiliang
* @Description 居民健康行为积分记录表
* @Date 2023-09-21 021 17:37
* @Param
* @return
**/
@Data
public class PointRecordVo {
/**
* 主键
*/
private Long id;
/**
* 居民积分记录主键
*/
private String recordId;
/**
* 居民业务主键
*/
@ApiModelProperty("居民业务主键")
private String residentNo;
/**
* 行为序号
*/
@ApiModelProperty("行为序号")
private String actId;
/**
* 行为名称
*/
@ApiModelProperty("行为名称")
private String actName;
/**
* 积分分值
*/
@ApiModelProperty("积分分值")
private Integer score;
/**
* 积分日期
*/
@ApiModelProperty("积分日期")
private Date scoreDate;
/**
* 医生签字
*/
@ApiModelProperty("医生签字")
private String doctorSignature;
/**
* 行为累计分数
*/
@ApiModelProperty("行为累计分数")
private Integer aggregateScore;
/**
* 当前累计积分
*/
@ApiModelProperty("当前累计积分")
private Integer currentScore;
/**
*
*/
private String createBy;
/**
*
*/
private Date createTime;
/**
*
*/
private String updateBy;
/**
*
*/
private Date updateTime;
/**
* 删除标志0未删除 1删除
*/
private String delFlag;
/**
*
*/
private String remark;
}

View File

@ -0,0 +1,119 @@
package com.xinelu.familydoctor.applet.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @Author mengkuiliang
* @Description 积分兑换记录对象
* @Date 2023-09-21 021 17:38
* @Param
* @return
**/
@Data
public class PrizeExchangeVo {
/**
* 自增主键
*/
private Integer id;
/**
* 业务主键
*/
@ApiModelProperty("业务主键")
private String exchangeId;
/**
* 兑换码
*/
@ApiModelProperty("兑换码")
private String exchangeCode;
/**
* 居民业务主键
*/
@ApiModelProperty("居民业务主键")
private String residentNo;
/**
* 奖品业务主键
*/
@ApiModelProperty("奖品业务主键")
private String prizeId;
/**
* 奖品名称
*/
@ApiModelProperty("奖品名称")
private String prizeName;
/**
* 所需积分
*/
@ApiModelProperty("所需积分")
private Integer score;
/**
* 提供单位业务主键
*/
@ApiModelProperty("提供单位业务主键")
private String orgNo;
/**
* 提供单位名称
*/
@ApiModelProperty("提供单位名称")
private String orgName;
/**
* 兑换数量
*/
@ApiModelProperty("兑换数量")
private Integer exchangeNum;
/**
* 状态0未使用1已使用
*/
@ApiModelProperty("状态0未使用1已使用")
private String status;
/**
* 条形码
*/
@ApiModelProperty("条形码")
private String barCode;
/**
* 兑换时间
*/
@ApiModelProperty("兑换时间")
@JsonFormat(pattern ="yyyy-MM-dd HH:mm", timezone = "GMT+8")
private Date exchangeDate;
/**
* 使用时间
* */
@ApiModelProperty("使用时间")
@JsonFormat(pattern ="yyyy-MM-dd HH:mm", timezone = "GMT+8")
private Date useDate;
@ApiModelProperty("兑换医生业务主键")
private String doctorId;
@ApiModelProperty("兑换医生姓名")
private String doctorName;
/**
* 删除标志0未删除 1删除
*/
@ApiModelProperty("删除标志0未删除 1删除")
private String delFlag;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,70 @@
package com.xinelu.familydoctor.applet.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author mengkuiliang
* @Description 奖品对象
* @Date 2023-09-21 021 17:38
* @Param
* @return
**/
@Data
public class PrizeVo {
/**
* 自增主键
*/
private Integer id;
/**
* 业务主键
*/
@ApiModelProperty("业务主键")
private String prizeId;
/**
* 奖品类型 1物品 2服务
* */
@ApiModelProperty("奖品类型 1物品 2服务")
private String prizeCategory;
/**
* 奖品名称
*/
@ApiModelProperty("奖品名称")
private String prizeName;
/**
* 所需积分
*/
@ApiModelProperty("所需积分")
private String score;
/**
* 提供单位业务主键
*/
@ApiModelProperty("提供单位业务主键")
private String orgNo;
/**
* 提供单位名称
*/
@ApiModelProperty("提供单位名称")
private String orgName;
/**
* 库存数量
*/
@ApiModelProperty("库存数量")
private Integer stock;
/**
* 附件
*/
@ApiModelProperty("附件")
private String attachment;
}

View File

@ -0,0 +1,97 @@
package com.xinelu.familydoctor.applet.service;
import com.xinelu.familydoctor.applet.pojo.body.PatientInfoBody;
import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo;
import com.xinelu.familydoctor.applet.pojo.query.PatientInfoQuery;
import java.util.List;
/**
* 小程序注册Service接口
*
* @author xinelu
* @date 2023-09-25
*/
public interface IPatientInfoService {
/**
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
* @Author mengkuiliang
* @Description 获取注册详细信息
* @Date 2023-09-21 021 9:44
* @Param [registerCode]
**/
public PatientInfo selectPatientInfoByCode(String patientCode);
/**
* @return int
* @Author mengkuiliang
* @Description 修改
* @Date 2023-09-21 021 10:54
* @Param [patientInfo]
**/
public int updatePatientInfo(PatientInfo body);
/**
* @return void
* @Author mengkuiliang
* @Description 获取OpenId
* @Date 2023-09-21 021 9:18
* @Param []
**/
String getOpenId(String code) throws Exception;
/**
* @return java.lang.String
* @Author mengkuiliang
* @Description 身份证号是否已注册
* @Date 2023-09-21 021 10:00
* @Param [openId]
**/
PatientInfo isRegisterByCardNo(String cardNo);
/**
* @return void
* @Author mengkuiliang
* @Description 注册
* @Date 2023-09-21 021 10:13
* @Param [body]
**/
void register(PatientInfoBody body) throws Exception;
/**
* @return void
* @Author mengkuiliang
* @Description 解绑
* @Date 2023-09-21 021 10:50
* @Param [cardNo]
**/
void unbinding(String patientCode);
/**
* @Author mengkuiliang
* @Description 获取已注册列表
* @Date 2023-09-21 021 14:51
* @Param [openid]
* @return java.lang.String
**/
List<PatientInfo> getList(String openid, String cityCode);
/**
* @Author mengkuiliang
* @Description 切换账号
* @Date 2023-09-21 021 15:17
* @Param [registerCode]
* @return void
**/
PatientInfo switchResident(String openid, String patientCode);
/**
* @Author mengkuiliang
* @Description 获取当前注册居民
* @Date 2023-09-25 025 15:28
* @Param [openid]
* @return java.lang.String
**/
PatientInfo getCurrentResident(String openid, String cityCode);
}

View File

@ -0,0 +1,231 @@
package com.xinelu.familydoctor.applet.service.impl;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSONObject;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.common.utils.bean.BeanUtils;
import com.xinelu.common.utils.http.HttpUtils;
import com.xinelu.common.utils.http.SslUtils;
import com.xinelu.common.utils.uuid.IdUtils;
import com.xinelu.familydoctor.applet.mapper.PatientInfoMapper;
import com.xinelu.familydoctor.applet.pojo.body.PatientInfoBody;
import com.xinelu.familydoctor.applet.pojo.entity.PatientInfo;
import com.xinelu.familydoctor.applet.service.IPatientInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 小程序注册Service业务层处理
*
* @author xinelu
* @date 2023-09-25
*/
@Service
@Slf4j
public class PatientInfoServiceImpl implements IPatientInfoService {
@Resource
private PatientInfoMapper patientInfoMapper;
@Value("${applet.wxAppid}")
private String WX_APPID;
@Value("${applet.wxSecret}")
private String WX_SECRET;
@Value("${applet.grantType}")
private String GRANTTYPE;
@Value("${applet.openIDUrl}")
private String OPENID_URL;
/**
* @return com.xinelu.familydoctor.applet.pojo.entity.PatientInfo
* @Author mengkuiliang
* @Description 获取注册详细信息
* @Date 2023-09-21 021 9:44
* @Param [registerCode]
**/
@Override
public PatientInfo selectPatientInfoByCode(String patientCode) {
return patientInfoMapper.selectPatientInfoByCode(patientCode);
}
/**
* @return int
* @Author mengkuiliang
* @Description 修改注册信息
* @Date 2023-09-21 021 10:53
* @Param [patientInfo]
**/
@Override
public int updatePatientInfo(PatientInfo body) {
return patientInfoMapper.updatePatientInfo(body);
}
/**
* @return java.lang.String
* @Author mengkuiliang
* @Description 获取OpenId
* @Date 2023-09-21 021 9:19
* @Param []
**/
@Override
public String getOpenId(String code) {
try {
SslUtils.ignoreSsl();
String params = "appid=" + WX_APPID + "&secret=" + WX_SECRET + "&js_code=" + code + "&grant_type=" + GRANTTYPE;
log.info("获取openID请求参数{}", params);
String result = HttpUtils.sendPost(OPENID_URL, params);
JSONObject json = JSONObject.parseObject(result);
// {"errcode":40029,"errmsg":"invalid code, rid: 650bf9c3-31a6c960-2b437029"}
log.info("获取openID响应结果{}", json.toJSONString());
if (!json.containsKey("openid")) {
throw new ServiceException(json.getString("errmsg"));
}
return json.getString("openid");
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* @return java.lang.String
* @Author mengkuiliang
* @Description 身份证号是否已注册
* @Date 2023-09-21 021 10:00
* @Param [openId]
**/
public PatientInfo isRegisterByCardNo(String cardNo) {
return patientInfoMapper.isRegisterByCardNo(cardNo);
}
/**
* @return void
* @Author mengkuiliang
* @Description 注册
* @Date 2023-09-21 021 10:14
* @Param [body]
**/
@Override
public void register(PatientInfoBody body) {
// 获取当前微信绑定的居民
List<PatientInfo> list = patientInfoMapper.getList(body.getOpenid(), body.getCityCode());
PatientInfo patientInfo = patientInfoMapper.isRegisterByCardNo(body.getCardNo());
if (patientInfo == null) {
PatientInfo entity = new PatientInfo();
BeanUtils.copyBeanProp(entity, body);
entity.setPatientCode(IdUtils.fastSimpleUUID());
entity.setBindingTime(new Date());
entity.setIsChecked((list == null || list.size() == 0) ? "1" : "0");
entity.setCreateTime(new Date());
entity.setCreateBy(body.getCardNo());
patientInfoMapper.insertPatientInfo(entity);
} else {
if (!StringUtils.isBlank(patientInfo.getOpenid())) {
throw new ServiceException("该身份证号已被注册");
}
patientInfo.setIsChecked((list == null || list.size() == 0) ? "1" : "0");
patientInfo.setOpenid(body.getOpenid());
patientInfo.setUnionid(body.getUnionid());
patientInfo.setPatientName(body.getPatientName());
patientInfo.setPhone(body.getPhone());
patientInfo.setAddress(body.getAddress());
patientInfo.setUpdateTime(new Date());
patientInfo.setUpdateBy(body.getCardNo());
patientInfo.setHeadPictureUrl(body.getHeadPictureUrl());
patientInfo.setDelFlag(0);
patientInfoMapper.updatePatientInfo(patientInfo);
}
}
/**
* @return void
* @Author mengkuiliang
* @Description 解绑
* @Date 2023-09-21 021 10:50
* @Param [cardNo]
**/
@Override
public void unbinding(String patientCode) {
PatientInfo register = patientInfoMapper.selectPatientInfoByCode(patientCode);
if (register == null || StringUtils.isBlank(register.getOpenid())) {
return;
}
register.setIsChecked("0");
register.setOpenid("");
register.setUpdateTime(new Date());
register.setUpdateBy(register.getCreateBy());
patientInfoMapper.updatePatientInfo(register);
}
/**
* @return java.lang.String
* @Author mengkuiliang
* @Description 获取已注册列表
* @Date 2023-09-21 021 14:52
* @Param [openid]
**/
@Override
public List<PatientInfo> getList(String openid, String cityCode) {
return patientInfoMapper.getList(openid, cityCode);
}
/**
* @return void
* @Author mengkuiliang
* @Description 切换账号
* @Date 2023-09-21 021 15:18
* @Param [registerCode]
**/
@Override
public PatientInfo switchResident(String openid, String patientCode) {
PatientInfo register = patientInfoMapper.selectPatientInfoByCode(patientCode);
if (register == null) {
throw new ServiceException("该账号未注册不能切换");
} else {
if (StringUtils.isBlank(register.getOpenid())) {
throw new ServiceException("该账号未注册不能切换");
}
if (!openid.equals(register.getOpenid())) {
throw new ServiceException("该账号已被其他人绑定不能切换");
}
patientInfoMapper.switchResident(openid, patientCode);
}
return patientInfoMapper.selectPatientInfoByCode(patientCode);
}
/**
* @return java.lang.String
* @Author mengkuiliang
* @Description 获取当前注册居民
* @Date 2023-09-25 025 15:29
* @Param [openid]
**/
@Override
public PatientInfo getCurrentResident(String openid, String cityCode) {
List<PatientInfo> list = patientInfoMapper.getList(openid, cityCode);
if (list == null || list.size() == 0) {
return null;
}
// 获取当前选中的
List<PatientInfo> currentList = list.stream().filter(p -> p.getIsChecked().equals("1")).collect(Collectors.toList());
if (currentList.size() > 0) {
return currentList.get(0);
} else {
// 没有已选择的则取最新注册的一条数据
// 更新选择标识
patientInfoMapper.updateChecked(list.get(0).getPatientCode(), "1");
list.get(0).setIsChecked("1");
return list.get(0);
}
}
}

View File

@ -0,0 +1,439 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xinelu.familydoctor.applet.mapper.PatientInfoMapper">
<resultMap type="com.xinelu.familydoctor.applet.pojo.entity.PatientInfo" id="PatientInfoResult">
<result property="id" column="id"/>
<result property="areaCode" column="area_code"/>
<result property="communityCode" column="community_code"/>
<result property="patientCode" column="patient_code"/>
<result property="patientName" column="patient_name"/>
<result property="cardNo" column="card_no"/>
<result property="userId" column="user_id"/>
<result property="unionid" column="unionid"/>
<result property="openid" column="openid"/>
<result property="phone" column="phone"/>
<result property="address" column="address"/>
<result property="urgentContactName" column="urgent_contact_name"/>
<result property="urgentContactPhone" column="urgent_contact_phone"/>
<result property="communityAliasName" column="community_alias_name"/>
<result property="homeLongitude" column="home_longitude"/>
<result property="homeLatitude" column="home_latitude"/>
<result property="headPictureUrl" column="head_picture_url"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="password" column="password"/>
<result property="integral" column="integral"/>
<result property="loginFlag" column="login_flag"/>
<result property="primaryAccountFlag" column="primary_account_flag"/>
<result property="serviceIds" column="service_ids"/>
<result property="locationName" column="location_name"/>
<result property="source" column="source"/>
<result property="invitationPatientId" column="invitation_patient_id"/>
<result property="totalSignInDays" column="total_sign_in_days"/>
<result property="sex" column="sex"/>
<result property="birthDate" column="birth_date"/>
<result property="delFlag" column="del_flag"/>
<result property="personalWechatCodeUrl" column="personal_wechat_code_url"/>
<result property="disablingCondition" column="disabling_condition"/>
<result property="disablingReason" column="disabling_reason"/>
<result property="cityCode" column="city_code"/>
<result property="bindingTime" column="binding_time"/>
<result property="isChecked" column="is_checked"/>
</resultMap>
<sql id="selectPatientInfoVo">
select id,
area_code,
community_code,
patient_code,
patient_name,
card_no,
user_id,
unionid,
openid,
phone,
address,
urgent_contact_name,
urgent_contact_phone,
community_alias_name,
home_longitude,
home_latitude,
head_picture_url,
create_by,
create_time,
update_by,
update_time,
password,
integral,
login_flag,
primary_account_flag,
service_ids,
location_name,
source,
invitation_patient_id,
total_sign_in_days,
sex,
birth_date,
del_flag,
personal_wechat_code_url,
disabling_condition,
disabling_reason,
city_code,
binding_time,
is_checked
from patient_info
</sql>
<select id="selectPatientInfoList" parameterType="com.xinelu.familydoctor.applet.pojo.entity.PatientInfo"
resultMap="PatientInfoResult">
<include refid="selectPatientInfoVo"/>
<where>
<if test="patientName != null and patientName != ''">
and patient_name like concat('%', #{patientName}, '%')
</if>
<if test="cardNo != null and cardNo != ''">
and card_no = #{cardNo}
</if>
<if test="openid != null and openid != ''">
and openid = #{openid}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="address != null and address != ''">
and address = #{address}
</if>
<if test="cityCode != null and cityCode != ''">
and city_code = #{cityCode}
</if>
<if test="bindingTime != null ">
and binding_time = #{bindingTime}
</if>
<if test="isChecked != null and isChecked != ''">
and is_checked = #{isChecked}
</if>
</where>
order by binding_time desc
</select>
<insert id="insertPatientInfo" parameterType="com.xinelu.familydoctor.applet.pojo.entity.PatientInfo"
useGeneratedKeys="true"
keyProperty="id">
insert into patient_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaCode != null">area_code,
</if>
<if test="communityCode != null">community_code,
</if>
<if test="patientCode != null">patient_code,
</if>
<if test="patientName != null">patient_name,
</if>
<if test="cardNo != null">card_no,
</if>
<if test="userId != null">user_id,
</if>
<if test="unionid != null">unionid,
</if>
<if test="openid != null">openid,
</if>
<if test="phone != null">phone,
</if>
<if test="address != null">address,
</if>
<if test="urgentContactName != null">urgent_contact_name,
</if>
<if test="urgentContactPhone != null">urgent_contact_phone,
</if>
<if test="communityAliasName != null">community_alias_name,
</if>
<if test="homeLongitude != null">home_longitude,
</if>
<if test="homeLatitude != null">home_latitude,
</if>
<if test="headPictureUrl != null">head_picture_url,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="password != null">password,
</if>
<if test="integral != null">integral,
</if>
<if test="loginFlag != null">login_flag,
</if>
<if test="primaryAccountFlag != null">primary_account_flag,
</if>
<if test="serviceIds != null">service_ids,
</if>
<if test="locationName != null">location_name,
</if>
<if test="source != null">source,
</if>
<if test="invitationPatientId != null">invitation_patient_id,
</if>
<if test="totalSignInDays != null">total_sign_in_days,
</if>
<if test="sex != null">sex,
</if>
<if test="birthDate != null">birth_date,
</if>
<if test="delFlag != null">del_flag,
</if>
<if test="personalWechatCodeUrl != null">personal_wechat_code_url,
</if>
<if test="disablingCondition != null">disabling_condition,
</if>
<if test="disablingReason != null">disabling_reason,
</if>
<if test="cityCode != null and cityCode != ''">city_code,
</if>
<if test="bindingTime != null">binding_time,
</if>
<if test="isChecked != null">is_checked,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="areaCode != null">#{areaCode},
</if>
<if test="communityCode != null">#{communityCode},
</if>
<if test="patientCode != null">#{patientCode},
</if>
<if test="patientName != null">#{patientName},
</if>
<if test="cardNo != null">#{cardNo},
</if>
<if test="userId != null">#{userId},
</if>
<if test="unionid != null">#{unionid},
</if>
<if test="openid != null">#{openid},
</if>
<if test="phone != null">#{phone},
</if>
<if test="address != null">#{address},
</if>
<if test="urgentContactName != null">#{urgentContactName},
</if>
<if test="urgentContactPhone != null">#{urgentContactPhone},
</if>
<if test="communityAliasName != null">#{communityAliasName},
</if>
<if test="homeLongitude != null">#{homeLongitude},
</if>
<if test="homeLatitude != null">#{homeLatitude},
</if>
<if test="headPictureUrl != null">#{headPictureUrl},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="password != null">#{password},
</if>
<if test="integral != null">#{integral},
</if>
<if test="loginFlag != null">#{loginFlag},
</if>
<if test="primaryAccountFlag != null">#{primaryAccountFlag},
</if>
<if test="serviceIds != null">#{serviceIds},
</if>
<if test="locationName != null">#{locationName},
</if>
<if test="source != null">#{source},
</if>
<if test="invitationPatientId != null">#{invitationPatientId},
</if>
<if test="totalSignInDays != null">#{totalSignInDays},
</if>
<if test="sex != null">#{sex},
</if>
<if test="birthDate != null">#{birthDate},
</if>
<if test="delFlag != null">#{delFlag},
</if>
<if test="personalWechatCodeUrl != null">#{personalWechatCodeUrl},
</if>
<if test="disablingCondition != null">#{disablingCondition},
</if>
<if test="disablingReason != null">#{disablingReason},
</if>
<if test="cityCode != null and cityCode != ''">#{cityCode},
</if>
<if test="bindingTime != null">#{bindingTime},
</if>
<if test="isChecked != null">#{isChecked},
</if>
</trim>
</insert>
<update id="updatePatientInfo" parameterType="com.xinelu.familydoctor.applet.pojo.entity.PatientInfo">
update patient_info
<trim prefix="SET" suffixOverrides=",">
<if test="areaCode != null">
area_code = #{areaCode},
</if>
<if test="communityCode != null">community_code =
#{communityCode},
</if>
<if test="patientName != null">patient_name =
#{patientName},
</if>
<if test="cardNo != null">card_no =
#{cardNo},
</if>
<if test="userId != null">user_id =
#{userId},
</if>
<if test="unionid != null">unionid =
#{unionid},
</if>
<if test="openid != null">openid =
#{openid},
</if>
<if test="phone != null">phone =
#{phone},
</if>
<if test="address != null">address =
#{address},
</if>
<if test="urgentContactName != null">urgent_contact_name =
#{urgentContactName},
</if>
<if test="urgentContactPhone != null">urgent_contact_phone =
#{urgentContactPhone},
</if>
<if test="communityAliasName != null">community_alias_name =
#{communityAliasName},
</if>
<if test="homeLongitude != null">home_longitude =
#{homeLongitude},
</if>
<if test="homeLatitude != null">home_latitude =
#{homeLatitude},
</if>
<if test="headPictureUrl != null">head_picture_url =
#{headPictureUrl},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="password != null">password =
#{password},
</if>
<if test="integral != null">integral =
#{integral},
</if>
<if test="loginFlag != null">login_flag =
#{loginFlag},
</if>
<if test="primaryAccountFlag != null">primary_account_flag =
#{primaryAccountFlag},
</if>
<if test="serviceIds != null">service_ids =
#{serviceIds},
</if>
<if test="locationName != null">location_name =
#{locationName},
</if>
<if test="source != null">source =
#{source},
</if>
<if test="invitationPatientId != null">invitation_patient_id =
#{invitationPatientId},
</if>
<if test="totalSignInDays != null">total_sign_in_days =
#{totalSignInDays},
</if>
<if test="sex != null">sex =
#{sex},
</if>
<if test="birthDate != null">birth_date =
#{birthDate},
</if>
<if test="delFlag != null">del_flag =
#{delFlag},
</if>
<if test="personalWechatCodeUrl != null">personal_wechat_code_url =
#{personalWechatCodeUrl},
</if>
<if test="disablingCondition != null">disabling_condition =
#{disablingCondition},
</if>
<if test="disablingReason != null">disabling_reason =
#{disablingReason},
</if>
<if test="cityCode != null and cityCode != ''">city_code =
#{cityCode},
</if>
<if test="bindingTime != null">binding_time =
#{bindingTime},
</if>
<if test="isChecked != null">is_checked =
#{isChecked},
</if>
</trim>
where patient_code = #{patientCode}
</update>
<!-- 获取注册详细信息 -->
<select id="selectPatientInfoByCode" parameterType="String"
resultMap="PatientInfoResult">
<include refid="selectPatientInfoVo"/>
where patient_code = #{patientCode} limit 1
</select>
<!-- 身份证号是否已注册 -->
<select id="isRegisterByCardNo" resultMap="PatientInfoResult">
<include refid="selectPatientInfoVo"/>
where card_no = #{cardNo} limit 1
</select>
<!-- 获取已注册列表 -->
<select id="getList" resultType="com.xinelu.familydoctor.applet.pojo.entity.PatientInfo">
<include refid="selectPatientInfoVo"/>
where openid = #{openid} and del_flag = 0
<if test="cityCode != null and cityCode != '' and cityCode != 'null'">
and city_code = #{cityCode}
</if>
order by binding_time desc
</select>
<!-- 切换账号 -->
<update id="switchResident">
update patient_info
set is_checked = (case when patient_code = #{patientCode} then '1' else '0' end)
where openid = #{openid}
</update>
<!-- 更新选中标识 -->
<update id="updateChecked">
update patient_info set is_checked = #{isChecked} where patient_code = #{patientCode}
</update>
</mapper>

View File

@ -72,6 +72,12 @@
<artifactId>xinelu-system</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>
</dependencies>
</project>
</project>

View File

@ -0,0 +1,22 @@
package com.xinelu.framework.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class HttpConfig {
/**
* 超时时间
*/
private int TIMEOUT = 1 * 60 * 1000;
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(TIMEOUT);
requestFactory.setReadTimeout(TIMEOUT);
return new RestTemplate();
}
}

View File

@ -0,0 +1,78 @@
package com.xinelu.framework.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.builders.RequestParameterBuilder;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* swagger2接口文档配置
*/
@Configuration
@EnableKnife4j
@EnableSwagger2
@Import(BeanValidatorPluginsConfiguration.class)
public class Knife4jConfig {
@Value("${token.header}")
private String tokenHeader;
@Value("${spring.profiles.active}")
private String profile;
@Value("${swagger-ui.base-url}")
private String swaggerUrl;
@Bean
public Docket docket(Environment environment) {
Profiles profiles = Profiles.of(profile);
RequestParameterBuilder tokenPar = new RequestParameterBuilder();
List<RequestParameter> pars = new ArrayList<>();
tokenPar.name(tokenHeader).in(ParameterType.HEADER).description("令牌").required(false).build();
pars.add(tokenPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.enable(environment.acceptsProfiles(profiles))
.apiInfo(apiInfo())
.securityContexts(Collections.singletonList(securityContext()))
.securitySchemes(Collections.singletonList(apiKey()))
.select()
.paths(PathSelectors.any())
.apis(RequestHandlerSelectors.basePackage(swaggerUrl))
.build()
.globalRequestParameters(pars);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().version("v3.0.0")
.title("新医路平台接口文档")
.build();
}
private ApiKey apiKey() {
return new ApiKey("token令牌", "Authorization", "header");
}
private SecurityContext securityContext() {
return SecurityContext.builder().securityReferences(securityReferences()).build();
}
private List<SecurityReference> securityReferences() {
AuthorizationScope[] scopes = {new AuthorizationScope("global", "accessEverything")};
return Collections.singletonList(new SecurityReference("token令牌", scopes));
}
}

View File

@ -5,6 +5,7 @@ import com.xinelu.framework.security.filter.JwtAuthenticationTokenFilter;
import com.xinelu.framework.security.handle.AuthenticationEntryPointImpl;
import com.xinelu.framework.security.handle.LogoutSuccessHandlerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
@ -65,6 +66,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private PermitAllUrlProperties permitAllUrl;
@Value("${token.ant-matchers}")
private String antMatchers;
/**
* 解决 无法直接注入 AuthenticationManager
*
@ -112,6 +116,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// 静态资源可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**", "/applet/test/**", "/nurseApplet/**", "/nurseApp/**").permitAll()
.antMatchers(antMatchers.split(",")).permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
.and()