提交 ee0e36b3 作者: 余乾开

Merge branch 'release/0518-2040'

name: Build and Push to ACR
on:
push:
branches: [ "develop" ]
env:
REGION_ID: cn-shenzhen
REGISTRY: mmc-registry.cn-shenzhen.cr.aliyuncs.com
NAMESPACE: sharefly
IMAGE: cms
TAG: ${{ github.sha }}
ACR_EE_REGISTRY: mmc-registry.cn-shenzhen.cr.aliyuncs.com
ACR_EE_INSTANCE_ID: cri-yhk5zgfc2v1sia6l
ACR_EE_NAMESPACE: sharefly
ACR_EE_IMAGE: cms
ACR_EE_TAG: ${{ github.sha }}
JAVA_VERSION: '8'
GITLAB_URL: https://oauth2:MjVJKxB7m4tCy7symBzn@git.mmcuav.cn/iuav/cms.git
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: ${{env.JAVA_VERSION}}
- name: Login to ACR EE with the AccessKey pair
uses: aliyun/acr-login@v1
with:
login-server: "https://${{ env.ACR_EE_REGISTRY }}"
region-id: "${{ env.REGION_ID }}"
username: "QD--KeBiTeHangKong@1354706964800968"
password: "MMC@2023&ACR"
instance-id: "${{ env.ACR_EE_INSTANCE_ID }}"
- name: Build and push image to ACR EE
run: |
mvn clean package
docker build -t "$ACR_EE_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG" .
docker push "$ACR_EE_REGISTRY/$ACR_EE_NAMESPACE/$ACR_EE_IMAGE:$TAG"
- name: Kustomize Set Image
run: |-
cd kustomization/overlays/dev
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash /dev/stdin 3.8.6
./kustomize edit set image REGISTRY/NAMESPACE/IMAGE:TAG=$REGISTRY/$NAMESPACE/$IMAGE:$TAG
- name: Commit and Push
run: |
git config user.name "Chuck"
git config user.email "Chuck@users.noreply.github.com"
git remote set-url origin "$GITLAB_URL"
git commit -am "generated Image update"
git push origin develop
\ No newline at end of file
# Created by .ignore support plugin (hsz.mobi)
target
*.class
.project
.classpath
.prefs
.settings
.idea
*.iml
*/application.yml
FROM openjdk:8-jdk-alpine
#VOLUME ["/tmp","/files","/var/logs/"]
ARG JAVA_OPTS
ENV JAVA_OPTS=$JAVA_OPTS
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
COPY ./csm-service/cms-service-user/target/cms-service-user-1.0-SNAPSHOT.jar cms.jar
EXPOSE 35150
# For Spring-Boot project, use the entrypoint below to reduce Tomcat startup time.
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar cms.jar
## 新云享飞-用户管理
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cms-common</artifactId>
<groupId>com.mmc.iuav.cms</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<artifactId>cms-common-model</artifactId>
<dependencies>
<!-- apache 提供的一些工具类 -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
</dependency>
<dependency>
<groupId>com.mmc.iuav.cms</groupId>
<artifactId>cms-common-util</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.mmc.iuav.user.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/18 17:28
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class UserAccountSimpleDTO implements Serializable {
private static final long serialVersionUID = 3451336520607073343L;
@ApiModelProperty(value = "用户id")
private Integer id;
@ApiModelProperty(value = "用户类型")
private Integer accountType;
@ApiModelProperty(value = "用户uid")
private String uid;
@ApiModelProperty(value = "手机号")
private String phoneNum;
@ApiModelProperty(value = "用户名称")
private String userName;
@ApiModelProperty(value = "用户昵称")
private String nickName;
@ApiModelProperty(value = "用户头像")
private String userImg;
@ApiModelProperty(value = "用户性别:0未知、1男、2女")
private Integer userSex;
@ApiModelProperty(value = "用户邮箱")
private String email;
@ApiModelProperty(value = "用户来源,0自然流、1海报、2抖音、3公众号、4社群、5招投标、6官网")
private Integer source;
@ApiModelProperty(value = "用户可用状态:0禁用、1可用")
private Integer accountStatus;
@ApiModelProperty(value = "账号类型:0后台管理账号 ; 100云享飞-客户端;")
private Integer portType;
@ApiModelProperty(value = "企业认证状态, 0未通过,1通过")
private Integer companyAuthStatus;
}
\ No newline at end of file
package com.mmc.iuav.user.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/16 15:17
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AppUserSucVO implements Serializable {
private static final long serialVersionUID = 7491711282161485720L;
@ApiModelProperty(value = "用户id")
private Integer userAccountId;
@ApiModelProperty(value = "token")
private String token;
}
package com.mmc.iuav.user.model.vo;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/17 13:42
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CompanyAuthVO implements Serializable {
private static final long serialVersionUID = 3584743219477515646L;
@ApiModelProperty(value = "id")
@NotNull(message = "id创建修改不能为空", groups = { Update.class })
private Integer id;
@ApiModelProperty(value = "用户id")
@NotNull(message = "用户id不能为空", groups = { Insert.class, Update.class})
private Integer userAccountId;
@ApiModelProperty(value = "企业名称")
@NotBlank(message = "企业名称", groups = { Insert.class, Update.class})
private String companyName;
@ApiModelProperty(value = "统一社会信用代码")
@NotBlank(message = "统一社会信用代码", groups = { Insert.class, Update.class})
private String creditCode;
@ApiModelProperty(value = "营业执照")
@NotBlank(message = "营业执照", groups = { Insert.class, Update.class })
private String licenseImg;
@ApiModelProperty(value = "企业认证状态,0未通过,1已通过")
private Integer authStatus;
}
package com.mmc.iuav.user.model.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/17 21:27
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CooperationTagVO implements Serializable {
private static final long serialVersionUID = 8884567706797525506L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "合作标签名称")
private String tagName;
@ApiModelProperty(value = "合作标签img")
private String tagImg;
@ApiModelProperty(value = "合作标签描述")
private String tagDescription;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.mmc.iuav.user.model.vo;
import com.mmc.iuav.group.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/16 21:18
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value = "com.mmc.iuav.user.model.vo.UserAccountVO", description = "用户信息")
public class UserAccountVO implements Serializable {
private static final long serialVersionUID = 7067111726018678883L;
@ApiModelProperty(value = "用户id")
@NotNull(message = "用户id不能为空",groups = {Update.class})
private Integer id;
@ApiModelProperty(value = "用户类型")
private Integer accountType;
@ApiModelProperty(value = "用户uid")
private String uid;
@ApiModelProperty(value = "手机号")
private String phoneNum;
@ApiModelProperty(value = "用户名称")
private String userName;
@ApiModelProperty(value = "用户昵称")
private String nickName;
@ApiModelProperty(value = "用户头像")
private String userImg;
@ApiModelProperty(value = "用户性别:0未知、1男、2女")
private Integer userSex;
@ApiModelProperty(value = "用户邮箱")
@Email
private String email;
@ApiModelProperty(value = "用户来源,0自然流、1海报、2抖音、3公众号、4社群、5招投标、6官网")
private Integer source;
@ApiModelProperty(value = "用户可用状态:0禁用、1可用")
private Integer accountStatus;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "账号类型:0后台管理账号 ; 100云享飞-客户端;")
private Integer portType;
@ApiModelProperty(value = "注册时间")
private Date createTime;
}
package com.mmc.iuav.user.model.vo;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/17 22:02
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserApplyTagVO implements Serializable {
private static final long serialVersionUID = -1004953417393220972L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "加盟标签id")
@NotNull(message = "加盟标签id不能为空", groups = { Insert.class })
private Integer cooperationTagId;
@ApiModelProperty(value = "用户id")
@NotNull(message = "加盟标签id不能为空", groups = { Insert.class })
private Integer userAccountId;
@ApiModelProperty(value = "申请人名称")
@NotBlank(message = "申请人名称不能为空", groups = { Insert.class })
private String applyName;
@ApiModelProperty(value = "申请人手机号")
@NotBlank(message = "申请人手机号不能为空", groups = { Insert.class })
private String applyPhone;
@ApiModelProperty(value = "申请审核状态,0待审核,1通过,2未通过")
private Integer applyStatus;
@ApiModelProperty(value = "备注")
private String remark;
}
package com.mmc.iuav.user.model.vo;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.group.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/16 13:56
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "com.mmc.iuav.user.model.vo.WxLoginVO", description = "登录参数")
public class WxLoginVO implements Serializable {
private static final long serialVersionUID = 2500957724470423989L;
@ApiModelProperty(value = "请求code")
@NotNull(message = "code不能为空", groups = {Insert.class})
private String code;
@ApiModelProperty(value = "登录来源, 0小程序登录, 1pc扫码登录", example = "0", allowableValues = "0,1")
@NotNull(message = "登录来源不能为空", groups = {Insert.class})
private Integer fromPort;
@ApiModelProperty(value = "用户来源:0自然流,1海报,2抖音,3公众号,4社群,5招投标,默认0", example = "0")
private Integer source;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cms-common</artifactId>
<groupId>com.mmc.iuav.cms</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<artifactId>cms-common-util</artifactId>
<dependencies>
<!-- apache 提供的一些工具类 -->
<!-- <dependency>-->
<!-- <groupId>commons-codec</groupId>-->
<!-- <artifactId>commons-codec</artifactId>-->
<!-- <version>1.15</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>commons-lang</groupId>-->
<!-- <artifactId>commons-lang</artifactId>-->
<!-- <version>2.6</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
<encoding>utf-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.mmc.iuav.auth;
/**
* @author: zj
* @Date: 2023/5/16 20:18
*/
public interface JwtConstant {
public final static String BASE64KEY = "IUAV&&iuavhhh@20230516888888";
public final static String SUBJECT = "mmc_iuav888";
public final static String ISSUER = "mmc_uav";
public final static long EXPIRATION = 1 * 24 * 60 * 60 * 1000L;
public final static String TOKEN_TYPE = "TOKEN_TYPE";
public final static String M_TOKEN = "M_TOKEN"; //后台管理用户token
public final static String IUAV_TOKEN = "IUAV_TOKEN"; //小程序token
public final static String USER_ACCOUNT_ID = "USER_ACCOUNT_ID";
public final static String ROLE_ID = "ROLE_ID";
}
package com.mmc.iuav.auth;
import com.mmc.iuav.general.CodeUtil;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.security.Key;
import java.util.Date;
import java.util.Map;
/**
* @author: zj
* @Date: 2023/5/16 20:14
*/
public class JwtUtil {
/**
* 根据map中的信息生成token, tokenId为随机生成码,有效时间为24h
*
* @param claims 封装到token中的map
* @return
*/
public static String createJwt(Map<String, Object> claims) {
return createJwt(claims, JwtConstant.EXPIRATION);
}
public static String createJwt(Map<String, Object> claims, long expiration) {
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(JwtConstant.BASE64KEY);
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
long nowMillis = System.currentTimeMillis();
long expMillis = nowMillis + expiration;
Date now = new Date(nowMillis);
Date exp = new Date(expMillis);
JwtBuilder builder = Jwts.builder().setClaims(claims).setId(CodeUtil.randomCode(6)).setIssuedAt(now)
.setSubject(JwtConstant.SUBJECT).setIssuer(JwtConstant.ISSUER).signWith(signatureAlgorithm, signingKey)
.setExpiration(exp);
return builder.compact();
}
/**
* 解析前端传来的token,解析成功则返回Claims,解析失败返回null;解析成功后可通过claims获取信息
*
* @param jwt
* @return
*/
public static Claims parseJwt(String jwt) {
Claims claims = Jwts.parser().setSigningKey(DatatypeConverter.parseBase64Binary(JwtConstant.BASE64KEY))
.parseClaimsJws(jwt).getBody();
return claims;
}
}
package com.mmc.iuav.general;
import java.util.Random;
/**
* @author: zj
* @Date: 2023/5/16 20:01
*/
public class CodeUtil {
private static Random random = new Random();
public static String getRandomNum(int length) {
StringBuffer sb = new StringBuffer();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(String.valueOf(random.nextInt(10)));
}
return sb.toString();
}
public static String generateUserUID() {
return CodeUtil.getRandomNum(9);
}
public static String randomCode(int i) {
return CodeUtil.getRandomNum(i);
}
}
package com.mmc.iuav.group;
/**
* @author: zj
* @Date: 2023/5/16 16:32
*/
public interface Insert {
}
package com.mmc.iuav.group;
/**
* @author: zj
* @Date: 2023/5/16 16:32
*/
public interface Update {
}
package com.mmc.iuav.http;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import static java.lang.System.out;
/**
* @author zj
*/
public class HttpHelper {
// get 请求
public static String httpGet(String url, Header[] headers) throws Exception {
HttpUriRequest uriRequest = new HttpGet(url);
if (null != headers) {
uriRequest.setHeaders(headers);
}
CloseableHttpClient httpClient = null;
try {
httpClient = declareHttpClientSSL(url);
CloseableHttpResponse httpresponse = httpClient.execute(uriRequest);
HttpEntity httpEntity = httpresponse.getEntity();
String result = EntityUtils.toString(httpEntity, REQ_ENCODEING_UTF8);
return result;
} catch (ClientProtocolException e) {
out.println(String.format("http请求失败,uri{%s},exception{%s}", new Object[] { url, e }));
} catch (IOException e) {
out.println(String.format("IO Exception,uri{%s},exception{%s}", new Object[] { url, e }));
} finally {
if (null != httpClient) {
httpClient.close();
}
}
return null;
}
// post 请求
public static String httpPost(String url, String params) throws Exception {
HttpPost post = new HttpPost(url);
post.addHeader("Content-Type", "application/json;charset=" + REQ_ENCODEING_UTF8);
// 设置传输编码格式
StringEntity stringEntity = new StringEntity(params, REQ_ENCODEING_UTF8);
stringEntity.setContentEncoding(REQ_ENCODEING_UTF8);
post.setEntity(stringEntity);
HttpResponse httpresponse = null;
CloseableHttpClient httpClient = null;
try {
httpClient = declareHttpClientSSL(url);
httpresponse = httpClient.execute(post);
HttpEntity httpEntity = httpresponse.getEntity();
String result = EntityUtils.toString(httpEntity, REQ_ENCODEING_UTF8);
return result;
} catch (ClientProtocolException e) {
out.println(String.format("http请求失败,uri{%s},exception{%s}", new Object[] { url, e }));
} catch (IOException e) {
out.println(String.format("IO Exception,uri{%s},exception{%s}", new Object[] { url, e }));
} finally {
if (null != httpClient) {
httpClient.close();
}
}
return null;
}
private static CloseableHttpClient declareHttpClientSSL(String url) {
if (url.startsWith("https://")) {
return sslClient();
} else {
return HttpClientBuilder.create().setConnectionManager(httpClientConnectionManager).build();
}
}
/**
* 设置SSL请求处理
*
*/
private static CloseableHttpClient sslClient() {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
@Override
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLConnectionSocketFactory sslConnectionSocketFactory = SSLConnectionSocketFactory.getSocketFactory();
return HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).build();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (KeyManagementException e) {
throw new RuntimeException(e);
}
}
// this is config
private static final String REQ_ENCODEING_UTF8 = "utf-8";
private static PoolingHttpClientConnectionManager httpClientConnectionManager;
public HttpHelper() {
httpClientConnectionManager = new PoolingHttpClientConnectionManager();
httpClientConnectionManager.setMaxTotal(100);
httpClientConnectionManager.setDefaultMaxPerRoute(20);
}
// get 请求
public static String httpGet(String url) throws Exception {
return httpGet(url, null);
}
}
package com.mmc.iuav.http;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import org.springframework.stereotype.Component;
import javax.net.ssl.*;
import java.io.*;
import java.net.ConnectException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Iterator;
import java.util.Map;
/**
* @author: zj
* @Date: 2023/5/16 15:27
*/
@Component
public class HttpsRequestUtil {
public static String httpsRequest(String url, String method, Map<String, String> headerMap, String bodyData)
throws Exception {
HttpsURLConnection conn = null;
OutputStream out = null;
String rsp = null;
byte[] byteArray = bodyData.getBytes("utf-8");
try {
URL uri = new URL(url);
conn = (HttpsURLConnection) uri.openConnection();
// 忽略证书验证--Begin
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
// 忽略证书验证--End
conn.setRequestMethod(method);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Host", uri.getHost());
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
if (headerMap != null) {
Iterator<Map.Entry<String, String>> it = headerMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
conn.setRequestProperty(entry.getKey(), entry.getValue());
}
}
out = conn.getOutputStream();
out.write(byteArray);
out.close();
if (conn.getResponseCode() == 200) {
rsp = getStreamAsString(conn.getInputStream(), "utf-8");
} else {
rsp = getStreamAsString(conn.getErrorStream(), "utf-8");
}
} catch (Exception e) {
if (null != out) {
out.close();
}
e.printStackTrace();
}
return rsp;
}
/**
* 获取小程序二维码
*
* @param url
* @param method
* @param headerMap
* @param bodyData
* @return
* @throws Exception
*/
public static String getACodeBase64(String url, String method, Map<String, String> headerMap, String bodyData)
throws Exception {
HttpsURLConnection conn = null;
OutputStream out = null;
String rsp = null;
byte[] byteArray = bodyData.getBytes("utf-8");
try {
URL uri = new URL(url);
conn = (HttpsURLConnection) uri.openConnection();
// 忽略证书验证--Begin
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
// 忽略证书验证--End
conn.setRequestMethod(method);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Host", uri.getHost());
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
if (headerMap != null) {
Iterator<Map.Entry<String, String>> it = headerMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
conn.setRequestProperty(entry.getKey(), entry.getValue());
}
}
out = conn.getOutputStream();
out.write(byteArray);
out.close();
if (conn.getResponseCode() == 200) {
byte[] bytes = InputStreamToByte(conn.getInputStream());
//rsp = Base64.encodeBase64String(bytes);
rsp = Base64.encode(bytes);
} else {
rsp = getStreamAsString(conn.getErrorStream(), "utf-8");
}
} catch (Exception e) {
if (null != out) {
out.close();
}
e.printStackTrace();
}
return rsp;
}
/**
* 输入流转字节流
*/
private static byte[] InputStreamToByte(InputStream in) throws IOException {
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int ch;
while ((ch = in.read(buffer)) != -1) {
bytestream.write(buffer, 0, ch);
}
byte data[] = bytestream.toByteArray();
bytestream.close();
return data;
}
private static String getStreamAsString(InputStream stream, String charset) throws IOException {
try {
Reader reader = new InputStreamReader(stream, charset);
StringBuilder response = new StringBuilder();
final char[] buff = new char[1024];
int read = 0;
while ((read = reader.read(buff)) > 0) {
response.append(buff, 0, read);
}
return response.toString();
} finally {
if (stream != null) {
stream.close();
}
}
}
/**
* HTTPS GET请求
*
* @param url
* @param headerMap
* @return
*/
public static String httpsGet(String url, Map<String, String> headerMap) {
String str_return = "";
HttpsURLConnection conn = null;
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[]{new TrustAnyTrustManager()}, new java.security.SecureRandom());
URL console = new URL(url);
conn = (HttpsURLConnection) console.openConnection();
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
if (headerMap != null) {
Iterator<Map.Entry<String, String>> it = headerMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
conn.setRequestProperty(entry.getKey(), entry.getValue());
}
}
conn.setSSLSocketFactory(sc.getSocketFactory());
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
conn.connect();
InputStream is = conn.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is, ("ISO-8859-1")));
String ret = "";
while (ret != null) {
ret = br.readLine();
if (ret != null && !ret.trim().equals("")) {
str_return = str_return + new String(ret.getBytes("ISO-8859-1"), "utf-8");
}
}
} catch (ConnectException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
conn.disconnect();
}
return str_return;
}
}
// 定制Verifier
class TrustAnyHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
class TrustAnyTrustManager implements X509TrustManager {
@Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
}
package com.mmc.iuav.response;
/**
* @author:zhenjie
* @Date:2023/5/16 10:42
*/
public interface BaseErrorInfoInterface {
/**
* 错误码
*
* @return
*/
String getResultCode();
/**
* 错误描述
*
* @return
*/
String getResultMsg();
}
package com.mmc.iuav.response;
import com.alibaba.fastjson2.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/16 10:51
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "com.mmc.iuav.response.ResultBody", description = "请求响应体")
public class ResultBody<T> implements Serializable {
private static final long serialVersionUID = -6913505187877217885L;
/**
* 响应代码
*/
@ApiModelProperty(value = "响应代码")
private String code;
/**
* 响应消息
*/
@ApiModelProperty(value = "响应消息")
private String message;
/**
* 响应结果
*/
@ApiModelProperty(value = "响应结果")
private T result;
public ResultBody(BaseErrorInfoInterface errorInfo) {
this.code = errorInfo.getResultCode();
this.message = errorInfo.getResultMsg();
}
/**
* 成功
*
* @return
*/
public static ResultBody success() {
return success(null);
}
/**
* 成功
*
* @param data
* @return
*/
public static <T> ResultBody success(T data) {
ResultBody rb = new ResultBody();
rb.setCode(ResultEnum.SUCCESS.getResultCode());
rb.setMessage(ResultEnum.SUCCESS.getResultMsg());
rb.setResult(data);
return rb;
}
/**
* 成功
*
* **/
public static ResultBody success1(ResultEnum enums){
ResultBody rb = new ResultBody();
rb.setCode("200");
rb.setMessage(enums.getResultMsg());
rb.setResult(null);
return rb;
}
public void buildSuccess() {
this.setCode(ResultEnum.SUCCESS.getResultCode());
this.setMessage(ResultEnum.SUCCESS.getResultMsg());
}
/**
* 失败
*/
public static ResultBody error(BaseErrorInfoInterface errorInfo) {
ResultBody rb = new ResultBody();
rb.setCode(errorInfo.getResultCode());
rb.setMessage(errorInfo.getResultMsg());
rb.setResult(null);
return rb;
}
/**
* 失败
*/
public static ResultBody error(String code, String message) {
ResultBody rb = new ResultBody();
rb.setCode(code);
rb.setMessage(message);
rb.setResult(null);
return rb;
}
/**
* 失败
*/
public static ResultBody error(ResultEnum enums) {
ResultBody rb = new ResultBody();
rb.setCode(enums.getResultCode());
rb.setMessage(enums.getResultMsg());
rb.setResult(null);
return rb;
}
/**
* 失败
*/
public static ResultBody error(String message) {
ResultBody rb = new ResultBody();
rb.setCode("-1");
rb.setMessage(message);
rb.setResult(null);
return rb;
}
/**
* 失败
*/
public static ResultBody error(ResultEnum enums, Object data) {
ResultBody rb = new ResultBody();
rb.setCode(enums.getResultCode());
rb.setMessage(enums.getResultMsg());
rb.setResult(data);
return rb;
}
public static boolean isSuccess(ResultBody res) {
return res.getCode().equals(ResultEnum.SUCCESS.getResultCode());
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
}
package com.mmc.iuav.response;
/**
* @author: zj
* @Date: 2023/5/16 10:41
*/
public enum ResultEnum implements BaseErrorInfoInterface{
SUCCESS("200", "success"),
FAIL("500", "fail"),
PARAM_ERROR("400", "参数错误"),
//企业认证
BUSINESS_LICENSE_CHECK_ANALYSIS_ERROR("1000", "营业执照解析失败,请上传有效清晰的执照"),
COMPANY_NOT_AUTH_ERROR("1001", "未进行企业认证"),
BUSINESS_LICENSE_CHECK_PARAMETER_ERROR("1002", "企业信息与营业执照信息不一致,请重新上传"),
APPLET_PORT_TYPE_ERROR("7001", "小程序端口类型错误"),
APPLET_LOGIN_ERROR("7002", "获取小程序登录失败");
/**
* 错误码
*
* @return
*/
String resultCode;
/**
* 错误描述
*
* @return
*/
String resultMsg;
ResultEnum(String resultCode, String resultMsg) {
this.resultCode = resultCode;
this.resultMsg = resultMsg;
}
@Override
public String getResultCode() {
return this.resultCode;
}
@Override
public String getResultMsg() {
return this.resultMsg;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>iuav-cms</artifactId>
<groupId>com.mmc.iuav.cms</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cms-common</artifactId>
<packaging>pom</packaging>
<modules>
<module>cms-common-model</module>
<module>cms-common-util</module>
</modules>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>csm-service</artifactId>
<groupId>com.mmc.iuav.cms</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cms-service-user</artifactId>
<dependencies>
<dependency>
<groupId>com.mmc.iuav.cms</groupId>
<artifactId>cms-common-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.mmc.iuav.cms</groupId>
<artifactId>cms-common-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 引入 Web 功能 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 健康监控 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 引入 Feign, 可以以声明的方式调用微服务 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- 使用okhttp-feign-连接池技术 -->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<!-- mybatis驱动&Druid数据源-start -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- mybatis驱动&Druid数据源-end -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- RabbitMQ -->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.mmc.iuav.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author:zhenjie
* @Date:2023/5/15 15:35
*/
@SpringBootApplication
public class UserApplication {
public static void main(String[] args) {
SpringApplication.run(UserApplication.class, args);
}
}
package com.mmc.iuav.user.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author:zhenjie
* @Date:2023/5/16 10:07
*/
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Knife4jConfiguration {
@Bean(value = "defaultApi2")
public Docket defaultApi2() {
Docket docket=new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
//分组名称
.groupName("用户服务")
.select()
//这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage("com.mmc.iuav.user.controller"))
.paths(PathSelectors.any())
.build();
return docket;
}
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title("iuav用户相关")
.description("swagger-bootstrap-ui-demo RESTful APIs")
.termsOfServiceUrl("https://www.iuav.com/")
.contact("group@qq.com")
.version("1.0")
.build();
}
}
package com.mmc.iuav.user.constant;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @author: zj
* @Date: 2023/5/16 13:34
*/
@Data
@Component
public class UserSystemConstant {
@Value("${wx.app.id}")
private String wxAppId;
@Value("${wx.app.secret}")
private String wxAppSecret;
@Value("${wx.app.miniprogram-state}")
private String miniProgramState;
@Value("${wx.app.env-version}")
private String envVersion;
@Value("${wx.sub.appid}")
private String wxSubAppId;
@Value("${wx.sub.secret}")
private String wxSubSecret;
@Value("${third-party.ali.app-code}")
private String aliAppCode;
@Value("${third-party.qcc.app-key}")
private String qccAppKey;
@Value("${third-party.qcc.secret-key}")
private String qccSecretKey;
}
package com.mmc.iuav.user.constant;
import org.springframework.stereotype.Component;
/**
* @author: zj
* @Date: 2023/5/16 16:02
*/
public class WxConstant {
public static final Integer APP = 0;
public static final Integer WEB = 1;
public static final String CODE2_SESSION_URL = "https://api.weixin.qq.com/sns/jscode2session";
public static final String GRANT_TYPE = "authorization_code";
public static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token";
public static final String OPEN_ID = "openid";
public static final String UNION_ID = "unionid";
public static final String SESSION_KEY = "session_key";
}
package com.mmc.iuav.user.controller;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.AppUserSucVO;
import com.mmc.iuav.user.model.vo.WxLoginVO;
import com.mmc.iuav.user.service.AuthService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author: zj
* @Date: 2023/5/15 15:50
*/
@Api(tags = "登录授权")
@RequestMapping("/auth/")
@RestController
public class AuthController {
@Autowired
private AuthService authService;
@ApiOperation(value = "小程序登录/注册")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = AppUserSucVO.class) })
@PostMapping("appletLogin")
public ResultBody appletLogin(@Validated(value = {Insert.class})@RequestBody WxLoginVO wxLoginVO){
return authService.appletLogin(wxLoginVO);
}
}
package com.mmc.iuav.user.controller;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.AppUserSucVO;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.model.vo.WxLoginVO;
import com.mmc.iuav.user.service.CompanyAuthService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author: zj
* @Date: 2023/5/17 13:33
*/
@Api(tags = "企业认证相关")
@RequestMapping("/company-auth/")
@RestController
public class CompanyAuthController {
@Autowired
private CompanyAuthService companyAuthService;
@ApiOperation(value = "提交企业认证")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("add")
public ResultBody add(@Validated(value = {Insert.class})@RequestBody CompanyAuthVO companyAuthVO){
return companyAuthService.add(companyAuthVO);
}
@ApiOperation(value = "企业工商模糊搜索")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@GetMapping("fuzzyQueryCompany")
public ResultBody fuzzyQueryCompany(@ApiParam(value = "企业名称", required = true) @RequestParam String searchKey) {
return companyAuthService.fuzzyQueryCompany(searchKey);
}
}
package com.mmc.iuav.user.controller;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.service.CooperationService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author: zj
* @Date: 2023/5/17 21:17
*/
@Api(tags = "合作加盟")
@RequestMapping("/cooperation/")
@RestController
public class CooperationController {
@Autowired
private CooperationService cooperationService;
@ApiOperation(value = "加盟标签列表")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = CooperationTagVO.class) })
@GetMapping("listTag")
public ResultBody listTag() {
return cooperationService.listTag();
}
@ApiOperation(value = "申请加盟")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("apply")
public ResultBody apply(@Validated(value = {Insert.class})@RequestBody UserApplyTagVO userApplyTagVO){
return cooperationService.apply(userApplyTagVO);
}
}
package com.mmc.iuav.user.controller;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.group.Update;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
import com.mmc.iuav.user.model.vo.AppUserSucVO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.model.vo.WxLoginVO;
import com.mmc.iuav.user.service.UserAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author: zj
* @Date: 2023/5/15 15:32
*/
@Api(tags = "账号相关接口")
@RequestMapping("/user-account/")
@RestController
public class UserAccountController {
@Autowired
private UserAccountService userAccountService;
@ApiOperation(value = "获取用户信息")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = UserAccountVO.class) })
@GetMapping("info")
public UserAccountVO info(@RequestParam Integer userAccountId){
return userAccountService.getUserAccountById(userAccountId);
}
@ApiOperation(value = "修改用户信息")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("update")
public ResultBody update(@Validated(value = {Update.class})@RequestBody UserAccountVO userAccountVO){
return userAccountService.update(userAccountVO);
}
@ApiOperation(value = "获取用户基本信息")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = UserAccountSimpleDTO.class) })
@GetMapping("feignGetUserSimpleInfo")
public UserAccountSimpleDTO feignGetUserSimpleInfo(@RequestParam Integer userAccountId){
return userAccountService.getUserSimpleInfo(userAccountId);
}
}
package com.mmc.iuav.user.controller;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.service.WxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author: zj
* @Date: 2023/5/17 11:16
*/
@Api(tags = "微信相关接口")
@RequestMapping("/wx/")
@RestController
public class WxController {
@Autowired
private WxService wxService;
@ApiOperation(value = "小程序-获取当前用户的小程序推荐码")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = String.class) })
@PostMapping("getAppletRcdCode")
public ResultBody getAppletRcdCode(HttpServletRequest request) {
return ResultBody.success();
// return wxService.getAppletCodeImgBase64(WxMsgDataConfig.USER_APPLET_PAGE_INDEX,
// WxHandler.createRcdScene(this.getCurrentUser(request).getId()));
}
}
package com.mmc.iuav.user.dao;
import com.mmc.iuav.user.entity.CompanyAuthDO;
import org.apache.ibatis.annotations.Mapper;
/**
* @author: zj
* @Date: 2023/5/17 13:38
*/
@Mapper
public interface CompanyAuthDao {
/**
* 通过用户id获取企业认证信息
* @param userAccountId
* @return
*/
CompanyAuthDO getCompanyAuth(Integer userAccountId);
/**
* 添加企业认证信息
* @param companyAuthDO
*/
void addCompanyAuth(CompanyAuthDO companyAuthDO);
}
package com.mmc.iuav.user.dao;
import com.mmc.iuav.user.entity.CooperationTagDO;
import com.mmc.iuav.user.entity.UserApplyTagDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author: zj
* @Date: 2023/5/17 21:20
*/
@Mapper
public interface CooperationDao {
/**
* 加盟标签列表
* @return
*/
List<CooperationTagDO> listTags();
/**
* 加盟申请
* @param userApplyTagDO
*/
void addApply(UserApplyTagDO userApplyTagDO);
/**
* 根据用户id获取合作申请
* @param userAccountId
* @return
*/
UserApplyTagDO getUserApplyTag(Integer userAccountId);
/**
* 修改用户申请
* @param userApplyTagDO
*/
void updateUserApplyTag(UserApplyTagDO userApplyTagDO);
}
package com.mmc.iuav.user.dao;
import com.mmc.iuav.user.entity.UserAccountDO;
import org.apache.ibatis.annotations.Mapper;
/**
* @author: zj
* @Date: 2023/5/16 19:26
*/
@Mapper
public interface UserServiceDao {
/**
* 根据用户unionId查询用户信息
* @param unionId
* @return
*/
UserAccountDO getUserAccountInfoByUnionId(String unionId);
/**
* 插入用户信息
* @param userAccountDO
*/
void insertUserAccount(UserAccountDO userAccountDO);
/**
* 根据用户id查询用户信息
* @param userAccountId
* @return
*/
UserAccountDO getUserAccountById(Integer userAccountId);
/**
* 修改用户信息
* @param userAccountDO
*/
void update(UserAccountDO userAccountDO);
}
package com.mmc.iuav.user.entity;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/17 14:22
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CompanyAuthDO implements Serializable {
private static final long serialVersionUID = -9166003341814537635L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "用户id")
private Integer userAccountId;
@ApiModelProperty(value = "企业名称")
private String companyName;
@ApiModelProperty(value = "统一社会信用代码")
private String creditCode;
@ApiModelProperty(value = "营业执照")
private String licenseImg;
@ApiModelProperty(value = "企业认证状态,0未通过,1已通过")
private Integer authStatus;
public CompanyAuthDO(CompanyAuthVO companyAuthVO) {
this.userAccountId = companyAuthVO.getUserAccountId();
this.companyName = companyAuthVO.getCompanyName();
this.creditCode = companyAuthVO.getCreditCode();
this.licenseImg = companyAuthVO.getLicenseImg();
}
public CompanyAuthVO buildCompanyAuth() {
return CompanyAuthVO.builder().id(this.id).companyName(this.companyName).userAccountId(this.userAccountId)
.creditCode(this.creditCode).authStatus(this.authStatus).licenseImg(this.licenseImg).build();
}
}
package com.mmc.iuav.user.entity;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/17 21:24
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CooperationTagDO implements Serializable {
private static final long serialVersionUID = 4469387912588336014L;
private Integer id;
private String tagName;
private String tagImg;
private String tagDescription;
private Date createTime;
public CooperationTagVO buildCooperationTagVO(){
return CooperationTagVO.builder()
.id(id)
.tagName(tagName)
.tagImg(tagImg)
.tagDescription(tagDescription)
.createTime(createTime)
.build();
}
}
package com.mmc.iuav.user.entity;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/16 17:00
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserAccountDO implements Serializable {
private static final long serialVersionUID = 5007589179946146721L;
private Integer id;
private Integer accountType;
private String uid;
private String phoneNum;
private String userName;
private String nickName;
private String userImg;
private String openId;
private String unionId;
private Integer userSex;
private String email;
private Integer source;
private Integer accountStatus;
private String remark;
private Integer portType;
private Integer deleted;
private Date createTime;
private Date updateTime;
public UserAccountDO(UserAccountVO userAccountVO) {
this.id = userAccountVO.getId();
this.phoneNum = userAccountVO.getPhoneNum();
this.userName = userAccountVO.getUserName();
this.nickName = userAccountVO.getNickName();
this.userImg = userAccountVO.getUserImg();
this.userSex = userAccountVO.getUserSex();
this.email = userAccountVO.getEmail();
this.accountStatus = userAccountVO.getAccountStatus();
this.remark = userAccountVO.getRemark();
this.portType = userAccountVO.getPortType();
}
public UserAccountVO buildUserAccountVO() {
return UserAccountVO.builder().id(this.id).uid(this.uid).accountType(this.accountType).phoneNum(this.phoneNum).userName(this.userName).nickName(this.nickName)
.userImg(this.userImg).userSex(this.userSex).email(this.email).source(this.source).accountStatus(this.accountStatus).remark(this.remark).portType(this.portType)
.createTime(this.createTime).build();
}
public UserAccountSimpleDTO buildUserAccountSimpleDTO() {
return UserAccountSimpleDTO.builder().id(this.id).uid(this.uid).accountType(this.accountType).phoneNum(this.phoneNum).userName(this.userName).nickName(this.nickName)
.userImg(this.userImg).userSex(this.userSex).email(this.email).source(this.source).accountStatus(this.accountStatus).portType(this.portType)
.build();
}
}
package com.mmc.iuav.user.entity;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author: zj
* @Date: 2023/5/17 21:59
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserApplyTagDO implements Serializable {
private static final long serialVersionUID = -7581203992821286124L;
private Integer id;
private Integer cooperationTagId;
private Integer userAccountId;
private String applyName;
private String applyPhone;
private Integer applyStatus;
private String remark;
public UserApplyTagVO buildUserApplyTagVO(){
return UserApplyTagVO.builder().id(id).cooperationTagId(cooperationTagId).userAccountId(this.userAccountId)
.applyName(this.applyName).applyPhone(this.applyPhone).applyStatus(this.applyStatus).remark(this.remark).build();
}
public UserApplyTagDO(UserApplyTagVO userApplyTagVO){
this.cooperationTagId = userApplyTagVO.getCooperationTagId();
this.userAccountId = userApplyTagVO.getUserAccountId();
this.applyName = userApplyTagVO.getApplyName();
this.applyPhone = userApplyTagVO.getApplyPhone();
this.remark = userApplyTagVO.getRemark();
}
}
package com.mmc.iuav.user.service;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.WxLoginVO;
/**
* @author: zj
* @Date: 2023/5/16 13:50
*/
public interface AuthService {
/**
* 小程序用户登录接口
* @param wxLoginVO
* @return
*/
ResultBody appletLogin(WxLoginVO wxLoginVO);
}
package com.mmc.iuav.user.service;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
/**
* @author: zj
* @Date: 2023/5/17 13:37
*/
public interface CompanyAuthService {
/**
* 添加企业认证
* @param companyAuthVO
* @return
*/
ResultBody add(CompanyAuthVO companyAuthVO);
/**
* 根据企业名称模糊查询
* @param searchKey
* @return
*/
ResultBody fuzzyQueryCompany(String searchKey);
/**
* 根据用户账号查询企业认证
* @param userAccountId
* @return
*/
CompanyAuthVO getCompanyAuthByUId(Integer userAccountId);
}
package com.mmc.iuav.user.service;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
/**
* @author: zj
* @Date: 2023/5/17 21:19
*/
public interface CooperationService {
/**
* 加盟标签列表
* @return
*/
ResultBody listTag();
/**
* 用户申请加盟
* @param cooperationTagVO
* @return
*/
ResultBody apply(UserApplyTagVO cooperationTagVO);
}
package com.mmc.iuav.user.service;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
/**
* @author: zj
* @Date: 2023/5/16 13:48
*/
public interface UserAccountService {
/**
* Get the user account
* @param unionId
* @return
*/
UserAccountVO getUserAccountInfoByUnionId(String unionId);
/**
* Insert the user account
* @param userAccountDO
*/
void insertUserAccount(UserAccountDO userAccountDO);
/**
* 通过用户id获取用户信息
* @param userAccountId
* @return
*/
UserAccountVO getUserAccountById(Integer userAccountId);
/**
* 修改用户信息
* @param userAccountVO
* @return
*/
ResultBody update(UserAccountVO userAccountVO);
/**
* 获取用户基本信息
* @param userAccountId
* @return
*/
UserAccountSimpleDTO getUserSimpleInfo(Integer userAccountId);
}
package com.mmc.iuav.user.service;
import com.mmc.iuav.user.model.vo.WxLoginVO;
/**
* @author: zj
* @Date: 2023/5/16 13:43
*/
public interface WxService {
/**
* 小程序登录调用接口
* @param wxLoginVO
* @return
*/
String appLogin(WxLoginVO wxLoginVO);
/**
* pc扫码登录
* @param wxLoginVO
* @return
*/
String pcLogin(WxLoginVO wxLoginVO);
}
package com.mmc.iuav.user.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mmc.iuav.auth.JwtConstant;
import com.mmc.iuav.auth.JwtUtil;
import com.mmc.iuav.general.CodeUtil;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.constant.WxConstant;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.model.vo.AppUserSucVO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.model.vo.WxLoginVO;
import com.mmc.iuav.user.service.AuthService;
import com.mmc.iuav.user.service.UserAccountService;
import com.mmc.iuav.user.service.WxService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @author: zj
* @Date: 2023/5/16 13:51
*/
@Slf4j
@Service
public class AuthServiceImpl implements AuthService {
@Autowired
private WxService wxService;
@Autowired
private UserAccountService userAccountService;
@Override
public ResultBody appletLogin(WxLoginVO wxLoginVO) {
String unionId;
String openId;
if (wxLoginVO.getFromPort().toString().equals(WxConstant.APP.toString())) {
//调用小程序登录接口,里面包含unionId
String appWxJson = wxService.appLogin(wxLoginVO);
if (appWxJson == null) {
return ResultBody.error(ResultEnum.APPLET_PORT_TYPE_ERROR);
}
JSONObject json = JSON.parseObject(appWxJson);
if (!json.containsKey(WxConstant.OPEN_ID) || !json.containsKey(WxConstant.SESSION_KEY)) {
log.error("wx appLogin error==>" + json);
return ResultBody.error(ResultEnum.APPLET_LOGIN_ERROR, json);
}
unionId = json.getString(WxConstant.UNION_ID);
openId = json.getString(WxConstant.OPEN_ID);
}else if (wxLoginVO.getFromPort().equals(WxConstant.WEB)){
//获取access_token接口,里面包含unionId
String pcWxJson = wxService.pcLogin(wxLoginVO);
if (pcWxJson == null) {
return ResultBody.error(ResultEnum.APPLET_PORT_TYPE_ERROR);
}
JSONObject json = JSON.parseObject(pcWxJson);
if (!json.containsKey(WxConstant.OPEN_ID) ||!json.containsKey(WxConstant.SESSION_KEY)) {
log.error("wx pcLogin error==>" + json);
return ResultBody.error(ResultEnum.APPLET_LOGIN_ERROR, json);
}
unionId = json.getString(WxConstant.UNION_ID);
openId = json.getString(WxConstant.OPEN_ID);
}else {
return ResultBody.error(ResultEnum.PARAM_ERROR);
}
//数据库查询用户信息
UserAccountVO userAccountVO = userAccountService.getUserAccountInfoByUnionId(unionId);
if (userAccountVO == null) {
UserAccountDO userAccountDO = new UserAccountDO();
userAccountDO.setUnionId(unionId);
userAccountDO.setOpenId(openId);
userAccountDO.setUid(CodeUtil.generateUserUID());
userAccountDO.setAccountType(0);
userAccountDO.setPortType(100);
userAccountDO.setSource(wxLoginVO.getSource());
userAccountService.insertUserAccount(userAccountDO);
userAccountVO = userAccountDO.buildUserAccountVO();
}
Map<String, Object> map = new HashMap<String, Object>();
map.put(JwtConstant.USER_ACCOUNT_ID, userAccountVO.getId());
map.put(JwtConstant.ROLE_ID, 0);
map.put(JwtConstant.TOKEN_TYPE, JwtConstant.IUAV_TOKEN);
String token = JwtUtil.createJwt(map);
return ResultBody.success(AppUserSucVO.builder().token(token).userAccountId(userAccountVO.getId()).build());
}
}
package com.mmc.iuav.user.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.dao.CompanyAuthDao;
import com.mmc.iuav.user.entity.CompanyAuthDO;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.service.CompanyAuthService;
import com.mmc.iuav.user.util.QccEntAuthUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author: zj
* @Date: 2023/5/17 13:38
*/
@Slf4j
@Service
public class CompanyAuthServiceImpl implements CompanyAuthService {
@Autowired
private QccEntAuthUtil qccEntAuthUtil;
@Autowired
private CompanyAuthDao companyAuthDao;
@Override
public ResultBody add(CompanyAuthVO companyAuthVO) {
log.info("用户:"+companyAuthVO.getUserAccountId()+" 企业认证:{}", JSONObject.toJSONString(companyAuthVO));
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(companyAuthVO.getUserAccountId());
if (companyAuthDO != null){
return ResultBody.success("已通过");
}
ResultBody companyCheckRes = this.companyCheck(companyAuthVO);
System.out.println(companyCheckRes);
if (!companyCheckRes.getCode().equals("200")){
return companyCheckRes;
}
companyAuthDO = new CompanyAuthDO(companyAuthVO);
companyAuthDO.setAuthStatus(1);
companyAuthDao.addCompanyAuth(companyAuthDO);
return ResultBody.success();
}
public ResultBody companyCheck(CompanyAuthVO companyAuthVO){
String businessRes = qccEntAuthUtil.businessLicenseCheck(companyAuthVO.getLicenseImg());
if (businessRes == null){
ResultBody resultBody = ResultBody.error(ResultEnum.BUSINESS_LICENSE_CHECK_ANALYSIS_ERROR);
return resultBody;
}
//将字符串转化成json对象
JSONObject businessResJson=JSONObject.parseObject(businessRes);
if(businessResJson.getString("success").equals("false")) {
return ResultBody.error(ResultEnum.BUSINESS_LICENSE_CHECK_ANALYSIS_ERROR);
}else {
if(businessResJson.getString("name").equals(this.convert(companyAuthVO.getCompanyName()))
&&businessResJson.getString("reg_num").equals(companyAuthVO.getCreditCode())){
String check2Res = qccEntAuthUtil.check2(companyAuthVO.getCompanyName(), companyAuthVO.getCreditCode());
if (check2Res != null){
String status = qccEntAuthUtil.FormartJson(check2Res, "Status");
if (status.equals("200")){
Integer verifyCode = qccEntAuthUtil.resultFormatJson(check2Res);
if (verifyCode.equals(1)){
return ResultBody.success();
}
String returnString = "";
if (verifyCode.equals(0)){
returnString = "统一社会信用代码有误";
}else if (verifyCode.equals(2)){
returnString = "企业名称不一致";
}else if (verifyCode.equals(3)){
returnString = "法定代表人名称不一致";
}
return ResultBody.error(returnString);
}
String errorString = "";
if (status.equals("201")){
errorString = "查询无结果";
}else if (status.equals("202")){
errorString = "查询参数错误,请检查";
}else if (status.equals("205")){
errorString = "等待处理中";
}else if (status.equals("207")){
errorString = "请求数据的条目数超过上限(5000)";
}else if (status.equals("208")){
errorString = "此接口不支持此公司类型查询";
}else if (status.equals("209")){
errorString = "企业数量超过上限";
}else if (status.equals("213")){
errorString = "参数长度不能小于2";
}else if (status.equals("215")){
errorString = "不支持的查询关键字";
}else if (status.equals("218")){
errorString = "该企业暂不支持空壳扫描";
}else if (status.equals("219")){
errorString = "该企业暂不支持准入尽调";
}else if (status.equals("105")){
errorString = "接口已下线停用";
}else if (status.equals("110")){
errorString = "当前相同查询连续出错,请等2小时后重试";
}else {
errorString = "认证报错,请联系管理员";
}
return ResultBody.error(errorString);
}else {
return ResultBody.error("认证报错");
}
}else {
return ResultBody.error(ResultEnum.BUSINESS_LICENSE_CHECK_PARAMETER_ERROR);
}
}
}
public String convert(String entName){
StringBuffer afterConvertEntName=new StringBuffer(entName);
afterConvertEntName.length();
for(int i=0;i<afterConvertEntName.length();i++){
if(afterConvertEntName.charAt(i)=='('){
afterConvertEntName.setCharAt(i,'(');
}
if(afterConvertEntName.charAt(i)==')'){
afterConvertEntName.setCharAt(i,')');
}
}
return afterConvertEntName.toString();
}
@Override
public ResultBody fuzzyQueryCompany(String searchKey) {
String companyResult = qccEntAuthUtil.fuzzySearch(searchKey);
//将字符串转化成json对象
JSONObject entResultJson=JSONObject.parseObject(companyResult);
if(companyResult==null){
return ResultBody.error("无数据,请手动输入");
}
if("200".equals(entResultJson.getString("Status"))){
return ResultBody.success(entResultJson);
}else {
return ResultBody.error("无数据,请手动输入");
}
}
@Override
public CompanyAuthVO getCompanyAuthByUId(Integer userAccountId) {
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userAccountId);
if (companyAuthDO == null){
return null;
}
return companyAuthDO.buildCompanyAuth();
}
}
package com.mmc.iuav.user.service.impl;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.dao.CompanyAuthDao;
import com.mmc.iuav.user.dao.CooperationDao;
import com.mmc.iuav.user.entity.CompanyAuthDO;
import com.mmc.iuav.user.entity.CooperationTagDO;
import com.mmc.iuav.user.entity.UserApplyTagDO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.service.CooperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author: zj
* @Date: 2023/5/17 21:19
*/
@Service
public class CooperationServiceImpl implements CooperationService {
@Autowired
private CooperationDao cooperationDao;
@Autowired
private CompanyAuthDao companyAuthDao;
@Override
public ResultBody listTag() {
List<CooperationTagDO> list = cooperationDao.listTags();
List<CooperationTagVO> resList = list.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
return ResultBody.success(resList);
}
@Override
public ResultBody apply(UserApplyTagVO userApplyTagVO) {
//判断企业认证
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userApplyTagVO.getUserAccountId());
if (companyAuthDO == null) {
return ResultBody.error(ResultEnum.COMPANY_NOT_AUTH_ERROR);
}
UserApplyTagDO userApplyTagDO = new UserApplyTagDO(userApplyTagVO);
//判断是否已加盟
UserApplyTagDO existUserApplyTagDO = cooperationDao.getUserApplyTag(userApplyTagVO.getUserAccountId());
if (existUserApplyTagDO != null) {
if (existUserApplyTagDO.getApplyStatus().equals(0)){
return ResultBody.error("已存在合作申请,待审核");
}else if (existUserApplyTagDO.getApplyStatus().equals(1)){
return ResultBody.success("已申请通过");
}else {
userApplyTagDO.setId(existUserApplyTagDO.getId());
userApplyTagDO.setApplyStatus(0);
cooperationDao.updateUserApplyTag(userApplyTagDO);
return ResultBody.success();
}
}
cooperationDao.addApply(userApplyTagDO);
return ResultBody.success();
}
}
package com.mmc.iuav.user.service.impl;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.dao.UserServiceDao;
import com.mmc.iuav.user.entity.UserAccountDO;
import com.mmc.iuav.user.model.dto.UserAccountSimpleDTO;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.model.vo.UserAccountVO;
import com.mmc.iuav.user.service.CompanyAuthService;
import com.mmc.iuav.user.service.UserAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author: zj
* @Date: 2023/5/16 13:48
*/
@Service
public class UserAccountServiceImpl implements UserAccountService {
@Autowired
private UserServiceDao userServiceDao;
@Autowired
private CompanyAuthService companyAuthService;
@Override
public UserAccountVO getUserAccountInfoByUnionId(String unionId) {
UserAccountDO userAccountDO = userServiceDao.getUserAccountInfoByUnionId(unionId);
if (userAccountDO != null) {
return userAccountDO.buildUserAccountVO();
}
return null;
}
@Override
public void insertUserAccount(UserAccountDO userAccountDO) {
userServiceDao.insertUserAccount(userAccountDO);
}
@Override
public UserAccountVO getUserAccountById(Integer userAccountId) {
UserAccountDO userAccountDO = userServiceDao.getUserAccountById(userAccountId);
UserAccountVO userAccountVO = userAccountDO.buildUserAccountVO();
return userAccountVO;
}
@Override
public ResultBody update(UserAccountVO userAccountVO) {
UserAccountDO userAccountDO = new UserAccountDO(userAccountVO);
userServiceDao.update(userAccountDO);
return ResultBody.success();
}
@Override
public UserAccountSimpleDTO getUserSimpleInfo(Integer userAccountId) {
UserAccountDO userAccountDO = userServiceDao.getUserAccountById(userAccountId);
UserAccountSimpleDTO userAccountSimpleDTO = userAccountDO.buildUserAccountSimpleDTO();
CompanyAuthVO companyAuthVO = companyAuthService.getCompanyAuthByUId(userAccountId);
if (companyAuthVO != null) {
userAccountSimpleDTO.setCompanyAuthStatus(companyAuthVO.getAuthStatus());
}else {
userAccountSimpleDTO.setCompanyAuthStatus(0);
}
return userAccountSimpleDTO;
}
}
package com.mmc.iuav.user.service.impl;
import com.mmc.iuav.http.HttpsRequestUtil;
import com.mmc.iuav.user.constant.UserSystemConstant;
import com.mmc.iuav.user.constant.WxConstant;
import com.mmc.iuav.user.model.vo.WxLoginVO;
import com.mmc.iuav.user.service.WxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author: zj
* @Date: 2023/5/16 13:44
*/
@Service
public class WxServiceImpl implements WxService {
@Autowired
private UserSystemConstant userSystemConstant;
@Override
public String appLogin(WxLoginVO wxLoginVO) {
String url = WxConstant.CODE2_SESSION_URL + "?appid=" + userSystemConstant.getWxAppId() + "&secret=" + userSystemConstant.getWxAppSecret() + "&js_code=" + wxLoginVO.getCode()
+ "&grant_type=" + WxConstant.GRANT_TYPE;
String data = HttpsRequestUtil.httpsGet(url, null);
return data;
}
@Override
public String pcLogin(WxLoginVO wxLoginVO) {
String url = WxConstant.ACCESS_TOKEN_URL + "?appid=" + userSystemConstant.getWxAppId() + "&secret=" + userSystemConstant.getWxAppSecret() + "&code=" + wxLoginVO.getCode()
+ "&grant_type=" + WxConstant.GRANT_TYPE;
String data = HttpsRequestUtil.httpsGet(url, null);
return data;
}
}
package com.mmc.iuav.user.util;
import com.alibaba.fastjson2.JSONException;
import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mmc.iuav.http.HttpHelper;
import com.mmc.iuav.http.HttpsRequestUtil;
import com.mmc.iuav.user.constant.UserSystemConstant;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.client.methods.HttpHead;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
/**
* @author: zj
* @Date: 2023/5/17 13:37
*/
@Component
public class QccEntAuthUtil {
@Autowired
private UserSystemConstant userSystemConstant;
public String fuzzySearch(String searchKey) {
String reqInterNme = "http://api.qichacha.com/FuzzySearch/GetList";
//pageSize=6,显示6条
//String paramStr = "searchKey="+searchKey;
String status = "";
try {
HttpHead reqHeader = new HttpHead();
String[] autherHeader = RandomAuthentHeader();
reqHeader.setHeader("Token", autherHeader[0]);
reqHeader.setHeader("Timespan", autherHeader[1]);
reqHeader.setHeader("Content-Type", "application/json; charset=UTF-8");
reqHeader.setHeader("Accept", "application/json; charset=UTF-8");
reqHeader.setHeader("Accept-language", "zh-CN,zh;q=0.9");
reqHeader.setHeader("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
final String reqUri = reqInterNme.concat("?key=").concat(userSystemConstant.getQccAppKey()).concat("&searchKey=").concat(searchKey).concat("&pageSize=6");
String tokenJson = HttpHelper.httpGet(reqUri, reqHeader.getAllHeaders());
return tokenJson;
} catch (Exception e1) {
e1.printStackTrace();
return null;
}
}
public String check2(String companyName, String creditCode){
String reqInterNme = "https://api.qichacha.com/ECITwoElVerify/GetInfo";
String status = "";
try {
HttpHead reqHeader = new HttpHead();
String[] autherHeader = RandomAuthentHeader();
reqHeader.setHeader("Token", autherHeader[0]);
reqHeader.setHeader("Timespan", autherHeader[1]);
String verifyType = "1";
final String reqUri = reqInterNme.concat("?key=").concat(userSystemConstant.getQccAppKey()).concat("&verifyName=").concat(companyName).concat("&creditCode=").concat(creditCode).concat("&verifyType=").concat(verifyType);
String tokenJson = HttpHelper.httpGet(reqUri, reqHeader.getAllHeaders());
status = FormartJson(tokenJson, "Status");
if (!HttpCodeRegex.isAbnornalRequest(status)) {
PrettyPrintJson(tokenJson);
}
return tokenJson;
} catch (Exception e1) {
e1.printStackTrace();
}
return null;
}
// public static String check3(String companyName, String creditCode, String operName){
// String reqInterNme = "https://api.qichacha.com/ECIThreeElVerify/GetInfo";
// String status = "";
// try {
// HttpHead reqHeader = new HttpHead();
// String[] autherHeader = RandomAuthentHeader();
// reqHeader.setHeader("Token", autherHeader[0]);
// reqHeader.setHeader("Timespan", autherHeader[1]);
// final String reqUri = reqInterNme.concat("?key=").concat(APP_KEY).concat("&companyName=").concat(companyName).concat("&creditCode=").concat(creditCode).concat("&operName=").concat(operName);
// String tokenJson = HttpHelper.httpGet(reqUri, reqHeader.getAllHeaders());
// status = FormartJson(tokenJson, "Status");
// if (!HttpCodeRegex.isAbnornalRequest(status)) {
// PrettyPrintJson(tokenJson);
// }
// return tokenJson;
// } catch (Exception e1) {
// e1.printStackTrace();
// }
// return null;
// }
public String businessLicenseCheck(String businessLicenseUrl){
String url = "https://bizlicense.market.alicloudapi.com/rest/160601/ocr/ocr_business_license.json";
String method = "POST";
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + userSystemConstant.getAliAppCode());
headers.put("Content-Type", "application/json; charset=UTF-8");
Map<String, String> querys = new HashMap<String, String>();
String bodys = "{\"image\":\""+businessLicenseUrl+"\"}";
try {
String response = HttpsRequestUtil.httpsRequest(url, method, headers, bodys);
//获取response的body
if(response.equals("Invalid Result - invalid business license")){
return null;
}
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 获取返回码 Res Code
*/
static class HttpCodeRegex {
private static final String ABNORMAL_REGIX = "(101)|(102)";
private static final Pattern pattern = Pattern.compile(ABNORMAL_REGIX);
protected static boolean isAbnornalRequest(final String status) {
return pattern.matcher(status).matches();
}
}
/**
* 获取Auth Code
* @return
*/
protected String[] RandomAuthentHeader() {
String timeSpan = String.valueOf(System.currentTimeMillis() / 1000);
String[] authentHeaders = new String[] { DigestUtils.md5Hex(userSystemConstant.getQccAppKey().concat(timeSpan).concat(userSystemConstant.getQccSecretKey())).toUpperCase(), timeSpan };
return authentHeaders;
}
/**
* 解析JSON
* @param jsonString
* @param key
* @return
* @throws JSONException
*/
public String FormartJson(String jsonString, String key) throws JSONException {
//JSONObject jObject = new JSONObject(jsonString);
JSONObject jsonObject = JSONObject.parseObject(jsonString);
return (String) jsonObject.get(key);
}
/**
* 解析JSON
* @param jsonString
* @return
* @throws JSONException
*/
public Integer resultFormatJson(String jsonString) throws JSONException {
//JSONObject jObject = new JSONObject(jsonString);
JSONObject jsonObject = JSONObject.parseObject(jsonString);
Object object = jsonObject.get("Result");
JSONObject result = JSONObject.parseObject(object.toString());
return (Integer) result.get("VerifyResult");
}
/**
* pretty print 返回值
* @param jsonString
* @throws JSONException
*/
protected static void PrettyPrintJson(String jsonString) throws JSONException {
try {
ObjectMapper mapper = new ObjectMapper();
Object obj = mapper.readValue(jsonString, Object.class);
String indented = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
System.out.println(indented);
} catch (JsonProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
server:
port: 35150
servlet:
context-path: /userapp
#spring
spring:
application:
name: userapp
#Database
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-wz9dd796t4j1giz6t2o.mysql.rds.aliyuncs.com:3306/iuav_cms?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8
username: tmj
password: MMC@2022&MYSQL
# Druid数据源配置
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 10 #初始化连接池大小
min-idle: 10 #最小大小
max-active: 50 #最大大小
max-wait: 60000 #获取连接时最大等待时间,单位毫秒
time-between-eviction-runs-millis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
min-evictable-idle-time-millis: 300000 #配置一个连接在池中最小生存的时间,单位是毫秒
validation-query: SELECT 1 FROM DUAL #用来检测连接是否有效的sql
test-while-idle: true #申请连接的时候检测,建议配置为true,不影响性能,并且保证安全性
testOnBorrow: false #获取连接时执行检测,建议关闭,影响性能
testOnReturn: false #归还连接时执行检测,建议关闭,影响性能
pool-prepared-statements: false #是否开启PSCache,PSCache对支持游标的数据库性能提升巨大,oracle建议开启,mysql下建议关闭
filters: stat,wall #配置扩展插件,常用的插件有=>stat:监控统计 log4j:日志 wall:防御sql注入
filter:
wall:
config:
multi-statement-allow: true
db-type: mysql
enabled: true
connection-properties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 #打开慢sql记录和延迟时间
web-stat-filter:
url-pattern: /*
exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
enabled: true
stat-view-servlet:
enabled: true
login-username: druid
login-password: druid
jackson:
date-format: yyyy-MM-dd HH:mm:ss
#mybatis
mybatis:
executor-type: simple
mapper-locations: classpath:mapper/**/*.xml
type-aliases-package: com.mmc.iuav.user.entity
configuration:
map-underscore-to-camel-case: true
wx:
sub:
appid: wx5c6a105a0ddca4c5
secret: 96c75255dd26f82f8d55e15b59e101c7
app:
id: wx18b7883acd204278
secret: 28afe74ba373830237a8133a7431ee82
miniprogram-state: trial
env-version: trial
token-path: /userservlet/wechat/getAppletUserAccessToken
port: user
third-party:
ali:
app-code: 524b1864a88f47458c1061bae3811570
qcc:
app-key: 5015e664848d406ab1ca4b505c3da803
secret-key: 7C4DB8CCECC148175E46392CC0A1B410
\ No newline at end of file
server:
port: 35150
servlet:
context-path: /userapp
#spring
spring:
application:
name: userapp
#Database
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-wz9dd796t4j1giz6t.mysql.rds.aliyuncs.com:3306/iuav_cms?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2B8
username: tmj
password: MMC@2022&MYSQL
# Druid数据源配置
type: com.alibaba.druid.pool.DruidDataSource
druid:
initial-size: 10 #初始化连接池大小
min-idle: 10 #最小大小
max-active: 50 #最大大小
max-wait: 60000 #获取连接时最大等待时间,单位毫秒
time-between-eviction-runs-millis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
min-evictable-idle-time-millis: 300000 #配置一个连接在池中最小生存的时间,单位是毫秒
validation-query: SELECT 1 FROM DUAL #用来检测连接是否有效的sql
test-while-idle: true #申请连接的时候检测,建议配置为true,不影响性能,并且保证安全性
testOnBorrow: false #获取连接时执行检测,建议关闭,影响性能
testOnReturn: false #归还连接时执行检测,建议关闭,影响性能
pool-prepared-statements: false #是否开启PSCache,PSCache对支持游标的数据库性能提升巨大,oracle建议开启,mysql下建议关闭
filters: stat,wall #配置扩展插件,常用的插件有=>stat:监控统计 log4j:日志 wall:防御sql注入
filter:
wall:
config:
multi-statement-allow: true
db-type: mysql
enabled: true
connection-properties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 #打开慢sql记录和延迟时间
web-stat-filter:
url-pattern: /*
exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
enabled: true
stat-view-servlet:
enabled: true
login-username: druid
login-password: druid
#mybatis
mybatis:
executor-type: simple
mapper-locations: classpath:mapper/**/*.xml
type-aliases-package: com.mmc.iuav.user
configuration:
map-underscore-to-camel-case: true
wx:
sub:
appid: wx5c6a105a0ddca4c5
secret: 96c75255dd26f82f8d55e15b59e101c7
app:
id: wx18b7883acd204278
secret: 28afe74ba373830237a8133a7431ee82
miniprogram-state: trial
env-version: trial
token-path: /userservlet/wechat/getAppletUserAccessToken
port: user
third-party:
ali:
app-code: 524b1864a88f47458c1061bae3811570
qcc:
app-key: 5015e664848d406ab1ca4b505c3da803
secret-key: 7C4DB8CCECC148175E46392CC0A1B410
\ No newline at end of file
spring:
profiles:
active: dev
---
spring:
profiles: dev
---
spring:
profiles: beta
---
spring:
profiles: product
\ 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.mmc.iuav.user.dao.CompanyAuthDao">
<!-- <resultMap id="companyAuthResultMAp" type="com.mmc.iuav.user.entity.CompanyAuthDO">-->
<!-- <id column="id" property="id"/>-->
<!-- <result property="authStatus" column="auth_status"/>-->
<!-- <result property="userAccountId" column="user_account_id"/>-->
<!-- <result property="companyName" column="company_name"/>-->
<!-- <result property="creditCode" column="credit_code"/>-->
<!-- <result property="licenseImg" column="license_img"/>-->
<!-- </resultMap>-->
<insert id="addCompanyAuth" parameterType="com.mmc.iuav.user.entity.CompanyAuthDO"
keyProperty="id" useGeneratedKeys="true">
insert into company_auth(user_account_id,company_name,credit_code,license_img,auth_status,create_time)
values (#{userAccountId}, #{companyName}, #{creditCode}, #{licenseImg}, #{authStatus}, NOW())
</insert>
<!-- <select id="getCompanyAuth" resultMap="companyAuthResultMAp">-->
<!-- select id,user_account_id,company_name,credit_code,license_img,auth_status-->
<!-- from company_auth where user_account_id = #{userAccountId}-->
<!-- </select>-->
<select id="getCompanyAuth" resultType="com.mmc.iuav.user.entity.CompanyAuthDO">
select id,user_account_id,company_name,credit_code,license_img,auth_status
from company_auth where user_account_id = #{userAccountId}
</select>
</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.mmc.iuav.user.dao.CooperationDao">
<insert id="addApply" parameterType="com.mmc.iuav.user.entity.UserApplyTagDO" useGeneratedKeys="true" keyProperty="id">
insert into user_apply_tag(cooperation_tag_id, user_account_id, apply_name, apply_phone, remark, create_time)
values(#{cooperationTagId}, #{userAccountId}, #{applyName}, #{applyPhone}, #{remark}, NOW())
</insert>
<update id="updateUserApplyTag" parameterType="com.mmc.iuav.user.entity.UserApplyTagDO">
UPDATE user_apply_tag
<set>
<if test="cooperationTagId != null">
cooperation_tag_id = #{cooperationTagId},
</if>
<if test="userAccountId != null">
user_account_id = #{userAccountId},
</if>
<if test="applyName != null">
apply_name = #{applyName},
</if>
<if test="applyPhone != null">
apply_phone = #{applyPhone},
</if>
<if test="applyStatus != null">
apply_status = #{applyStatus},
</if>
<if test="remark != null">
remark = #{remark},
</if>
</set>
WHERE id = #{id};
</update>
<select id="listTags" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
select id, tag_name, tag_img, tag_description, create_time from cooperation_tag
</select>
<select id="getUserApplyTag" resultType="com.mmc.iuav.user.entity.UserApplyTagDO">
select id, cooperation_tag_id, user_account_id, apply_name, apply_phone, apply_status, remark, create_time
from user_apply_tag
where user_account_id = #{userAccountId} and is_deleted = 0
</select>
</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.mmc.iuav.user.dao.UserServiceDao">
<resultMap id="userAccountResultMap" type="com.mmc.iuav.user.entity.UserAccountDO">
<id property="id" column="id"/>
<result property="accountType" column="account_type"/>
<result property="uid" column="uid"/>
<result property="phoneNum" column="phone_num"/>
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="userImg" column="user_img"/>
<result property="openId" column="open_id"/>
<result property="unionId" column="union_id"/>
<result property="userSex" column="user_sex"/>
<result property="email" column="email"/>
<result property="source" column="source"/>
<result property="accountStatus" column="account_status"/>
<result property="remark" column="remark"/>
<result property="portType" column="port_type"/>
<result property="deleted" column="is_deleted"/>
<result property="createTime" column="createTime"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<insert id="insertUserAccount" parameterType="com.mmc.iuav.user.entity.UserAccountDO"
useGeneratedKeys="true" keyProperty="id">
insert into user_account(account_type, uid, phone_num, user_name, nick_name, user_img, open_id, union_id, user_sex, email, source, remark, port_type, create_time)
values(#{accountType}, #{uid}, #{phoneNum}, #{userName}, #{nickName}, #{userImg}, #{userImg}, #{openId}, #{unionId}, #{userSex}, #{email}, #{source}, #{accountStatus},
#{remark}, #{portType}, NOW())
</insert>
<update id="update" parameterType="com.mmc.iuav.user.entity.UserAccountDO">
update user_account
<set>
<if test="phoneNum != null">
phone_num = #{phoneNum},
</if>
<if test="userName != null">
user_name = #{userName},
</if>
<if test="nickName != null">
nick_name = #{nickName},
</if>
<if test="userImg != null">
user_img = #{userImg},
</if>
<if test="userSex != null">
user_sex = #{userSex},
</if>
<if test="email != null">
email = #{email},
</if>
<if test="accountStatus != null">
account_status = #{accountStatus},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="portType != null">
port_type = #{portType}
</if>
</set>
<where>
id = #{id}
</where>
</update>
<select id="getUserAccountInfoByUnionId" resultType="com.mmc.iuav.user.entity.UserAccountDO">
select id, account_type, uid, phone_num, user_name, nick_name, user_img, open_id, union_id, user_sex, email, source, account_status, remark,
port_type, is_deleted, create_time, update_time
from user_account
where union_id = #{unionId} and is_deleted = 0
</select>
<select id="getUserAccountById" resultType="com.mmc.iuav.user.entity.UserAccountDO">
select id, account_type, uid, phone_num, user_name, nick_name, user_img, open_id, union_id, user_sex, email, source, account_status, remark,
port_type, is_deleted, create_time, update_time
from user_account
where id = #{id}
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>iuav-cms</artifactId>
<groupId>com.mmc.iuav.cms</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>csm-service</artifactId>
<packaging>pom</packaging>
<modules>
<module>cms-service-user</module>
</modules>
</project>
\ No newline at end of file
# application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: cms-application
namespace: argocd
spec:
project: default # 项目名
source:
repoURL: http://git.mmcuav.cn/iuav/cms.git
targetRevision: HEAD #develop master # 分支名
path: kustomization/overlays/dev # 资源文件路径
destination:
server: https://kubernetes.default.svc # API Server 地址
namespace: dev # 部署应用的命名空间
# 默认情况下每 3 分钟会检测 Git 仓库一次
syncPolicy:
syncOptions:
- CreateNamespace=true
automated:
selfHeal: true
prune: true
apiVersion: v1
kind: ConfigMap
metadata:
name: cms-map
namespace: default
data:
SPRING_PROFILES_ACTIVE: default
apiVersion: apps/v1
kind: Deployment
metadata:
name: cms-deployment
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: cms
template:
metadata:
labels:
app: cms
spec:
containers:
- name: cms
image: REGISTRY/NAMESPACE/IMAGE:TAG
resources:
limits:
memory: 1024Mi
cpu: 100m
ports:
- containerPort: 35150
env:
- name: SPRING_PROFILES_ACTIVE
valueFrom:
configMapKeyRef:
name: cms-map
key: SPRING_PROFILES_ACTIVE
\ No newline at end of file
#apiVersion: extensions/v1beta1
#kind: Ingress
#metadata:
# name: pms-ingress
# namespace: default
#spec:
# rules:
# - host: infra.mmcuav.cn
# http:
# paths:
# - backend:
# serviceName: pms-svc
# servicePort: 8081
# path: /
\ No newline at end of file
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
app: cms
resources:
- ./deployment.yaml
- ./service.yaml
- ./configMap.yaml
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: cms-svc
namespace: default
spec:
selector:
app: cms
type: NodePort
ports:
- protocol: TCP
port: 35150
\ No newline at end of file
apiVersion: v1
kind: ConfigMap
metadata:
name: cms-map
data:
SPRING_PROFILES_ACTIVE: dev
\ No newline at end of file
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
#namePrefix: dev-
namespace: dev
commonLabels:
variant: dev
commonAnnotations:
note: This is dev!
patches:
- path: ./configMap.yaml
- path: ./service.yaml
images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly/cms
newTag: fc56802f1c384f63e37ae47db73f8fe81f17073b
apiVersion: v1
kind: Service
metadata:
name: cms-svc
namespace: dev
spec:
selector:
app: cms
type: NodePort
ports:
- protocol: TCP
port: 35150
nodePort: 30150
\ No newline at end of file
apiVersion: v1
kind: ConfigMap
metadata:
name: cms-map
data:
SPRING_PROFILES_ACTIVE: prod
\ No newline at end of file
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: prod
#namePrefix: prod-
commonLabels:
variant: prod
commonAnnotations:
note: This is prod!
patches:
- configMap.yaml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mmc.iuav.cms</groupId>
<artifactId>iuav-cms</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>cms-common</module>
<module>csm-service</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath />
</parent>
<properties>
<spring-cloud.version>Hoxton.SR6</spring-cloud.version>
<springfox.version>2.9.2</springfox.version>
<spring-cloud-alibaba-seata.version>2.2.1.RELEASE</spring-cloud-alibaba-seata.version>
<seata.version>1.1.0</seata.version>
</properties>
<dependencies>
<!-- lombok 工具通过在代码编译时期动态的将注解替换为具体的代码, IDEA 需要添加 lombok 插件 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.29</version>
</dependency>
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<!-- 引入swagger-bootstrap-ui包 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${springfox.version}</version>
</dependency>
<!--logback 日志 -->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.3</version>
</dependency>
</dependencies>
<!-- 标识 SpringCloud 的版本 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
<version>${spring-cloud-alibaba-seata.version}</version>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<version>${seata.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.13.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- 配置远程仓库 -->
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论