Commit 0fe262fc authored by wanglianxi's avatar wanglianxi

初版

parents
# http://editorconfig.org
root = true
# 空格替代Tab缩进在各种编辑工具下效果一致
[*]
indent_style = space
indent_size = 4
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
[*.java]
indent_style = tab
[*.{json,yml}]
indent_size = 2
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
# maven #
target
logs
# windows #
Thumbs.db
# Mac #
.DS_Store
# eclipse #
.settings
.project
.classpath
.log
*.class
# idea #
.idea
*.iml
# Package Files #
*.jar
*.war
*.ear
/target
BladeX商业授权许可协议
一、 知识产权:
BladeX系列产品知识产权归上海布雷德网络科技独立所有
二、 许可:
1. 在您完全接受并遵守本协议的基础上,本协议授予您使用BladeX的某些权利和非独占性许可。
2. 本协议中,将本产品使用用途分为“专业版用途”和“企业版用途”。
3. “专业版用途”定义:指个人在非团体机构中出于任何目的使用本产品(任何目的包括商业目的或非盈利目的)。
4. “企业版用途”定义:指团体机构(例如公司企业、政府、学校、军队、医院、社会团体等各类组织)(不包含集团,若集团使用则需为各个子公司分别购买企业授权)出于任何目的使用本产品(任何目的包括商业目的或非盈利目的)。
三、 约束和限制:
1. 本产品只能由您为本协议许可的目的而使用,您不得透露给任何第三方;
2. 从本产品取得的任何信息、软件、产品或服务,您不得对其进行修改、改编或基于以上内容创建同种类别的衍生产品并售卖。
3. 您不得对本产品以及与之关联的商业授权进行发布、出租、销售、分销、抵押、转让、许可或发放子许可证。
4. 本产品商业授权版可能包含一些独立功能或特性,这些功能只有在您购买商业授权后才可以使用。在未取得商业授权的情况下,您不得使用、尝试使用或复制这些授权版独立功能。
5. 若您的客户要求以源码方式交付软件,需缴纳企业版授权费用,否则本产品部分不得提供源码。
四、 不得用于非法或禁止的用途:
您在使用本产品或服务时,不得将本产品产品或服务用于任何非法用途或本协议条款、条件和声明禁止的用途。
五、 免责说明:
1. 本产品按“现状”授予许可,您须自行承担使用本产品的风险。BladeX团队不对此提供任何明示、暗示或任何其它形式的担保和表示。在任何情况下,对于因使用或无法使用本软件而导致的任何损失(包括但不仅限于商业利润损失、业务中断或业务信息丢失),BladeX团队无需向您或任何第三方负责,即使BladeX团队已被告知可能会造成此类损失。在任何情况下, BladeX团队均不就任何直接的、间接的、附带的、后果性的、特别的、惩戒性的和处罚性的损害赔偿承担任何责任,无论该主张是基于保证、合同、侵权(包括疏忽)或是基于其他原因作出。
2. 本产品可能内置有第三方服务,您应自行评估使用这些第三方服务的风险,由使用此类第三方服务而产生的纠纷,全部责任由您自行承担。
3. BladeX团队不对使用本产品构建的网站中任何信息内容以及导致的任何版权纠纷、法律争议和后果承担任何责任,全部责任由您自行承担。
4. BladeX团队可能会经常提供产品更新或升级,但BladeX团队没有为根据本协议许可的产品提供维护或更新的责任。
六、 权利和所有权的保留:
BladeX团队保留所有未在本协议中明确授予您的所有权利。BladeX团队保留随时更新本协议的权利,并只需公示于对应产品项目的LICENSE文件,无需征得您的事先同意且无需另行通知,更新后的内容应于公示即时生效。您可以随时访问产品地址并查阅最新版许可条款,在更新生效后您继续使用本产品则被视作您已接受了新的条款。
七、 协议终止
1. 您一旦开始复制、下载、安装或者使用本产品,即被视为完全理解并接受本协议的各项条款,在享有上述条款授予的许可权力同时,也受到相关的约束和限制,本协议许可范围以外的行为,将直接违反本协议并构成侵权。
2. 一旦您违反本协议的条款,BladeX团队随时可能终止本协议、收回许可和授权,并要求您承担相应法律和经济责任。
## 版权声明
* BladeX是一个商业化软件,系列产品知识产权归**上海布雷德网络科技**独立所有
* 您一旦开始复制、下载、安装或者使用本产品,即被视为完全理解并接受本协议的各项条款
* 更多详情请看:[BladeX商业授权许可协议](/LICENSE)
## 答疑流程
>1. 遇到问题或Bug
>2. 业务型问题打断点调试尝试找出问题所在
>3. 系统型问题通过百度、谷歌、社区查找解决方案
>4. 未解决问题则进入技术社区进行发帖提问:[https://sns.bladex.vip/](https://sns.bladex.vip/)
>5. 将帖子地址发至商业群,特别简单三言两语就能描述清楚的也可在答疑时间内发至商业群提问
>6. 发帖的时候一定要描述清楚,详细描述遇到问题的**重现步骤**、**报错详细信息**、**相关代码与逻辑**、**使用软件版本**以及**操作系统版本**,否则随意发帖提问将会提高我们的答疑难度。
## 答疑时间
* 工作日:9:00 ~ 17:00 提供答疑,周末、节假日休息,暂停答疑
* 请勿**私聊提问**,以免被其他用户的消息覆盖从而无法获得答疑
* 答疑时间外遇到问题可以将问题发帖至[技术社区](https://sns.bladex.vip/),我们后续会逐个回复
## 授权范围
* 专业版:只可用于**个人学习****个人私活**项目,不可用于公司或团队,不可泄露给任何第三方
* 企业版:可用于**企业名下**的任何项目,企业版员工在**未购买**专业版授权前,只授权开发**所在授权企业名下**的项目,**不得将BladeX用于个人私活**
* 共同遵守:若甲方需要您提供项目源码,则需代为甲方购买BladeX企业授权,甲方购买后续的所有项目都无需再次购买授权
## 商用权益
* ✔️ 遵守[商业协议](/LICENSE)的前提下,将BladeX系列产品用于授权范围内的商用项目,并上线运营
* ✔️ 遵守[商业协议](/LICENSE)的前提下,不限制项目数,不限制服务器数
* ✔️ 遵守[商业协议](/LICENSE)的前提下,将自行编写的业务代码申请软件著作权
## 何为侵权
* ❌ 不遵守商业协议,私自销售商业源码
* ❌ 以任何理由将BladeX源码用于申请软件著作权
* ❌ 将商业源码以任何途径任何理由泄露给未授权的单位或个人
* ❌ 开发完毕项目,没有为甲方购买企业授权,向甲方提供了BladeX代码
* ❌ 基于BladeX拓展研发与BladeX有竞争关系的衍生框架,并将其开源或销售
## 侵权后果
* 情节较轻:第一次发现警告处理
* 情节较重:封禁账号,踢出商业群,并保留追究法律责任的权利
* 情节严重:与本地律师事务所合作,以公司名义起诉侵犯计算机软件著作权
## 举报有奖
* 向官方提供有用线索并成功捣毁盗版个人或窝点,将会看成果给予 500~10000 不等的现金奖励
* 官方唯一指定QQ:1272154962
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-common</artifactId>
<name>${project.artifactId}</name>
<version>${bladex.project.version}</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-launch</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-auto</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.cache;
/**
* 缓存名
*
* @author Chill
*/
public interface CacheNames {
String NOTICE_ONE = "blade:notice:one";
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.config;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
/**
* 公共封装包配置类
*
* @author Chill
*/
@Configuration
@AllArgsConstructor
public class BladeCommonConfiguration {
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.constant;
/**
* 通用常量
*
* @author Chill
*/
public interface CommonConstant {
/**
* sword 系统名
*/
String SWORD_NAME = "sword";
/**
* saber 系统名
*/
String SABER_NAME = "saber";
/**
* 顶级父节点id
*/
Integer TOP_PARENT_ID = 0;
/**
* 顶级父节点名称
*/
String TOP_PARENT_NAME = "顶级";
/**
* 默认密码
*/
String DEFAULT_PASSWORD = "123456";
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.constant;
import org.springblade.core.launch.constant.AppConstant;
import static org.springblade.core.launch.constant.AppConstant.APPLICATION_NAME_PREFIX;
/**
* 启动常量
*
* @author Chill
*/
public interface LauncherConstant {
/**
* xxljob
*/
String APPLICATION_XXLJOB_NAME = APPLICATION_NAME_PREFIX + "xxljob";
/**
* xxljob
*/
String APPLICATION_XXLJOB_ADMIN_NAME = APPLICATION_NAME_PREFIX + "xxljob-admin";
/**
* nacos dev 地址
*/
String NACOS_DEV_ADDR = "182.92.221.124:8848";
/**
* nacos prod 地址
*/
String NACOS_PROD_ADDR = "172.17.45.176:8848";
/**
* nacos test 地址
*/
String NACOS_TEST_ADDR = "172.17.45.176:8848";
/**
* sentinel dev 地址
*/
String SENTINEL_DEV_ADDR = "182.92.221.124:8858";
/**
* sentinel prod 地址
*/
String SENTINEL_PROD_ADDR = "172.17.45.176:8858";
/**
* sentinel test 地址
*/
String SENTINEL_TEST_ADDR = "172.17.45.176:8858";
/**
* seata dev 地址
*/
String SEATA_DEV_ADDR = "127.0.0.1:8091";
/**
* seata prod 地址
*/
String SEATA_PROD_ADDR = "172.30.0.68:8091";
/**
* seata test 地址
*/
String SEATA_TEST_ADDR = "172.30.0.68:8091";
/**
* zipkin dev 地址
*/
String ZIPKIN_DEV_ADDR = "http://127.0.0.1:9411";
/**
* zipkin prod 地址
*/
String ZIPKIN_PROD_ADDR = "http://172.30.0.71:9411";
/**
* zipkin test 地址
*/
String ZIPKIN_TEST_ADDR = "http://172.30.0.71:9411";
/**
* elk dev 地址
*/
String ELK_DEV_ADDR = "127.0.0.1:9000";
/**
* elk prod 地址
*/
String ELK_PROD_ADDR = "172.30.0.72:9000";
/**
* elk test 地址
*/
String ELK_TEST_ADDR = "172.30.0.72:9000";
/**
* seata file模式
*/
String FILE_MODE = "file";
/**
* seata nacos模式
*/
String NACOS_MODE = "nacos";
/**
* seata default模式
*/
String DEFAULT_MODE = "default";
/**
* seata group后缀
*/
String GROUP_NAME = "-group";
/**
* seata 服务组格式
*
* @param appName 服务名
* @return group
*/
static String seataServiceGroup(String appName) {
return appName.concat(GROUP_NAME);
}
/**
* 动态获取nacos地址
*
* @param profile 环境变量
* @return addr
*/
static String nacosAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
return NACOS_PROD_ADDR;
case (AppConstant.TEST_CODE):
return NACOS_TEST_ADDR;
default:
return NACOS_DEV_ADDR;
}
}
/**
* 动态获取sentinel地址
*
* @param profile 环境变量
* @return addr
*/
static String sentinelAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
return SENTINEL_PROD_ADDR;
case (AppConstant.TEST_CODE):
return SENTINEL_TEST_ADDR;
default:
return SENTINEL_DEV_ADDR;
}
}
/**
* 动态获取seata地址
*
* @param profile 环境变量
* @return addr
*/
static String seataAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
return SEATA_PROD_ADDR;
case (AppConstant.TEST_CODE):
return SEATA_TEST_ADDR;
default:
return SEATA_DEV_ADDR;
}
}
/**
* 动态获取zipkin地址
*
* @param profile 环境变量
* @return addr
*/
static String zipkinAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
return ZIPKIN_PROD_ADDR;
case (AppConstant.TEST_CODE):
return ZIPKIN_TEST_ADDR;
default:
return ZIPKIN_DEV_ADDR;
}
}
/**
* 动态获取elk地址
*
* @param profile 环境变量
* @return addr
*/
static String elkAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
return ELK_PROD_ADDR;
case (AppConstant.TEST_CODE):
return ELK_TEST_ADDR;
default:
return ELK_DEV_ADDR;
}
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.launch;
import org.springblade.common.constant.LauncherConstant;
import org.springblade.core.auto.service.AutoService;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.launch.service.LauncherService;
import org.springblade.core.launch.utils.PropsUtil;
import org.springframework.boot.builder.SpringApplicationBuilder;
import java.util.Properties;
/**
* 启动参数拓展
*
* @author smallchil
*/
@AutoService(LauncherService.class)
public class LauncherServiceImpl implements LauncherService {
@Override
public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
Properties props = System.getProperties();
// 通用注册
PropsUtil.setProperty(props, "spring.cloud.nacos.discovery.server-addr", LauncherConstant.nacosAddr(profile));
PropsUtil.setProperty(props, "spring.cloud.nacos.config.server-addr", LauncherConstant.nacosAddr(profile));
PropsUtil.setProperty(props, "spring.cloud.sentinel.transport.dashboard", LauncherConstant.sentinelAddr(profile));
// dubbo注册
PropsUtil.setProperty(props, "dubbo.application.name", appName);
PropsUtil.setProperty(props, "dubbo.application.qos.enable", "false");
PropsUtil.setProperty(props, "dubbo.protocol.name", "dubbo");
PropsUtil.setProperty(props, "dubbo.registry.address", "nacos://" + LauncherConstant.nacosAddr(profile));
PropsUtil.setProperty(props, "dubbo.version", AppConstant.APPLICATION_VERSION);
PropsUtil.setProperty(props, "dubbo.scan.base-packages", AppConstant.BASE_PACKAGES);
// seata注册地址
PropsUtil.setProperty(props, "seata.service.grouplist.default", LauncherConstant.seataAddr(profile));
// seata注册group格式
PropsUtil.setProperty(props, "seata.tx-service-group", LauncherConstant.seataServiceGroup(appName));
// seata配置服务group
PropsUtil.setProperty(props, "seata.service.vgroup-mapping.".concat(LauncherConstant.seataServiceGroup(appName)), LauncherConstant.DEFAULT_MODE);
// seata注册模式配置
// PropsUtil.setProperty(props, "seata.registry.type", LauncherConstant.NACOS_MODE);
// PropsUtil.setProperty(props, "seata.registry.nacos.server-addr", LauncherConstant.nacosAddr(profile));
// PropsUtil.setProperty(props, "seata.config.type", LauncherConstant.NACOS_MODE);
// PropsUtil.setProperty(props, "seata.config.nacos.server-addr", LauncherConstant.nacosAddr(profile));
}
}
package org.springblade.common.utils;
/** 计算工时的工具类 对应的工时是Attendance类中的xxdayHours字段。
* @author Night
* Date: 2019/12/19
*/
public class AttendanceTimeUtil {
/** 处理 08:00-12:00|14:00-18:00 这种以|分割的时间段字符串
* @param workTime 08:00-12:00|14:00-18:00
* @return 总小时数
*/
public static int regexAndCalcHours(String workTime){
if (workTime.equals("")){
return 0;
}
String[] timeQuantums = workTime.split("\\|");
int timeHours = 0;
for (String timeQuantum : timeQuantums){
timeHours += calcHours(timeQuantum);
}
return timeHours;
}
/** 计算这个时间段的小时数
* @param timeQuantum 时间段字符串08:00-12:00
* @return 小时数
*/
public static int calcHours(String timeQuantum){
String[] timeDots = timeQuantum.split("-");
return regexendAndCast(timeDots[0],timeDots[1]);
}
public static int regexendAndCast(String time1, String time2){
int timeInt1 = Integer.parseInt(time1.replaceAll(":\\d+",""));
int timeInt2 = Integer.parseInt(time2.replaceAll(":\\d+",""));
if (timeInt1 > timeInt2){
return 24 - timeInt1 + timeInt2;
}
return timeInt2 - timeInt1;
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.common.utils;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
/**
* 通用工具类
*
* @author Chill
*/
public class CommonUtil {
/**
* <p>获取md5 32位小写字符串</p>
* @param str
* @return
*/
public final static String MD5(String str) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
char[] charArray = str.toCharArray();
byte[] byteArray = new byte[charArray.length];
for (int i = 0; i < charArray.length; i++)
byteArray[i] = (byte) charArray[i];
byte[] md5Bytes = md5.digest(byteArray);
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++) {
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16)
hexValue.append("0");
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
/**
* <p>将多个字符串拼接获取md5 32位小写字符串</p>
* @param strings
* @return
*/
public static final String MD5(String... strings){
StringBuffer sb=new StringBuffer();
for (String str:strings) {
sb.append(str);
}
return MD5(sb.toString());
}
/**
* <p>获取乐观锁version</p>
* @return
*/
public static final long getVersion(){
return System.nanoTime();
}
/**
* <p>获取uuid</p>
* @return
*/
public static final String getUUID(){
return UUID.randomUUID().toString();
}
/**
* <p>将时间按照指定的格式转换成string</p>
* @param date
* @param format
* @return
*/
public static final String dateFormat(Date date, String format){
SimpleDateFormat simpleDateFormat=new SimpleDateFormat(format);
return simpleDateFormat.format(date);
}
/**
* <p>数据乘以10000</p>
* @param decimal
* @return
*/
public static final long multiply1w(BigDecimal decimal){
return decimal.multiply(new BigDecimal(10000)).longValue();
}
}
package org.springblade.common.utils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/** 时间戳转换工具类
* @author Night
* Date: 2019/12/12
*/
public class UnixTimestampUtils {
public static String getFormatDate(String timeInMill){
if (timeInMill.equals("")){
return "";
} else {
long unFormatDate = new Long(timeInMill);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return simpleDateFormat.format(unFormatDate);
}
}
/** 判断日期是不是周六日
* @param date 数据库date
* @return boolean
* @throws ParseException ParseException
*/
public static boolean isWeekend (String date) throws ParseException {
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
Date bdate = format1.parse(date);
Calendar cal = Calendar.getInstance();
cal.setTime(bdate);
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
return true;
} else {
return false;
}
}
}
${AnsiColor.BLUE} ______ _ _ ___ ___
${AnsiColor.BLUE} | ___ \| | | | \ \ / /
${AnsiColor.BLUE} | |_/ /| | __ _ __| | ___ \ V /
${AnsiColor.BLUE} | ___ \| | / _` | / _` | / _ \ > <
${AnsiColor.BLUE} | |_/ /| || (_| || (_| || __/ / . \
${AnsiColor.BLUE} \____/ |_| \__,_| \__,_| \___|/__/ \__\
${AnsiColor.BLUE}:: BladeX :: ${spring.application.name}:${AnsiColor.RED}${blade.env}${AnsiColor.BLUE} :: Running SpringBoot ${spring-boot.version} :: ${AnsiColor.BRIGHT_BLACK}
FROM anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER smallchill@163.com
RUN mkdir -p /blade/gateway
WORKDIR /blade/gateway
EXPOSE 80
ADD ./target/blade-gateway.jar ./app.jar
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
CMD ["--spring.profiles.active=test"]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-gateway</artifactId>
<name>${project.artifactId}</name>
<version>${bladex.project.version}</version>
<packaging>jar</packaging>
<dependencies>
<!--Blade-->
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-launch</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId>
<exclusions>
<exclusion>
<groupId>org.springblade</groupId>
<artifactId>blade-core-launch</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-jwt</artifactId>
</dependency>
<!--Spring-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<!--Hystrix-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--Swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-ui</artifactId>
</dependency>
<!--<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.launch.BladeApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* 项目启动
*
* @author Chill
*/
@EnableHystrix
@EnableScheduling
@SpringCloudApplication
public class GateWayApplication {
public static void main(String[] args) {
BladeApplication.run(AppConstant.APPLICATION_GATEWAY_NAME, GateWayApplication.class, args);
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.config;
import org.springblade.gateway.handler.ErrorExceptionHandler;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.web.reactive.result.view.ViewResolver;
import java.util.Collections;
import java.util.List;
/**
* 异常处理配置类
*
* @author Chill
*/
@Configuration
@AutoConfigureBefore(ErrorWebFluxAutoConfiguration.class)
@EnableConfigurationProperties({ServerProperties.class, ResourceProperties.class})
public class ErrorHandlerConfiguration {
private final ServerProperties serverProperties;
private final ApplicationContext applicationContext;
private final ResourceProperties resourceProperties;
private final List<ViewResolver> viewResolvers;
private final ServerCodecConfigurer serverCodecConfigurer;
public ErrorHandlerConfiguration(ServerProperties serverProperties,
ResourceProperties resourceProperties,
ObjectProvider<List<ViewResolver>> viewResolversProvider,
ServerCodecConfigurer serverCodecConfigurer,
ApplicationContext applicationContext) {
this.serverProperties = serverProperties;
this.applicationContext = applicationContext;
this.resourceProperties = resourceProperties;
this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
this.serverCodecConfigurer = serverCodecConfigurer;
}
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
ErrorExceptionHandler exceptionHandler = new ErrorExceptionHandler(
errorAttributes,
this.resourceProperties,
this.serverProperties.getError(),
this.applicationContext);
exceptionHandler.setViewResolvers(this.viewResolvers);
exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
return exceptionHandler;
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.config;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.gateway.handler.SwaggerResourceHandler;
import org.springblade.gateway.handler.SwaggerSecurityHandler;
import org.springblade.gateway.handler.SwaggerUiHandler;
import org.springblade.gateway.props.AuthProperties;
import org.springblade.gateway.props.RouteProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.cors.reactive.CorsUtils;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
/**
* 路由配置信息
*
* @author Chill
*/
@Slf4j
@Configuration
@AllArgsConstructor
@EnableConfigurationProperties({RouteProperties.class, AuthProperties.class})
public class RouterFunctionConfiguration {
private final SwaggerResourceHandler swaggerResourceHandler;
private final SwaggerSecurityHandler swaggerSecurityHandler;
private final SwaggerUiHandler swaggerUiHandler;
/**
* 这里为支持的请求头,如果有自定义的header字段请自己添加
*/
private static final String ALLOWED_HEADERS = "X-Requested-With, Tenant-Id, Blade-Auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client";
private static final String ALLOWED_METHODS = "GET,POST,PUT,DELETE,OPTIONS,HEAD";
private static final String ALLOWED_ORIGIN = "*";
private static final String ALLOWED_EXPOSE = "*";
private static final String MAX_AGE = "18000L";
/**
* 跨域配置
*/
@Bean
public WebFilter corsFilter() {
return (ServerWebExchange ctx, WebFilterChain chain) -> {
ServerHttpRequest request = ctx.getRequest();
if (CorsUtils.isCorsRequest(request)) {
ServerHttpResponse response = ctx.getResponse();
HttpHeaders headers = response.getHeaders();
headers.add("Access-Control-Allow-Headers", ALLOWED_HEADERS);
headers.add("Access-Control-Allow-Methods", ALLOWED_METHODS);
headers.add("Access-Control-Allow-Origin", ALLOWED_ORIGIN);
headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE);
headers.add("Access-Control-Max-Age", MAX_AGE);
headers.add("Access-Control-Allow-Credentials", "true");
if (request.getMethod() == HttpMethod.OPTIONS) {
response.setStatusCode(HttpStatus.OK);
return Mono.empty();
}
}
return chain.filter(ctx);
};
}
@Bean
public RouterFunction routerFunction() {
return RouterFunctions.route(RequestPredicates.GET("/swagger-resources")
.and(RequestPredicates.accept(MediaType.ALL)), swaggerResourceHandler)
.andRoute(RequestPredicates.GET("/swagger-resources/configuration/ui")
.and(RequestPredicates.accept(MediaType.ALL)), swaggerUiHandler)
.andRoute(RequestPredicates.GET("/swagger-resources/configuration/security")
.and(RequestPredicates.accept(MediaType.ALL)), swaggerSecurityHandler);
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.dynamic;
import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteDefinitionWriter;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
import java.util.List;
/**
* 动态路由业务类
*
* @author Chill
*/
@Service
public class DynamicRouteService implements ApplicationEventPublisherAware {
private final RouteDefinitionWriter routeDefinitionWriter;
private ApplicationEventPublisher publisher;
public DynamicRouteService(RouteDefinitionWriter routeDefinitionWriter) {
this.routeDefinitionWriter = routeDefinitionWriter;
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.publisher = applicationEventPublisher;
}
/**
* 增加路由
*/
public String save(RouteDefinition definition) {
try {
routeDefinitionWriter.save(Mono.just(definition)).subscribe();
this.publisher.publishEvent(new RefreshRoutesEvent(this));
return "save success";
} catch (Exception e) {
e.printStackTrace();
return "save failure";
}
}
/**
* 更新路由
*/
public String update(RouteDefinition definition) {
try {
this.routeDefinitionWriter.delete(Mono.just(definition.getId()));
this.routeDefinitionWriter.save(Mono.just(definition)).subscribe();
this.publisher.publishEvent(new RefreshRoutesEvent(this));
return "update success";
} catch (Exception e) {
e.printStackTrace();
return "update failure";
}
}
/**
* 更新路由
*/
public String updateList(List<RouteDefinition> routeDefinitions) {
routeDefinitions.forEach(this::update);
return "update done";
}
/**
* 删除路由
*/
public String delete(String id) {
try {
this.routeDefinitionWriter.delete(Mono.just(id));
return "delete success";
} catch (Exception e) {
e.printStackTrace();
return "delete failure";
}
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.dynamic;
import com.alibaba.cloud.nacos.NacosConfigProperties;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.launch.constant.NacosConstant;
import org.springblade.core.launch.props.BladeProperties;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.Executor;
/**
* 动态路由监听器
*
* @author Chill
*/
@Order
@Slf4j
@Component
public class DynamicRouteServiceListener {
private final DynamicRouteService dynamicRouteService;
private final NacosDiscoveryProperties nacosDiscoveryProperties;
private final NacosConfigProperties nacosConfigProperties;
private final BladeProperties bladeProperties;
public DynamicRouteServiceListener(DynamicRouteService dynamicRouteService, NacosDiscoveryProperties nacosDiscoveryProperties, NacosConfigProperties nacosConfigProperties, BladeProperties bladeProperties) {
this.dynamicRouteService = dynamicRouteService;
this.nacosDiscoveryProperties = nacosDiscoveryProperties;
this.nacosConfigProperties = nacosConfigProperties;
this.bladeProperties = bladeProperties;
dynamicRouteServiceListener();
}
/**
* 监听Nacos下发的动态路由配置
*/
private void dynamicRouteServiceListener() {
try {
String dataId = NacosConstant.dataId(bladeProperties.getName(), bladeProperties.getEnv(), NacosConstant.NACOS_CONFIG_JSON_FORMAT);
String group = nacosConfigProperties.getGroup();
Properties properties = new Properties();
properties.setProperty(PropertyKeyConst.SERVER_ADDR, nacosDiscoveryProperties.getServerAddr());
properties.setProperty(PropertyKeyConst.NAMESPACE, nacosDiscoveryProperties.getNamespace());
ConfigService configService = NacosFactory.createConfigService(properties);
configService.addListener(dataId, group, new Listener() {
@Override
public void receiveConfigInfo(String configInfo) {
List<RouteDefinition> routeDefinitions = JSON.parseArray(configInfo, RouteDefinition.class);
dynamicRouteService.updateList(routeDefinitions);
}
@Override
public Executor getExecutor() {
return null;
}
});
String configInfo = configService.getConfig(dataId, group, 5000);
if (configInfo != null) {
List<RouteDefinition> routeDefinitions = JSON.parseArray(configInfo, RouteDefinition.class);
dynamicRouteService.updateList(routeDefinitions);
}
} catch (NacosException ignored) {
}
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.dynamic;
import lombok.Data;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 过滤器定义模型
*
* @author Chill
*/
@Data
public class GatewayFilter {
/**
* 过滤器对应的Name
*/
private String name;
/**
* 对应的路由规则
*/
private Map<String, String> args = new LinkedHashMap<>();
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.dynamic;
import lombok.Data;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 路由断言定义模型
*
* @author Chill
*/
@Data
public class GatewayPredicate {
/**
* 断言对应的Name
*/
private String name;
/**
* 配置的断言规则
*/
private Map<String, String> args = new LinkedHashMap<>();
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.dynamic;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* Gateway的路由定义模型
*
* @author Chill
*/
@Data
public class GatewayRoute {
/**
* 路由的id
*/
private String id;
/**
* 路由断言集合配置
*/
private List<GatewayPredicate> predicates = new ArrayList<>();
/**
* 路由过滤器集合配置
*/
private List<GatewayFilter> filters = new ArrayList<>();
/**
* 路由规则转发的目标uri
*/
private String uri;
/**
* 路由执行的顺序
*/
private int order = 0;
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.filter;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.Claims;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.jwt.JwtUtil;
import org.springblade.gateway.props.AuthProperties;
import org.springblade.gateway.provider.AuthProvider;
import org.springblade.gateway.provider.RequestProvider;
import org.springblade.gateway.provider.ResponseProvider;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets;
/**
* 鉴权认证
*
* @author Chill
*/
@Slf4j
@Component
@AllArgsConstructor
public class AuthFilter implements GlobalFilter, Ordered {
private AuthProperties authProperties;
private ObjectMapper objectMapper;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
String originalRequestUrl = RequestProvider.getOriginalRequestUrl(exchange);
String path = exchange.getRequest().getURI().getPath();
if (isSkip(path) || isSkip(originalRequestUrl)) {
return chain.filter(exchange);
}
ServerHttpResponse resp = exchange.getResponse();
String headerToken = exchange.getRequest().getHeaders().getFirst(AuthProvider.AUTH_KEY);
String paramToken = exchange.getRequest().getQueryParams().getFirst(AuthProvider.AUTH_KEY);
if (StringUtils.isAllBlank(headerToken, paramToken)) {
return unAuth(resp, "缺失令牌,鉴权失败");
}
String auth = StringUtils.isBlank(headerToken) ? paramToken : headerToken;
String token = JwtUtil.getToken(auth);
Claims claims = JwtUtil.parseJWT(token);
if (claims == null) {
return unAuth(resp, "请求未授权");
}
return chain.filter(exchange);
}
private boolean isSkip(String path) {
return AuthProvider.getDefaultSkipUrl().stream().map(url -> url.replace(AuthProvider.TARGET, AuthProvider.REPLACEMENT)).anyMatch(path::startsWith)
|| authProperties.getSkipUrl().stream().map(url -> url.replace(AuthProvider.TARGET, AuthProvider.REPLACEMENT)).anyMatch(path::startsWith);
}
private Mono<Void> unAuth(ServerHttpResponse resp, String msg) {
resp.setStatusCode(HttpStatus.UNAUTHORIZED);
resp.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
String result = "";
try {
result = objectMapper.writeValueAsString(ResponseProvider.unAuth(msg));
} catch (JsonProcessingException e) {
log.error(e.getMessage(), e);
}
DataBuffer buffer = resp.bufferFactory().wrap(result.getBytes(StandardCharsets.UTF_8));
return resp.writeWith(Flux.just(buffer));
}
@Override
public int getOrder() {
return -100;
}
}
/*
* Copyright (c) 2018-2028, DreamLu All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: DreamLu 卢春梦 (596392912@qq.com)
*/
package org.springblade.gateway.filter;
import io.jsonwebtoken.Claims;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.jwt.JwtUtil;
import org.springblade.gateway.provider.AuthProvider;
import org.springblade.gateway.provider.RequestProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.util.ArrayList;
import java.util.List;
/**
* webflux 日志请求记录,方便开发调试。请求日志过滤器排序尽量低。
*
* <p>
* 注意:暂时不支持结构体打印,想实现,请看下面的链接。
* https://stackoverflow.com/questions/45240005/how-to-log-request-and-response-bodies-in-spring-webflux
* https://github.com/Silvmike/webflux-demo/blob/master/tests/src/test/java/ru/hardcoders/demo/webflux/web_handler/filters/logging
* </p>
*
* @author dream.lu
*/
@Slf4j
@Configuration
@RequiredArgsConstructor
@ConditionalOnProperty(value = "blade.log.request.enabled", havingValue = "true", matchIfMissing = true)
public class GlobalRequestLogFilter implements GlobalFilter, Ordered {
private final WebEndpointProperties endpointProperties;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
// 打印请求路径
String path = request.getPath().pathWithinApplication().value();
// 忽略 endpoint 请求
String endpointBasePath = endpointProperties.getBasePath();
if (StringUtils.isNotBlank(endpointBasePath) && path.startsWith(endpointBasePath)) {
return chain.filter(exchange);
}
String requestUrl = RequestProvider.getOriginalRequestUrl(exchange);
// 构建成一条长 日志,避免并发下日志错乱
StringBuilder beforeReqLog = new StringBuilder(300);
// 日志参数
List<Object> beforeReqArgs = new ArrayList<>();
beforeReqLog.append("\n\n================ Gateway Request Start ================\n");
// 打印路由
beforeReqLog.append("===> {}: {}\n");
// 参数
String requestMethod = request.getMethodValue();
beforeReqArgs.add(requestMethod);
beforeReqArgs.add(requestUrl);
// 打印请求头
HttpHeaders headers = request.getHeaders();
headers.forEach((headerName, headerValue) -> {
beforeReqLog.append("===Headers=== {}: {}\n");
beforeReqArgs.add(headerName);
if (AuthProvider.AUTH_KEY.toLowerCase().equals(headerName)) {
String value = headerValue.get(0);
String token = JwtUtil.getToken(value);
Claims claims = JwtUtil.parseJWT(token);
beforeReqArgs.add((claims == null) ? "" : claims.toString());
beforeReqLog.append("===Headers=== {}: {}\n");
beforeReqArgs.add(headerName.concat("-original"));
beforeReqArgs.add(StringUtils.join(headerValue));
} else {
beforeReqArgs.add(StringUtils.join(headerValue));
}
});
beforeReqLog.append("================ Gateway Request End =================\n");
// 打印执行时间
log.info(beforeReqLog.toString(), beforeReqArgs.toArray());
return chain.filter(exchange);
}
@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
}
}
/*
* Copyright (c) 2018-2028, DreamLu All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: DreamLu 卢春梦 (596392912@qq.com)
*/
package org.springblade.gateway.filter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.util.MultiValueMap;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.util.UriComponentsBuilder;
import reactor.core.publisher.Mono;
import java.util.ArrayList;
import java.util.List;
/**
* webflux 相应日志,方便开发调试,注意排序要优先。
*
* @author dream.lu
*/
@Slf4j
@Configuration
@RequiredArgsConstructor
@ConditionalOnProperty(value = "blade.log.request.enabled", havingValue = "true", matchIfMissing = true)
public class GlobalResponseLogFilter implements GlobalFilter, Ordered {
private final WebEndpointProperties endpointProperties;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
// 打印请求路径
String path = request.getPath().pathWithinApplication().value();
// 忽略 endpoint 请求
String endpointBasePath = endpointProperties.getBasePath();
if (StringUtils.isNotBlank(endpointBasePath) && path.startsWith(endpointBasePath)) {
return chain.filter(exchange);
}
return chain.filter(exchange).then(
Mono.fromRunnable(() -> {
MultiValueMap<String, String> queryParams = request.getQueryParams();
String requestUrl = UriComponentsBuilder.fromPath(path).queryParams(queryParams).build().toUriString();
// 构建成一条长 日志,避免并发下日志错乱
StringBuilder responseLog = new StringBuilder(300);
// 日志参数
List<Object> responseArgs = new ArrayList<>();
responseLog.append("\n\n================ Gateway Response Start ================\n");
ServerHttpResponse response = exchange.getResponse();
// 打印路由 200 get: /api/xxx/xxx
responseLog.append("<=== {} {}: {}\n");
// 参数
String requestMethod = request.getMethodValue();
responseArgs.add(response.getStatusCode().value());
responseArgs.add(requestMethod);
responseArgs.add(requestUrl);
// 打印请求头
HttpHeaders headers = response.getHeaders();
headers.forEach((headerName, headerValue) -> {
responseLog.append("===Headers=== {}: {}\n");
responseArgs.add(headerName);
responseArgs.add(StringUtils.join(headerValue));
});
responseLog.append("================ Gateway Response End =================\n");
// 打印执行时间
log.info(responseLog.toString(), responseArgs.toArray());
})
);
}
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
}
}
package org.springblade.gateway.filter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.util.Arrays;
import java.util.stream.Collectors;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.addOriginalRequestUrl;
/**
* <p>
* 全局拦截器,作用所有的微服务
* <p>
* 1. 对请求头中参数进行处理 from 参数进行清洗
* 2. 重写StripPrefix = 1,支持全局
*
* @author lengleng
*/
@Component
public class RequestFilter implements GlobalFilter, Ordered {
/**
* Process the Web request and (optionally) delegate to the next
* {@code WebFilter} through the given {@link GatewayFilterChain}.
*
* @param exchange the current server exchange
* @param chain provides a way to delegate to the next filter
* @return {@code Mono<Void>} to indicate when request processing is complete
*/
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
// 1. 清洗请求头中from 参数
ServerHttpRequest request = exchange.getRequest().mutate()
.headers(httpHeaders -> httpHeaders.remove("X"))
.build();
// 2. 重写StripPrefix
addOriginalRequestUrl(exchange, request.getURI());
String rawPath = request.getURI().getRawPath();
String newPath = "/" + Arrays.stream(StringUtils.tokenizeToStringArray(rawPath, "/"))
.skip(1L).collect(Collectors.joining("/"));
ServerHttpRequest newRequest = request.mutate()
.path(newPath)
.build();
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, newRequest.getURI());
return chain.filter(exchange.mutate().request(newRequest.mutate().build()).build());
}
@Override
public int getOrder() {
return -1000;
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.handler;
import org.springblade.gateway.provider.ResponseProvider;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.ResourceProperties;
import org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler;
import org.springframework.boot.web.reactive.error.ErrorAttributes;
import org.springframework.cloud.gateway.support.NotFoundException;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.server.*;
import org.springframework.web.server.ResponseStatusException;
import java.util.Map;
/**
* 异常处理
*
* @author Chill
*/
public class ErrorExceptionHandler extends DefaultErrorWebExceptionHandler {
public ErrorExceptionHandler(ErrorAttributes errorAttributes, ResourceProperties resourceProperties,
ErrorProperties errorProperties, ApplicationContext applicationContext) {
super(errorAttributes, resourceProperties, errorProperties, applicationContext);
}
/**
* 获取异常属性
*/
@Override
protected Map<String, Object> getErrorAttributes(ServerRequest request, boolean includeStackTrace) {
int code = 500;
Throwable error = super.getError(request);
if (error instanceof NotFoundException) {
code = 404;
}
if (error instanceof ResponseStatusException) {
code = ((ResponseStatusException) error).getStatus().value();
}
return ResponseProvider.response(code, this.buildMessage(request, error));
}
/**
* 指定响应处理方法为JSON处理的方法
*
* @param errorAttributes
*/
@Override
protected RouterFunction<ServerResponse> getRoutingFunction(ErrorAttributes errorAttributes) {
return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse);
}
/**
* 根据code获取对应的HttpStatus
*
* @param errorAttributes
*/
@Override
protected HttpStatus getHttpStatus(Map<String, Object> errorAttributes) {
int statusCode = (int) errorAttributes.get("code");
return HttpStatus.valueOf(statusCode);
}
/**
* 构建异常信息
*
* @param request
* @param ex
* @return
*/
private String buildMessage(ServerRequest request, Throwable ex) {
StringBuilder message = new StringBuilder("Failed to handle request [");
message.append(request.methodName());
message.append(" ");
message.append(request.uri());
message.append("]");
if (ex != null) {
message.append(": ");
message.append(ex.getMessage());
}
return message.toString();
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.handler;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
/**
* SwaggerResourceHandler
*
* @author lengleng
*/
@Slf4j
@Component
@AllArgsConstructor
public class SwaggerResourceHandler implements HandlerFunction<ServerResponse> {
private final SwaggerResourcesProvider swaggerResources;
/**
* Handle the given request.
*
* @param request the request to handler
* @return the response
*/
@Override
public Mono<ServerResponse> handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(swaggerResources.get()));
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import springfox.documentation.swagger.web.SecurityConfigurationBuilder;
/**
* SwaggerSecurityHandler
*
* @author lengleng
*/
@Slf4j
@Component
public class SwaggerSecurityHandler implements HandlerFunction<ServerResponse> {
/**
* Handle the given request.
*
* @param request the request to handler
* @return the response
*/
@Override
public Mono<ServerResponse> handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(SecurityConfigurationBuilder.builder().build()));
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.handler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import springfox.documentation.swagger.web.UiConfigurationBuilder;
/**
* SwaggerUiHandler
*
* @author lengleng
*/
@Slf4j
@Component
public class SwaggerUiHandler implements HandlerFunction<ServerResponse> {
/**
* Handle the given request.
*
* @param request the request to handler
* @return the response
*/
@Override
public Mono<ServerResponse> handle(ServerRequest request) {
return ServerResponse.status(HttpStatus.OK)
.contentType(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(UiConfigurationBuilder.builder().build()));
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.props;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import java.util.ArrayList;
import java.util.List;
/**
* 权限过滤
*
* @author Chill
*/
@Data
@RefreshScope
@ConfigurationProperties("blade.secure")
public class AuthProperties {
/**
* 放行API集合
*/
private final List<String> skipUrl = new ArrayList<>();
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.props;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import java.util.ArrayList;
import java.util.List;
/**
* 路由配置类
*
* @author Chill
*/
@Data
@RefreshScope
@ConfigurationProperties("blade.document")
public class RouteProperties {
private final List<RouteResource> resources = new ArrayList<>();
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.props;
import lombok.Data;
import org.springblade.core.launch.constant.AppConstant;
/**
* Swagger聚合文档属性
*
* @author Chill
*/
@Data
public class RouteResource {
/**
* 文档名
*/
private String name;
/**
* 文档所在服务地址
*/
private String location;
/**
* 文档版本
*/
private String version = AppConstant.APPLICATION_VERSION;
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.provider;
import java.util.ArrayList;
import java.util.List;
/**
* 鉴权配置
*
* @author Chill
*/
public class AuthProvider {
public static String TARGET = "/**";
public static String REPLACEMENT = "";
public static String AUTH_KEY = "Blade-Auth";
private static List<String> defaultSkipUrl = new ArrayList<>();
static {
defaultSkipUrl.add("/example");
defaultSkipUrl.add("/oauth/token/**");
defaultSkipUrl.add("/oauth/captcha/**");
defaultSkipUrl.add("/oauth/user-info");
defaultSkipUrl.add("/token/**");
defaultSkipUrl.add("/actuator/health/**");
defaultSkipUrl.add("/v2/api-docs/**");
defaultSkipUrl.add("/v2/api-docs-ext/**");
defaultSkipUrl.add("/auth/**");
defaultSkipUrl.add("/log/**");
defaultSkipUrl.add("/menu/routes");
defaultSkipUrl.add("/menu/auth-routes");
defaultSkipUrl.add("/menu/top-menu");
defaultSkipUrl.add("/tenant/info");
defaultSkipUrl.add("/process/resource-view");
defaultSkipUrl.add("/process/diagram-view");
defaultSkipUrl.add("/manager/check-upload");
defaultSkipUrl.add("/order/create");
defaultSkipUrl.add("/error/**");
defaultSkipUrl.add("/assets/**");
defaultSkipUrl.add("/message/send");
}
/**
* 默认无需鉴权的API
*/
public static List<String> getDefaultSkipUrl() {
return defaultSkipUrl;
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.provider;
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.util.MultiValueMap;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import java.util.LinkedHashSet;
/**
* RequestProvider
*
* @author Chill
*/
public class RequestProvider {
/**
* 获取原始url
*
* @param exchange
* @return
*/
public static String getOriginalRequestUrl(ServerWebExchange exchange) {
ServerHttpRequest request = exchange.getRequest();
LinkedHashSet<URI> uris = exchange.getRequiredAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
URI requestUri = uris.stream().findFirst().orElse(request.getURI());
MultiValueMap<String, String> queryParams = request.getQueryParams();
return UriComponentsBuilder.fromPath(requestUri.getRawPath()).queryParams(queryParams).build().toUriString();
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.provider;
import java.util.HashMap;
import java.util.Map;
/**
* 请求响应返回
*
* @author Chill
*/
public class ResponseProvider {
/**
* 成功
*
* @param message 信息
* @return
*/
public static Map<String, Object> success(String message) {
return response(200, message);
}
/**
* 失败
*
* @param message 信息
* @return
*/
public static Map<String, Object> fail(String message) {
return response(400, message);
}
/**
* 未授权
*
* @param message 信息
* @return
*/
public static Map<String, Object> unAuth(String message) {
return response(401, message);
}
/**
* 服务器异常
*
* @param message 信息
* @return
*/
public static Map<String, Object> error(String message) {
return response(500, message);
}
/**
* 构建返回的JSON数据格式
*
* @param status 状态码
* @param message 信息
* @return
*/
public static Map<String, Object> response(int status, String message) {
Map<String, Object> map = new HashMap<>(16);
map.put("code", status);
map.put("message", message);
map.put("data", null);
return map;
}
}
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.gateway.provider;
import lombok.AllArgsConstructor;
import org.springblade.gateway.props.RouteProperties;
import org.springblade.gateway.props.RouteResource;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import java.util.ArrayList;
import java.util.List;
/**
* 聚合接口文档注册
*
* @author Chill
*/
@Primary
@Component
@AllArgsConstructor
public class SwaggerProvider implements SwaggerResourcesProvider {
private static final String API_URI = "/v2/api-docs-ext";
private RouteProperties routeProperties;
@Override
public List<SwaggerResource> get() {
List<SwaggerResource> resources = new ArrayList<>();
List<RouteResource> routeResources = routeProperties.getResources();
routeResources.forEach(routeResource -> resources.add(swaggerResource(routeResource)));
return resources;
}
private SwaggerResource swaggerResource(RouteResource routeResource) {
SwaggerResource swaggerResource = new SwaggerResource();
swaggerResource.setName(routeResource.getName());
swaggerResource.setLocation(routeResource.getLocation().concat(API_URI));
swaggerResource.setSwaggerVersion(routeResource.getVersion());
return swaggerResource;
}
}
blade:
#多团队协作服务配置
ribbon:
rule:
#开启配置
enabled: true
#负载均衡优先调用的ip段
prior-ip-pattern:
- 192.168.0.*
- 127.0.0.1
server:
port: 80
spring:
cloud:
gateway:
discovery:
locator:
enabled: true
loadbalancer:
retry:
enabled: true
# 聚合文档配置
blade:
document:
resources:
- name: 授权模块
location: /blade-auth
- name: 工作台模块
location: /blade-desk
- name: 系统模块
location: /blade-system
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-sched-api</artifactId>
<name>${project.artifactId}</name>
<version>${bladex.project.version}</version>
<packaging>jar</packaging>
<properties>
<poi.version>4.1.0</poi.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-tenant</artifactId>
</dependency>
<dependency>
<groupId>com.github.liaochong</groupId>
<artifactId>myexcel</artifactId>
<version>2.7.0</version>
</dependency>
<!-- POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<skipDockerBuild>true</skipDockerBuild>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>xyts-release</id>
<name>xyts-release</name>
<url>http://tool-nexus.ez-hosbed.com/repository/maven-releases/</url>
</repository>
</distributionManagement>
</project>
package org.springblade.mid.convert;
import com.xytx.common.exception.CommonException;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.utils.CommonUtil;
import org.springblade.common.utils.UnixTimestampUtils;
import org.springblade.mid.entity.Schedule;
import org.springblade.mid.vo.HourStatisticsVO;
import org.springblade.mid.vo.ScheduleDetailVO;
import org.springblade.mid.vo.ScheduleVO;
import org.springframework.beans.BeanUtils;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static org.springblade.common.utils.AttendanceTimeUtil.regexAndCalcHours;
/** ScheduleVO2ScheduleList 转换器
* @author Night
* Date: 2019/12/20
*/
@Slf4j
public class AboutScheduleConverter {
/** 新增排班信息时用到的转换器
* @param scheduleVO scheduleVO
* @return List<Schedule>
*/
public static List<Schedule> convertScheduleVO2ScheduleList(ScheduleVO scheduleVO, List<String> holidayList, List<String> workweekendList){
log.info("【AboutScheduleConverter>>>convertScheduleVO2ScheduleList】scheduleVO={}", scheduleVO);
List<Schedule> scheduleList = new ArrayList<>();
// 组装每一个schedule
List<ScheduleDetailVO> scheduleDetailVOList = scheduleVO.getScheduleDetailVOList();
// 准备通用实体部分
scheduleDetailVOList.forEach(e -> {
Schedule schedule = new Schedule();
BeanUtils.copyProperties(scheduleVO, schedule);
String id = e.getScheduleId();
if (id == null || id.equals("")){
id = "S" + CommonUtil.getUUID().replace("-", "");
}
String date = UnixTimestampUtils.getFormatDate(e.getDate());
String worktime = e.getWorktime();
int hours = regexAndCalcHours(worktime);
schedule.setId(id);
schedule.setDate(date).setWorktime(worktime).setClassesId(e.getClassesId()).setAttendanceTime(worktime)
.setHours(hours).setClassesName(e.getClassesName());
// 计算所有工时
schedule = calcAllHours(schedule,holidayList,workweekendList);
scheduleList.add(schedule);
});
return scheduleList;
}
/** List<Schedule> -> List<ScheduleVO>
* @param scheduleList scheduleList
* @param nurseIdSet nurseIdSet
* @return List<ScheduleVO>
*/
public static List<ScheduleVO> schedule2ScheuleVO(List<Schedule> scheduleList, Set<String> nurseIdSet){
log.info("【AboutScheduleConverter>>>schedule2ScheuleVO】scheduleList={} nurseIdSet={}", scheduleList,nurseIdSet);
List<ScheduleVO> scheduleVOList = new ArrayList<>();
nurseIdSet.forEach(nurseId -> {
ScheduleVO scheduleVO = new ScheduleVO();
scheduleList.stream().filter(schedule -> nurseId.equals(schedule.getNurseId())).forEach(schedule -> {
ScheduleDetailVO scheduleDetailVO = new ScheduleDetailVO();
BeanUtils.copyProperties(schedule, scheduleVO);
scheduleDetailVO.setScheduleId(schedule.getId()).setDate(schedule.getDate())
.setWorktime(schedule.getWorktime()).setAttendanceTime(schedule.getAttendanceTime())
.setHours(schedule.getHours()).setClassesId(schedule.getClassesId())
.setClassesName(schedule.getClassesName());
scheduleVO.getScheduleDetailVOList().add(scheduleDetailVO);
});
scheduleVOList.add(scheduleVO);
});
return scheduleVOList;
}
/** 计算工作时长
* @param scheduleList scheduleList
* @param nurseIdSet nurseIdSet
* @return List<ScheduleVO>
*/
public static List<HourStatisticsVO> calcAttendanceOfHours(List<Schedule> scheduleList, Set<String> nurseIdSet){
log.info("【AboutScheduleConverter>>>calcAttendanceOfHours】scheduleList={} nurseIdSet={}", scheduleList,nurseIdSet);
List<HourStatisticsVO> hourStatisticsVOList = new ArrayList<>();
for (String nurseId : nurseIdSet) {
HourStatisticsVO hourStatisticsVO = new HourStatisticsVO();
int total = 0;
int stdhour = 0;
int holhour = 0;
for (Schedule schedule : scheduleList) {
if (nurseId.equals(schedule.getNurseId())) {
total += schedule.getHours();
BeanUtils.copyProperties(schedule,hourStatisticsVO);
hourStatisticsVO.setTotalHours(total);
hourStatisticsVO.setStdHours(stdhour += schedule.getStdHour());
hourStatisticsVO.setHolidayHour(holhour += schedule.getHolidayHour());
}
}
hourStatisticsVOList.add(hourStatisticsVO);
}
return hourStatisticsVOList;
}
/** 计算某一天的除总工时以外所有工时信息 加班 节假日 ,
* @return Schedule
*/
public static Schedule calcAllHours(Schedule schedule, List<String> holidayList, List<String> workweekendList){
int hours = schedule.getHours();
String date = schedule.getDate();
try {
if (holidayList.contains(date)){
schedule.setStdHour(0).setOutHour(hours).setHolidayHour(hours);
return schedule;
} else if(workweekendList.contains(date)){
schedule.setStdHour(Math.min(hours,8)).setOutHour(hours > 8 ? hours - 8 : 0);
return schedule;
} else if(UnixTimestampUtils.isWeekend(date)){
schedule.setStdHour(0).setOutHour(hours);
return schedule;
} else {
schedule.setStdHour(Math.min(hours, 8)).setOutHour(hours > 8 ? hours - 8 : 0);
}
} catch (ParseException ex) {
throw new CommonException(10001,"判断周末出错!");
}
return schedule;
}
}
package org.springblade.mid.entity;
public class AddressEntity {
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_agent")
public class Agent extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 租户ID
*/
private String tenantId;
/**
* 负责人user_id
*/
private String userId;
/**
* 省ID
*/
private Integer provinceId;
/**
* 市ID
*/
private Integer cityId;
/**
* 区ID
*/
private Integer areaId;
/**
* 机构名称
*/
private String agentName;
/**
* 机构介绍
*/
private String agentIntroduce;
/**
* 机构电话
*/
private String agentTel;
/**
* 机构logo
*/
private String agentLogo;
/**
* 机构地址
*/
private String agentPosition;
/**
* 详细地址
*/
private String detailAddress;
/**
* 数据隔离ID
*/
private String dataId;
/**
* 账号
*/
private String username;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author max
* @since 2020-04-27
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="AgentHos对象", description="")
@TableName("care_agent_hos")
public class AgentHos extends SuperEntity {
private static final long serialVersionUID = 1L;
private String agentId;
private String agentName;
private String hosId;
private String hosName;
private String time;
@TableLogic
private int isDeleted;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("应用配置entity")
@TableName("app_config")
public class AppConfig implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 租户ID
*/
@ApiModelProperty(value = "租户ID")
private String tenantId;
/**
* appid
*/
@ApiModelProperty(value = "appid")
private String appId;
/**
* secret
*/
@ApiModelProperty(value = "secret")
private String appSecret;
/**
* 商户号
*/
@ApiModelProperty(value = "商户号")
private String mchId;
/**
* 商户号
*/
@ApiModelProperty(value = "商户收款key")
private String mchKey;
/**
* 小程序
*/
@ApiModelProperty(value = "小程序")
private String miniProgram;
/**
* 小程序
*/
@ApiModelProperty(value = "退款证书")
private String certificate;
/**
* 小程序
*/
@ApiModelProperty(value = "退款开关 0关闭 1开启")
private Integer refund;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* <p>
* 地区信息表
* </p>
*
* @author MIND
* @since 2019-09-28
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_area")
public class Area extends SuperEntity {
private static final long serialVersionUID = 1L;
/**
* 代码
*/
private Integer code;
/**
* 名称
*/
private String name;
/**
* 层级,1=省,2=市,3=区
*/
private Integer lvl;
/**
* 上级代码
*/
private Integer parentCode;
//子
@TableField(exist = false)
private List<Area> areas;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* Created with IDEA
* author:Mind
*
* Date:2019/8/22
* Time:16:14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BaseEntity extends SuperEntity {
/**
* serialVersionUID
*/
private static final long serialVersionUID = 199327361052220940L;
private int isDeleted;
private LocalDateTime createdTime;
@TableField(value = "updated_time",update = "now()")
private LocalDateTime updatedTime;
private String createdBy;
private String updatedBy;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author XYTX
* @since 2019-12-03
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_classes")
public class Classes extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 班次名称
*/
private String name;
/**
* 所属医院
*/
private String hosName;
/**
* 班次开始时间
*/
private String starTime;
/**
* 班次结束时间
*/
private String endTime;
/**
* 护士长id,用来查询班次列表
*/
private String doctorId;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author XYTX
* @since 2019-11-26
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_doctor")
public class Doctor extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 医院id
*/
@ApiModelProperty(value = "医院id",notes = "医院id")
private String hospitalId;
/**
* 租户ID
*/
@ApiModelProperty(value = "租户ID",notes = "租户ID")
private String tenantId;
/**
* 姓名
*/
@ApiModelProperty(value = "真实姓名",notes = "真实姓名")
private String relName;
/**
* 性别 0 女 1 男
*/
@ApiModelProperty(value = "性别 0 女 1 男",notes = "性别 0 女 1 男")
private Integer sex;
/**
* 等级
*/
@ApiModelProperty(value = "等级",notes = "等级")
private String level;
/**
* 0 医生 1 护士长
*/
@ApiModelProperty(value = "0 医生 1 护士长",notes = "0 医生 1 护士长")
private Integer type;
/**
* 所属医院
*/
@ApiModelProperty(value = "所属医院",notes = "所属医院")
private String hospital;
/**
* 电话
*/
@ApiModelProperty(value = "电话",notes = "电话")
private String phone;
/**
* 添加人
*/
@ApiModelProperty(value = "添加人",notes = "添加人")
private String addPeople;
/**
* 科室
*/
@ApiModelProperty(value = "科室",notes = "科室")
private String depart;
/**
* 登录账号
*/
@ApiModelProperty(value = "登录账号",notes = "登录账号")
private String account;
/**
* 0 未删除 1已删除
*/
@TableLogic
@ApiModelProperty(value = "0 未删除 1已删除",notes = "0 未删除 1已删除")
private int isDeleted;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* 法定节假日日期信息
* @author Night
* Date: 2020/1/9
*/
@Data
@TableName("care_holiday")
public class Holiday extends BaseEntity {
private String date;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_hospital")
public class Hospital extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 租户ID
*/
private String tenantId;
/**
* 省ID
*/
private Integer provinceId;
/**
* 市ID
*/
private Integer cityId;
/**
* 区ID
*/
private Integer areaId;
/**
* 医院类别
*/
private String type;
/**
* 医院名称
*/
private String hosName;
/**
* 科室
*/
private String depart;
/**
* 医院介绍
*/
private String hosIntroduce;
/**
* 医院电话
*/
private String hosTel;
/**
* 医院logo
*/
private String hosLogo;
/**
* 医院地址
*/
private String hosPosition;
/**
* 代理商ID
*/
private String agentId;
/**
* 代理商名称
*/
private String agentName;
/**
* 详细地址
*/
private String detailAddress;
/**
* 数据隔离ID
*/
private String dataId;
/**
* 乐观锁
*/
private Integer revision;
/**
* 等级
*/
private String level;
/**
* 账号
*/
private String username;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author XYTX
* @since 2019-11-26
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_login")
public class Login extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 登录账号
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 电话
*/
private String tel;
/**
* 言
*/
private String salt;
/**
* 1 正常 2 停用
*/
private Integer status;
/**
* 0 未删除 1已删除
*/
@TableLogic
private int isDeleted;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 护工护士表
* </p>
*
* @author MIND
* @since 2019-09-18
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_nurse")
public class Nurse extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "租户id",notes = "租户id")
private String tenantId;
/**
* 会员ID
*/
private String memberId;
/**
* 代理商ID
*/
@ApiModelProperty(value = "代理商ID",notes = "代理商ID")
private String agentId;
/**
* 所属护理公司
*/
@ApiModelProperty(value = "所属护理公司",notes = "所属护理公司")
private String agentName;
/**
* 所属医院ID
*/
@ApiModelProperty(value = "所属医院ID",notes = "所属医院ID")
private String hosId;
/**
* 所属医院名称
*/
@ApiModelProperty(value = "所属医院名称",notes = "所属医院名称")
private String hosName;
/**
* 添加人
*/
@ApiModelProperty(value = "添加人",notes = "添加人")
private String addUser;
/**
* 电话
*/
@ApiModelProperty(value = "电话",notes = "电话")
private String tel;
/**
* 登录账号
*/
@ApiModelProperty(value = "登录账号",notes = "登录账号")
private String username;
/**
* 服务省ID
*/
@ApiModelProperty(value = "服务省ID",notes = "服务省ID")
private String provinceId;
/**
* 服务市ID
*/
@ApiModelProperty(value = "服务市ID",notes = "服务市ID")
private String cityId;
/**
* 服务区ID
*/
@ApiModelProperty(value = "服务区ID",notes = "服务区ID")
private String areaId;
/**
* 护工类型1护士,2护工
*/
@ApiModelProperty(value = "护工类型1护士,2护工",notes = "护工类型1护士,2护工")
private Integer type;
/**
* 头像
*/
@ApiModelProperty(value = "头像",notes = "头像")
private String avator;
/**
* 真实姓名
*/
@ApiModelProperty(value = "真实姓名",notes = "真实姓名")
private String realName;
/**
* 身份证
*/
@ApiModelProperty(value = "身份证",notes = "身份证")
@TableField("ID_card")
private String idCard;
/**
* 正面证件照
*/
@ApiModelProperty(value = "正面证件照",notes = "正面证件照")
private String froutCardImg;
/**
* 反面证件照
*/
@ApiModelProperty(value = "反面证件照",notes = "反面证件照")
private String backCardImg;
/**
* 性别,1男,2女,3待定
*/
@ApiModelProperty(value = "性别,1男,2女,3待定",notes = "性别,1男,2女,3待定")
private Integer sex;
/**
* 认证状态 1认证中,2认证通过,3认证未通过
*/
@ApiModelProperty(value = "认证状态 1认证中,2认证通过,3认证未通过",notes = "认证状态 1认证中,2认证通过,3认证未通过")
private String status;
/**
* 从业时间
*/
@ApiModelProperty(value = "从业时间",notes = "从业时间")
private String employmentTime;
/**
* 护理年份
*/
@ApiModelProperty(value = "护理年份",notes = "护理年份")
private String employmentYear;
/**
* 护士等级
*/
@ApiModelProperty(value = "护士等级",notes = "护士等级")
private Integer level;
/**
* 服务标签以","分割 以","分割
*/
//@ApiModelProperty(value = "身份证",notes = "身份证")
private String tags;
/**
* 资质证明
*/
@ApiModelProperty(value = "资质证明",notes = "资质证明")
private String qualificationProofImg;
/**
* 执业证明
*/
@ApiModelProperty(value = "执业证明",notes = "执业证明")
private String licenseProofImg;
/**
* 工作证明
*/
@ApiModelProperty(value = "工作证明",notes = "工作证明")
private String workProofImg;
/**
* 民族
*/
@ApiModelProperty(value = "民族",notes = "民族")
private String nation;
/**
* 出生日期
*/
@ApiModelProperty(value = "出生日期",notes = "出生日期")
private String birthday;
/**
* 戶籍
*/
@ApiModelProperty(value = "戶籍",notes = "戶籍")
private String registeredPermanent;
/**
* 身高
*/
@ApiModelProperty(value = "身高",notes = "身高")
private String stature;
/**
* 体重
*/
@ApiModelProperty(value = "体重",notes = "体重")
private String weight;
/**
* 自我介紹
*/
@ApiModelProperty(value = "自我介紹",notes = "自我介紹")
private String introduce;
/**
* 监管员
*/
@ApiModelProperty(value = "监管员",notes = "监管员")
private String supervisor;
/**
* 服务数
*/
@ApiModelProperty(value = "服务数",notes = "服务数")
private Integer serviceNum;
/**
* 好评率
*/
@ApiModelProperty(value = "好评率",notes = "好评率")
private String favorableRate;
/**
* 合作方式
*/
@ApiModelProperty(value = "合作方式",notes = "合作方式")
private String withMethod;
/**
* 结算方式
*/
@ApiModelProperty(value = "结算方式",notes = "结算方式")
private String payMethod;
/**
* 职业
*/
@ApiModelProperty(value = "职业",notes = "职业")
private String profession;
/**
* 学历
*/
@ApiModelProperty(value = "学历",notes = "学历")
private String education;
/**
* 年龄
*/
@ApiModelProperty(value = "年龄",notes = "年龄")
private Integer age;
/**
* 街道地址
*/
@ApiModelProperty(value = "街道地址",notes = "街道地址")
private String address;
/**
* 数据隔离ID
*/
private String dataId;
/**
* 乐观锁
*/
private Long revision;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author Night
* Date: 2020/5/11
*/
@Data
@Accessors(chain = true)
@TableName("care_pay_method")
@ApiModel(value = "PayMethod对象", description = "支付方式对象")
public class PayMethod implements Serializable {
private static final long serialVersionUID = 1L;
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
@TableId(value = "id",type = IdType.ASSIGN_ID)
private Long id;
@TableLogic
@ApiModelProperty(value = "逻辑删除标识")
private int isDeleted;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime createdTime;
@TableField(value = "updated_time",update = "now()")
@ApiModelProperty(value = "修改时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime updatedTime;
@ApiModelProperty(value = "创建人")
@JsonSerialize(using = ToStringSerializer.class)
private Long createdBy;
@ApiModelProperty(value = "修改人")
@JsonSerialize(using = ToStringSerializer.class)
private Long updatedBy;
@NotNull
@ApiModelProperty(value = "支付方式名称",required=true)
private String name;
@ApiModelProperty(value = "支付类型 1 款到发货 2 货到付款")
private Integer type;
@ApiModelProperty(value = "支付方式 1 在线支付 2 线下支付")
private Integer method;
@ApiModelProperty(value = "图标")
private String icon;
@ApiModelProperty(value = "介绍")
private String introduce;
@ApiModelProperty(value = "排序")
private Integer sortnum;
@ApiModelProperty(value = "内容")
private String content;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_nurse")
public class Pension extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 租户ID
*/
@ApiModelProperty(value = "租户ID")
private String tenantId;
/**
* 省ID
*/
private Integer provinceId;
/**
* 市ID
*/
private Integer cityId;
/**
* 区ID
*/
private Integer areaId;
/**
* 机构名称
*/
private String agentName;
/**
* 机构介绍
*/
private String agentIntroduce;
/**
* 机构电话
*/
private String agentTel;
/**
* 机构logo
*/
private String agentLogo;
/**
* 机构地址
*/
private String agentPosition;
/**
* 详细地址
*/
private String detailAddress;
/**
* 数据隔离ID
*/
private String dataId;
/**
* 账号
*/
private String username;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author XYTX
* @since 2019-12-03
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("care_schedule")
public class Schedule extends BaseEntity {
private static final long serialVersionUID = 1L;
private String nurseId;
/**
* 护理员姓名
*/
private String nurseName;
private String doctorId;
/**
* 护士长姓名
*/
private String doctorName;
private String agentId;
/**
* 所属服务公司
*/
private String agentName;
private String hosId;
/**
* 所属医院
*/
private String hosName;
/**
* 当天标准工时
*/
private Integer stdHour;
/**
* 当天加班工时
*/
private Integer outHour;
/**
* 当天节假日工时
*/
private Integer holidayHour;
/**
* 科室name
*/
private String departmentName;
/**
* 排班日期
*/
private String date;
/**
* 排班信息 类似这种 08:00-12:00|14:00-18:00
*/
private String worktime;
/**
* 考勤时间 可以在考勤页面修改的时间。
*/
private String attendanceTime;
/**
* 当天工作时长 根据当前表的考勤时间段计算
*/
private int hours;
/**
* 班次id
*/
private String classesId;
/**
* 班次名称
*/
private String classesName;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@TableName("social_user")
@Data
public class SocialUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 租户ID
*/
@ApiModelProperty(value = "租户ID")
private String tenantId;
@ApiModelProperty(value = "创建日期")
private Date createdDate;
@ApiModelProperty(value = "修改日期")
private Date lastModifiedDate;
@ApiModelProperty(value = "修改日期")
private Integer version;
@ApiModelProperty(value = "openId")
private String uniqueId;
@ApiModelProperty(value = "用户ID")
private Long userId;
@ApiModelProperty(value = "昵称")
private Integer name;
@ApiModelProperty(value = "性别")
private Integer gender;
@ApiModelProperty(value = "头像")
private Integer averter;
@ApiModelProperty(value = "电话")
private Integer tel;
@ApiModelProperty(value = "account")
private String account;
@TableLogic
private Integer isEnabled;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* Created with IDEA
* author:Mind
*
* Date:2019/8/22
* Time:16:16
*/
@Data
@Accessors(chain = true)
public class SuperEntity implements Serializable {
/**
* serialVersionUID
*/
private static final long serialVersionUID = -4801865210961587582L;
@TableId(type = IdType.ID_WORKER_STR)
private String id;
}
package org.springblade.mid.entity;
import lombok.Data;
import java.io.Serializable;
@Data
public class WXConfig implements Serializable {
//{"mchId":"1520601861","apiKey":"GRMd42LnZBf0ce1tuiKo4cTUsXYMB8aX","displayName":"微信支付(小程序)","appId":"wx97a520365a9cc0b9","fee":"0","logo":"http://xy-health-pro.oss-cn-beijing.aliyuncs.com/upload/image/202003/13949ffb-76e3-4e9e-9225-b16d8cc99ed5.png","description":null,"appSecret":"ae90c42a8dd8853259d409eb169e337b","feeType":"SCALE"}
private String openIdRequestURL = "https://api.weixin.qq.com/sns/oauth2/access_token";
private String apiKey;
private String appId;
private String appSecret;
private String mchId;
}
package org.springblade.mid.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* 法定周末工作日日期
* @author Night
* Date: 2020/1/9
*/
@Data
@TableName("care_workweekend")
public class Workweekend extends BaseEntity {
private String date;
}
package org.springblade.mid.excel;
import com.github.liaochong.myexcel.core.annotation.ExcelColumn;
import lombok.Data;
/**
* @author Night
* Date: 2020/4/13
*/
@Data
public class NurseCrowd {
/**
* 代理商ID
*/
@ExcelColumn(index = 0)
private String agentId;
/**
* 所属护理公司
*/
@ExcelColumn(index = 1)
private String agentName;
/**
* 所属医院ID
*/
@ExcelColumn(index = 2)
private String hosId;
/**
* 所属医院名称
*/
@ExcelColumn(index = 3)
private String hosName;
/**
* 添加人
*/
@ExcelColumn(index = 4)
private String addUser;
/**
* 电话
*/
@ExcelColumn(index = 5)
private String tel;
/**
* 护工类型1护士,2护工
*/
@ExcelColumn(index = 6)
private Integer type;
/**
* 真实姓名
*/
@ExcelColumn(index = 7)
private String realName;
/**
* 性别,1男,2女,3待定
*/
@ExcelColumn(index = 8)
private Integer sex;
/**
* 认证状态 1认证中,2认证通过,3认证未通过
*/
@ExcelColumn(index = 9)
private String status;
}
package org.springblade.mid.feign;
import org.springblade.mid.entity.Agent;
import org.springblade.mid.entity.Hospital;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(
value = "blade-mid",
fallback = IAgentClientFallback.class
)
public interface IAgentClient {
String API_PREFIX = "/api-agent";
String SAVE = API_PREFIX + "/save";
@GetMapping(SAVE)
R save(@RequestBody Agent agent);
}
package org.springblade.mid.feign;
import org.springblade.mid.entity.Agent;
import org.springblade.mid.entity.Hospital;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;
@Component
public class IAgentClientFallback implements IAgentClient {
@Override
public R save(Agent agent) {
return R.data(new Hospital());
}
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.AppConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(
value = "blade-mid",
fallback = IConfigClientFallback.class
)
public interface IAppConfigClient {
String API_PREFIX = "/api-config";
String FIND = API_PREFIX + "/find";
@GetMapping(FIND)
R<AppConfig> find(@RequestParam String tenantId);
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.AppConfig;
import org.springframework.stereotype.Component;
@Component
public class IConfigClientFallback implements IAppConfigClient {
@Override
public R<AppConfig> find(String tenantId) {
return null;
}
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Doctor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
@FeignClient(
value = "blade-mid",
fallback = IDoctorClientFallback.class
)
public interface IDoctorClient {
String API_PREFIX = "/api-doctor";
String FIND = API_PREFIX + "/find";
@GetMapping(FIND)
R<Doctor> find(String id);
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Doctor;
import org.springframework.stereotype.Component;
//@Component
public class IDoctorClientFallback{
// implements IDoctorClient {
// @Override
// public R<Doctor> find(String id) {
// return R.data(null);
// }
}
package org.springblade.mid.feign;
import org.springblade.mid.entity.Hospital;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(
value = "blade-mid",
fallback = IHospitalClientFallback.class
)
public interface IHospitalClient {
String API_PREFIX = "/api-hospital";
String SAVE = API_PREFIX + "/save";
String FIND = API_PREFIX + "/find";
@GetMapping(SAVE)
R save(@RequestBody Hospital hospital);
@GetMapping(FIND)
R<Hospital> find(String id);
}
package org.springblade.mid.feign;
import org.springblade.mid.entity.Hospital;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;
@Component
public class IHospitalClientFallback implements IHospitalClient {
@Override
public R save(Hospital hospital) {
return R.data(new Hospital());
}
@Override
public R<Hospital> find(String id) {
return R.fail("获取数据失败");
}
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Agent;
import org.springblade.mid.entity.Nurse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(
value = "blade-mid",
fallback = INurseClientFallback.class
)
public interface INurseClient {
String API_PREFIX = "/api-nurse";
String FIND = API_PREFIX + "/nurseByIds";
@GetMapping(FIND)
R<List<Nurse>> find(@RequestParam("nurseIds") String nurseIds);
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Agent;
import org.springblade.mid.entity.Hospital;
import org.springblade.mid.entity.Nurse;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class INurseClientFallback implements INurseClient {
@Override
public R<List<Nurse>> find(String nurseIds) {
return R.fail("获取数据失败");
}
}
package org.springblade.mid.feign;
import com.fasterxml.jackson.databind.util.JSONPObject;
import org.springblade.mid.vo.OauthReq;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
@FeignClient(
value = "blade-auth",
fallback = IOauthFallback.class
)
public interface IOauthClient {
/**
*
* @param tenantId
* @param username
* @param password
* @param type
* @param scope
* @param grantType
* @param tid
* @param auth
* @return
*/
@PostMapping(value = "/oauth/token")
public Map<String,String> token1(@RequestParam String tenantId,@RequestParam String username,@RequestParam String password,@RequestParam String type,@RequestParam String scope,@RequestParam("grant_type")String grantType,@RequestHeader("Tenant-Id") String tid,@RequestHeader("Authorization") String auth);
}
package org.springblade.mid.feign;
import org.springblade.mid.vo.OauthReq;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class IOauthFallback implements IOauthClient {
@Override
public Map<String, String> token1(String tenantId, String username, String password, String type, String scope, String grantType, String tid, String auth) {
return null;
}
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Pension;
public interface IPensionClient {
public R<Pension> find(String id );
public R save(Pension pension);
public R upd(Pension pension);
public R del(String ids);
}
package org.springblade.mid.feign;
import org.springblade.mid.entity.Pension;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;
//@Component
public class IPensionClientFallback implements IPensionClient {
@Override
public R<Pension> find(String id) {
return null;
}
@Override
public R<Pension> save(Pension pension) {
return null;
}
@Override
public R<Pension> upd(Pension pension) {
return null;
}
@Override
public R<Pension> del(String ids) {
return null;
}
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Agent;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(
value = "blade-mid",
fallback = ISocialUserClientFallback.class
)
public interface ISocialUserClient {
String API_PREFIX = "/api-socialUser";
String FIND = API_PREFIX + "/find";
@GetMapping(FIND)
R find(@RequestParam("userId") Long userId);
}
package org.springblade.mid.feign;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Agent;
import org.springblade.mid.entity.Hospital;
import org.springframework.stereotype.Component;
@Component
public class ISocialUserClientFallback implements ISocialUserClient {
@Override
public R find(Long userId) {
return R.fail("获取数据失败");
}
}
package org.springblade.mid.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author Night
* Date: 2019/12/23
*/
@Data
@Accessors(chain = true)
public class HourStatisticsVO implements Serializable {
private static final long serialVersionUID = -6838236645311519639L;
private String nurseId;
/**
* 护理员姓名
*/
private String nurseName;
private String doctorId;
/**
* 护士长姓名
*/
private String doctorName;
private String agentId;
/**
* 所属服务公司
*/
private String agentName;
private String hosId;
/**
* 所属医院
*/
private String hosName;
/**
* 科室name
*/
private String departmentName;
/**
* 标准工时
*/
private int stdHours;
/**
* 节假日工时
*/
private int holidayHour;
/**
* 总工时
*/
private int totalHours;
}
package org.springblade.mid.vo;
import lombok.Data;
@Data
public class OauthReq {
private String username;
private String password;
private String tenantId;
private String scope="all";
private String grant_type="password";
private String type="account";
}
package org.springblade.mid.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/** 保存 排班id和排班日期和排班班次的时间段
* 用于ScheduleVO中保存一周的排班信息
* @author Night
* Date: 2019/12/20
*/
@Data
@Accessors(chain = true)
public class ScheduleDetailVO implements Serializable {
private static final long serialVersionUID = 2023698099603992097L;
private String scheduleId;
private String date;
/**
* 班次时间段
*/
private String worktime;
/**
* 考勤信息
*/
private String attendanceTime;
/**
* 工作时长
*/
private int hours;
/**
* 班次id
*/
private String classesId;
/**
* 班次名称
*/
private String classesName;
}
package org.springblade.mid.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 排班vo对象 除了List属性都是当前护理员的通用属性
*
* @author Night
* Date: 2019/12/20
*/
@Data
@Accessors(chain = true)
public class ScheduleVO implements Serializable {
private static final long serialVersionUID = -4236318611754299510L;
private String nurseId;
/**
* 护理员姓名
*/
private String nurseName;
private String doctorId;
/**
* 护士长姓名
*/
private String doctorName;
private String agentId;
/**
* 所属服务公司
*/
private String agentName;
private String hosId;
/**
* 所属医院
*/
private String hosName;
/**
* 科室name
*/
private String departmentName;
private List<ScheduleDetailVO> scheduleDetailVOList = new ArrayList<>();
}
package org.springblade.mid.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class WxConfig {
/**
* 租户ID
*/
@ApiModelProperty(value = "appid")
private String appId;
/**
* 租户ID
*/
@ApiModelProperty(value = "secret")
private String appSecret;
/**
* 租户ID
*/
@ApiModelProperty(value = "商户号")
private String mchId;
}
FROM 172.17.45.176:8000/blade/alpine-jdk1.8:latest
MAINTAINER smallchill@163.com
RUN mkdir -p /blade/mid
WORKDIR /blade/mid
EXPOSE 8208
ADD ./target/blade-mid.jar ./app.jar
#设置环境变量
ENV SPRING_PROFILES_ACTIVE=dev
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=$SPRING_PROFILES_ACTIVE", "-jar", "app.jar"]
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>BladeX-Biz</artifactId>
<groupId>org.springblade</groupId>
<version>2.4.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blade-sched</artifactId>
<name>${project.artifactId}</name>
<version>${bladex.project.version}</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-sched-api</artifactId>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-user-api</artifactId>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-swagger</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-tenant</artifactId>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-system</artifactId>
<version>${bladex.project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<imageName>${docker.registry.url}/blade/${project.artifactId}:${project.version}</imageName>
<dockerDirectory>${project.basedir}</dockerDirectory>
<dockerHost>${docker.registry.host}</dockerHost>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<registryUrl>${docker.registry.url}</registryUrl>
<serverId>${docker.registry.url}</serverId>
<pushImage>true</pushImage>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<!--suppress UnresolvedMavenProperty -->
<copy overwrite="true"
tofile="${session.executionRootDirectory}/target/${project.artifactId}.jar"
file="${project.build.directory}/${project.artifactId}.jar" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package org.springblade.agent;
import org.springblade.core.cloud.feign.EnableBladeFeign;
import org.springblade.core.launch.BladeApplication;
import org.springframework.cloud.client.SpringCloudApplication;
@EnableBladeFeign
@SpringCloudApplication
public class ScheduleApplication {
public static void main(String[] args) {
BladeApplication.run("blade-schedule", ScheduleApplication.class, args);
}
}
package org.springblade.agent.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.agent.service.IAddressService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Area;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@AllArgsConstructor
@Slf4j
@RequestMapping("/address")
@Api("地址信息")
public class AddressController {
private IAddressService addressService;
@RequestMapping(value = "/addressList", method = RequestMethod.GET)
@ApiOperation("获取地理位置信息")
@Cacheable("areasist")
public R addressList() {
log.info("---->获取地址列表");
return R.data(addressService.addressList());
}
@RequestMapping(value = "/lazyList", method = RequestMethod.GET)
@ApiOperation("获取地理位置信息")
@ApiImplicitParams({
@ApiImplicitParam(value = "lvl",dataType ="String"),
@ApiImplicitParam(value = "parentCode",dataType ="String")
})
public R lazyList(@RequestParam Map<String,Object> params) {
log.info("---->获取地址列表");
return R.data(addressService.list(Condition.getQueryWrapper(params, Area.class)));
}
}
package org.springblade.agent.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.mid.entity.Agent;
import org.springblade.agent.service.IAgentService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/agent")
@Slf4j
@Api(tags = "代理商((弃用)),租户里面增删改")
public class AgentController extends BladeController {
private IAgentService agentService;
@PostMapping(value = "/select/list")
public R<List<Agent>> selAgentList() {
log.info("接口【selAgentList】");
return R.data(agentService.list());
}
@PostMapping(value = "/manage/list")
public R<IPage<Agent>> manageList(@RequestBody Map<String,Object> jsonObject, Query query) {
log.info("接口【selAgentList】");
return R.data(agentService.page(Condition.getPage(query),Condition.getQueryWrapper(jsonObject,Agent.class)));
}
/**
*
* @return
*/
@PostMapping(value = "/manage/ins")
public R insAgent(@RequestBody Agent agent) {
log.info("新增代理商【insAgent】,入参={}",agent);
return R.status(agentService.save(agent));
}
/**
* 护工/护士列表
* @return
*/
@PostMapping(value = "/manage/upd")
public R updAgent(@RequestBody Agent agent) {
log.info("修改代理商【updAgent】,入参={}",agent);
return R.status(agentService.update(Condition.getQueryWrapper(agent)));
}
/**
* 删除代理商
* @return
*/
@PostMapping(value = "/manage/del")
public R delAgent(String ids) {
log.info("删除代理商【delAgent】,入参={}",ids);
return R.status(agentService.removeByIds(Func.toLongList(ids)));
}
/**
* @param id
* @return
*/
@PostMapping(value = "/manage/byid")
public R<Agent> selById(String id) {
log.info("查询代理商【selById】,入参={}",id);
return R.data(agentService.getById(id));
}
}
package org.springblade.agent.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.mid.entity.AgentHos;
import org.springblade.agent.service.IAgentHosService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* <p>
* 前端控制器
* </p>
*
* @author max
* @since 2020-04-27
*/
@RestController
@RequestMapping("/bind")
@Slf4j
@AllArgsConstructor
@Api(value = "医院和代理商绑定",tags = "医院和代理商绑定")
public class AgentHosController extends BladeController {
private IAgentHosService agentHosService;
/**
* @Author: ssh
* @Description: 服务公司
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping(value = "/agenttohos/list")
@ApiOperation(value = "绑定列表",notes = "绑定列表")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public R<IPage<AgentHos>> bindAgentToHosListCro(@RequestBody JSONObject jsonObject, Query query){
// CommonUtil.hasAllRequired(jsonObject, "agentId");
log.info("【BindController>>>detail】Param = {}", jsonObject);
return R.data(agentHosService.page(Condition.getPage(query),Condition.getQueryWrapper(jsonObject,AgentHos.class)));
}
/**
* @Author: ssh
* @Description: 绑定
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping(value = "/agenttohos/bind")
@ApiImplicitParams(
{
@ApiImplicitParam(value = "agentId",required = true),
@ApiImplicitParam(value = "agentName",required = true),
@ApiImplicitParam(value = "hosId",required = true),
@ApiImplicitParam(value = "hosName",required = true)
}
)
@ApiOperation(value = "绑定",notes = "绑定")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public R bindAgentToHos(@RequestBody Map<String,Object> jsonObject){
// CommonUtil.hasAllRequired(jsonObject, "agentId,agentName,hosId,hosName");
log.info("【BindController>>>bindAgentToHos】Param = {}", jsonObject);
return R.status(agentHosService.bindAgentToHos(jsonObject));
}
/**
* @Author: ssh
* @Description: 修改
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping(value = "/agenttohos/updtime")
@ApiOperation(value = "修改",notes = "修改")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public R updAgentToHos(@RequestBody AgentHos agentHos){
log.info("【BindController>>>bindAgentToHos】Param = {}", agentHos);
return R.status(agentHosService.update(Condition.getQueryWrapper(agentHos)));
}
/**
* @Author: ssh
* @Description: 删除
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping(value = "/agenttohos/del")
@ApiOperation(value = "删除",notes = "删除")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public R delAgentToHos(String ids){
// CommonUtil.hasAllRequired(json, "id");
log.info("【BindController>>>bindAgentToHos】Param = {}", ids);
return R.status(agentHosService.removeByIds(Func.toLongList(ids)));
}
}
package org.springblade.agent.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.mid.entity.AppConfig;
import org.springblade.agent.service.IAppConfigService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RequestMapping("/config")
@RestController
@AllArgsConstructor
public class AppConfigController {
private IAppConfigService appConfigService;
@GetMapping("/detail")
@ApiOperation(value = "配置详情",notes = "配置详情")
public R findConfig(String tenantId,BladeUser user){
return R.data(appConfigService.getOne(new QueryWrapper<AppConfig>().lambda().eq(AppConfig::getTenantId,tenantId)));
}
@PostMapping("/submit")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
@ApiOperation(value = "配置新增",notes = "配置新增")
public R submit(@RequestBody AppConfig appConfig, BladeUser user){
AppConfig config = appConfigService.getOne(Wrappers.<AppConfig>query().lambda().eq(AppConfig::getTenantId,user.getTenantId()));
if(config != null){
return R.fail("该用户已有配置信息,请勿重复添加");
}
return R.data(appConfigService.save(appConfig));
}
@PutMapping("/update")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
@ApiOperation(value = "配置修改",notes = "配置修改")
public R update(@RequestBody AppConfig appConfig, BladeUser user){
AppConfig config = appConfigService.getOne(Wrappers.<AppConfig>query().lambda().eq(AppConfig::getTenantId,user.getTenantId()).ne(AppConfig::getId,appConfig.getId()));
if(config != null){
return R.fail("参数错误,请确认");
}
return R.data(appConfigService.updateById(appConfig));
}
@PostMapping("/del")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
@ApiOperation(value = "删除配置",notes = "删除配置")
public R delConfig(String ids,BladeUser user){
return R.data(appConfigService.removeByIds(Func.toLongList(ids)));
}
@GetMapping("/list")
@ApiOperation(value = "配置列表",notes = "配置列表")
public R list(@RequestParam Map<String,Object> config, Query query, BladeUser user){
return R.data(appConfigService.page(Condition.getPage(query),Condition.getQueryWrapper(config,AppConfig.class)));
}
@GetMapping("/find")
@ApiOperation(value = "通过域名主站获取配置",notes = "通过域名主站获取配置")
public R lists(String miniProgram){
return R.data(StringUtils.isEmpty(miniProgram)?new Object():appConfigService.getOne(Wrappers.lambdaQuery(AppConfig.class).eq(AppConfig::getMiniProgram,miniProgram)));
}
}
package org.springblade.agent.controller;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@AllArgsConstructor
@Slf4j
@RequestMapping("/address")
@Api("排班")
public class ClassController extends BladeController {
}
package org.springblade.agent.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.BladeUser;
import org.springblade.mid.entity.Doctor;
import org.springblade.agent.service.IDoctorService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @Auther FREAKS
* @Date 2019/12/6
*/
@RequestMapping(value = "/doctor")
@RestController
@AllArgsConstructor
@Slf4j
@Api("医生/护士长操作")
public class DoctorController {
private IDoctorService doctorService;
/**
* @Author: FREAKS
* @Description: 医生列表
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping("list")
@ApiImplicitParams({
@ApiImplicitParam(value = "type",required = true,example="0 医生 1 护士长"),
@ApiImplicitParam(value = "relName",required = false),
@ApiImplicitParam(value = "depart",required = false),
@ApiImplicitParam(value = "tenantId",required = true)
})
@ApiOperation(value = "医生列表",notes = "医生列表")
// @PreAuth("hasAnyRole('doctor', 'header_nurse')")
public R<IPage> doctorList(@RequestBody Map<String,Object> doctor, Query query){
log.info("DoctorController===>>>【doctorList】,入参={}",doctor);
return R.data(doctorService.page(Condition.getPage(query), Condition.getQueryWrapper(doctor, Doctor.class)));
}
/**
* @Author: Max Su
* @Description: 新增医生信息
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping("ins")
@ApiOperation(value = "新增医生信息",notes = "新增医生信息")
// @PreAuth("hasAnyRole('doctor', 'header_nurse')")
public R insDoc(@RequestBody Doctor doctor, BladeUser user){
log.info("DoctorController===>>>【insDoc】,入参={}",doctor);
// doctor.setTenantId(user.getTenantId());
return R.status(doctorService.save(doctor));
}
/**
* @Author: Max Su
* @Description: 新增医生信息
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping("detail")
@ApiOperation(value = "医生信息",notes = "医生信息")
// @PreAuth("hasAnyRole('doctor', 'header_nurse')")
public R selectDoc(String id, BladeUser user){
log.info("DoctorController===>>>【insDoc】,入参={}",id);
return R.data(doctorService.getById(id));
}
/**
* @Author: Max Su
* @Description: 修改医生信息
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping("upd")
@ApiOperation(value = "修改医生信息",notes = "修改医生信息")
// @PreAuth("hasAnyRole('doctor', 'header_nurse')")
public R updDoc(@RequestBody Doctor doctor, BladeUser user){
log.info("DoctorController===>>>【updDoc】,入参={}",doctor);
doctor.setTenantId(user.getTenantId());
return R.status(doctorService.updateById(doctor));
}
// /**
// * @Author: Max Su
// * @Description: 查询停用启用状态
// * @Date: 2019/12/6
// * @Param:
// * @Return:
// */
// @PostMapping("selLoginStatus")
// @ResponseBody
// public R selLoginStatus(@RequestBody JSONObject jsonObject){
//// log.info("DoctorController===>>>【updDoc】,入参={}",jsonObject);
//// TxResultResponse tx = new TxResultResponse(CommonCode.SUCCESS.getCode(), "操作成功!");
//// try {
//// if(Strings.isNullOrEmpty(jsonObject.getString("username"))){
//// throw new CommonException(CommonCode.DATA_NOT_FOUND.getCode(),"入参username为空");
//// }
//// return loginService.selByUsername(jsonObject.getString("username"));
//// } catch (CommonException e) {
//// log.error("DoctorController===>>>【updDoc】,e={}", e);
//// return new TxResultResponse(e.getCode(), e.getMsg());
//// } catch (Exception e) {
//// e.printStackTrace();
//// log.error("DoctorController===>>>【updDoc】,e={}", e);
//// return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
//// }
//// }
/**
* @Author: Max Su
* @Description: 删除医生信息
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping("del")
@ApiOperation(value = "删除医生信息",notes = "删除医生信息")
// @PreAuth("hasAnyRole('doctor', 'header_nurse')")
public R delDoc(String ids){
log.info("DoctorController===>>>【delDoc】,入参={}",ids);
return R.status(doctorService.removeByIds(Func.toLongList(ids)));
}
/**
* @Author: Max Su
* @Description: 重置密码
* @Date: 2019/12/6
* @Param:
* @Return:
*/
// @PostMapping("reset")
// @ResponseBody
// public TxResultResponse resetPassword(@RequestBody JSONObject jsonObject){
// log.info("DoctorController===>>>【resetPassword】,入参={}",jsonObject);
// try {
// TxResultResponse tx = loginService.resetPassword(jsonObject.getString("username"));
// return tx;
// } catch (CommonException e) {
// log.error("DoctorController===>>>【resetPassword】,e={}", e);
// return new TxResultResponse(e.getCode(), e.getMsg());
// } catch (Exception e) {
// e.printStackTrace();
// log.error("DoctorController===>>>【resetPassword】,e={}", e);
// return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
// }
// }
// /**
// * @Author: Max Su
// * @Description: 科室列表
// * @Date: 2019/12/10
// * @Param:
// * @Return:
// */
// @PostMapping("depart")
// @ResponseBody
// public R getDepart(@RequestBody JSONObject jsonObject){
// TxResultResponse tx = new TxResultResponse(CommonCode.SUCCESS.getCode(),"操作成功!");
// log.info("DoctorController===>>>【getDepart】,入参={}",jsonObject);
// try {
// List<String> departList = doctorService.getDepart(jsonObject);
// tx.setData(departList);
// return tx;
// } catch (CommonException e) {
// log.error("DoctorController===>>>【getDepart】,e={}", e);
// return new TxResultResponse(e.getCode(), e.getMsg());
// } catch (Exception e) {
// e.printStackTrace();
// log.error("DoctorController===>>>【getDepart】,e={}", e);
// return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
// }
// }
}
package org.springblade.agent.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.mid.entity.Hospital;
import org.springblade.agent.service.IHospitalService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RequestMapping(value = "/hospital")
@RestController
@Api("医院操作((弃用)),租户里面增删改")
@AllArgsConstructor
@Slf4j
public class HospitalController extends BladeController {
IHospitalService hospitalService;
/**
* 新增医院
* @param hospital
* @return
*/
@PostMapping(value = "/manage/ins")
@ApiOperation(value = "新增医院(弃用)",notes = "新增医院(弃用)")
public R insHospital(@RequestBody Hospital hospital) {
log.info("HospitalController-->>>【insHospital】,入参={}",hospital);
return R.status(hospitalService.save(hospital));
}
/**
* 修改医院
* @param hospital
* @return
*/
@PostMapping(value = "/manage/upd")
@ApiOperation(value = "修改医院",notes = "修改医院")
public R updHospital(@RequestBody Hospital hospital) {
log.info("HospitalController-->>>【updHospital】,入参={}",hospital);
return R.status(hospitalService.update(Condition.getQueryWrapper(hospital)));
}
/**
* 删除医院
* @param ids
* @return
*/
@PostMapping(value = "/manage/del")
@ApiOperation(value = "删除医院",notes = "删除医院")
public R delHospital(@RequestBody String ids) {
log.info("HospitalController-->>>【delHospital】,入参={}",ids);
return R.status(hospitalService.removeByIds(Func.toLongList(ids)));
}
/**
*
* @param json
* @param query
* @return
*/
@PostMapping(value = "/manage/list")
@ApiOperation(value = "医院列表",notes = "医院列表")
public R<IPage<Hospital>> getHosList(@RequestBody Map<String,Object> json, Query query) {
log.info("HospitalController-->>>【getHosList】 列表,入参={}",json);
return R.data(hospitalService.page(Condition.getPage(query), Condition.getQueryWrapper(json, Hospital.class)));
}
/**
* @param agentId
* @return
*/
@GetMapping(value = "/manage/byid")
@ApiOperation(value = "通过id获取医院信息",notes = "通过id获取医院信息")
public R<Hospital> selById(String agentId) {
log.info("查询代理商【selById】,入参={}",agentId);
return R.data(hospitalService.getById(Func.toLong(agentId)));
}
}
package org.springblade.agent.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.liaochong.myexcel.core.DefaultExcelReader;
import com.google.common.base.Strings;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.mid.entity.Login;
import org.springblade.mid.entity.Nurse;
import org.springblade.mid.excel.NurseCrowd;
import org.springblade.agent.service.IHospitalService;
import org.springblade.agent.service.ILoginService;
import org.springblade.agent.service.INurseService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/nurse")
@Slf4j
@AllArgsConstructor
@Api("护士护工操作")
public class NurseController extends BladeController {
private INurseService nurseService;
private ILoginService loginService;
private IHospitalService hospitalService;
/**
* 指派更换治疗室接口
* @param params
* @return
*/
@PostMapping(value = "/nurseList")
@ApiImplicitParam(value = "agentId",required = true)
@ApiOperation(value = "根据代理商id获取,护工/护士列表",notes = "根据代理商id获取,护工/护士列表")
public R nurseList(@RequestBody Map<String,Object> params) {
log.info("根据代理商id获取,护工/护士列表【nurseList】,入参={}",params);
List<Nurse> nurses = nurseService.list(Condition.getQueryWrapper(params, Nurse.class).eq("type", 4).eq("is_deleted", 0));
ArrayList<JSONObject> jsonObjects = new ArrayList<>();
nurses.forEach(N->{
JSONObject json = new JSONObject();
json.put("id",N.getId());
json.put("name",N.getRealName());
jsonObjects.add(json);
});
log.info("根据代理商id获取,护工/护士列表【nurseList】,response={}",jsonObjects);
return R.data(jsonObjects);
}
/**
* 护工/护士列表
* @return
*/
@PostMapping(value = "/list")
@ApiOperation(value = "获取护工/护士列表",notes = "获取护工/护士列表")
public R<IPage<Nurse>> selectNurse(@RequestBody Nurse json, Query query) {
log.info("NurseController-->>>【selectNurse】 列表,入参={}",json);
return R.data(nurseService.page(Condition.getPage(query),Condition.getQueryWrapper(json).orderByDesc("created_time")));
}
/**
* 护工/护士列表
* @return
*/
@PreAuth("hasAnyRole('header_nurse','admin','administrator')")
@PostMapping(value = "/ins")
@ApiOperation(value = "新增护工/护士列表",notes = "新增护工/护士列表")
public R insNurse(@RequestBody Nurse jsonObject) {
log.info("NurseController-->>>【insNurse】,入参={}",jsonObject);
return R.status(nurseService.save(jsonObject));
}
/**
* @Author: FREAKS
* @Description: 查询停用启用状态
* @Date: 2019/12/6
* @Param:
* @Return:
*/
@PostMapping("/selLoginStatus")
@ApiOperation(value = "查询停用启用状态",notes = "查询停用启用状态")
public R selLoginStatus(@RequestBody Map<String,Object> jsonObject){
log.info("DoctorController===>>>【updDoc】,入参={}",jsonObject);
return R.data(loginService.getOne(Condition.getQueryWrapper(jsonObject, Login.class)));
}
/**
* 修改
* @return
*/
@PreAuth("hasAnyRole('header_nurse','admin','administrator')")
@PostMapping(value = "/upd")
@ApiOperation(value = "修改护士护工",notes = "修改护士护工")
public R updNurse(@RequestBody Nurse jsonObject) {
log.info("NurseController-->>>【updNurse】,入参={}",jsonObject);
return R.status(nurseService.updateById(jsonObject));
}
/**
* 删除
* @return
*/
@PreAuth("hasAnyRole('header_nurse','admin','administrator')")
@PostMapping(value = "/del")
@ApiOperation(value = "删除护士护工",notes = "删除护士护工")
public R delNurse(String ids) {
log.info("NurseController-->>>【delNurse】,入参={}",ids);
return R.status(nurseService.removeByIds(Func.toLongList(ids)));
}
/**
* 删除
* @return
*/
@PostMapping(value = "/detail")
@ApiOperation(value = "护士护工详情",notes = "护士护工详情")
public R selectNurse(String id) {
log.info("NurseController-->>>【delNurse】,入参={}",id);
return R.data(nurseService.getById(id));
}
/**
* @Author: FREAKS
* @Description: 医院列表
* @Date: 2019/12/10
* @Param:
* @Return:
*/
@PostMapping(value = "/hospital")
@ApiOperation(value = "查询停用启用状态",notes = "查询停用启用状态")
public R hospitalList() {
return R.data(hospitalService.list());
}
@PostMapping(value = "exceltosql")
@ApiOperation(value = "查询停用启用状态",notes = "查询停用启用状态")
public R exceltosql(MultipartFile file) throws Exception {
log.info("进入导入excel表格方法,文件名为{}",file.getOriginalFilename());
List<Nurse> list = new ArrayList<>();
List<NurseCrowd> result = DefaultExcelReader.of(NurseCrowd.class).sheet(0)
.rowFilter(row -> row.getRowNum() > 0).read(file.getInputStream());
result.forEach(e -> {
if (nurseHasNullOrEmpty(e)) {
Nurse nurse = new Nurse();
BeanUtils.copyProperties(e, nurse);
list.add(nurse);
}
});
return R.status(nurseService.saveBatch(list));
}
/**
* @param nurseCrowd 保证导入的地段没空或者null。
* @return
*/
private boolean nurseHasNullOrEmpty(NurseCrowd nurseCrowd) {
for (Field f : nurseCrowd.getClass().getDeclaredFields()){
f.setAccessible(true);
try {
if (f.get(nurseCrowd) == null || StringUtils.isBlank(f.get(nurseCrowd).toString())){
return false;
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return true;
}
}
package org.springblade.agent.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.agent.service.PayMethodService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.mid.entity.PayMethod;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@AllArgsConstructor
@Slf4j
@RequestMapping("/paymethod")
@Api("支付方式信息")
public class PayMethodController {
private PayMethodService payMethodService;
@RequestMapping(value = "/payMethodList", method = RequestMethod.GET)
@ApiOperation("获取支付方式信息")
public R PayMethodList(@RequestParam Map<String,Object> payMethod, Query query) {
log.info("---->获取支付方式列表");
return R.data(payMethodService.page(Condition.getPage(query),Condition.getQueryWrapper(payMethod,PayMethod.class)));
}
@RequestMapping(value = "/addPayMethod", method = RequestMethod.POST)
@ApiOperation("增加支付方式信息")
public R insert(@RequestBody PayMethod payMethod) {
log.info("---->增加支付方式");
return R.data(payMethodService.save(payMethod));
}
@RequestMapping(value = "/updatePayMethod", method = RequestMethod.POST)
@ApiOperation("编辑支付方式信息")
public R update(@RequestBody PayMethod payMethod) {
log.info("---->编辑支付方式");
return R.data(payMethodService.updateById(payMethod));
}
@RequestMapping(value = "/deletePayMethod", method = RequestMethod.POST)
@ApiOperation("删除支付方式信息")
public R delete(@RequestParam String ids) {
log.info("---->删除支付方式");
return R.data(payMethodService.removeByIds(Func.toLongList(ids)));
}
}
package org.springblade.agent.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.mid.entity.Pension;
import org.springblade.agent.service.IPensionService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/pension")
@Slf4j
@Api(value = "养老机构管理",tags = "养老机构管理((弃用)),租户里面增删改")
public class PensionController extends BladeController {
private IPensionService pensionService;
@GetMapping("/detail")
@ApiOperation(value = "养老机构详情",notes = "养老机构详情")
public R find(String id ){
return R.data(pensionService.getById(id));
}
@GetMapping("/list")
@ApiOperation(value = "养老机构列表",notes = "养老机构列表")
public R<IPage<Pension>> list(@RequestParam Map<String,Object> pension, Query query){
return R.data(pensionService.page(Condition.getPage(query),Condition.getQueryWrapper(pension, Pension.class)));
}
@GetMapping("/submit")
@ApiOperation(value = "养老机构新增",notes = "养老机构新增")
public R add(@RequestBody Pension pension ){
return R.data(pensionService.saveOrUpdate(pension));
}
@GetMapping("/del")
@ApiOperation(value = "养老机构删除",notes = "养老机构删除")
public R del(String ids ){
return R.data(pensionService.removeByIds(Func.toLongList(ids)));
}
@GetMapping("/upd")
@ApiOperation(value = "养老机构更新",notes = "养老机构更新")
public R upd( Pension pension ){
return R.data(pensionService.update());
}
}
package org.springblade.agent.controller;
public class Plugin {
}
package org.springblade.agent.controller;
import com.alibaba.fastjson.JSONObject;
import com.xytx.common.code.CommonCode;
import com.xytx.common.code.TxResultResponse;
import com.xytx.common.exception.CommonException;
import lombok.extern.slf4j.Slf4j;
import org.springblade.agent.service.IScheduleService;
import org.springblade.agent.service.ScheduleService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author Night
* Date: 2019/12/23
*/
@RestController
@RequestMapping("/schedule")
@Slf4j
public class ScheduleController {
@Resource
private ScheduleService scheduleService;
@PostMapping("/list")
@ResponseBody
public R scheduleList(@RequestBody JSONObject jsonObject, BladeUser bladeUser){
log.info("ScheduleController===>>>【scheduleList】,入参={}",jsonObject);
jsonObject.put("tenId",bladeUser.getTenantId());
return scheduleService.scheduleList(jsonObject);
}
@PostMapping("/insert")
@ResponseBody
public TxResultResponse insSchedule(@RequestBody ScheduleVO scheduleVO){
log.info("ScheduleController===>>>【insSchedule】,入参={}",scheduleVO);
try {
return scheduleService.insSchedule(scheduleVO);
} catch (CommonException e) {
log.error("ScheduleController===>>>【insSchedule】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【insSchedule】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
@PostMapping("/update")
@ResponseBody
public TxResultResponse updateSchedule(@RequestBody JSONObject jsonObject){
log.info("ScheduleController===>>>【updateSchedule】,入参={}",jsonObject);
try {
return scheduleService.updateAttendanceTime(jsonObject);
} catch (CommonException e) {
log.error("ScheduleController===>>>【updateSchedule】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【updateSchedule】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
@PostMapping("/hourstatistic")
@ResponseBody
public TxResultResponse hourStatistic(@RequestBody JSONObject jsonObject){
log.info("ScheduleController===>>>【hourStatistic】,入参={}",jsonObject);
try {
return scheduleService.hourStatistic(jsonObject);
} catch (CommonException e) {
log.error("ScheduleController===>>>【hourStatistic】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【hourStatistic】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
@PostMapping("/getnurselist")
@ResponseBody
public TxResultResponse getnurselist(@RequestBody JSONObject jsonObject){
log.info("ScheduleController===>>>【getnurselist】,入参={}",jsonObject);
try {
return scheduleService.getNurseOfDoctor(jsonObject);
} catch (CommonException e) {
log.error("ScheduleController===>>>【getnurselist】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【getnurselist】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
@PostMapping("/getagentlist")
@ResponseBody
public TxResultResponse getagentlist(@RequestBody JSONObject jsonObject){
log.info("ScheduleController===>>>【getagentlist】,入参={}",jsonObject);
try {
return scheduleService.getAgentOfDoctor(jsonObject);
} catch (CommonException e) {
log.error("ScheduleController===>>>【getagentlist】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【getagentlist】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
@PostMapping("/getHeadNurseList")
@ResponseBody
public TxResultResponse getHeadNurseList(@RequestBody JSONObject jsonObject){
log.info("ScheduleController===>>>【getHeadNurseList】,入参={}",jsonObject);
try {
return scheduleService.getHeadNurseList(jsonObject);
} catch (CommonException e) {
log.error("ScheduleController===>>>【getHeadNurseList】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【getHeadNurseList】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
@PostMapping("/getNurseListofagent")
@ResponseBody
public TxResultResponse getNurseList(@RequestBody JSONObject jsonObject){
log.info("ScheduleController===>>>【getNurseList】,入参={}",jsonObject);
try {
return scheduleService.getNurseList(jsonObject);
} catch (CommonException e) {
log.error("ScheduleController===>>>【getNurseList】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【getNurseList】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
@PostMapping("/getAgentOfHos")
@ResponseBody
public TxResultResponse getAgentOfHos(@RequestBody JSONObject jsonObject){
log.info("ScheduleController===>>>【getAgentOfHos】,入参={}",jsonObject);
try {
return scheduleService.getAgentOfHos(jsonObject);
} catch (CommonException e) {
log.error("ScheduleController===>>>【getAgentOfHos】,e={}", e);
return new TxResultResponse(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("ScheduleController===>>>【getAgentOfHos】,e={}", e);
return new TxResultResponse(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
}
package org.springblade.agent.controller.login;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.agent.service.ISocialUsersService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.mid.entity.SocialUser;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.entity.UserInfo;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/social")
public class SocialUserLoginController extends BladeController {
private ISocialUsersService socialUserService;
private IUserClient userClient;
@PostMapping("/login")
public R login(String code, String tenantId){
JSONObject signSuccess = null;
try {
signSuccess = socialUserService.isSignSuccess(code, tenantId);
}catch (Exception e){
return R.fail(e.getMessage());
}
if(StringUtils.isEmpty(signSuccess.getString("openid"))){
return R.data(signSuccess);
}
SocialUser one = socialUserService.getOne(new QueryWrapper<SocialUser>().lambda()
.eq(SocialUser::getTenantId, tenantId)
.eq(SocialUser::getUniqueId,signSuccess.getString("openid")));
// 没有关联则创建虚拟账号
if(null == one){
String account = Func.randomUUID();
User user = new User();
user.setAccount(account);
user.setPassword("xy2020");
user.setTenantId(tenantId);
user.setRoleId("1123598816738675202");
userClient.saveUser(user);
R<UserInfo> userInfoR = userClient.userInfo(tenantId, account);
Long id = userInfoR.getData().getUser().getId();
SocialUser socialUser = new SocialUser();
socialUser.setIsEnabled(0);
socialUser.setTenantId(tenantId);
socialUser.setUniqueId(signSuccess.getString("openid"));
socialUser.setAccount(account);
socialUser.setUserId(id);
socialUser.setVersion(1);
boolean save = socialUserService.save(socialUser);
if(save){
one=socialUser;
}else {
return R.fail("登陆失败");
}
}
// login
Map<String, String> login = socialUserService.login(one);
login.put("openid",signSuccess.getString("openid"));
// 有则返回信息
return R.data(login);
}
@PostMapping("/save")
public R login(@RequestBody SocialUser socialUser){
return R.status(socialUserService.save(socialUser));
}
@PostMapping("/list")
public R list(@RequestBody SocialUser socialUser, Query query){
return R.data(socialUserService.page(Condition.getPage(query),Condition.getQueryWrapper(socialUser)));
}
}
package org.springblade.agent.controller.login;
//@RestController
//@AllArgsConstructor
//@RequestMapping
//public class WeiXinController extends BladeController {
//
// private ISocialUserService socialUserService;
//
// private IPluginService pluginService;
//
// public static void main(String[] args) {
//
// }
//
//
//}
package org.springblade.agent.controller.upload;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
/**
* 文件上传工具包
*/
public class FileUtils {
/**
*
* @param file 文件
* @param path 文件存放路径
* @param fileName 源文件名
* @return
*/
public static boolean upload(MultipartFile file, String path, String fileName){
// 生成新的文件名
//String realPath = path + "/" + FileNameUtils.getFileName(fileName);
//使用原文件名
String realPath = path + "/" + fileName;
File dest = new File(realPath);
//判断文件父目录是否存在
if(!dest.getParentFile().exists()){
dest.getParentFile().mkdir();
}
try {
//保存文件
file.transferTo(dest);
return true;
} catch (IllegalStateException e) {
// Auto-generated catch block
e.printStackTrace();
return false;
} catch (IOException e) {
// Auto-generated catch block
e.printStackTrace();
return false;
}
}
}
package org.springblade.agent.controller.upload;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map;
/**
* @program: care_app_consumer
* @description:
* @author: shenshanghua@ez-hosbed.com
* @create: 2019-08-26 17:25
*/
@RestController
@RequestMapping("/up")
@Api("上传操作")
public class UploadController {
private static final Logger log = LoggerFactory.getLogger(UploadController.class);
//@Value("${upload.filePath}")
private String path;
/**
* @param file 要上传的文件
* @return
*/
@RequestMapping("fileUpload")
public String upload(@RequestParam("fileName") MultipartFile file, Map<String, Object> map) {
// 要上传的目标文件存放路径
String localPath = "/opt/photo_file";
// 上传成功或者失败的提示
String msg = "";
if (FileUtils.upload(file, localPath, file.getOriginalFilename())) {
// 上传成功,给出页面提示
msg = "上传成功!";
} else {
msg = "上传失败!";
}
// 显示图片
map.put("msg", msg);
map.put("fileName", file.getOriginalFilename());
return "forward:/test";
}
@PostMapping(value = "uploadPic")
public R uploadPic(@RequestParam("fileName") MultipartFile file, Map<String, Object> map) {
log.info("【TestController>>>uploadPic】Param = {}", file.getOriginalFilename());
// 要上传的目标文件存放路径
String localPath = "/opt/photo_file_app/image";
// String localPath = "C:\\Users\\EDZ\\Pictures\\new";
// 上传成功或者失败的提示
String msg = "";
log.info("【TestController>>>uploadPic】{}", "111");
if (FileUtils.upload(file, localPath, file.getOriginalFilename())) {
// 上传成功,给出页面提示
log.info("【TestController>>>uploadPic】{}", "222");
msg = "上传成功!";
} else {
msg = "上传失败!";
log.info("【TestController>>>uploadPic】{}", "333");
log.error("【TestController>>>uploadPic】异常{}");
R.fail("上传失败");
}
log.info("【TestController>>>uploadPic】{}", "444");
// 显示图片
map.put("msg", msg);
map.put("fileName", file.getOriginalFilename());
map.put("filePath", path + file.getOriginalFilename());
log.info("【TestController>>>uploadPic】{}", "555");
log.info("【tx】={}", map);
return R.data(map);
}
}
package org.springblade.agent.feign;
import lombok.AllArgsConstructor;
import org.springblade.mid.entity.Agent;
import org.springblade.agent.service.IAgentService;
import org.springblade.core.tool.api.R;
import org.springblade.mid.feign.IAgentClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@ApiIgnore
@RestController
@AllArgsConstructor
public class ApiAgentClient implements IAgentClient {
private IAgentService agentService;
@GetMapping(SAVE)
@Override
public R save(Agent agent) {
return R.status(agentService.save(agent));
}
}
package org.springblade.agent.feign;
import lombok.AllArgsConstructor;
import org.springblade.mid.entity.Doctor;
import org.springblade.agent.service.IDoctorService;
import org.springblade.core.tool.api.R;
import org.springblade.mid.feign.IDoctorClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@ApiIgnore
@RestController
@AllArgsConstructor
public class ApiDockerClient implements IDoctorClient {
private IDoctorService iDoctorService;
@GetMapping(FIND)
@Override
public R<Doctor> find(String id) {
Doctor doctor = iDoctorService.getById(id);
if(null == doctor){
return R.fail("未找到医生信息");
}
return R.data(doctor);
}
}
package org.springblade.agent.feign;
import lombok.AllArgsConstructor;
import org.springblade.mid.entity.Hospital;
import org.springblade.agent.service.IHospitalService;
import org.springblade.core.tool.api.R;
import org.springblade.mid.feign.IHospitalClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
/**
* 接口权限Feign实现类
*
* @author Chill
*/
@ApiIgnore
@RestController
@AllArgsConstructor
public class ApiHospitalClient implements IHospitalClient {
private IHospitalService hospitalService;
@PostMapping(SAVE)
@Override
public R save(Hospital hospital) {
return R.status(hospitalService.save(hospital));
}
@GetMapping(FIND)
@Override
public R<Hospital> find(String id) {
return null;
}
}
package org.springblade.agent.feign;
import lombok.AllArgsConstructor;
import org.springblade.agent.service.IAgentService;
import org.springblade.agent.service.INurseService;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Agent;
import org.springblade.mid.entity.Nurse;
import org.springblade.mid.feign.IAgentClient;
import org.springblade.mid.feign.INurseClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
@ApiIgnore
@RestController
@AllArgsConstructor
public class ApiNurseClient implements INurseClient {
private INurseService iNurseService;
@GetMapping(FIND)
@Override
public R<List<Nurse>> find(String nurseIds) {
return R.data(iNurseService.getNurseByIds(nurseIds));
}
}
package org.springblade.agent.feign;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springblade.mid.entity.Pension;
import org.springblade.agent.service.IPensionService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.mid.feign.IPensionClient;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/api-pension")
public class ApiPensionClient implements IPensionClient {
private IPensionService pensionService;
@Override
@GetMapping("/detail")
public R find(String id ){
return R.data(pensionService.getById(id));
}
@Override
public R save(Pension pension) {
return R.data(pensionService.saveOrUpdate(pension));
}
@GetMapping("/list")
public R<IPage<Pension>> list(@RequestParam Map<String,Object> pension, Query query){
return R.data(pensionService.page(Condition.getPage(query),Condition.getQueryWrapper(pension, Pension.class)));
}
@Override
@GetMapping("/del")
public R del(String ids ){
return R.data(pensionService.removeByIds(Func.toLongList(ids)));
}
@Override
@GetMapping("/upd")
public R upd( Pension pension ){
return R.data(pensionService.update());
}
}
package org.springblade.agent.feign;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.agent.service.IAgentService;
import org.springblade.agent.service.ISocialUsersService;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Agent;
import org.springblade.mid.entity.SocialUser;
import org.springblade.mid.feign.IAgentClient;
import org.springblade.mid.feign.ISocialUserClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
@ApiIgnore
@RestController
@AllArgsConstructor
public class ApiSocialUserClient implements ISocialUserClient {
private ISocialUsersService iSocialUsersService;
@GetMapping(FIND)
@Override
public R find(Long userId) {
return R.data(iSocialUsersService.getOne(Wrappers.<SocialUser>query().lambda().eq(SocialUser::getUserId,userId)));
}
}
package org.springblade.agent.feign;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import org.springblade.mid.entity.AppConfig;
import org.springblade.agent.service.IAppConfigService;
import org.springblade.core.tool.api.R;
import org.springblade.mid.feign.IAppConfigClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@AllArgsConstructor
public class AppConfigClient implements IAppConfigClient {
private IAppConfigService appConfigService;
@Override
@GetMapping(FIND)
public R<AppConfig> find(String tenantId) {
return R.data(appConfigService.getOne(new QueryWrapper<AppConfig>().lambda().eq(AppConfig::getTenantId,tenantId)));
}
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Area;
public interface AddressMapper extends BaseMapper<Area> {
}
package org.springblade.agent.mapper;
import org.springblade.mid.entity.AgentHos;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author max
* @since 2020-04-27
*/
public interface AgentHosMapper extends BaseMapper<AgentHos> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Agent;
public interface AgentMapper extends BaseMapper<Agent> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.AppConfig;
public interface AppConfigMapper extends BaseMapper<AppConfig> {
}
package org.springblade.agent.mapper;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Classes;
import java.util.List;
public interface ClassMapper extends BaseMapper<Classes> {
List<JSONObject> relationList(Integer type, String doctorId, String nurseName);
}
<?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="org.springblade.agent.mapper.ClassMapper">
<insert id="relationNurse">
INSERT INTO care_doctor_nurse (doctor_id,nurse_id,doc_name,nurse_name,hos_id,hos_name,agent_id,agent_name,`type`) values
(#{doctorId},#{nurseId},#{docName},#{nurseName},#{hosId},#{hosName},#{agentId},#{agentName},#{type})
</insert>
<select id="relationList" resultType="com.alibaba.fastjson.JSONObject">
select
cdn.doctor_id as 'doctorId',
cdn.nurse_id as 'nurseId',
cdn.doc_name as 'docName',
cdn.nurse_name as 'nurseName',
cdn.hos_id as 'hosId',
cdn.hos_name as 'hosName',
cdn.agent_id as 'agentId',
cdn.agent_name as 'agentName',
cdn.`type` as 'type'
from care_doctor_nurse cdn
<where>
<if test="type !=null and type !=''">
and cdn.`type` = #{type}
</if>
<if test="doctorId !=null and doctorId !=''">
and cdn.doctor_id = #{doctorId}
</if>
<if test="nurseName !=null and nurseName !=''">
and cdn.nurse_name = #{nurseName}
</if>
</where>
</select>
<delete id="delRelation" parameterType="string">
delete from care_doctor_nurse
where nurse_id = #{nurseId}
</delete>
<select id="hasRelation" parameterType="string" resultType="boolean">
<![CDATA[select count(nurse_id) from care_doctor_nurse
where nurse_id = #{nurseId} ]]>
</select>
</mapper>
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Doctor;
public interface DoctorMapper extends BaseMapper<Doctor> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Holiday;
import java.util.List;
/**
* @author Night
* Date: 2020/1/9
*/
public interface HolidayMapper extends BaseMapper<Holiday> {
List<String> dateList();
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Hospital;
public interface HospitalMapper extends BaseMapper<Hospital> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Login;
public interface LoginMapper extends BaseMapper<Login> {
}
package org.springblade.agent.mapper;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Nurse;
import java.util.List;
public interface NurseMapper extends BaseMapper<Nurse> {
List<Nurse> getNurseByIds(Long[] ids);
List<JSONObject> getNurseOfDoctor(JSONObject jsonObject);
List<JSONObject> getAgentOfDoctor(JSONObject jsonObject);
}
<?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="org.springblade.agent.mapper.NurseMapper">
<resultMap id="nurseResultMap" type="org.springblade.mid.entity.Nurse">
<result column="id" property="id"/>
<result column="real_name" property="realName"/>
</resultMap>
<select id="getNurseByIds" resultMap="nurseResultMap">
SELECT
id,real_name
FROM
care_nurse
WHERE
id IN
<foreach collection="array" item="ids" index="index" open="(" close=")" separator=",">
#{ids}
</foreach>
and is_deleted = 0
</select>
<select id="getNurseOfDoctor" resultType="com.alibaba.fastjson.JSONObject">
select distinct nurse_id as nurseId,
nurse_name as nurseName,
agent_name as agentName
from care_doctor_nurse
where doctor_id = #{doctorId}
</select>
<select id="getAgentOfDoctor" resultType="com.alibaba.fastjson.JSONObject">
select distinct agent_id as agentId,
agent_name as agentName
from care_doctor_nurse
where doctor_id = #{doctorId}
</select>
</mapper>
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.PayMethod;
/**
* @author Night
* Date: 2020/5/11
*/
public interface PayMethodMapper extends BaseMapper<PayMethod> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Pension;
public interface PensionMapper extends BaseMapper<Pension> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Schedule;
public interface ScheduleMapper extends BaseMapper<Schedule> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.SocialUser;
public interface SocialUserMapper extends BaseMapper<SocialUser> {
}
package org.springblade.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.mid.entity.Workweekend;
import java.util.List;
/**
* @author Night
* Date: 2020/1/9
*/
public interface WorkweekendMapper extends BaseMapper<Workweekend> {
List<String> dateList();
}
package org.springblade.agent.service;
import org.springblade.mid.entity.Holiday;
import java.util.List;
/**
* @author Night
* Date: 2020/1/9
*/
public interface HolidayService {
int insert(Holiday holiday);
List<Holiday> getList();
int delete(String id);
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Area;
import org.springblade.core.tool.api.R;
import java.util.List;
public interface IAddressService extends IService<Area> {
List<Area> addressList();
}
package org.springblade.agent.service;
import org.springblade.mid.entity.AgentHos;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author max
* @since 2020-04-27
*/
public interface IAgentHosService extends IService<AgentHos> {
Boolean bindAgentToHos(Map<String, Object> jsonObject);
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Agent;
public interface IAgentService extends IService<Agent> {
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.AppConfig;
public interface IAppConfigService extends IService<AppConfig> {
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Classes;
public interface IClassService extends IService<Classes> {
}
package org.springblade.agent.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Doctor;
import java.util.List;
public interface IDoctorService extends IService<Doctor> {
int updDoctor(JSONObject jsonObject);
int delDoctor(JSONObject jsonObject);
List<String> getDepart(JSONObject jsonObject);
Doctor getDocInfo(String username);
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Hospital;
public interface IHospitalService extends IService<Hospital> {
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Login;
public interface ILoginService extends IService<Login> {
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Nurse;
import java.util.List;
public interface INurseService extends IService<Nurse> {
List<Nurse> getNurseByIds(String ids);
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Pension;
public interface IPensionService extends IService<Pension> {
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
public interface IPluginService extends IService {
}
package org.springblade.agent.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.Schedule;
import org.springblade.core.tool.api.R;
public interface IScheduleService extends IService<Schedule> {
Object scheduleList(JSONObject jsonObject);
}
package org.springblade.agent.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.SocialUser;
import java.util.Map;
public interface ISocialUsersService extends IService<SocialUser> {
JSONObject isSignSuccess(String code, String tenantId);
Map<String,String> login(SocialUser one);
}
package org.springblade.agent.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.mid.entity.PayMethod;
public interface PayMethodService extends IService<PayMethod> {
}
package org.springblade.agent.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.core.tool.api.R;
import org.springblade.mid.entity.Schedule;
import org.springblade.mid.vo.ScheduleVO;
import java.util.List;
public interface ScheduleService extends IService<Schedule> {
R scheduleList(JSONObject jsonObject);
R insSchedule(ScheduleVO scheduleVO);
R updateAttendanceTime(JSONObject jsonObject);
R hourStatistic(JSONObject jsonObject);
R getNurseOfDoctor(JSONObject jsonObject);
R getAgentOfDoctor(JSONObject jsonObject);
List<ScheduleVO> getScheduleList(JSONObject jsonObject);
R getHeadNurseList(JSONObject jsonObject);
R getNurseList(JSONObject jsonObject);
R getAgentOfHos(JSONObject jsonObject);
}
package org.springblade.agent.service;
import org.springblade.mid.entity.Workweekend;
import java.util.List;
/**
* @author Night
* Date: 2020/1/9
*/
public interface WorkweekendService {
int insert(Workweekend workweekend);
List<Workweekend> getList();
int delete(String id);
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.springblade.mid.entity.Area;
import org.springblade.agent.mapper.AddressMapper;
import org.springblade.agent.service.IAddressService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Area> implements IAddressService {
@Override
public List<Area> addressList() {
List<Area> areas = list();
Iterator<Area> iterator = areas.iterator();
ArrayList<Area> areaArrayList = Lists.newArrayList();
while (iterator.hasNext()) {
Area area = iterator.next();
if (area.getParentCode() == null) {
areaArrayList.add(area);
iterator.remove();
}
}
areaArrayList.forEach(ap -> constructTree(ap, areas));
return areaArrayList;
}
private void constructTree(Area area, List<Area> treeModels) {
Iterator<Area> iterator = treeModels.iterator();
//保存子节点
List<Area> childrens = new ArrayList<>();
while (iterator.hasNext()) {
Area node = iterator.next();
//找出下一级的节点
if (area.getCode().equals(node.getParentCode())) {
childrens.add(node);
iterator.remove();
}
}
if (!CollectionUtils.isEmpty(childrens)) {
area.setAreas(childrens);
}
if (!CollectionUtils.isEmpty(treeModels) && !childrens.isEmpty()) {
childrens.forEach(node -> constructTree(node, treeModels));
}
}
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springblade.mid.entity.AgentHos;
import org.springblade.agent.mapper.AgentHosMapper;
import org.springblade.agent.service.IAgentHosService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务实现类
* </p>
*
* @author max
* @since 2020-04-27
*/
@Service
public class AgentHosServiceImpl extends ServiceImpl<AgentHosMapper, AgentHos> implements IAgentHosService {
@Override
public Boolean bindAgentToHos(Map<String, Object> jsonObject) {
QueryWrapper<AgentHos> queryWrapper = Condition.getQueryWrapper(jsonObject, AgentHos.class);
List<AgentHos> agentHosList = list(queryWrapper);
if (agentHosList.size() < 1 ) {
return save(queryWrapper.getEntity());
}
return Boolean.FALSE;
}
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.mid.entity.Agent;
import org.springblade.agent.mapper.AgentMapper;
import org.springblade.agent.service.IAgentService;
import org.springframework.stereotype.Service;
@Service
public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements IAgentService {
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.mid.entity.AppConfig;
import org.springblade.agent.mapper.AppConfigMapper;
import org.springblade.agent.service.IAppConfigService;
import org.springframework.stereotype.Service;
@Service
public class AppConfigServiceImpl extends ServiceImpl<AppConfigMapper, AppConfig> implements IAppConfigService {
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.agent.mapper.ClassMapper;
import org.springblade.agent.service.IClassService;
import org.springblade.mid.entity.Classes;
import org.springframework.stereotype.Service;
@Service
public class ClassServiceImpl extends ServiceImpl<ClassMapper, Classes> implements IClassService {
}
package org.springblade.agent.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.mid.entity.Doctor;
import org.springblade.agent.mapper.DoctorMapper;
import org.springblade.agent.service.IDoctorService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements IDoctorService {
@Override
public int updDoctor(JSONObject jsonObject) {
return 0;
}
@Override
public int delDoctor(JSONObject jsonObject) {
return 0;
}
@Override
public List<String> getDepart(JSONObject jsonObject) {
return null;
}
@Override
public Doctor getDocInfo(String username) {
return null;
}
}
package org.springblade.agent.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.springblade.agent.mapper.HolidayMapper;
import org.springblade.agent.service.HolidayService;
import org.springblade.common.utils.CommonUtil;
import org.springblade.common.utils.UnixTimestampUtils;
import org.springblade.mid.entity.Holiday;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author Night
* Date: 2020/1/9
*/
@Service("holidayService")
@Slf4j
public class HolidayServiceImpl implements HolidayService {
@Resource
private HolidayMapper holidayMapper;
@Override
public int insert(Holiday holiday) {
log.info("新增节假日信息,参数={}",holiday);
// 2020-01-12 00:00:00
Holiday mysqlHoliday = new Holiday();
BeanUtils.copyProperties(holiday,mysqlHoliday);
mysqlHoliday.setId(CommonUtil.getUUID().replace("-",""));
mysqlHoliday.setDate(UnixTimestampUtils.getFormatDate(holiday.getDate()));
return holidayMapper.insert(holiday);
}
@Override
public List<Holiday> getList() {
return holidayMapper.selectList(null);
}
@Override
public int delete(String id) {
log.info("删除节假日信息,参数={}",id);
return holidayMapper.deleteById(id);
}
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.mid.entity.Hospital;
import org.springblade.agent.mapper.HospitalMapper;
import org.springblade.agent.service.IHospitalService;
import org.springframework.stereotype.Service;
@Service
public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> implements IHospitalService {
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.mid.entity.Login;
import org.springblade.agent.mapper.LoginMapper;
import org.springblade.agent.service.ILoginService;
import org.springframework.stereotype.Service;
@Service
public class LoginServiceImpl extends ServiceImpl<LoginMapper, Login> implements ILoginService {
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.utils.Func;
import org.springblade.mid.entity.Nurse;
import org.springblade.agent.mapper.NurseMapper;
import org.springblade.agent.service.INurseService;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@AllArgsConstructor
public class NurseServiceImpl extends ServiceImpl<NurseMapper, Nurse> implements INurseService {
private NurseMapper nurseMapper;
@Override
public List<Nurse> getNurseByIds(String ids) {
return nurseMapper.getNurseByIds(Func.toLongArray(ids));
}
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.agent.mapper.PayMethodMapper;
import org.springblade.agent.service.PayMethodService;
import org.springblade.mid.entity.PayMethod;
import org.springframework.stereotype.Service;
@Service
public class PayMethodServiceImpl extends ServiceImpl<PayMethodMapper, PayMethod> implements PayMethodService {
}
package org.springblade.agent.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.mid.entity.Pension;
import org.springblade.agent.mapper.PensionMapper;
import org.springblade.agent.service.IPensionService;
import org.springframework.stereotype.Service;
@Service
public class PensionServiceImpl extends ServiceImpl<PensionMapper, Pension> implements IPensionService {
}
package org.springblade.agent.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mysql.cj.util.StringUtils;
import com.xytx.common.code.CommonCode;
import com.xytx.common.code.TxResultResponse;
import com.xytx.common.exception.CommonException;
import lombok.extern.slf4j.Slf4j;
import org.springblade.agent.mapper.*;
import org.springblade.agent.service.ScheduleService;
import org.springblade.common.utils.AttendanceTimeUtil;
import org.springblade.common.utils.UnixTimestampUtils;
import org.springblade.core.tool.api.R;
import org.springblade.mid.convert.AboutScheduleConverter;
import org.springblade.mid.entity.AgentHos;
import org.springblade.mid.entity.Doctor;
import org.springblade.mid.entity.Nurse;
import org.springblade.mid.entity.Schedule;
import org.springblade.mid.vo.HourStatisticsVO;
import org.springblade.mid.vo.ScheduleVO;
import org.springblade.system.feign.ISysClient;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @Auther Night
* @Date 2019/12/20
*/
@Component
@Service("scheduleService")
@Slf4j
public class ScheduleServiceImpl extends ServiceImpl<ScheduleMapper, Schedule> implements ScheduleService {
@Resource
private ScheduleMapper scheduleMapper;
@Resource
private ClassMapper classesMapper;
@Resource
private HolidayMapper holidayMapper;
@Resource
private WorkweekendMapper workweekendMapper;
@Resource
private DoctorMapper doctorMapper;
@Resource
private NurseMapper nurseMapper;
@Resource
private AgentHosMapper agentHosMapper;
@Resource
private ISysClient sysClient;
/**
* 查看排班信息
*
* @param jsonObject jsonObject
* @return TxResultResponse
* @throws CommonException CommonException
*/
@Override
public R scheduleList(JSONObject jsonObject) throws CommonException {
log.info("【ScheduleServiceImpl>>>scheduleList】jsonObject = {}", jsonObject);
try {
String tenId = jsonObject.getString("tenId");
sysClient.getTenant(tenId).getData().getType();
QueryWrapper<Schedule> queryWrapper = getqueryWrapper(jsonObject);
Integer pageSize = jsonObject.getInteger("pageSize");
Integer pageNum = jsonObject.getInteger("pageNum");
IPage<Schedule> iPage = new Page<>(pageNum,pageSize * 7);
IPage<ScheduleVO> voiPage = new Page<>();
// 查询时间段内的所有信息
List<Schedule> schedules = scheduleMapper.selectPage(iPage,queryWrapper).getRecords();
// 判断是不是护士长平台的检索请求
if (jsonObject.getString("doctorId") != null && !jsonObject.getString("doctorId").equals("")) {
// 确定是护士长平台的检索请求,接下来判断是不是检索已经排班后的数据
if ((jsonObject.getString("nurseId") == null || jsonObject.getString("nurseId").equals("")) &&
(jsonObject.getString("hosId") == null || jsonObject.getString("hosId").equals("")) &&
(jsonObject.getString("departmentName") == null || jsonObject.getString("departmentName").equals("")) &&
(jsonObject.getString("agentId") == null || jsonObject.getString("agentId").equals(""))){
// 没传上述参数 表示是正在排版中的检索请求
String doctorId = jsonObject.getString("doctorId");
List<ScheduleVO> fakeScheduleVOList = getfakeScheduleVoList(doctorId);
if (schedules.size() == 0) {
voiPage.setRecords(fakeScheduleVOList);
} else {
// 拿取当前周的信息拼装成ScheduleVO
List<ScheduleVO> scheduleVOList = getScheduleVoList(schedules);
Map<String, ScheduleVO> map = fakeScheduleVOList.stream().collect(Collectors.toMap(ScheduleVO::getNurseId, e -> e, (k1, k2) -> k2));
map.putAll(scheduleVOList.stream().collect(Collectors.toMap(ScheduleVO::getNurseId, e -> e, (k1, k2) -> k2)));
List<ScheduleVO> result = new ArrayList<>(map.values());
voiPage.setRecords(result);
}
return R.data(iPage);
} else{
// 是护士长排班完成之后的检索请求
List<ScheduleVO> scheduleVOList = getScheduleVoList(schedules);
voiPage.setRecords(scheduleVOList);
}
} else {
// 不是护士长平台
List<ScheduleVO> scheduleVOList = getScheduleVoList(schedules);
voiPage.setRecords(scheduleVOList);
}
return R.data(voiPage);
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>scheduleList】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>scheduleList】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/**
* 保存或者更新排班信息
*
* @param scheduleVO scheduleVO
* @return TxResultResponse
*/
@Override
@Transactional
public R insSchedule(ScheduleVO scheduleVO) {
log.info("【ScheduleServiceImpl>>>insSchedule】schedule = {}", scheduleVO);
try {
List<String> holidayList = holidayMapper.dateList();
List<String> workweekendList = workweekendMapper.dateList();
List<Schedule> scheduleList = AboutScheduleConverter.convertScheduleVO2ScheduleList(scheduleVO, holidayList, workweekendList);
// 插入这个 scheduleList
boolean issuccess = this.saveOrUpdateBatch(scheduleList);
if (!issuccess) {
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), "录入排班失败");
}
return R.status(true);
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>insSchedule】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>insSchedule】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/**
* 更新考勤信息
*
* @param jsonObject jsonObject
* @return TxResultResponse
*/
@Override
@Transactional
public R updateAttendanceTime(JSONObject jsonObject) {
log.info("【ScheduleServiceImpl>>>updateAttendanceTime】jsonObject = {}", jsonObject);
try {
List<String> holidayList = holidayMapper.dateList();
List<String> workweekendList = workweekendMapper.dateList();
String attendanceTime = jsonObject.getString("attendanceTime");
String scheduleId = jsonObject.getString("scheduleId");
int hours = AttendanceTimeUtil.regexAndCalcHours(attendanceTime);
Schedule schedule = scheduleMapper.selectById(scheduleId);
schedule.setAttendanceTime(attendanceTime).setHours(hours);
schedule = AboutScheduleConverter.calcAllHours(schedule, holidayList, workweekendList);
int count = scheduleMapper.updateById(schedule);
if (count < 1) {
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), "更新考勤信息失败");
}
return R.status(true);
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>updateAttendanceTime】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>updateAttendanceTime】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/**
* 工时统计
*
* @param jsonObject jsonObject
* @return TxResultResponse
* @throws CommonException CommonException
*/
@Override
public R hourStatistic(JSONObject jsonObject) throws CommonException {
TxResultResponse tx = new TxResultResponse(CommonCode.SUCCESS.getCode(), CommonCode.SUCCESS.getMsg());
log.info("【ScheduleServiceImpl>>>hourStatistic】jsonObject = {}", jsonObject);
try {
QueryWrapper<Schedule> queryWrapper = getqueryWrapper(jsonObject);
// 查询时间段内的所有信息
List<Schedule> schedules = scheduleMapper.selectList(queryWrapper);
// 拿取当前周的信息拼装成HourStatisticsVO
Set<String> nurseIdSet = schedules.stream().map(Schedule::getNurseId).collect(Collectors.toSet());
List<HourStatisticsVO> hourStatisticsVOList = AboutScheduleConverter.calcAttendanceOfHours(schedules, nurseIdSet);
Integer pageSize = (Integer) jsonObject.get("pageSize");
Integer pageNum = (Integer) jsonObject.get("pageNum");
if (pageNum == null || pageSize == null) {
pageNum = 1;
pageSize = 15;
}
Page iPage = new Page(pageNum,pageSize);
iPage.setRecords(hourStatisticsVOList);
return R.data(iPage);
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>hourStatistic】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>hourStatistic】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/**
* 获取当前护士长的护理员
*
* @param jsonObject jsonObject
* @return TxResultResponse
* @throws CommonException CommonException
*/
@Override
public R getNurseOfDoctor(JSONObject jsonObject) throws CommonException {
log.info("【ScheduleServiceImpl>>>getNurseOfDoctor】jsonObject = {}", jsonObject);
try {
List<JSONObject> nameList = nurseMapper.getNurseOfDoctor(jsonObject);
return R.data(nameList);
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>getNurseOfDoctor】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>getNurseOfDoctor】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/**
* 获取当前护士长相关服务公司名字
*
* @param jsonObject jsonObject
* @return TxResultResponse
*/
@Override
public R getAgentOfDoctor(JSONObject jsonObject) {
log.info("【ScheduleServiceImpl>>>getAgentOfDoctor】jsonObject = {}", jsonObject);
try {
List<JSONObject> nameList = nurseMapper.getAgentOfDoctor(jsonObject);
return R.data(nameList);
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>getAgentOfDoctor】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>getAgentOfDoctor】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/**
* 组建QueryWrapper
*
* @param jsonObject jsonObject
* @return QueryWrapper
*/
private QueryWrapper<Schedule> getqueryWrapper(JSONObject jsonObject) {
QueryWrapper<Schedule> queryWrapper = new QueryWrapper<>();
// 拼装条件 当前护士长下面的护理员
if (jsonObject.getString("doctorId") != null && !jsonObject.getString("doctorId").equals("")) {
queryWrapper.eq("doctor_id", jsonObject.getString("doctorId"));
}
if (jsonObject.getString("startTime") != null && !jsonObject.getString("startTime").equals("")) {
queryWrapper.ge("date", UnixTimestampUtils.getFormatDate(jsonObject.getString("startTime")));
}
if (jsonObject.getString("endTime") != null && !jsonObject.getString("endTime").equals("")) {
queryWrapper.le("date", UnixTimestampUtils.getFormatDate(jsonObject.getString("endTime")));
}
if (jsonObject.getString("agentName") != null && !jsonObject.getString("agentName").equals("")) {
queryWrapper.eq("agent_name", jsonObject.getString("agentName"));
}
if (jsonObject.getString("agentId") != null && !jsonObject.getString("agentId").equals("")) {
queryWrapper.eq("agent_id", jsonObject.getString("agentId"));
}
if (jsonObject.getString("nurseId") != null && !jsonObject.getString("nurseId").equals("")) {
queryWrapper.eq("nurse_id", jsonObject.getString("nurseId"));
}
if (jsonObject.getString("nurseName") != null && !jsonObject.getString("nurseName").equals("")) {
queryWrapper.eq("nurse_name", jsonObject.getString("nurseName"));
}
if (jsonObject.getString("hosId") != null && !jsonObject.getString("hosId").equals("")) {
queryWrapper.eq("hos_id", jsonObject.getString("hosId"));
}
if (jsonObject.getString("departmentName") != null && !jsonObject.getString("departmentName").equals("")) {
queryWrapper.eq("department_name", jsonObject.getString("departmentName"));
}
queryWrapper.orderByDesc("nurse_id");
queryWrapper.orderByAsc("date");
return queryWrapper;
}
/**
* 导出排班、考勤信息用这个接口
*
* @param jsonObject jsonObject
* @return TxResultResponse
* @throws CommonException CommonException
*/
@Override
public List<ScheduleVO> getScheduleList(JSONObject jsonObject) throws CommonException {
log.info("【ScheduleServiceImpl>>>getScheduleList】jsonObject = {}", jsonObject);
try {
QueryWrapper<Schedule> queryWrapper = getqueryWrapper(jsonObject);
// 查询时间段内的所有信息
List<Schedule> schedules = scheduleMapper.selectList(queryWrapper);
// 拿取当前周的信息拼装成ScheduleVO
Set<String> nurseIdSet = schedules.stream().map(Schedule::getNurseId).collect(Collectors.toSet());
List<ScheduleVO> scheduleVOList = AboutScheduleConverter.schedule2ScheuleVO(schedules, nurseIdSet);
return scheduleVOList;
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>scheduleList】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>scheduleList】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/** 获取全部关联人员信息,转成vo格式
* @param doctorId doctorId
* @return List<ScheduleVO>
*/
private List<ScheduleVO> getfakeScheduleVoList(String doctorId){
List<JSONObject> relationList = classesMapper.relationList(3, doctorId,null);
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(relationList));
List<ScheduleVO> fakeScheduleVOList = JSONObject.parseArray(jsonArray.toJSONString(), ScheduleVO.class);
return fakeScheduleVOList;
}
/** 获取List<ScheduleVO>
* @param schedules schedules
* @return List<ScheduleVO>
*/
private List<ScheduleVO> getScheduleVoList(List<Schedule> schedules){
Set<String> nurseIdSet = schedules.stream().map(Schedule::getNurseId).collect(Collectors.toSet());
List<ScheduleVO> scheduleVOList = AboutScheduleConverter.schedule2ScheuleVO(schedules, nurseIdSet);
return scheduleVOList;
}
/** xy平台使用的查看护士长列表
* @return 全部护士长信息
*/
@Override
public R getHeadNurseList(JSONObject jsonObject) {
log.info("【ScheduleServiceImpl>>>getHeadNurseList】参数={}",jsonObject);
try {
TxResultResponse tx = new TxResultResponse(CommonCode.SUCCESS.getCode(), CommonCode.SUCCESS.getMsg());
QueryWrapper<Doctor> queryWrapper = new QueryWrapper<>();
String hospitalId = jsonObject.getString("hosId");
String departmentName = jsonObject.getString("departmentName");
String doctorId = jsonObject.getString("doctorId");
queryWrapper.eq(!StringUtils.isNullOrEmpty(hospitalId),"hospital_id",hospitalId);
queryWrapper.eq(!StringUtils.isNullOrEmpty(departmentName),"depart",departmentName);
queryWrapper.eq(!StringUtils.isNullOrEmpty(doctorId),"id",doctorId);
queryWrapper.like("account","hsz");
return R.data(doctorMapper.selectList(queryWrapper));
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>getHeadNurseList】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>getHeadNurseList】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/** xy平台使用的查看护理员列表
* @return 全部护理员信息
*/
@Override
public R getNurseList(JSONObject jsonObject) {
log.info("【ScheduleServiceImpl>>>getNurseList】参数={}",jsonObject);
try {
QueryWrapper<Nurse> queryWrapper = new QueryWrapper<>();
String agentId = jsonObject.getString("agentId");
queryWrapper.eq(!StringUtils.isNullOrEmpty(agentId),"agent_id",agentId);
queryWrapper.eq("type",3);
return R.data(nurseMapper.selectList(queryWrapper));
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>getNurseList】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>getNurseList】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
/** 医院平台使用的查看关联的服务公司列表接口
* @param jsonObject jsonObject
* @return TxResultResponse
*/
@Override
public R getAgentOfHos(JSONObject jsonObject) {
log.info("【ScheduleServiceImpl>>>getAgentOfHos】参数={}",jsonObject);
try {
QueryWrapper<AgentHos> queryWrapper = new QueryWrapper<>();
String hosId = jsonObject.getString("hosId");
queryWrapper.eq(!StringUtils.isNullOrEmpty(hosId),"hos_id",hosId);
queryWrapper.eq("is_deleted",0);
return R.data(agentHosMapper.selectList(queryWrapper));
} catch (CommonException e) {
log.error("【ScheduleServiceImpl>>>getAgentOfHos】CommonException e={}", e.getMsg());
throw new CommonException(e.getCode(), e.getMsg());
} catch (Exception e) {
e.printStackTrace();
log.error("【ScheduleServiceImpl>>>getAgentOfHos】Exception e={}", e.getMessage());
throw new CommonException(CommonCode.SERVER_ERROR.getCode(), CommonCode.SERVER_ERROR.getMsg());
}
}
}
package org.springblade.agent.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jodd.util.Base64;
import org.apache.commons.lang.StringUtils;
import org.apache.oltu.oauth2.client.OAuthClient;
import org.apache.oltu.oauth2.client.URLConnectionClient;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
import org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse;
import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse;
import org.apache.oltu.oauth2.common.OAuth;
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
import org.apache.oltu.oauth2.common.message.types.GrantType;
import org.springblade.agent.service.IAppConfigService;
import org.springblade.core.mp.support.Condition;
import org.springblade.mid.entity.AppConfig;
import org.springblade.mid.entity.SocialUser;
import org.springblade.agent.mapper.SocialUserMapper;
import org.springblade.agent.service.ISocialUsersService;
import org.springblade.mid.feign.IOauthClient;
import org.springblade.mid.vo.OauthReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
@Service
public class SocialUsersServiceImpl extends ServiceImpl<SocialUserMapper, SocialUser> implements ISocialUsersService {
@Autowired
IAppConfigService appConfigService;
@Autowired
IOauthClient oauthClient;
/**
* openId请求URL
*/
private static final String OPEN_ID_REQUEST_URL = "https://open.weixin.qq.com/connect/oauth2/authorize#wechat_redirect";
/**
* openId请求URL
*/
private static final String LOGIN_URL = "https://api.weixin.qq.com/sns/jscode2session";
RestTemplate restTemplate = new RestTemplate();
@Override
public JSONObject isSignSuccess(String code,String tenantId) {
if (StringUtils.isEmpty(code)) {
return null;
}
AppConfig one = appConfigService.getOne( new QueryWrapper<AppConfig>().lambda().eq(AppConfig::getTenantId,tenantId));
Map<String,String> m = new HashMap<>();
m.put("appid", one.getAppId());
m.put("secret", one.getAppSecret());
m.put("js_code",code);
String x = restTemplate.getForObject(LOGIN_URL+"?appid={appid}&secret={secret}&js_code={js_code}&grant_type=authorization_code",String.class,m);
JSONObject parse = JSONObject.parseObject(x);
System.out.println(parse);
return parse;
}
@Override
public Map<String,String> login(SocialUser one) {
OauthReq oauthReq = new OauthReq();
oauthReq.setUsername(one.getAccount());
oauthReq.setPassword("xy2020");
oauthReq.setTenantId(one.getTenantId());
Map<String,String> jsonpObject = oauthClient.token1(oauthReq.getTenantId(), oauthReq.getUsername(),oauthReq.getPassword(),oauthReq.getType(),oauthReq.getScope(),oauthReq.getGrant_type(),oauthReq.getTenantId(),"Basic " + Base64.encodeToString("saber:saber_secret"));
return jsonpObject;
}
}
package org.springblade.agent.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.springblade.agent.mapper.WorkweekendMapper;
import org.springblade.agent.service.WorkweekendService;
import org.springblade.common.utils.CommonUtil;
import org.springblade.common.utils.UnixTimestampUtils;
import org.springblade.mid.entity.Workweekend;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author Night
* Date: 2020/1/9
*/
@Service("WorkweekendService")
@Slf4j
public class WorkweekendServiceImpl implements WorkweekendService {
@Resource
private WorkweekendMapper workweekendMapper;
@Override
public int insert(Workweekend workweekend) {
log.info("新增周末工作日信息,参数={}",workweekend);
Workweekend mysqlWorkweekend = new Workweekend();
BeanUtils.copyProperties(workweekend,mysqlWorkweekend);
mysqlWorkweekend.setId(CommonUtil.getUUID().replace("-",""));
mysqlWorkweekend.setDate(UnixTimestampUtils.getFormatDate(workweekend.getDate()));
return workweekendMapper.insert(workweekend);
}
@Override
public List<Workweekend> getList() {
return workweekendMapper.selectList(null);
}
@Override
public int delete(String id) {
log.info("删除周末工作日信息,参数={}",id);
return workweekendMapper.deleteById(id);
}
}
#服务器端口
server:
port: 9003
#数据源配置
spring:
datasource:
url: ${blade.datasource.dev.url}
username: ${blade.datasource.dev.username}
password: ${blade.datasource.dev.password}
#服务器端口
server:
port: 9003
#数据源配置
spring:
datasource:
url: ${blade.datasource.prod.url}
username: ${blade.datasource.prod.username}
password: ${blade.datasource.prod.password}
#服务器端口
server:
port: 9003
#数据源配置
spring:
datasource:
url: ${blade.datasource.test.url}
username: ${blade.datasource.test.username}
password: ${blade.datasource.test.password}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springblade</groupId>
<artifactId>BladeX-schedule</artifactId>
<version>2.4.0.RELEASE</version>
<packaging>pom</packaging>
<properties>
<bladex.project.version>2.4.0.RELEASE</bladex.project.version>
<java.version>1.8</java.version>
<flowable.version>6.4.2</flowable.version>
<dubbo.version>2.7.5</dubbo.version>
<spring.boot.version>2.1.13.RELEASE</spring.boot.version>
<spring.cloud.version>Greenwich.SR5</spring.cloud.version>
<spring.platform.version>Cairo-SR8</spring.platform.version>
<!-- 推荐使用Harbor -->
<docker.registry.url>172.17.45.176:8000</docker.registry.url>
<docker.registry.host>http://127.0.0.1:2375</docker.registry.host>
<docker.username>admin</docker.username>
<docker.password>Harbor12345</docker.password>
<docker.namespace>blade</docker.namespace>
<docker.plugin.version>1.4.13</docker.plugin.version>
<common.version>ez_common-1.1</common.version>
</properties>
<modules>
<module>blade-common</module>
<module>blade-gateway</module>
<module>blade-sched</module>
<module>blade-sched-api</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springblade.platform</groupId>
<artifactId>blade-bom</artifactId>
<version>${bladex.project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-common</artifactId>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>${spring.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.xytx.common</groupId>
<version>${common.version}</version>
<artifactId>common-exception</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<fork>true</fork>
<finalName>${project.build.finalName}</finalName>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<configuration>
<username>${docker.username}</username>
<password>${docker.password}</password>
<repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
<!--子服务添加如下配置,运行 mvn deploy 命令便会自动打包镜像-->
<!--<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>-->
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-antrun-plugin</artifactId>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>run</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <tasks>-->
<!-- &lt;!&ndash;suppress UnresolvedMavenProperty &ndash;&gt;-->
<!-- <copy overwrite="true"-->
<!-- tofile="${session.executionRootDirectory}/target/${project.artifactId}.jar"-->
<!-- file="${project.build.directory}/${project.artifactId}.jar" />-->
<!-- </tasks>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>xyts-release</id>
<name>XYTS Release Repository</name>
<url>http://tool-nexus.ez-hosbed.com/repository/maven-releases/</url>
</repository>
<repository>
<id>aliyun-repos</id>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>blade-release</id>
<name>Release Repository</name>
<url>http://nexus.bladex.vip/repository/maven-releases/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>xyts-release</id>
<name>XYTS Release Repository</name>
<url>http://tool-nexus.ez-hosbed.com/repository/maven-releases/</url>
</repository>
</distributionManagement>
</project>
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