fix: 码全代码添加
This commit is contained in:
38
template/cvbp/cvbp-public/cvbp-web-api/.gitignore
vendored
Normal file
38
template/cvbp/cvbp-public/cvbp-web-api/.gitignore
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
62
template/cvbp/cvbp-public/cvbp-web-api/pom.xml
Normal file
62
template/cvbp/cvbp-public/cvbp-web-api/pom.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
-->
|
||||
|
||||
<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>
|
||||
<groupId>com.codvision</groupId>
|
||||
<artifactId>cvbp-public</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>cvbp-web-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.codvision</groupId>
|
||||
<artifactId>cvbp-common-feign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.codvision</groupId>
|
||||
<artifactId>cvbp-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-json</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.api;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.codvision.webapi.bean.RemoteOrg;
|
||||
import com.codvision.webapi.bean.RemoteSysUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户接口
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
public interface SysUserApi {
|
||||
|
||||
/**
|
||||
* 分页查询系统用户
|
||||
*
|
||||
* @param keyword 关键字
|
||||
* @param oid 组织id
|
||||
* @param roleId 角色id
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 页面大小
|
||||
* @return 系统用户信息
|
||||
*/
|
||||
IPage<RemoteSysUser> pageUserList(String keyword,
|
||||
Integer oid,
|
||||
Integer roleId,
|
||||
List<Integer> uidList,
|
||||
int pageNum,
|
||||
int pageSize);
|
||||
|
||||
/**
|
||||
* 获取所有用户列表
|
||||
*
|
||||
* @param keyword 关键字
|
||||
* @param oid 组织id
|
||||
* @param roleId 角色id
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<RemoteSysUser> getAllUserList(String keyword, Integer oid, Integer roleId);
|
||||
|
||||
/**
|
||||
* 分页查询系统组织
|
||||
*
|
||||
* @param keyword 关键字
|
||||
* @param isAll 是否全部
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 页面大小
|
||||
* @return 系统用户信息
|
||||
*/
|
||||
IPage<RemoteOrg> pageOrgList(String keyword, Boolean isAll, int pageNum, int pageSize);
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
*
|
||||
* @param sysUser 用户信息
|
||||
* @return uid
|
||||
*/
|
||||
Integer addUser(RemoteSysUser sysUser);
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户详情
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @return 用户详情
|
||||
*/
|
||||
RemoteSysUser getUserDetail(Integer uid);
|
||||
|
||||
/**
|
||||
* 根据用户名获取用户详情
|
||||
*
|
||||
* @param loginName 登录名
|
||||
* @return
|
||||
*/
|
||||
RemoteSysUser getUserDetail(String loginName);
|
||||
|
||||
/**
|
||||
* 切换用户所属组织及对应角色
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @param oid 组织id
|
||||
* @param roleCode 角色编码
|
||||
*/
|
||||
void updateUserOrgRole(Integer uid, Integer oid, String roleCode);
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.api.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.commoncore.utils.DecPwdUtil;
|
||||
import com.codvision.commoncore.utils.ResponseUtil;
|
||||
import com.codvision.webapi.api.SysUserApi;
|
||||
import com.codvision.webapi.bean.RemoteOrg;
|
||||
import com.codvision.webapi.bean.RemoteSysUser;
|
||||
import com.codvision.webapi.bean.RemoteUserOrgRole;
|
||||
import com.codvision.webapi.common.EncryptUtil;
|
||||
import com.codvision.webapi.common.ListResponseEntity;
|
||||
import com.codvision.webapi.remote.RemoteOrgService;
|
||||
import com.codvision.webapi.remote.RemoteUserService;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统用户接口实现
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
public class SysUserApiImpl implements SysUserApi {
|
||||
|
||||
@Resource
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Resource
|
||||
private RemoteOrgService remoteOrgService;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public IPage<RemoteSysUser> pageUserList(String keyword, Integer oid, Integer roleId, List<Integer> uidList, int pageNum, int pageSize) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("keyword", keyword);
|
||||
map.put("oid", oid);
|
||||
map.put("role", roleId);
|
||||
// map.put("uidList", uidList);
|
||||
map.put("page", pageNum);
|
||||
map.put("size", pageSize);
|
||||
|
||||
ListResponseEntity<RemoteSysUser> responseList;
|
||||
try {
|
||||
String encryption = EncryptUtil.encoderBody(map);
|
||||
ResponseEntity<String> response = remoteUserService.pageUserList(encryption);
|
||||
if (!ResponseUtil.isSuccess(response)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
responseList = objectMapper.readValue(EncryptUtil.decoderBody(response.getData()),
|
||||
new TypeReference<ListResponseEntity<RemoteSysUser>>() {
|
||||
});
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
IPage<RemoteSysUser> page = new Page(responseList.getPage(), responseList.getSize(), responseList.getTotal());
|
||||
page.setRecords(responseList.getList());
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RemoteSysUser> getAllUserList(String keyword, Integer oid, Integer roleId) {
|
||||
IPage<RemoteSysUser> pageResult = pageUserList(keyword, oid, roleId, null, 1, 100000);
|
||||
return pageResult.getRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<RemoteOrg> pageOrgList(String keyword, Boolean isAll, int pageNum, int pageSize) {
|
||||
ResponseEntity<ListResponseEntity<RemoteOrg>> response
|
||||
= remoteOrgService.pageOrgList(keyword, isAll, pageNum, pageSize);
|
||||
if (!ResponseUtil.isSuccess(response)) {
|
||||
return null;
|
||||
}
|
||||
ListResponseEntity<RemoteOrg> responseList = response.getData();
|
||||
IPage<RemoteOrg> page = new Page(responseList.getPage(), responseList.getSize(), responseList.getTotal());
|
||||
page.setRecords(responseList.getList());
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addUser(RemoteSysUser sysUser) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
sysUser.setPassword(DecPwdUtil.encryptAes(sysUser.getPassword()));
|
||||
map.put("encryption", EncryptUtil.encoderBody(sysUser));
|
||||
|
||||
ResponseEntity<String> response = remoteUserService.add(map);
|
||||
if (!ResponseUtil.isSuccess(response)) {
|
||||
throw new BusinessException(response.getMessage());
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(objectMapper.readValue(EncryptUtil.decoderBody(response.getData()), String.class));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteSysUser getUserDetail(Integer uid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("uid", uid);
|
||||
|
||||
try {
|
||||
String encryption = EncryptUtil.encoderBody(map);
|
||||
ResponseEntity<String> response = remoteUserService.getByUid(encryption);
|
||||
if (!ResponseUtil.isSuccess(response)) {
|
||||
return null;
|
||||
}
|
||||
RemoteSysUser sysUser = objectMapper.readValue(EncryptUtil.decoderBody(response.getData()), RemoteSysUser.class);
|
||||
return sysUser;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteSysUser getUserDetail(String loginName) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("loginName", loginName);
|
||||
|
||||
try {
|
||||
String encryption = EncryptUtil.encoderBody(map);
|
||||
ResponseEntity<String> response = remoteUserService.getByLoginName(encryption);
|
||||
if (!ResponseUtil.isSuccess(response)) {
|
||||
return null;
|
||||
}
|
||||
RemoteSysUser sysUser = objectMapper.readValue(EncryptUtil.decoderBody(response.getData()), RemoteSysUser.class);
|
||||
return sysUser;
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserOrgRole(Integer uid, Integer oid, String roleCode) {
|
||||
RemoteUserOrgRole userOrgRole = new RemoteUserOrgRole(uid, oid, null, roleCode);
|
||||
RemoteSysUser sysUser = new RemoteSysUser();
|
||||
sysUser.setId(uid);
|
||||
sysUser.setUserOrgRoles(Arrays.asList(userOrgRole));
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("encryption", EncryptUtil.encoderBody(sysUser));
|
||||
|
||||
ResponseEntity<String> response = remoteUserService.update(map);
|
||||
if (!ResponseUtil.isSuccessNotData(response)) {
|
||||
throw new BusinessException(response.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.codvision.webapi.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统组织
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "RemoteOrg", description = "系统组织")
|
||||
public class RemoteOrg implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8195853779944467097L;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private Integer oid;
|
||||
|
||||
@ApiModelProperty("组织名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("组织全称")
|
||||
private String fullname;
|
||||
|
||||
@ApiModelProperty("组织类型")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("组织等级")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty("父组织OID")
|
||||
private Integer poid;
|
||||
|
||||
@ApiModelProperty("wkt边界数据")
|
||||
private String wkt;
|
||||
|
||||
@ApiModelProperty("排序字段")
|
||||
private Integer orderby;
|
||||
|
||||
@ApiModelProperty("oid路径")
|
||||
private String oidPath;
|
||||
|
||||
@ApiModelProperty("组织名称路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("组织属性id")
|
||||
private Integer orgPropertyId;
|
||||
|
||||
@ApiModelProperty("专有钉钉部门code")
|
||||
private String zzdOrgCode;
|
||||
|
||||
@ApiModelProperty("行政区划编码")
|
||||
private String districtCode;
|
||||
|
||||
@ApiModelProperty("部门所属的行政区划OID")
|
||||
private Integer districtOid;
|
||||
|
||||
@ApiModelProperty("第三方数据ID")
|
||||
private String refOid;
|
||||
|
||||
@ApiModelProperty("第三方数据编码")
|
||||
private String refCode;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("逻辑删除辅助字段")
|
||||
private Integer delKey;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty(value = "属性名称")
|
||||
private String orgPropertyName;
|
||||
|
||||
@ApiModelProperty(value = "属性图标")
|
||||
private String orgPropertyIcon;
|
||||
|
||||
@ApiModelProperty(value = "行政区划编码长度")
|
||||
private Integer codeLength;
|
||||
|
||||
@ApiModelProperty("子部门")
|
||||
private List<RemoteOrg> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lingee
|
||||
* @date 2023/9/14
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "RemotePayNotify", description = "支付通知实体")
|
||||
public class RemotePayNotify implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2161707957116401928L;
|
||||
|
||||
@ApiModelProperty("签名")
|
||||
private String sign;
|
||||
|
||||
@ApiModelProperty("随机值")
|
||||
private String nonce;
|
||||
|
||||
@ApiModelProperty("商户号")
|
||||
private String mid;
|
||||
|
||||
@ApiModelProperty("终端号")
|
||||
private String tid;
|
||||
|
||||
@ApiModelProperty("业务类型 MINIDEFAULT")
|
||||
private String instMid;
|
||||
|
||||
@ApiModelProperty("商户订单号")
|
||||
private String merOrderId;
|
||||
|
||||
@ApiModelProperty("系统交易流水号")
|
||||
private String seqId;
|
||||
|
||||
@ApiModelProperty("订单状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("渠道订单号")
|
||||
private String targetOrderId;
|
||||
|
||||
@ApiModelProperty("支付渠道")
|
||||
private String targetSys;
|
||||
|
||||
@ApiModelProperty("订单详情")
|
||||
private String orderDesc;
|
||||
|
||||
@ApiModelProperty("订单创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty("买家ID")
|
||||
private String buyerId;
|
||||
|
||||
@ApiModelProperty("买家用户名")
|
||||
private String buyerUsername;
|
||||
|
||||
@ApiModelProperty("实付金额")
|
||||
private String buyerPayAmount;
|
||||
|
||||
@ApiModelProperty("订单金额")
|
||||
private String totalAmount;
|
||||
|
||||
@ApiModelProperty("开票金额")
|
||||
private String invoiceAmount;
|
||||
|
||||
@ApiModelProperty("实收金额")
|
||||
private String receiptAmount;
|
||||
|
||||
@ApiModelProperty("支付银行信息")
|
||||
private String bankCardNo;
|
||||
|
||||
@ApiModelProperty("支付渠道")
|
||||
private String billFunds;
|
||||
|
||||
@ApiModelProperty("支付渠道说明")
|
||||
private String billFundsDesc;
|
||||
|
||||
@ApiModelProperty("支付时间 格式yyyy-MM-dd HH:mm:ss")
|
||||
private String payTime;
|
||||
|
||||
@ApiModelProperty("支付银行卡参考号")
|
||||
private String refId;
|
||||
|
||||
@ApiModelProperty("结算日期 格式yyyy-MM-dd")
|
||||
private String settleDate;
|
||||
|
||||
@ApiModelProperty("商品交易单号")
|
||||
private String goodsTradeNo;
|
||||
|
||||
@ApiModelProperty("转接系统")
|
||||
private String connectSys;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 退款通知信息
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/8/11
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "PayRefundNotifyEntity", description = "退款通知信息")
|
||||
public class RemotePayRefundNotify extends RemotePayNotify implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -501809152297797274L;
|
||||
|
||||
@ApiModelProperty("退款金额")
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
@ApiModelProperty("退款说明")
|
||||
private String refundDesc;
|
||||
|
||||
@ApiModelProperty("退货订单号")
|
||||
private String refundOrderId;
|
||||
|
||||
@ApiModelProperty("退货外部订单号")
|
||||
private String refundExtOrderId;
|
||||
|
||||
@ApiModelProperty("退货渠道订单号")
|
||||
private String refundTargetOrderId;
|
||||
|
||||
@ApiModelProperty("退货时间")
|
||||
private String refundPayTime;
|
||||
|
||||
@ApiModelProperty("退货结算日期")
|
||||
private String refundSettleDate;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统用户
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "RemoteSysUser", description = "系统用户")
|
||||
public class RemoteSysUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7611598993628040722L;
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private Integer appUserOid;
|
||||
|
||||
@ApiModelProperty("登陆名")
|
||||
private String loginName;
|
||||
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty("用户真实姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("用户联系方式")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("拓展字段:头像")
|
||||
private String avatarUrl;
|
||||
|
||||
@ApiModelProperty("拓展字段:昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty("拓展字段:邮箱")
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty("浙政钉ID")
|
||||
private String zzdId;
|
||||
|
||||
@ApiModelProperty("普通钉钉userid")
|
||||
private String dingTalkUid;
|
||||
|
||||
@ApiModelProperty("微信服务号openId")
|
||||
private String wxMpOpenid;
|
||||
|
||||
@ApiModelProperty("微信小程序openId")
|
||||
private String wxMaOpenid;
|
||||
|
||||
@ApiModelProperty("微信unionId")
|
||||
private String wxUnionid;
|
||||
|
||||
@ApiModelProperty("删除标记,1:已删除,0:正常")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private String updateTime;
|
||||
|
||||
@ApiModelProperty("用户组织角色")
|
||||
private List<RemoteUserOrgRole> userOrgRoles;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用户组织角色
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/8/17
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "RemoteUserOrgRole", description = "用户组织角色")
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RemoteUserOrgRole implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3666579483846280443L;
|
||||
|
||||
@ApiModelProperty("用户UID")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty("组织OID")
|
||||
private Integer oid;
|
||||
|
||||
@ApiModelProperty("角色ID")
|
||||
private Integer roleId;
|
||||
|
||||
@ApiModelProperty("角色编码")
|
||||
private String roleCode;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.common;
|
||||
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webapi.config.EncryptProperties;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
/**
|
||||
* 加密工具类
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/8/3
|
||||
*/
|
||||
@Slf4j
|
||||
public class EncryptUtil {
|
||||
|
||||
public static String encoderBody(Object data) {
|
||||
EncryptProperties encryptProperties = SpringUtil.getBean(EncryptProperties.class);
|
||||
ObjectMapper objectMapper = SpringUtil.getBean(ObjectMapper.class);
|
||||
|
||||
try {
|
||||
byte[] bytes = objectMapper.writeValueAsBytes(data);
|
||||
|
||||
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, new SecretKeySpec(encryptProperties.getSecretKey().getBytes(), "AES"),
|
||||
new IvParameterSpec(encryptProperties.getSecretKey().getBytes()));
|
||||
return aes.encryptBase64(bytes);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new BusinessException(30001, "远程调用接口加密失败");
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] decoderBody(String bodyString) {
|
||||
EncryptProperties encryptProperties = SpringUtil.getBean(EncryptProperties.class);
|
||||
|
||||
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, new SecretKeySpec(encryptProperties.getSecretKey().getBytes(), "AES"),
|
||||
new IvParameterSpec(encryptProperties.getSecretKey().getBytes()));
|
||||
|
||||
byte[] decryptedBody;
|
||||
try {
|
||||
decryptedBody = aes.decrypt(bodyString);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new BusinessException(30001, "远程调用接口解密失败");
|
||||
}
|
||||
return decryptedBody;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.codvision.webapi.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 分页结果
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ListResponseEntity<T> {
|
||||
|
||||
private int total = 0;
|
||||
|
||||
private int page = 1;
|
||||
|
||||
private int size = 20;
|
||||
|
||||
private List<T> list;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.common;
|
||||
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 请求工具类
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/8/2
|
||||
*/
|
||||
public class RequestUtil {
|
||||
|
||||
/**
|
||||
* 获取请求
|
||||
*
|
||||
* @return servlet请求
|
||||
*/
|
||||
public static HttpServletRequest getRequest() {
|
||||
RequestAttributes attrs = RequestContextHolder.getRequestAttributes();
|
||||
if (attrs == null) {
|
||||
return null;
|
||||
}
|
||||
final ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) attrs;
|
||||
return servletRequestAttributes.getRequest();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 加密配置
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/8/2
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties("cvbp.encrypt")
|
||||
public class EncryptProperties {
|
||||
|
||||
/**
|
||||
* 加密密钥
|
||||
*/
|
||||
private String secretKey = "ms1sn1r3r7tb7wr9";
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.config;
|
||||
|
||||
import com.codvision.webapi.api.SysUserApi;
|
||||
import com.codvision.webapi.api.impl.SysUserApiImpl;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 远程调用配置
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
@Configuration
|
||||
public class WebApiConfig {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SysUserApi sysUserApi() {
|
||||
return new SysUserApiImpl();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 应用属性配置
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/25
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties("cvbp.api")
|
||||
public class WebApiProperties {
|
||||
|
||||
/**
|
||||
* 认证中心服务地址
|
||||
*/
|
||||
public String authUrl = "";
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 远程调用模块
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
package com.codvision.webapi;
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.remote;
|
||||
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commonfeign.config.OpenFeignConfig;
|
||||
import com.codvision.webapi.bean.RemoteOrg;
|
||||
import com.codvision.webapi.common.ListResponseEntity;
|
||||
import com.codvision.webapi.remote.interceptor.BaseRequestInterceptor;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 组织远程调用
|
||||
* @author lingee
|
||||
* @date 2023/8/17
|
||||
*/
|
||||
@FeignClient(name = "remote-org-sevice", url = "${cvbp.auth.host}", configuration = {OpenFeignConfig.class, BaseRequestInterceptor.class})
|
||||
public interface RemoteOrgService {
|
||||
|
||||
/**
|
||||
* 获取组织列表
|
||||
*
|
||||
* @param keyword 关键字
|
||||
* @param isAll 是否全部
|
||||
* @param page 当前页
|
||||
* @param size 页面大小
|
||||
* @return 组织分页结果
|
||||
*/
|
||||
@PostMapping("/org/all")
|
||||
ResponseEntity<ListResponseEntity<RemoteOrg>> pageOrgList(@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "isAll", required = false, defaultValue = "false") Boolean isAll,
|
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
|
||||
@RequestParam(value = "size", required = false, defaultValue = "10") int size);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.remote;
|
||||
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commonfeign.config.OpenFeignConfig;
|
||||
import com.codvision.webapi.remote.interceptor.BaseRequestInterceptor;
|
||||
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.RequestParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户远程服务
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/7/27
|
||||
*/
|
||||
@FeignClient(name = "remote-user-sevice", url = "${cvbp.auth.host}/sysUser", configuration = {OpenFeignConfig.class, BaseRequestInterceptor.class})
|
||||
public interface RemoteUserService {
|
||||
|
||||
/**
|
||||
* 获取用户信息列表
|
||||
*
|
||||
* @param encryption 加密查询条件
|
||||
* @return 用户结果
|
||||
*/
|
||||
@PostMapping(value = "/findAll")
|
||||
ResponseEntity<String> pageUserList(@RequestParam(value = "encryption") String encryption);
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
*
|
||||
* @param remoteSysUser 用户信息
|
||||
* @return 添加结果
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
ResponseEntity<String> add(@RequestBody Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*
|
||||
* @param params 用户信息
|
||||
* @return 更新结果
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
ResponseEntity<String> update(@RequestBody Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户信息
|
||||
*
|
||||
* @param encryption 加密后的用户id
|
||||
* @return 被加密的用户信息
|
||||
*/
|
||||
@PostMapping(value = "/detail")
|
||||
ResponseEntity<String> getByUid(@RequestParam(value = "encryption") String encryption);
|
||||
|
||||
/**
|
||||
* 根据登录名获取用户信息
|
||||
*
|
||||
* @param encryption 加密后的登录名
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/detailByName")
|
||||
ResponseEntity<String> getByLoginName(@RequestParam(value = "encryption") String encryption);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.remote.decoder;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.codvision.commoncore.common.ResponseEntity;
|
||||
import com.codvision.commoncore.exception.BusinessException;
|
||||
import com.codvision.webapi.config.EncryptProperties;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import feign.FeignException;
|
||||
import feign.Response;
|
||||
import feign.Util;
|
||||
import feign.codec.DecodeException;
|
||||
import feign.codec.Decoder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* 解密配置
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/8/2
|
||||
*/
|
||||
@Slf4j
|
||||
public class BaseResponseDecoder implements Decoder {
|
||||
|
||||
@Override
|
||||
public Object decode(Response response, Type type) throws IOException, DecodeException, FeignException {
|
||||
Response.Body body = response.body();
|
||||
if (response.status() == HttpStatus.NOT_FOUND.value() || response.status() == HttpStatus.NO_CONTENT.value()) {
|
||||
return Util.emptyValueOf(type);
|
||||
}
|
||||
if (body == null) {
|
||||
return null;
|
||||
}
|
||||
if (byte[].class.equals(type)) {
|
||||
return Util.toByteArray(body.asInputStream());
|
||||
}
|
||||
if (StrUtil.contains(type.getTypeName(), "com.codvision.commoncore.common.ResponseEntity")) {
|
||||
String bodyString = Util.toString(body.asReader(Util.UTF_8));
|
||||
// 解密
|
||||
return decryptResponse(bodyString, type);
|
||||
}
|
||||
throw new DecodeException(response.status(),
|
||||
String.format("%s is not a type supported by this decoder.", type), response.request());
|
||||
}
|
||||
|
||||
private Object decryptResponse(String bodyString, Type type) throws IOException {
|
||||
EncryptProperties encryptProperties = SpringUtil.getBean(EncryptProperties.class);
|
||||
ObjectMapper objectMapper = SpringUtil.getBean(ObjectMapper.class);
|
||||
|
||||
ResponseEntity<String> responseEntity = JSONUtil.toBean(bodyString, ResponseEntity.class);
|
||||
|
||||
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, new SecretKeySpec(encryptProperties.getSecretKey().getBytes(), "AES"),
|
||||
new IvParameterSpec(encryptProperties.getSecretKey().getBytes()));
|
||||
|
||||
byte[] decryptedBody;
|
||||
try {
|
||||
decryptedBody = aes.decrypt(StrUtil.str(responseEntity.getData(), Charset.defaultCharset()));
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
throw new BusinessException(30001, "请检查encryption参数值是否已加密传输");
|
||||
}
|
||||
|
||||
return objectMapper.readValue(decryptedBody, type.getClass());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2023 codvision.com All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.codvision.webapi.remote.interceptor;
|
||||
|
||||
import com.codvision.webapi.common.RequestUtil;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 基础请求拦截
|
||||
*
|
||||
* @author lingee
|
||||
* @date 2023/8/2
|
||||
*/
|
||||
@Slf4j
|
||||
public class BaseRequestInterceptor implements RequestInterceptor {
|
||||
|
||||
/**
|
||||
* Authorization方式认证
|
||||
*/
|
||||
private static final String HEADER_AUTHORIZATION = "Authorization";
|
||||
|
||||
@Override
|
||||
public void apply(RequestTemplate requestTemplate) {
|
||||
log.info("请求路径为:{}", requestTemplate.path());
|
||||
|
||||
HttpServletRequest request = Objects.requireNonNull(RequestUtil.getRequest());
|
||||
|
||||
String token = request.getHeader(HEADER_AUTHORIZATION);
|
||||
log.info("Authorization值为:{}", token);
|
||||
|
||||
requestTemplate.header(HEADER_AUTHORIZATION, token);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.codvision.webapi.config.WebApiConfig,\
|
||||
com.codvision.webapi.config.WebApiProperties,com.codvision.webapi.config.EncryptProperties
|
||||
Reference in New Issue
Block a user