Commit d8b472f4 authored by fangxinjiang's avatar fangxinjiang

新增小工具服务

parent fb79858f
apiVersion: apps/v1 # 指定api版本,此值必须在kubectl api-versions中
kind: Deployment # 指定创建资源的角色/类型
metadata: # 资源的元数据/属性
name: yifu-check # 资源的名字,在同一个namespace中必须唯一
namespace: qas-mvp # 部署在哪个namespace中
spec: # 资源规范字段
selector: # 选择器
matchLabels: # 匹配标签
app: yifu-check
replicas: 1 # 声明副本数目
#revisionHistoryLimit: 3 # 保留历史版本
#strategy: # 策略
# rollingUpdate: # 滚动更新
# maxSurge: 30% # 最大额外可以存在的副本数,可以为百分比,也可以为整数
# maxUnavailable: 30% # 示在更新过程中能够进入不可用状态的 Pod 的最大值,可以为百分比,也可以为整数
# type: RollingUpdate # 滚动更新策略
template: # 模版
metadata: # 模版
labels: # 设定资源的标签
app: yifu-check
annotations:
dapr.io/enabled: "true" #设定此参数为 true 注入Dapr sidecar到pod
dapr.io/app-id: "yifu-check" #应用程序唯一 ID。 用于服务发现、状态封装 和 发布/订阅 消费者ID
dapr.io/app-port: "5022" #这个参数告诉Dapr你的应用程序正在监听哪个端口。
#dapr.io/log-level: "debug" #为 Dapr sidecar设置日志级别。 允许的值是debug,info,warn,error。 默认是 info
#dapr.io/log-as-json: "false" #将此参数设置为true以JSON格式输出日志。 默认值为 false.
#dapr.io/config: file #告诉 Dapr 要使用哪个配置 CRD
dapr.io/app-protocol: "http" #告诉 Dapr 你的应用程序正在使用哪种协议。 有效选项是 http and grpc。 Default is http
#dapr.io/app-max-concurrency: "20" #限制应用程序的并发量。 有效的数值是大于 0
#dapr.io/app-ssl: "false" #告诉Dapr通过不安全的SSL连接调用应用程序。 同时适用于HTTP和gRPC。 Traffic between your app and the Dapr sidecar is encrypted with a certificate issued by a non-trusted certificate authority, which is considered insecure. 默认值为 false.
dapr.io/metrics-port: "9090" #设置 sidecar 度量服务器的端口。 默认值为 9090
#dapr.io/sidecar-cpu-limit: 2 #Dapr sidecar可以使用的最大CPU数量。 默认情况下未设置
#dapr.io/sidecar-memory-limit: "800Mi" #Dapr sidecar可以使用的最大内存量。默认情况下未设置 请参阅 https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/ 的有效值。
#dapr.io/sidecar-cpu-request: 1 #Dapr sidecar要求的 CPU 数量
#dapr.io/sidecar-memory-request #Dapr sidecar 请求的内存数量
#dapr.io/http-max-request-size: "8MB" #增加http和grpc服务器请求正文参数的最大大小,单位为MB,以处理大文件的上传。 默认值为 4 MB
dapr.io/sidecar-listen-addresses: "0.0.0.0"
# 更多dapr配置请参考 https://www.bookstack.cn/read/dapr-1.5-zh/cc77b74e2cc2f4d4.md
spec: # 资源规范字段
nodeSelector: # node 选择器
node-type: worker # node标签
containers: # 容器
- name: yifu-check # 容器的名字
image: hub.yifucenter.com:5500/qas-mvp/yifu-check-biz:1.0.0 # 容器镜像地址
imagePullPolicy: Always # 每次Pod启动拉取镜像策略,三个选择 Always、Never、IfNotPresent
# Always,每次都检查;Never,每次都不检查(不管本地是否有);IfNotPresent,如果本地有就不检查,如果没有就拉取(手动测试时,
# 已经打好镜像存在docker容器中时,使用存在不检查级别,
# 默认为每次都检查,然后会进行拉取新镜像,因镜像仓库不存在,导致部署失败)
ports:
- containerPort: 5022 # 容器端口
env: # 启动环境配置信息 active and timeZone set
- name: SPRING_PROFILES_ACTIVE
value: test
- name: TZ
value: Asia/Shanghai
resources: #资源配置限制
limits: # 最大使用
memory: "2048Mi"
#cpu: 300m # CPU,1核心 = 1000m
requests: # 容器运行时,最低资源需求,也就是说最少需要多少资源容器才能正常运行
#cpu: 100m
memory: "500Mi"
#livenessProbe: # pod 内部健康检查的设置
# httpGet: # 通过httpget检查健康,返回200-399之间,则认为容器正常
# path: /healthCheck # URI地址
# port: 8080 # 端口
# scheme: HTTP # 协议
# # host: 127.0.0.1 # 主机地址
# initialDelaySeconds: 30 # 表明第一次检测在容器启动后多长时间后开始
# timeoutSeconds: 5 # 检测的超时时间
# periodSeconds: 30 # 检查间隔时间
# successThreshold: 1 # 成功门槛
# failureThreshold: 5 # 失败门槛,连接失败5次,pod杀掉,重启一个新的pod
# readinessProbe: # Pod 准备服务健康检查设置
# httpGet:
# path: /healthCheck
# port: 8080
# scheme: HTTP
# initialDelaySeconds: 30
# timeoutSeconds: 5
# periodSeconds: 10
# successThreshold: 1
# failureThreshold: 5
#也可以用这种方法
#exec: 执行命令的方法进行监测,如果其退出码不为0,则认为容器正常
# command:
# - cat
# - /tmp/health
#也可以用这种方法
#tcpSocket: # 通过tcpSocket检查健康
# port: number
#ports:
# - name: http # 名称
# containerPort: 8080 # 容器开发对外的端口
# protocol: TCP # 协议
imagePullSecrets: # 镜像仓库拉取密钥
- name: login
#affinity: # 亲和性调试
# nodeAffinity: # 节点亲和力
# requiredDuringSchedulingIgnoredDuringExecution: # pod 必须部署到满足条件的节点上
# nodeSelectorTerms: # 节点满足任何一个条件就可以
# - matchExpressions: # 有多个选项,则只有同时满足这些逻辑选项的节点才能运行 pod
# - key: beta.kubernetes.io/arch
# operator: In
# values:
# - amd64
\ No newline at end of file
apiVersion: v1 # 指定api版本,此值必须在kubectl api-versions中
kind: Service # 指定创建资源的角色/类型
metadata: # 资源的元数据/属性
labels: # 设定资源的标签
app: yifu-check # 资源的名字,在同一个namespace中必须唯一
name: yifu-check # 资源的名字,在同一个namespace中必须唯一
namespace: qas-mvp # 部署在哪个namespace中
spec: # 资源规范字段
ports:
- port: 5022 # service 端口
protocol: TCP # 协议
targetPort: 5022 # 容器暴露的端口
name: http-check # 端口名称
- port: 3500 # service 端口
protocol: TCP # 协议
targetPort: 3500 # 容器暴露的端口
name: http-check-dapr
selector: # 选择器
app: yifu-check # 资源名称
type: ClusterIP # ClusterIP 类型
\ No newline at end of file
......@@ -42,5 +42,13 @@
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
</project>
package com.yifu.cloud.plus.v1.check.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
/**
* 实名校验限定调用API的条数表
*
* @author hgw
* @date 2022-6-10 11:07:37
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("t_check_api_num")
@Schema(description = "实名校验限定调用API的条数表")
public class TCheckApiNum extends Model<TCheckApiNum> {
private static final long serialVersionUID = 1L;
/**
* 创建月
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**
* 当月已调用API总条数,初始默认0条
*/
@NotNull(message = "当月已调用API总条数不能为空")
@Schema(description = "当月已调用API总条数")
private Integer apiNum;
/**
* 当月允许调用API总条数,初始默认每月10000条
*/
@NotNull(message = "当月允许调用API总条数不能为空")
@Schema(description = "当月允许调用API总条数")
private Integer canApiNum;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
}
package com.yifu.cloud.plus.v1.check.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-5-10 17:41:27
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("t_check_id_card")
@Schema(description = "身份证实名校验自留库")
public class TCheckIdCard extends Model<TCheckIdCard> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**
* 姓名
*/
@NotBlank(message = "姓名不能为空")
@Length(max = 20, message = "姓名不能超过20个字符")
@Schema(description = "姓名")
private String name;
/**
* 身份证
*/
@Length(max = 18, message = "身份证不能超过18个字符")
@Schema(description = "身份证")
private String idCard;
/**
* 是否正确:1正确。0错误。
*/
@NotNull(message = "是否正确:1正确。0错误。不能为空")
@Schema(description = "是否正确:1正确。0错误。")
private Integer isTrue;
/**
* 原因
*/
@Length(max = 50, message = "原因不能超过50个字符")
@Schema(description = "原因")
private String reason;
/**
* 类型0:初始导入数据;1调用api保存的数据
*/
@NotNull(message = "类型不能为空")
@Schema(description = "类型0:初始导入数据;1调用api保存的数据")
private Integer type;
/**
* 创建人
*/
@Length(max = 32, message = "创建人不能超过32个字符")
@Schema(description = "创建人")
private String createUser;
/**
* 创建时间
*/
@Schema(description = "创建时间")
@NotNull(message = "创建时间不能为空")
private LocalDateTime createTime;
}
package com.yifu.cloud.plus.v1.check.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
* 实名校验导入锁定表(锁定后不可导入,除非清理掉数据)
*
* @author hgw
* @date 2022-6-10 11:07:15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("t_check_lock")
@Schema(description = "实名校验导入锁定表(锁定后不可导入,除非清理掉数据)")
public class TCheckLock extends Model<TCheckLock> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
/**
* 创建人
*/
@NotBlank(message = "创建人不能为空")
@Length(max = 32, message = "创建人不能超过32个字符")
@Schema(description = "创建人")
private String createUser;
/**
* 创建人姓名
*/
@Length(max = 50, message = "创建人姓名不能超过50个字符")
@Schema(description = "创建人姓名")
private String createUserName;
/**
* 创建时间
*/
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 校验月
*/
@Length(max = 6, message = "校验月不能超过6个字符")
@Schema(description = "校验月")
private String createMonth;
/**
* 导入总条数
*/
@NotNull(message = "导入总条数不能为空")
@Schema(description = "导入总条数")
private Integer importNum;
/**
* 调用API总条数
*/
@NotNull(message = "调用API总条数不能为空")
@Schema(description = "调用API总条数")
private Integer apiNum;
/**
* 删除标志:0未删除;1已删除(1代表已完成导入或删除,释放了锁)
*/
@NotNull(message = "删除标志:0未删除;1已删除(1代表已完成导入或删除,释放了锁)不能为空")
@Schema(description = "删除标志:0未删除;1已删除(1代表已完成导入或删除,释放了锁)")
private Integer deleteFlag;
}
package com.yifu.cloud.plus.v1.check.utils;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashMap;
import java.util.Map;
/**
* @author hgw2
* @description 测试身份证
* @date 2022/5/7
*/
public class CheckIdCard {
@Value("${canCheck}")
private static boolean canCheck;
private static final String APP_ID_ID_CARD = "oi0mucL4";
private static final String APP_KEY_ID_CARD = "s4lW5JRA";
private static final String API_URL_ID_CARD = "https://api.253.com/open/idcard/id-card-auth";
private static JsonParser jsonParser = new JsonParser();
public static void checkIdCard(TCheckIdCard checkIdCard) {
if (canCheck) {
// 1.调用身份信息校验api
extracted(checkIdCard);
} else {
checkIdCard.setIsTrue(0);
checkIdCard.setReason("nacos中checks.yaml的配置canCheck未开启!");
}
}
// 核心调用
private static void extracted(TCheckIdCard checkIdCard) {
final JsonObject jsonObject = CheckIdCard.invokeIdCard(checkIdCard.getName(), checkIdCard.getIdCard());
// 2.处理返回结果
if (jsonObject != null) {
//响应code码。200000:成功,其他失败
String code = jsonObject.get("code").getAsString();
if ("200000".equals(code) && jsonObject.get("data") != null) {
// 调用身份信息校验成功
// 解析结果数据,进行业务处理
// 校验状态码 200000:成功,其他失败
String resultStr = jsonObject.get("data").getAsJsonObject().get("result").getAsString();
if ("01".equals(resultStr)) {
checkIdCard.setIsTrue(1);
checkIdCard.setReason("正确");
} else {
checkIdCard.setIsTrue(0);
String remark = jsonObject.get("data").getAsJsonObject().get("remark").getAsString();
checkIdCard.setReason("调用身份信息校验失败,resultStr:" + resultStr + ",msg:" + remark);
}
} else {
// 记录错误日志,正式项目中请换成log打印
checkIdCard.setIsTrue(0);
checkIdCard.setReason("调用身份信息校验失败,code:" + code + ",msg:" + jsonObject.get("message").getAsString());
}
} else {
checkIdCard.setIsTrue(0);
checkIdCard.setReason("接口无返回数据");
}
}
private static JsonObject invokeIdCard(String name, String idNum) {
Map<String, String> params = new HashMap<>();
params.put("appId", APP_ID_ID_CARD);
params.put("appKey", APP_KEY_ID_CARD);
params.put("name", name);
params.put("idNum", idNum);
String result = HttpUtils.post(API_URL_ID_CARD, params);
// 解析json,并返回结果
return jsonParser.parse(result).getAsJsonObject();
}
}
package com.yifu.cloud.plus.v1.check.utils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.nio.charset.Charset;
import java.util.Map;
/**
* @author hgw2
* @description 发送
* @date 2022/5/7
*/
public class HttpUtils {
private static final int REQUEST_TIMEOUT = 3 * 1000; // 设置请求超时10秒钟
private static final int CONNECT_TIMEOUT = 5 * 1000; // 连接超时时间
private static final int SO_TIMEOUT = 10 * 1000; // 数据传输超时
private static final String ENCODING = "UTF-8";
// 务必单例
private static CloseableHttpClient client;
static {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(CONNECT_TIMEOUT)
.setConnectionRequestTimeout(REQUEST_TIMEOUT)
.setSocketTimeout(SO_TIMEOUT)
.build();
client = HttpClients.custom().setDefaultRequestConfig(requestConfig).setMaxConnTotal(50).build();
}
public static String get(String url, Map<String, String> paramsMap) {
return send(RequestBuilder.get(url), paramsMap);
}
public static String post(String url, Map<String, String> paramsMap) {
return send(RequestBuilder.post(url), paramsMap);
}
public static String send(RequestBuilder requestBuilder, Map<String, String> paramsMap) {
requestBuilder.setCharset(Charset.forName(ENCODING));
String responseText = "";
if (paramsMap != null) {
for (Map.Entry<String, String> param : paramsMap.entrySet()) {
requestBuilder.addParameter(param.getKey(), param.getValue());
}
CloseableHttpResponse response = null;
try {
response = client.execute(requestBuilder.build());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = response.getEntity();
if (entity != null) {
responseText = EntityUtils.toString(entity, ENCODING);
}
}
} catch (Exception e) {
e.printStackTrace();//正式项目中请改为log打印
} finally {
try {
response.close();
} catch (Exception e) {
e.printStackTrace();//正式项目中请改为log打印
}
}
}
return responseText;
}
}
FROM moxm/java:1.8-full
RUN mkdir -p /consumer
RUN mkdir -p /yifu-check-biz
WORKDIR consumer
WORKDIR yifu-check-biz
ARG JAR_FILE=target/consumer-biz.jar
ARG JAR_FILE=target/yifu-check-biz.jar
COPY ${JAR_FILE} app.jar
......
package com.yifu.cloud.plus.v1.consumer;
package com.yifu.cloud.plus.v1.check;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer;
import org.springframework.boot.SpringApplication;
......@@ -11,10 +11,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
*/
@EnableYifuResourceServer
@SpringBootApplication
public class ConsumerApplication {
public class CheckApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
SpringApplication.run(CheckApplication.class, args);
}
}
package com.yifu.cloud.plus.v1.check.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.service.TCheckIdCardService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
@RestController
@AllArgsConstructor
@RequestMapping("/tcheckidcard")
@Tag(name = "身份证实名校验自留库")
public class TCheckIdCardController {
private final TCheckIdCardService tCheckIdCardService;
/**
* 简单分页查询
*
* @param page 分页对象
* @param tCheckIdCard 身份证实名校验自留库
* @return
*/
@Operation(description = "简单分页查询")
@GetMapping("/page")
public R<IPage<TCheckIdCard>> getTCheckIdCardPage(Page<TCheckIdCard> page, TCheckIdCard tCheckIdCard) {
return new R<>(tCheckIdCardService.getTCheckIdCardPage(page, tCheckIdCard));
}
@Operation(description = "获取所有list")
@GetMapping("/getAllList")
public R<List<TCheckIdCard>> getAllList(TCheckIdCard tCheckIdCard) {
return new R<>(tCheckIdCardService.getAllList(tCheckIdCard));
}
/**
* @param
* @Description: 获取身份证库
* @Author: hgw
* @Date: 2022/5/11 17:44
* @return: com.yifu.cloud.v1.common.core.util.R<java.util.Map < java.lang.String, com.yifu.cloud.v1.checks.api.entity.TCheckIdCard>>
**/
@Inner
@Operation(description = "获取身份证库")
@PostMapping("/inner/getAllChecksInfo")
public R<Map<String, TCheckIdCard>> getAllChecksInfo() {
return new R<>(new HashMap<>());
}
/**
* 通过id查询单条记录
*
* @param id
* @return R
*/
@Operation(description = "id查询")
@GetMapping("/{id}")
public R<TCheckIdCard> getById(@PathVariable("id") String id) {
return new R<>(tCheckIdCardService.getById(id));
}
/**
* 新增记录
*
* @param tCheckIdCard
* @return R
*/
@Operation(description = "新增(checks:tcheckidcard_add)")
@PostMapping
@PreAuthorize("@pms.hasPermission('checks:tcheckidcard_add')")
public R<Boolean> save(@Valid @RequestBody TCheckIdCard tCheckIdCard) {
return new R<>(tCheckIdCardService.save(tCheckIdCard));
}
/**
* 修改记录
*
* @param tCheckIdCard
* @return R
*/
@Operation(description = "修改(checks:tcheckidcard_edit)")
@SysLog("修改身份证实名校验自留库")
@PutMapping
@PreAuthorize("@pms.hasPermission('checks:tcheckidcard_edit')")
public R<Boolean> update(@RequestBody TCheckIdCard tCheckIdCard) {
return new R(tCheckIdCardService.updateById(tCheckIdCard));
}
/**
* 通过id删除一条记录
*
* @param id
* @return R
*/
@Operation(description = "删除(checks:tcheckidcard_del)")
@SysLog("删除身份证实名校验自留库")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('checks:tcheckidcard_del')")
public R<Boolean> removeById(@PathVariable String id) {
return new R<>(tCheckIdCardService.removeById(id));
}
/**
* @param checkList
* @Description: 校验姓名身份证
* @Author: hgw
* @Date: 2022-5-12 15:18:53
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Operation(description = "校验姓名身份证")
@SysLog("校验姓名身份证")
@PostMapping("/checkIdCard")
public R<List<TCheckIdCard>> checkIdCard(@RequestBody List<TCheckIdCard> checkList) {
return tCheckIdCardService.checkIdCard(checkList);
}
}
package com.yifu.cloud.plus.v1.check.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.check.entity.TCheckApiNum;
import org.apache.ibatis.annotations.Mapper;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
@Mapper
public interface TCheckApiNumMapper extends BaseMapper<TCheckApiNum> {
}
package com.yifu.cloud.plus.v1.check.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
@Mapper
public interface TCheckIdCardMapper extends BaseMapper<TCheckIdCard> {
/**
* 身份证实名校验自留库简单分页查询
*
* @param tCheckIdCard 身份证实名校验自留库
* @return
*/
IPage<TCheckIdCard> getTCheckIdCardPage(Page<TCheckIdCard> page, @Param("tCheckIdCard") TCheckIdCard tCheckIdCard);
/**
* @param
* @Description: 所有数据
* @Author: hgw
* @Date: 2022/5/12 15:28
* @return: java.util.List<com.yifu.cloud.v1.checks.api.entity.TCheckIdCard>
**/
List<TCheckIdCard> getAllList(@Param("tCheckIdCard") TCheckIdCard tCheckIdCard);
}
package com.yifu.cloud.plus.v1.check.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.check.entity.TCheckLock;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
@Mapper
public interface TCheckLockMapper extends BaseMapper<TCheckLock> {
/**
* @Description: 所有数据
* @Author: hgw
* @Date: 2022-6-10 11:15:00
* @return: java.util.List<com.yifu.cloud.v1.checks.api.entity.TCheckLock>
**/
List<TCheckLock> getAllList();
}
package com.yifu.cloud.plus.v1.check.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.check.entity.TCheckApiNum;
/**
* 校验锁
* @author hgw
* @date 2022-01-13 15:08:05
*/
public interface TCheckApiNumService extends IService<TCheckApiNum> {
}
package com.yifu.cloud.plus.v1.check.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.util.List;
import java.util.Map;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
public interface TCheckIdCardService extends IService<TCheckIdCard> {
/**
* 身份证实名校验自留库简单分页查询
*
* @param tCheckIdCard 身份证实名校验自留库
* @return
*/
IPage<TCheckIdCard> getTCheckIdCardPage(Page<TCheckIdCard> page, TCheckIdCard tCheckIdCard);
/**
* @param
* @Description: 获取所有list
* @Author: hgw
* @Date: 2022/5/12 15:29
* @return: java.util.List<com.yifu.cloud.v1.checks.api.entity.TCheckIdCard>
**/
List<TCheckIdCard> getAllList(TCheckIdCard tCheckIdCard);
Map<String, TCheckIdCard> getAllMap(TCheckIdCard tCheckIdCard);
/**
* @param checkList
* @Description: 校验
* @Author: hgw
* @Date: 2022/5/12 15:20
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.String>
**/
R<List<TCheckIdCard>> checkIdCard(List<TCheckIdCard> checkList);
}
package com.yifu.cloud.plus.v1.check.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.check.entity.TCheckLock;
import java.util.List;
/**
* 校验锁
*
* @author hgw
* @date 2022-01-13 15:08:05
*/
public interface TCheckLockService extends IService<TCheckLock> {
/**
* 查询全部
*/
List<TCheckLock> getAllList();
}
package com.yifu.cloud.plus.v1.check.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCheckApiNum;
import com.yifu.cloud.plus.v1.check.mapper.TCheckApiNumMapper;
import com.yifu.cloud.plus.v1.check.service.TCheckApiNumService;
import org.springframework.stereotype.Service;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
@Service
public class TCheckApiNumServiceImpl extends ServiceImpl<TCheckApiNumMapper, TCheckApiNum> implements TCheckApiNumService {
@Override
public boolean save(TCheckApiNum entity) {
return super.save(entity);
}
}
package com.yifu.cloud.plus.v1.check.service.impl;
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.yifu.cloud.plus.v1.check.entity.TCheckApiNum;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.entity.TCheckLock;
import com.yifu.cloud.plus.v1.check.mapper.TCheckIdCardMapper;
import com.yifu.cloud.plus.v1.check.service.TCheckApiNumService;
import com.yifu.cloud.plus.v1.check.service.TCheckIdCardService;
import com.yifu.cloud.plus.v1.check.service.TCheckLockService;
import com.yifu.cloud.plus.v1.check.utils.CheckIdCard;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
@AllArgsConstructor
@Service
public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCheckIdCard> implements TCheckIdCardService {
private final TCheckLockService tCheckLockService;
private final TCheckApiNumService tCheckApiNumService;
/**
* 身份证实名校验自留库简单分页查询
*
* @param tCheckIdCard 身份证实名校验自留库
* @return
*/
@Override
public IPage<TCheckIdCard> getTCheckIdCardPage(Page<TCheckIdCard> page, TCheckIdCard tCheckIdCard) {
return baseMapper.getTCheckIdCardPage(page, tCheckIdCard);
}
@Override
public List<TCheckIdCard> getAllList(TCheckIdCard tCheckIdCard) {
return baseMapper.getAllList(tCheckIdCard);
}
@Override
public Map<String, TCheckIdCard> getAllMap(TCheckIdCard tCheckIdCard) {
List<TCheckIdCard> list = baseMapper.getAllList(tCheckIdCard);
Map<String, TCheckIdCard> returnMap = new HashMap<>();
if (list != null && !list.isEmpty()) {
for (TCheckIdCard c : list) {
returnMap.put(c.getIdCard() + CommonConstants.DOWN_LINE_STRING + c.getName(), c);
}
}
return returnMap;
}
/**
* @param checkList
* @Description: 校验
* @Author: hgw
* @Date: 2022/5/12 15:47
* @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.checks.api.entity.TCheckIdCard>>
**/
@Override
public synchronized R<List<TCheckIdCard>> checkIdCard(List<TCheckIdCard> checkList) {
YifuUser user = SecurityUtils.getUser();
if (user == null || Common.isEmpty(user.getId())) {
return R.failed("请登录!");
}
List<TCheckLock> lockList = tCheckLockService.getAllList();
if (lockList != null && !lockList.isEmpty()) {
return R.failed("当前有用户在导入中,请稍后!或联系管理员处理表TCheckLock数据和重启校验服务");
}
String nowMonth = DateUtil.addMonth(0);
TCheckApiNum nowMonthNum = tCheckApiNumService.getById(nowMonth);
if (nowMonthNum == null) {
TCheckApiNum lastMonth = tCheckApiNumService.getById(DateUtil.addMonth(-1));
int canApiNum = 10000;
if (lastMonth != null && lastMonth.getCanApiNum() != null) {
canApiNum = lastMonth.getCanApiNum();
}
nowMonthNum = new TCheckApiNum();
nowMonthNum.setId(nowMonth);
nowMonthNum.setCanApiNum(canApiNum);
nowMonthNum.setApiNum(0);
tCheckApiNumService.save(nowMonthNum);
} else if (nowMonthNum.getApiNum() >= nowMonthNum.getCanApiNum()) {
return R.failed("当月总条数:" + nowMonthNum.getCanApiNum() + "已到达上限!");
}
if (checkList != null && !checkList.isEmpty()) {
TCheckLock lock = new TCheckLock();
lock.setImportNum(checkList.size());
lock.setApiNum(0);
lock.setCreateMonth(nowMonth);
lock.setCreateTime(LocalDateTime.now());
lock.setCreateUser(String.valueOf(user.getId()));
lock.setDeleteFlag(0);
lock.setCreateUserName(user.getNickname());
tCheckLockService.save(lock);
int nowApiNum = 0;
int canApiNum = nowMonthNum.getCanApiNum();
Map<String, TCheckIdCard> returnMap = this.getAllMap(null);
TCheckIdCard nowIdCard;
TCheckIdCard lastCard;
Map<String, TCheckIdCard> idCardMap = new HashMap<>();
String userId = String.valueOf(user.getId());
TCheckLock lockUpdate;
try {
for (TCheckIdCard c : checkList) {
if (Common.isNotNull(c.getIdCard()) && Common.isNotNull(c.getName())) {
lastCard = idCardMap.get(c.getIdCard());
if (lastCard != null) {
c.setIsTrue(lastCard.getIsTrue());
c.setReason(lastCard.getReason());
} else {
// 校验姓名身份证规则
if (!regIdCard(c.getIdCard())) {
c.setIsTrue(0);
c.setReason("身份证格式有误");
} else if (regEmpName(c.getName())) {
c.setIsTrue(0);
c.setReason("姓名含数字或空格,无法校验");
} else {
nowIdCard = returnMap.get(c.getIdCard() + CommonConstants.DOWN_LINE_STRING + c.getName());
if (nowIdCard != null) {
c.setIsTrue(nowIdCard.getIsTrue());
c.setReason(nowIdCard.getReason());
} else {
// 调用API校验
if (nowApiNum < canApiNum) {
nowApiNum++;
CheckIdCard.checkIdCard(c);
c.setCreateUser(userId);
c.setCreateTime(LocalDateTime.now());
c.setType(CommonConstants.ONE_INT);
returnMap.put(c.getIdCard() + CommonConstants.DOWN_LINE_STRING + c.getName(), c);
this.save(c);
nowMonthNum.setApiNum(nowMonthNum.getApiNum() + 1);
tCheckApiNumService.updateById(nowMonthNum);
} else {
c.setIsTrue(0);
c.setReason("调用花钱的Api的条数已达上限:" + nowMonthNum.getCanApiNum() + ",请联系管理员处理!");
}
}
}
// 将同身份证的结果存储下来备用,防止撞库
idCardMap.put(c.getIdCard(), c);
}
} else {
c.setIsTrue(0);
c.setReason("姓名身份证不可为空");
}
}
} catch (Exception e) {
lockUpdate = new TCheckLock();
lockUpdate.setId(lock.getId());
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
lockUpdate.setApiNum(nowApiNum);
tCheckLockService.updateById(lockUpdate);
throw new RuntimeException(e.getMessage() == null ? "校验身份证导入失败!" : "校验身份证导入失败:" + e.getMessage());
} finally {
lockUpdate = new TCheckLock();
lockUpdate.setId(lock.getId());
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
lockUpdate.setApiNum(nowApiNum);
tCheckLockService.updateById(lockUpdate);
}
return new R<>(checkList);
}
return R.failed("数据为空!");
}
/**
* @param content
* @Description: 判断身份证格式:18位数字,17位数字+X,15位数字,14位数字+X
* 格式正确返回true
* @Author: hgw
* @Date: 2022/5/13 11:53
* @return: boolean
**/
private static boolean regIdCard(String content) {
boolean flag = false;
Pattern p = Pattern.compile("\\d{18}|\\d{17}X|\\d{15}|\\d{14}X");
Matcher m = p.matcher(content);
if (m.matches()) {
flag = true;
}
return flag;
}
/**
* @param content
* @Description: 含数字,返回true
* @Author: hgw
* @Date: 2022/5/13 11:54
* @return: boolean
**/
private static boolean regEmpName(String content) {
boolean flag = false;
Pattern p = Pattern.compile(".*\\d+.*|.*\\s+.*");
Matcher m = p.matcher(content);
if (m.matches()) {
flag = true;
}
return flag;
}
}
package com.yifu.cloud.plus.v1.check.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCheckLock;
import com.yifu.cloud.plus.v1.check.mapper.TCheckLockMapper;
import com.yifu.cloud.plus.v1.check.service.TCheckLockService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 身份证实名校验自留库
*
* @author hgw
* @date 2022-05-11 16:12:18
*/
@Service
public class TCheckLockServiceImpl extends ServiceImpl<TCheckLockMapper, TCheckLock> implements TCheckLockService {
@Override
public List<TCheckLock> getAllList() {
return baseMapper.getAllList();
}
}
/*
* Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.consumer.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.consumer.entity.Consumer;
import com.yifu.cloud.plus.v1.consumer.service.ConsumerService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
/**
* consumer表
*
* @author fxj
* @date 2022-05-13 23:28:12
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/consumer" )
@Tag(name = "consumer表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ConsumerController {
private final ConsumerService consumerService;
/**
* 分页查询
* @param page 分页对象
* @param consumer consumer表
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('consumer_consumer_get')" )
public R getConsumerPage(Page page, Consumer consumer) {
return R.ok(consumerService.page(page, Wrappers.query(consumer)));
}
/**
* 通过id查询consumer表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('consumer_consumer_get')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(consumerService.getById(id));
}
/**
* 新增consumer表
* @param consumer consumer表
* @return R
*/
@Operation(summary = "新增consumer表", description = "新增consumer表")
@SysLog("新增consumer表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('consumer_consumer_add')" )
public R save(@RequestBody Consumer consumer) {
return R.ok(consumerService.saveTestSeata(consumer));
}
/**
* 修改consumer表
* @param consumer consumer表
* @return R
*/
@Operation(summary = "修改consumer表", description = "修改consumer表")
@SysLog("修改consumer表" )
@PutMapping
@PreAuthorize("@pms.hasPermission('consumer_consumer_edit')" )
public R updateById(@RequestBody Consumer consumer) {
return R.ok(consumerService.updateById(consumer));
}
/**
* 通过id删除consumer表
* @param id id
* @return R
*/
@Operation(summary = "通过id删除consumer表", description = "通过id删除consumer表")
@SysLog("通过id删除consumer表" )
@DeleteMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('consumer_consumer_del')" )
public R removeById(@PathVariable Long id) {
return R.ok(consumerService.removeById(id));
}
}
/*
* Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.consumer.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* consumer表
*
* @author fxj
* @date 2022-05-13 23:28:12
*/
@Data
@TableName("consumer")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "consumer表")
public class Consumer extends BaseEntity {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description ="主键")
private Long id;
/**
* 用户名
*/
@Schema(description ="用户名")
private String username;
/**
* 昵称
*/
@Schema(description ="昵称")
private String nicename;
}
/*
* Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.consumer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.consumer.entity.Consumer;
import org.apache.ibatis.annotations.Mapper;
/**
* consumer表
*
* @author fxj
* @date 2022-05-13 23:28:12
*/
@Mapper
public interface ConsumerMapper extends BaseMapper<Consumer> {
}
/*
* Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.consumer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.consumer.entity.Consumer;
/**
* consumer表
*
* @author fxj
* @date 2022-05-13 23:28:12
*/
public interface ConsumerService extends IService<Consumer> {
Boolean saveTestSeata(Consumer consumer);
}
/*
* Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
*/
package com.yifu.cloud.plus.v1.consumer.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.consumer.entity.Consumer;
import com.yifu.cloud.plus.v1.consumer.mapper.ConsumerMapper;
import com.yifu.cloud.plus.v1.consumer.service.ConsumerService;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprProviderProperties;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* consumer表
*
* @author fxj
* @date 2022-05-13 23:28:12
*/
@EnableConfigurationProperties(DaprProviderProperties.class)
@RequiredArgsConstructor
@Service
public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> implements ConsumerService {
private final DaprProviderProperties daprProperties;
@SneakyThrows
@GlobalTransactional // 分布式seata事务
@Transactional
@Override
public Boolean saveTestSeata(Consumer consumer) {
/*Provider provider = new Provider();
provider.setNicename(consumer.getNicename());
provider.setUsername(consumer.getUsername());
provider.setCreateBy(consumer.getCreateBy());
provider.setCreateTime(consumer.getCreateTime());
provider.setUpdateBy(consumer.getUpdateBy());
provider.setUpdateTime(consumer.getUpdateTime());
R result = HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(), "/provider", provider, Provider.class,null);
baseMapper.insert(consumer);*/
return true;
}
}
......@@ -23,6 +23,12 @@ security:
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
# 直接放行URL
ignore:
urls:
- /v3/api-docs
- /actuator/**
- /swagger-ui/**
# mybaits-plus配置
mybatis-plus:
......@@ -36,11 +42,7 @@ mybatis-plus:
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
# 直接放行URL
ignore:
urls:
- /v2/api-docs
- /actuator/**
spring:
application:
name: @artifactId@
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng 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 yifu4cloud.com 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: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.consumer.mapper.ConsumerMapper">
<resultMap id="consumerMap" type="com.yifu.cloud.plus.v1.consumer.entity.Consumer">
<id property="id" column="id"/>
<result property="username" column="username"/>
<result property="nicename" column="nicename"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.v1.checks.mapper.TCheckApiNumMapper">
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.check.mapper.TCheckIdCardMapper">
<resultMap id="tCheckIdCardMap" type="com.yifu.cloud.plus.v1.check.entity.TCheckIdCard">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="idCard" column="id_card"/>
<result property="isTrue" column="is_true"/>
<result property="reason" column="reason"/>
<result property="type" column="type"/>
<result property="createUser" column="CREATE_USER"/>
<result property="createTime" column="CREATE_TIME"/>
</resultMap>
<sql id="Base_Column_List">
a.id,
a.name,
a.id_card,
a.is_true,
a.reason,
a.type,
a.CREATE_USER,
a.CREATE_TIME
</sql>
<sql id="tCheckIdCard_where">
<if test="tCheckIdCard != null">
<if test="tCheckIdCard.id != null and tCheckIdCard.id.trim() != ''">
AND a.id = #{tCheckIdCard.id}
</if>
<if test="tCheckIdCard.name != null and tCheckIdCard.name.trim() != ''">
AND a.name = #{tCheckIdCard.name}
</if>
<if test="tCheckIdCard.idCard != null and tCheckIdCard.idCard.trim() != ''">
AND a.id_card = #{tCheckIdCard.idCard}
</if>
<if test="tCheckIdCard.isTrue != null">
AND a.is_true = #{tCheckIdCard.isTrue}
</if>
</if>
</sql>
<!--tCheckIdCard简单分页查询-->
<select id="getTCheckIdCardPage" resultMap="tCheckIdCardMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_check_id_card a
<where>
1=1
<include refid="tCheckIdCard_where"/>
</where>
</select>
<!--获取所有数据-->
<select id="getAllList" resultMap="tCheckIdCardMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_check_id_card a
<where>
1=1
<include refid="tCheckIdCard_where"/>
</where>
order by a.CREATE_TIME desc
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.check.mapper.TCheckLockMapper">
<resultMap id="tCheckIdCardMap" type="com.yifu.cloud.plus.v1.check.entity.TCheckLock">
<id property="id" column="id"/>
<result property="createUser" column="CREATE_USER"/>
<result property="createUserName" column="CREATE_USER_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="createMonth" column="CREATE_MONTH"/>
<result property="importNum" column="IMPORT_NUM"/>
<result property="apiNum" column="API_NUM"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
</resultMap>
<sql id="Base_Column_List">
ID,
CREATE_USER,
CREATE_USER_NAME,
CREATE_TIME,
CREATE_MONTH,
IMPORT_NUM,
API_NUM,
DELETE_FLAG
</sql>
<!--获取所有数据-->
<select id="getAllList" resultMap="tCheckIdCardMap">
SELECT
<include refid="Base_Column_List"/>
FROM t_check_lock a
where a.DELETE_FLAG = 0
</select>
</mapper>
......@@ -66,6 +66,12 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
......@@ -127,8 +127,16 @@ public interface CommonConstants {
* 下划线
* hgw 2022-6-9 17:36:35
*/
String DOWN_LINE = "_";
//空字符串
String DOWN_LINE_STRING = "_";
/**
* 空字符串
* hgw 2022-6-9 17:36:35
*/
String EMPTY_STRING ="";
/**
* 数字int 1
* @author fxj
*/
int ONE_INT = 1;
}
......@@ -2,6 +2,11 @@ package com.yifu.cloud.plus.v1.yifu.common.core.util;
import lombok.extern.slf4j.Slf4j;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
/**
* @author: FANG
......@@ -41,4 +46,12 @@ public class Common {
}
return false;
}
// 金额验证
public static boolean isNumber(String str) {
// 判断小数点后2位的数字的正则表达式
Pattern pattern = compile("^((-?[1-9]{1}\\d*)|(-?[0]{1}))(\\.(\\d){0,2})?$");
Matcher match = pattern.matcher(str);
return match.matches() != false;
}
}
package com.yifu.cloud.plus.v1.yifu.common.core.util;
import com.yifu.cloud.plus.v1.yifu.common.core.util.sms.MonthObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
/**
* 日期工具类
*
* @author fang
* @ClassName: DateUtil
* @date 2017年7月10日 下午4:13:33
*/
@Slf4j
public class DateUtil {
private DateUtil(){
throw new IllegalStateException("DateUtil class");
}
/**
* 可用时间格式
*/
private static String[] parsePatterns = {DateUtil.DATE_PATTERN, DateUtil.ISO_EXPANDED_DATE_FORMAT, DateUtil.DATETIME_PATTERN_SECOND, DateUtil.DATETIME_PATTERN_MINUTE, DateUtil.DATETIME_PATTERN_XIEGANG,
"yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyymmdd"};
/**
* Base ISO 8601 Date format yyyyMMdd i.e., 20021225 for the 25th day of
* December in the year 2002
*/
public static final String ISO_DATE_FORMAT = "yyyyMMdd";
/**
* Expanded ISO 8601 Date format yyyy-MM-dd i.e., 2002-12-25 for the 25th
* day of December in the year 2002
*/
public static final String ISO_EXPANDED_DATE_FORMAT = "yyyy-MM-dd";
/**
* yyyy/MM/dd
*/
public static final String DATETIME_PATTERN_XIEGANG = "yyyy/MM/dd";
/**
* yyyyMM
*/
public static final String DATETIME_YYYYMM = "yyyyMM";
/**
* yyyy-MM
*/
public static final String DATETIME_YYYY_MM = "yyyy-MM";
/**
* yyyy-MM-dd hh:mm:ss
*/
public static final String DATETIME_PATTERN_SECOND = "yyyy-MM-dd HH:mm:ss";
/**
* yyyy-MM-dd hh:mm:ss
*/
public static final String DATETIME_PATTERN_CONTAINS = "yyyyMMdd HH:mm:ss";
/**
* yyyy-MM-dd hh:mm:ss
*/
public static final String DATETIME_PATTERN_MINUTE = "yyyy-MM-dd HH:mm";
/**
* yyyyMMddHHmmss
*/
public static final String DATE_PATTERN = "yyyyMMddHHmmss";
protected static final float normalizedJulian(float jd) {
return Math.round(jd + 0.5f) - 0.5f;
}
/**
* Returns the Date from a julian. The Julian date will be converted to noon
* GMT, such that it matches the nearest half-integer (i.e., a julian date
* of 1.4 gets changed to 1.5, and 0.9 gets changed to 0.5.)
*
* @param jd the Julian date
* @return the Gregorian date
*/
public static final Date toDate(float jd) {
/*
* To convert a Julian Day Number to a Gregorian date, assume that it is
* for 0 hours, Greenwich time (so that it ends in 0.5). Do the
* following calculations, again dropping the fractional part of all
* multiplicatons and divisions. Note: This method will not give dates
* accurately on the Gregorian Proleptic Calendar, i.e., the calendar
* you get by extending the Gregorian calendar backwards to years
* earlier than 1582. using the Gregorian leap year rules. In
* particular, the method fails if Y<400.
*/
float z = (normalizedJulian(jd)) + 0.5f;
float w = (int) ((z - 1867216.25f) / 36524.25f);
float x = (int) (w / 4f);
float a = z + 1 + w - x;
float b = a + 1524;
float c = (int) ((b - 122.1) / 365.25);
float d = (int) (365.25f * c);
float e = (int) ((b - d) / 30.6001);
float f = (int) (30.6001f * e);
int day = (int) (b - d - f);
int month = (int) (e - 1);
if (month > 12) {
month = month - 12;
}
int year = (int) (c - 4715);
if (month > 2) {
year--;
}
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DATE, day);
return calendar.getTime();
}
/**
* Returns the days between two dates. Positive values indicate that the
* second date is after the first, and negative values indicate, well, the
* opposite. Relying on specific times is problematic.
*
* @param early the "first date"
* @param late the "second date"
* @return the days between the two dates
*/
public static final int daysBetween(Date early, Date late) {
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(early);
c2.setTime(late);
return daysBetween(c1, c2);
}
/**
* Returns the days between two dates. Positive values indicate that the
* second date is after the first, and negative values indicate, well, the
* opposite.
*
* @param early
* @param late
* @return the days between two dates.
*/
public static final int daysBetween(Calendar early, Calendar late) {
return (int) (toJulian(late) - toJulian(early));
}
/**
* Return a Julian date based on the input parameter. This is based from
* calculations found at
* <a href="http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html">Julian
* Day Calculations (Gregorian Calendar)</a>, provided by Bill Jeffrys.
*
* @param calendar a calendar instance
* @return the julian day number
*/
public static final float toJulian(Calendar calendar) {
int y = calendar.get(Calendar.YEAR);
int m = calendar.get(Calendar.MONTH);
int d = calendar.get(Calendar.DATE);
int a = y / 100;
int b = a / 4;
int c = 2 - a + b;
float e = (int) (365.25f * (y + 4716));
float f = (int) (30.6001f * (m + 1));
return ((c + d + e + f) - 1524.5f);
}
/**
* Return a Julian date based on the input parameter. This is based from
* calculations found at
* <a href="http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html">Julian
* Day Calculations (Gregorian Calendar)</a>, provided by Bill Jeffrys.
*
* @param date
* @return the julian day number
*/
public static final float toJulian(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
return toJulian(c);
}
/**
* @param isoString
* @param fmt
* @param field Calendar.YEAR/Calendar.MONTH/Calendar.DATE
* @param amount
* @return
* @throws ParseException
*/
public static final String dateIncrease(String isoString, String fmt, int field, int amount) {
try {
Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTime(stringToDate2(isoString, fmt));
cal.add(field, amount);
return dateToString(cal.getTime(), fmt);
} catch (Exception ex) {
return null;
}
}
/**
* Time Field Rolling function. Rolls (up/down) a single unit of time on the
* given time field.
*
* @param isoString
* @param field the time field.
* @param up Indicates if rolling up or rolling down the field value.
* use formating char's
* @throws ParseException if an unknown field value is given.
*/
public static final String roll(String isoString, String fmt, int field, boolean up) {
Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTime(stringToDate(isoString, fmt));
cal.roll(field, up);
return dateToString(cal.getTime(), fmt);
}
/**
* Time Field Rolling function. Rolls (up/down) a single unit of time on the
* given time field.
*
* @param isoString
* @param field the time field.
* @param up Indicates if rolling up or rolling down the field value.
* @throws ParseException if an unknown field value is given.
*/
public static final String roll(String isoString, int field, boolean up){
return roll(isoString, DATETIME_PATTERN_MINUTE, field, up);
}
/**
* java.util.Date
*
* @param dateText
* @param format
* @return
*/
public static Date stringToDate2(String dateText, String format) {
if (dateText == null) {
return null;
}
DateFormat df = null;
try {
if (format == null) {
df = new SimpleDateFormat();
} else {
df = new SimpleDateFormat(format);
}
// setLenient avoids allowing dates like 9/32/2001
// which would otherwise parse to 10/2/2001
df.setLenient(false);
return df.parse(dateText);
} catch (ParseException e) {
return null;
}
}
/**
* @return Timestamp
*/
public static java.sql.Timestamp getCurrentTimestamp() {
return new java.sql.Timestamp(System.currentTimeMillis());
}
/**
* java.util.Date
*
* @param dateString
* @param format
* @return
*/
public static Date stringToDate(String dateString, String format) {
return stringToDate2(dateString, format);
}
/**
* 校验按指定格式是否可以转换成日期
*
* @param @param dateString
* @param @param format
* @param @return 参数
* @return boolean 返回类型
* @throws
* @Title: checkStringToDate
*/
public static boolean checkStringToDate(String dateString, String formatStr) {
SimpleDateFormat format = new SimpleDateFormat(formatStr);
try {
format.setLenient(false);
format.parse(dateString);
} catch (ParseException e) {
return false;
}
return true;
}
/**
* java.util.Date
*
* @param dateString
*/
public static Date stringToDate(String dateString) {
return stringToDate2(dateString, ISO_EXPANDED_DATE_FORMAT);
}
/**
* @param pattern
* @param date
* @return
*/
public static String dateToString(Date date, String pattern) {
if (date == null) {
return null;
}
try {
SimpleDateFormat sfDate = new SimpleDateFormat(pattern);
sfDate.setLenient(false);
return sfDate.format(date);
} catch (Exception e) {
return null;
}
}
/**
* yyyy-MM-dd
*
* @param date
* @return
*/
public static String dateToString(Date date) {
return dateToString(date, ISO_EXPANDED_DATE_FORMAT);
}
/**
* @return
*/
public static Date getCurrentDateTime() {
Calendar calNow = Calendar.getInstance();
return calNow.getTime();
}
/**
* @param pattern
* @return
*/
public static String getCurrentDateString(String pattern) {
return dateToString(getCurrentDateTime(), pattern);
}
/**
* yyyy-MM-dd
*
* @return
*/
public static String getCurrentDateString() {
return dateToString(getCurrentDateTime(), ISO_EXPANDED_DATE_FORMAT);
}
/**
* 返回固定格式的当前时间 yyyy-MM-dd hh:mm:ss
*
* @param
* @return
*/
public static String dateToStringWithTime() {
return dateToString(new Date(), DATETIME_PATTERN_MINUTE);
}
/**
* yyyy-MM-dd hh:mm:ss
*
* @param date
* @return
*/
public static String dateToStringWithTime(Date date) {
return dateToString(date, DATETIME_PATTERN_MINUTE);
}
/**
* yyyyMMdd
*
* @param date
* @return String
*/
public static String dateToStringWithTimeIso(Date date) {
return dateToString(date, ISO_DATE_FORMAT);
}
/**
* @param date
* @param days
* @return java.util.Date
*/
public static Date dateIncreaseByDay(Date date, int days) {
Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTime(date);
cal.add(Calendar.DATE, days);
return cal.getTime();
}
/**
* @param date
* @param mnt
* @return java.util.Date
*/
public static Date dateIncreaseByMonth(Date date, int mnt) {
Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTime(date);
cal.add(Calendar.MONTH, mnt);
return cal.getTime();
}
/**
* @param date
* @param mnt
* @return java.util.Date
*/
public static Date dateIncreaseByYear(Date date, int mnt) {
Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTime(date);
cal.add(Calendar.YEAR, mnt);
return cal.getTime();
}
/**
* @param date yyyy-MM-dd
* @param days
* @return yyyy-MM-dd
*/
public static String dateIncreaseByDay(String date, int days) {
return dateIncreaseByDay(date, ISO_DATE_FORMAT, days);
}
/**
* @param date
* @param fmt
* @param days
* @return
*/
public static String dateIncreaseByDay(String date, String fmt, int days) {
return dateIncrease(date, fmt, Calendar.DATE, days);
}
/**
* @param src
* @param srcfmt
* @param desfmt
* @return
*/
public static String stringToString(String src, String srcfmt, String desfmt) {
return dateToString(stringToDate(src, srcfmt), desfmt);
}
/**
* @param date
* @return string
*/
public static String getYear(Date date) {
SimpleDateFormat formater = new SimpleDateFormat("yyyy");
return formater.format(date);
}
/**
* @param date
* @return string
*/
public static String getMonth(Date date) {
SimpleDateFormat formater = new SimpleDateFormat("MM");
return formater.format(date);
}
/**
* @param date
* @return string
*/
public static String getDay(Date date) {
SimpleDateFormat formater = new SimpleDateFormat("dd");
return formater.format(date);
}
/**
* @param date
* @return string
*/
public static String getHour(Date date) {
SimpleDateFormat formater = new SimpleDateFormat("HH");
return formater.format(date);
}
public static int getMinsFromDate(Date dt) {
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(dt);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int min = cal.get(Calendar.MINUTE);
return ((hour * 60) + min);
}
/**
* Function to convert String to Date Object. If invalid input then current
* or next day date is returned (Added by Ali Naqvi on 2006-5-16).
*
* @param str String input in YYYY-MM-DD HH:MM[:SS] format.
* @param isExpiry boolean if set and input string is invalid then next day date
* is returned
* @return Date
*/
public static Date convertToDate(String str, boolean isExpiry) {
SimpleDateFormat fmt = new SimpleDateFormat(DATETIME_PATTERN_MINUTE);
Date dt = null;
try {
dt = fmt.parse(str);
} catch (ParseException ex) {
Calendar cal = Calendar.getInstance();
if (isExpiry) {
cal.add(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
} else {
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
}
dt = cal.getTime();
}
return dt;
}
public static Date convertToDate(String str) {
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date dt = null;
try {
dt = fmt.parse(str);
} catch (ParseException ex) {
dt = new Date();
}
return dt;
}
public static String dateFromat(Date date, int minute) {
String dateFormat = null;
int year = Integer.parseInt(getYear(date));
int month = Integer.parseInt(getMonth(date));
int day = Integer.parseInt(getDay(date));
int hour = minute / 60;
int min = minute % 60;
dateFormat = year + (month > 9 ? String.valueOf(month) : "0" + month + "")
+ (day > 9 ? String.valueOf(day) : "0" + day) + " "
+ (hour > 9 ? String.valueOf(hour) : "0" + hour)
+ (min > 9 ? String.valueOf(min) : "0" + min) + "00";
return dateFormat;
}
public static String sDateFormat() {
return new SimpleDateFormat(DATE_PATTERN).format(Calendar.getInstance().getTime());
}
/**
* 判断是否为有效时间格式
*
* @param str
* @return
*/
public static Boolean valid(String str) {
Boolean result = false;
if (null != str) {
for (String Pattern : parsePatterns) {
if (Pattern.equals(str)) {
result = true;
break;
}
}
}
return result;
}
/**
* 返回一个有效时间格式串若自身无效则返回"yyyy-MM-dd"
*
* @param str
* @return
*/
public static String validAndReturn(String str) {
String result = ISO_EXPANDED_DATE_FORMAT;
if (valid(str)) {
result = str;
}
return result;
}
/**
* 根据type返回时间差(除不尽加1)
*
* @param end 结束时间
* @param begin 开始时间
* @param type 返回类型1秒2分3小时4天(type其他值都返回秒)
* @return
*/
public static long getSubTime(Date end, Date begin, Integer type) {
long between = 0;
if (end != null && begin != null) {
try {
// 得到两者的毫秒数
between = (end.getTime() - begin.getTime());
} catch (Exception ex) {
log.error("根据type返回时间差",ex);
}
return initSubTime(type, between);
} else {
return between;
}
}
private static long initSubTime(Integer type, long between) {
if (null == type) {
return between;
} else if (type == 2) {
long min = (between / (60 * 1000));
if (between % (60 * 1000) != 0) {
min++;
}
return min;
} else if (type == 3) {
long hour = (between / (60 * 60 * 1000));
if (between % (60 * 60 * 1000) != 0) {
hour++;
}
return hour;
} else if (type == 4) {
long day = between / (24 * 60 * 60 * 1000);
if (between % (24 * 60 * 60 * 1000) != 0) {
day++;
}
return day;
} else {
return between;
}
}
/**
* 已当月为基准往前退 i+1 个生成月份格式:YYYYMMDD 未完善
*
* @param @param i
* @param @return 参数
* @return String 返回类型
* @throws
* @Title: getMonthByNum
* @Description:
*/
public static List<MonthObject> getMonthByNum(int i, int endDate) {
List<MonthObject> socailStartList = new ArrayList<>();
MonthObject temp = null;
MonthObject temp2 = null;
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
// 取时间
Date date = new Date();
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
if (endDate <= Integer.parseInt(DateUtil.getDay(date))) {
// 把日期往后增加一个月.整数往后推,负数往前移动
calendar.add(Calendar.MONTH, 2);
} else {
// 把日期往后增加一个月.整数往后推,负数往前移动
calendar.add(Calendar.MONTH, 1);
}
temp2 = new MonthObject();
temp2.setMonth(sdf.format(calendar.getTime()));
date = calendar.getTime();
socailStartList.add(temp2);
for (int x = 1; x <= i; x++) {
calendar.setTime(date);
calendar.add(Calendar.MONTH, -x);
temp = new MonthObject();
temp.setMonth(sdf.format(calendar.getTime()));
socailStartList.add(temp);
}
return socailStartList;
}
/**
* 获得指定月份的日期
*
* @param i
* @return
* @Author fxj
* @Date 2019-09-18
**/
public static Date getDateByMonthNum(int i) {
// 取时间
Date date = new Date();
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
// 把日期往后增加一个月.整数往后推,负数往前移动
calendar.add(Calendar.MONTH, i);
return calendar.getTime();
}
/**
* @param @param i
* @param @return 参数
* @return List<MonthObject> 返回类型
* @throws
* @Title: getFutureMonthByNum
* @Description: (已当前月份未基准往后退 i + 1个月份)
*/
public static List<MonthObject> getFutureMonthByNum(int k, int endDate) {
List<MonthObject> socailStartList = new ArrayList<>();
MonthObject temp = null;
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
Date date = new Date();//取时间
Calendar calendar = new GregorianCalendar();
int j = 0;
if (endDate <= Integer.parseInt(DateUtil.getDay(date))) {
j = 2;
} else {
j = 1;
}
for (int x = j; x < k; x++) {
calendar.setTime(date);
calendar.add(Calendar.MONTH, x);
temp = new MonthObject();
temp.setMonth(sdf.format(calendar.getTime()));
socailStartList.add(temp);
}
return socailStartList;
}
public static List<Date> getDateListByStartEndDate(Date startDate, Date endDate) {
List<Date> lstDate = new ArrayList<>();
lstDate.add(startDate);
if (startDate.equals(endDate)) {
return lstDate;
}
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
Calendar calendar = new GregorianCalendar();
calendar.setTime(startDate);
for (int i = 1; i > 0; i = 1) {
calendar.add(Calendar.MONTH, i);
try {
if (sdf.format(calendar.getTime()).equals(sdf.format(endDate))) {
lstDate.add(sdf.parse(sdf.format(calendar.getTime())));
break;
}
lstDate.add(sdf.parse(sdf.format(calendar.getTime())));
} catch (ParseException e) {
log.error("getDateListByStartEndDate",e);
}
}
return lstDate;
}
/**
* @param @param startDate 起缴日期
* @param @param backNum 补缴月份
* @param @param type 补缴类型 1.当月缴纳当月 2.当月缴纳次月
* @param @return 参数
* @return boolean 返回类型
* @throws
* @Title: checkStartDate
* @Description: (判断日期是否在指定的日期范围内)
*/
public static boolean checkStartDate(Date startDate, int backNum, int type) {
Calendar calendar = new GregorianCalendar();
calendar.setTime(new Date());
Date temp = null;
if (type == 1) {
calendar.add(Calendar.MONTH, backNum);
} else if (type == 2) {
calendar.add(Calendar.MONTH, backNum - 1);
}
temp = calendar.getTime();
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
try {
// 当startDate 在temp 前 返回false
if (!startDate.before(sdf.parse(sdf.format(temp)))) {
return true;
}
} catch (ParseException e) {
return true;
}
return false;
}
public static int getMonthCountByDate(Date startDate, Date endDate) {
// type:1.当月缴当月的 2.当月缴次月的
int monthC = 0;
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
if (endDate == null) {
endDate = new Date();
}
try {
monthC = getMonthSpace(sdf.format(startDate), sdf.format(endDate));
monthC = monthC + 1;
} catch (ParseException e) {
log.error("getMonthCountByDate",e);
return 0;
}
return monthC;
}
/**
* @param date1 <String>
* @param date2 <String>
* @return int
* @throws ParseException
*/
public static int getMonthSpace(String date1, String date2)
throws ParseException {
int result = 0;
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(sdf.parse(date1));
c2.setTime(sdf.parse(date2));
result = 12 * (c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR)) + c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH);
return result / 1;
}
/**
* @param date1 <String>
* @param date2 <String>
* @return int
* @throws ParseException
*/
public static int getYearSpace(String date1, String date2)
throws ParseException {
int result = 0;
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(sdf.parse(date1));
c2.setTime(sdf.parse(date2));
result = 1 * (c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR)) + (c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH))/12;
return result / 1;
}
/**
* 获取任意时间的月的最后一天
* 描述:<描述函数实现的功能>.
*
* @param repeatDate
* @return
*/
public static String getMaxMonthDate(String repeatDate) {
SimpleDateFormat dft = new SimpleDateFormat(ISO_DATE_FORMAT);
Calendar calendar = Calendar.getInstance();
try {
if (StringUtils.isNotBlank(repeatDate) && !"null".equals(repeatDate)) {
calendar.setTime(dft.parse(repeatDate));
}
} catch (ParseException e) {
log.error("getMaxMonthDate",e);
}
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
return dft.format(calendar.getTime());
}
public static Date getMaxDayOfMonth(Date temp) {
SimpleDateFormat sdf = new SimpleDateFormat(ISO_DATE_FORMAT);
String dateStr = sdf.format(temp);
dateStr = getMaxMonthDate(dateStr);
Date res = null;
try {
res = sdf.parse(dateStr);
} catch (ParseException e) {
log.error("getMaxDayOfMonth",e);
}
return res;
}
public static Integer getDateOfNow() {
Calendar now = Calendar.getInstance();
return now.get(Calendar.DAY_OF_MONTH);
}
/**
* 获取i年后的时间自动 -1天
* @param @param date
* @param @param i
* @param @return
* @param @throws ParseException 参数
* @return String 返回类型
* @throws
* @Title: getMonthSpace
* @Description: (获取指定日期后指定 (i 个年的时间)
*/
public static String getDateStr(Date date, int i) {
String str = "";
Calendar c1 = Calendar.getInstance();
c1.setTime(date);
c1.set(Calendar.YEAR,c1.get(Calendar.YEAR)+i);
c1.set(Calendar.DAY_OF_MONTH,c1.get(Calendar.DAY_OF_MONTH) -1);
int year = c1.get(Calendar.YEAR);
int month = c1.get(Calendar.MONTH)+1;
int day = c1.get(Calendar.DAY_OF_MONTH);
str = year +""+ (month < 10 ? "0" + month : month) + (day < 10 ? "0" + day : day);
return str;
}
/**
* 获取指定月份
* @Author fxj
* @Date 2019-10-16
* @param yearMonth 格式 :YYYYMM
* @param i
* @return
* @Description (获取指定日期后指定 ( i)个月的时间YYYYMM)
**/
public static String getYearAndMonth(String yearMonth,int i){
if (!Common.isNotNull(yearMonth) || yearMonth.length() != 6 || !Common.isNumber(yearMonth)){
return null;
}
Calendar c1 = Calendar.getInstance();
c1.set(Integer.valueOf(yearMonth.substring(0,4)),Integer.valueOf(yearMonth.substring(4,6)),1);
c1.set(Calendar.MONTH,c1.get(Calendar.MONTH) + i);
String str ="";
int year = c1.get(Calendar.YEAR);
int month = c1.get(Calendar.MONTH);
if (month == 0){
year = year -1;
month = month + 12;
str = year + (month < 10 ? "0" + month: month + "");
}else{
str = year + (month < 10 ? "0" + month : month + "");
}
return str;
}
/**
* 获取指定月份
* @Author fxj
* @Date 2019-10-16
* @param yearMonth 格式 :LocalDateTime
* @param i
* @return
* @Description (获取指定日期后指定 ( i)个月的时间YYYYMM)
**/
public static String getYearAndMonth(LocalDateTime yearMonth, int i){
String str ="";
if(yearMonth != null) {
Calendar c1 = Calendar.getInstance();
c1.set(yearMonth.getYear(),yearMonth.getMonthValue(),1);
c1.set(Calendar.MONTH,c1.get(Calendar.MONTH) + i );
int year = c1.get(Calendar.YEAR);
int month = c1.get(Calendar.MONTH);
if (month == 0){
year = year -1;
month = month + 12;
str = year + (month < 10 ? "0" + month : Integer.toString(month));
}else{
str = year + (month < 10 ? "0" + month : Integer.toString(month));
}
}
return str;
}
/**
* @param i 加减年份
* @Description: 获取当前年月,对年月加减(yyyyMM)
* @Author: hgw
* @Date: 2019/10/29 17:13
* @return: java.lang.String
**/
public static String getYearMonthByAddYear(int i){
Calendar c1 = Calendar.getInstance();
c1.set(Calendar.YEAR,c1.get(Calendar.YEAR) + i);
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
return sdf.format(c1.getTime());
}
/**
* 获取第一天
* @Author fxj
* @Date 2019-10-16
* @param yearMonth YYYYMM
* @return
**/
public static Date getFirstDay(String yearMonth){
if (!Common.isNotNull(yearMonth) || yearMonth.length() != 6 || !Common.isNumber(yearMonth)){
return null;
}
Calendar c1 = Calendar.getInstance();
c1.set(Integer.valueOf(yearMonth.substring(0,4)),Integer.valueOf(yearMonth.substring(4,6))-1,1);
return c1.getTime();
}
/**
* 获取第一天
* @Author fxj
* @Date 2019-10-16
* @param yearMonth YYYYMM
* @return
**/
public static String getFirstDayString(String yearMonth){
return yearMonth.substring(0,4)+"-"+yearMonth.substring(4,6)+"-01";
}
/**
* 当月第一天
* @Author fxj
* @Date 2021-01-05
* @param
* @return
* @see com.yifu.cloud.v1.common.core.util
**/
public static LocalDateTime getFirstDay(){
return LocalDateTime.now().with(TemporalAdjusters.firstDayOfMonth());
}
/**
* 获取最后一天
* @Author fxj
* @Date 2019-10-16
* @param yearMonth YYYYMM
* @return
**/
public static Date getLastDay(String yearMonth){
if (!Common.isNotNull(yearMonth) || yearMonth.length() != 6 || !Common.isNumber(yearMonth)){
return null;
}
Calendar c1 = Calendar.getInstance();
c1.set(Integer.valueOf(yearMonth.substring(0,4)),Integer.valueOf(yearMonth.substring(4,6))-1,c1.getActualMaximum(Calendar.DAY_OF_MONTH));
return c1.getTime();
}
/**
* 根据指定的格式将字符串转换成Date 如输入:2003-11-19 11:20:20将按照这个转成时间
*
* @param src 将要转换的原始字符窜
* @param pattern 转换的匹配格式
* @return 如果转换成功则返回转换后的日期
* @throws ParseException
*/
public static Date parseDate(String src, String pattern) throws ParseException {
return getSDFormat(pattern).parse(src);
}
// 指定模式的时间格式
private static SimpleDateFormat getSDFormat(String pattern) {
return new SimpleDateFormat(pattern);
}
/**
* 指定日期的默认显示,具体格式:年-月-日
*
* @param date 指定的日期
* @return 指定日期按“年-月-日“格式显示
*/
public static String formatDate(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat(ISO_EXPANDED_DATE_FORMAT);
return sdf.format(date);
}
/**
* @param mnt 增减月份的 值
* @param yearMonth 202101
* @Description: 增减月份
* @Author: hgw
* @Date: 2019/9/17 10:15
* @return: java.lang.String
**/
public static String addMonthByYearMonth(int mnt, String yearMonth) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.valueOf(yearMonth.substring(0,4)),Integer.valueOf(yearMonth.substring(4,6))-1,1);
cal.add(Calendar.MONTH, mnt);
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
return sdf.format(cal.getTime());
}
/**
* @param mnt 增减月份的 值
* @param yearToMonth 2021-01
* @Description: 增减月份
* @Author: hgw
* @Date: 2019/9/17 10:15
* @return: java.lang.String
**/
public static String addMonthByYearToMonth(int mnt, String yearToMonth) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(yearToMonth.substring(0,4)),Integer.parseInt(yearToMonth.substring(5,7))-1,1);
cal.add(Calendar.MONTH, mnt);
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYY_MM);
return sdf.format(cal.getTime());
}
/**
* @param yearToMonth 2021-01
* @Description: 比较年月大小
* @Author: hgw
* @Date: 2021/4/27 14:55
* @return: boolean
**/
public static int paseYearToMonth(String yearToMonth) {
return Integer.parseInt(yearToMonth.substring(0,4) + yearToMonth.substring(5,7));
}
/**
* @param mnt 增减月份的 值
* @Description: 增减月份
* @Author: hgw
* @Date: 2019/9/17 10:15
* @return: java.lang.String
**/
public static String addMonth(int mnt) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, mnt);
SimpleDateFormat sdf = new SimpleDateFormat(DATETIME_YYYYMM);
return sdf.format(cal.getTime());
}
/**
* @param mnt 增减日的 值
* @Description: 增减日
* @Author: hgw
* @Date: 2021-7-15 11:36:23
* @return: java.lang.String
**/
public static String addDay(int mnt) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, mnt);
SimpleDateFormat sdf = new SimpleDateFormat(ISO_EXPANDED_DATE_FORMAT);
return sdf.format(cal.getTime());
}
/**
* @param taxYearMonth 计税月
* @Description: 根据计税年月返回个税扣除额
* @Author: hgw
* @Date: 2019/9/19 16:02
* @return: double
**/
public static BigDecimal getTaxMonthMoney(String taxYearMonth) {
try {
int taxYear = Integer.parseInt(taxYearMonth.substring(0, 4));
int taxMonth = Integer.parseInt(taxYearMonth.substring(4, 6));
int nowYear = Integer.parseInt(DateFormatUtils.format(new Date(), "yyyy"));
int nowMonth = Integer.parseInt(DateFormatUtils.format(new Date(), "MM"));
// 同一个计税年
if (nowYear - taxYear == 0) {
return new BigDecimal((nowMonth - taxMonth + 1) * 5000);
// 前一个计税年
} else if (nowYear - taxYear > 0) {
// 禅道461:王成说的。
return new BigDecimal((nowMonth) * 5000);
} else {
// 比当前年还大
return new BigDecimal(0);
}
} catch (Exception e) {
log.error("getTaxMonthMoney",e);
}
return new BigDecimal(0);
}
/**
* <p>Description: 返回最大值月份</p>
* @author hgw
* @Date 2019年4月29日下午6:52:41
* @param taxMonth
* @return
*/
/**
* @param taxMonth
* @Description: 返回起始计税月(例如:计税月是今年之前的,则取值今年1月,否则=计税月)
* @Author: hgw
* @Date: 2019/9/30 18:16
* @return: java.lang.String
**/
public static String getMaxYearMonth(String taxMonth) {
if (Common.isNotNull(taxMonth) && taxMonth.length() >= 6) {
taxMonth = taxMonth.substring(0, 6);
String nowYearMonth = getCurrentDateString("yyyy") + "01";
int nowYearMonthInt = Integer.parseInt(nowYearMonth);
if (Integer.parseInt(taxMonth) > nowYearMonthInt) {
return taxMonth;
} else {
return nowYearMonth;
}
}
return null;
}
/**
* <p>Description: 返回年月</p>
* @author hgw
* @Date 2019年5月16日下午6:39:02
* @param currentMonth
* @return
*/
public static String getYearMonth(String currentMonth) {
if (Common.isNotNull(currentMonth) && currentMonth.length() > 5) {
if (currentMonth.indexOf('-') >= 0) {
currentMonth = currentMonth.replace("-", "");
}
return currentMonth.substring(0,4) + currentMonth.substring(4,6);
}
return null;
}
/**
*
* @Author fxj
* @Date 2019-11-20
* @param backMonths 补缴月份数
* @param haveThisMonth 0是1否 补缴是否含当月 含当月 补缴月份数 -1 不含当月补缴月数不变
* @param isBack 0是1否 是否补缴 不补缴默认从当前月开始 至次月
* @return
**/
public static List<String> getMonthsForSocialAndFund(int isBack,int backMonths,int haveThisMonth){
List<String> months = new ArrayList<>();
int count = 0;
//补缴
if (isBack==0){
//含当月
if (haveThisMonth == 0){
count = backMonths-1;
//不含当月
}else if (haveThisMonth == 1){
count = backMonths;
}
}
LocalDateTime now = LocalDateTime.now();
while (count >= 0){
months.add(getYearAndMonth(now,-count));
count--;
}
months.add(getYearAndMonth(now,1));
return months;
}
/**
* @param cur
* @param to
* @Description: 比较月份大小
* @Author: hgw
* @Date: 2019/11/25 18:18
* @return: int
**/
public static int compareMonth(LocalDateTime cur, LocalDateTime to) {
return (cur.getYear() - to.getYear()) * 12 + (cur.getMonthValue() - to.getMonthValue());
}
/**
* @param a 第一个年月
* @param b 第二个年月
* @Description: 比较a和b的大小,a大,则返回true;
* @Author: hgw
* @Date: 2020/10/16 15:44
* @return: boolean
**/
public static boolean compareYearMonth(String a, String b) {
try {
if (a != null && b != null && !"".equals(a) && !"".equals(b) && a.length() == 6 && b.length() == 6) {
int aInt = Integer.parseInt(a.substring(0, 4));
int bInt = Integer.parseInt(b.substring(0, 4));
if (aInt > bInt) {
return true;
} else if (aInt < bInt) {
return false;
} else {
aInt = Integer.parseInt(a.substring(4, 6));
bInt = Integer.parseInt(b.substring(4, 6));
return aInt > bInt;
}
}
return true;
} catch (NumberFormatException e) {
return true;
}
}
/**
* @param
* @Author: wangan
* @Date: 2020/12/21
* @Description: 获取这个月
* @return: java.lang.String
* @see com.yifu.cloud.v1.common.core.util
**/
public static String getThisMonth(){
SimpleDateFormat sf = new SimpleDateFormat(DateUtil.DATETIME_YYYYMM);
Date nowDate = new Date();
String thisMonth = sf.format(nowDate);
return thisMonth;
}
/**
* @param
* @Author: wangan
* @Date: 2020/12/21
* @Description: 获取上个月
* @return: java.lang.String
* @see com.yifu.cloud.v1.common.core.util
**/
public static String getLastMonth(){
SimpleDateFormat sf = new SimpleDateFormat(DateUtil.DATETIME_YYYYMM);
Date nowDate = new Date();
Calendar instance = Calendar.getInstance();
instance.setTime(nowDate);
instance.add(Calendar.MONTH, -1);
String lastMonth = sf.format(instance.getTime());
return lastMonth;
}
/**
* @param
* @Author: wangan
* @Date: 2020/12/21
* @Description: 获取上n个月
* @return: java.lang.String
* @see com.yifu.cloud.v1.common.core.util
**/
public static String getLastXMonth(int month){
SimpleDateFormat sf = new SimpleDateFormat(DateUtil.DATETIME_YYYYMM);
Date nowDate = new Date();
Calendar instance = Calendar.getInstance();
instance.setTime(nowDate);
instance.add(Calendar.MONTH, month);
return sf.format(instance.getTime());
}
/**
* @param yearMonth 年月(例:202201)
* @param month 增减数值(例:1,或 -1)
* @Description: String年月,根据month增减,大多数为了获取下月或上月使用
* @Author: hgw
* @Date: 2022/3/31 20:43
* @return: java.lang.String
**/
public static String addMonthByString(String yearMonth, int month) {
if (Common.isNotNull(yearMonth)) {
try {
SimpleDateFormat sf = new SimpleDateFormat(DateUtil.DATETIME_YYYYMM);
Date d1 = sf.parse(yearMonth);
Calendar instance = Calendar.getInstance();
instance.setTime(d1);
instance.add(Calendar.MONTH, month);
return sf.format(instance.getTime());
} catch (ParseException e) {
return null;
}
} else {
return null;
}
}
}
/**
* Copyright © 2017yifu. All rights reserved.
*
* @Title: MonthObject.java
* @Prject: worfuplus
* @Package: com.worfu.web.bo
* @Description: TODO
* @author: Administrator
* @date: 2017年8月22日 上午9:51:33
* @version: V1.0
*/
/**
* @Title: MonthObject.java
* @Package com.worfu.web.bo
* @Description: TODO(用一句话描述该文件做什么)
* @author fang
* @date 2017年8月22日
* @version V1.0
*/
package com.yifu.cloud.plus.v1.yifu.common.core.util.sms;
/**
*
* @author: fang 前台繳納月份实体
* @createDate: 2017年8月22日 上午9:51:33
*/
/**
* @ClassName: MonthObject
* @Description: TODO(这里用一句话描述这个类的作用)
* @author fang
* @date 2017年8月22日
*
*/
public class MonthObject {
private String month;
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
}
\ No newline at end of file
......@@ -173,7 +173,7 @@ public class SysDataAuthServiceImpl extends ServiceImpl<SysDataAuthMapper, SysDa
List<SysDataAuthMenuRel> menuSettleList = sysDataAuthVO.getMenuSettleList();
List<SysDataAuthMenuRel> menuDeptList = sysDataAuthVO.getMenuDeptList();
// 存储sql的map,用作缓存 键:linkId + CommonConstants.DOWN_LINE + menu.getMenuId()
// 存储sql的map,用作缓存 键:linkId + CommonConstants.DOWN_LINE_STRING + menu.getMenuId()
Map<String, String> authSqlMap = new HashMap<>();
StringBuilder sql = new StringBuilder();
String mapSql;
......@@ -196,7 +196,7 @@ public class SysDataAuthServiceImpl extends ServiceImpl<SysDataAuthMapper, SysDa
sql.append(" or dept.dept_id = #deptId ");
}
for (SysDataAuthMenuRel menu : menuDeptList) {
authSqlMap.put(linkId + CommonConstants.DOWN_LINE + menu.getMenuId(), sql.toString());
authSqlMap.put(linkId + CommonConstants.DOWN_LINE_STRING + menu.getMenuId(), sql.toString());
menu.setSysDataAuthId(mainId);
menu.setType(3);
}
......@@ -208,13 +208,13 @@ public class SysDataAuthServiceImpl extends ServiceImpl<SysDataAuthMapper, SysDa
nowSql = " or a.create_by = #create_by ";
sysDataAuth.setIsCreateAuth(1);
for (SysDataAuthMenuRel menu : menuCreateList) {
mapSql = authSqlMap.get(linkId + CommonConstants.DOWN_LINE + menu.getMenuId());
mapSql = authSqlMap.get(linkId + CommonConstants.DOWN_LINE_STRING + menu.getMenuId());
if (!Common.isEmpty(mapSql)) {
nowMapSql = new StringBuilder(nowSql).append(mapSql);
} else {
nowMapSql = new StringBuilder(nowSql);
}
authSqlMap.put(linkId + CommonConstants.DOWN_LINE + menu.getMenuId(), nowMapSql.toString());
authSqlMap.put(linkId + CommonConstants.DOWN_LINE_STRING + menu.getMenuId(), nowMapSql.toString());
menu.setType(1);
menu.setSysDataAuthId(mainId);
}
......@@ -226,13 +226,13 @@ public class SysDataAuthServiceImpl extends ServiceImpl<SysDataAuthMapper, SysDa
nowSql = " or a.settleDomainId in ('0'#settleDomainId) ";
sysDataAuth.setIsSettleAuth(1);
for (SysDataAuthMenuRel menu : menuSettleList) {
mapSql = authSqlMap.get(linkId + CommonConstants.DOWN_LINE + menu.getMenuId());
mapSql = authSqlMap.get(linkId + CommonConstants.DOWN_LINE_STRING + menu.getMenuId());
if (!Common.isEmpty(mapSql)) {
nowMapSql = new StringBuilder(nowSql).append(mapSql);
} else {
nowMapSql = new StringBuilder(nowSql);
}
authSqlMap.put(linkId + CommonConstants.DOWN_LINE + menu.getMenuId(), nowMapSql.toString());
authSqlMap.put(linkId + CommonConstants.DOWN_LINE_STRING + menu.getMenuId(), nowMapSql.toString());
menu.setType(2);
menu.setSysDataAuthId(mainId);
}
......@@ -250,13 +250,13 @@ public class SysDataAuthServiceImpl extends ServiceImpl<SysDataAuthMapper, SysDa
sqls.setSysDataAuthId(mainId);
diySqlService.save(sqls);
for (SysDiySqlMenuRel menuSql : menuSqlList) {
mapSql = authSqlMap.get(linkId + CommonConstants.DOWN_LINE + menuSql.getMenuId());
mapSql = authSqlMap.get(linkId + CommonConstants.DOWN_LINE_STRING + menuSql.getMenuId());
if (!Common.isEmpty(mapSql)) {
nowMapSql = new StringBuilder(nowSql).append(mapSql);
} else {
nowMapSql = new StringBuilder(nowSql);
}
authSqlMap.put(linkId + CommonConstants.DOWN_LINE + menuSql.getMenuId(), nowMapSql.toString());
authSqlMap.put(linkId + CommonConstants.DOWN_LINE_STRING + menuSql.getMenuId(), nowMapSql.toString());
menuSql.setSysDataAuthId(mainId);
menuSql.setSysDiySqlId(sqls.getId());
}
......
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