Commit 4dfa9645 by 崔彦峰

svn to git

0 parents
Showing 72 changed files with 6806 additions and 0 deletions
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
\ No newline at end of file \ No newline at end of file
File mode changed
<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>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rpc</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx</groupId>
<artifactId>wechat-build-server</artifactId>
<version>1.0-SNAPSHOT</version>
<name>wechat-build-server</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>rpc-scrm-wechat-api</artifactId>
<version>4.55.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.18.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.wechatbuild.Constants.oa;
/**
* @Description
* @author chizw
* @create 2025/2/13 16:36
* @version ver.1.0.0
*/
public interface WorkWechatMediaConstants {
/**
* 上传临时素材
*/
public final static String MEDIA_UPLOAD_PATH = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type={1}";
/**
* 获取临时素材
*/
public final static String MEDIA_GET_PATH = "https://qyapi.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}";
}
package cn.com.glsx.wechatbuild.Constants.oa;
/**
* @Description
* @author chizw
* @create 2025/2/13 16:36
* @version ver.1.0.0
*/
public interface WorkWechatOAConstants {
/**
* 获取审批模板详情
*/
public final static String OA_GET_TEMPLATE_DETAIL_PATH = "https://qyapi.weixin.qq.com/cgi-bin/oa/gettemplatedetail?access_token={0}";
/**
* 提交审批申请
*/
public final static String OA_APPLY_EVENT_PATH = "https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token={0}";
/**
* 获取审批申请详情
*/
public final static String OA_GET_APPROVAL_DETAIL_PATH = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail?access_token={0}";
/**
* 手机号获取userid
*/
public final static String GET_USERID_PATH = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token={0}";
/**
* 发送应用消息
* POST https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN
*/
String WW_SEND_MESSAGE_PATH = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}";
/**
* 读取成员GET
*/
public final static String WW_GET_USER_PATH = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={0}&userid={1}";
/**
* 批量获取审批单号
* POST https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovalinfo?access_token=ACCESS_TOKEN
*/
String WW_GETAPPROVALINFO_PATH = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovalinfo?access_token={0}";
/**
* 获取单个部门详情
*
*/
String WW_GET_DEPARTMENT_INFO_PATH = "https://qyapi.weixin.qq.com/cgi-bin/department/get?access_token={0}&id={1}";
}
package cn.com.glsx.wechatbuild;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* @Title: Main.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.wechatbuild.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: SystemProperty.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Configuration
@ConfigurationProperties("system")
public class SystemProperty {
// 对应配置项:system.name
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.wechatbuild.config;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
//@Component
public class SystemPropertyRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
System.setProperty("https.protocols", "TLSv1.2,TLSv1.3");
}
}
package cn.com.glsx.wechatbuild.config;
import java.text.MessageFormat;
/**
* 微信api通用配置类
* @Title WechatApiUrlConfig
* @Description:
* @author Suro
* @date 2021/7/21 13:59
* @version V1.0
* @Company:didihu.com.cn
**/
public class WechatApiUrlConfig {
/**
* 获取格式化后的api链接
* @param templateApi api链接模板
* @param params
* @return
* @author zengqi
* @date 2021年9月15日 下午7:29:45
*/
public static String getApi(String templateApi, Object...params){
return MessageFormat.format(templateApi, params);
}
}
package cn.com.glsx.wechatbuild.controller;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.wechatbuild.manager.WorkWechatContactUserCheckInManager;
import cn.com.glsx.wechatbuild.manager.WorkWechatUserManager;
import cn.com.glsx.wechatbuild.model.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/wechat")
public class WechatController {
@Autowired
private WorkWechatContactUserCheckInManager workWechatContactUserCheckInManager;
@Autowired
private WorkWechatUserManager workWechatUserManager;
@PostMapping("/getUserCheckInDayData")
public WorkWechatUserCheckInDayDataResponseDTO getUserCheckInDayData(@RequestBody GetWorkWechatUserCheckInDayDataRequestDTO requestBody) {
WorkWechatUserCheckInDayDataResponseDTO workWechatUserCheckInDayDataResponseDTO=new WorkWechatUserCheckInDayDataResponseDTO();
try {
workWechatUserCheckInDayDataResponseDTO = workWechatContactUserCheckInManager.getUserCheckInDayData(
requestBody);
}catch(RpcServiceException e){
ErrorEnum error = e.getError();
workWechatUserCheckInDayDataResponseDTO.setErrCode(Integer.valueOf(error.getValue()));
workWechatUserCheckInDayDataResponseDTO.setErrMsg(error.getDisplayName());
}
return workWechatUserCheckInDayDataResponseDTO;
}
@PostMapping("/getUserCheckInData")
public WorkWechatUserCheckInDataResponseDTO getUserCheckInData(@RequestBody GetWorkWechatUserCheckInDataRequestDTO requestBody) {
WorkWechatUserCheckInDataResponseDTO workWechatUserCheckInDayDataResponseDTO=new WorkWechatUserCheckInDataResponseDTO();
try {
workWechatUserCheckInDayDataResponseDTO = workWechatContactUserCheckInManager.getUserCheckInData(
requestBody);
}catch(RpcServiceException e){
ErrorEnum error = e.getError();
workWechatUserCheckInDayDataResponseDTO.setErrCode(Integer.valueOf(error.getValue()));
workWechatUserCheckInDayDataResponseDTO.setErrMsg(error.getDisplayName());
}
return workWechatUserCheckInDayDataResponseDTO;
}
@PostMapping("/getUserInfo")
public WorkWechatUserInfoResponseDTO getUserInfo(@RequestBody GetWorkWechatUserRequestDTO requestBody) {
WorkWechatUserInfoResponseDTO responseDTO = new WorkWechatUserInfoResponseDTO();
try {
responseDTO = workWechatUserManager.getUserInfo(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
responseDTO.setErrCode(Integer.valueOf(error.getValue()));
responseDTO.setErrMsg(e.getMessage());
}
return responseDTO;
}
}
package cn.com.glsx.wechatbuild.controller;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.department.request.GetWorkWechatDepartmentListRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.department.response.WorkWechatDepartmentListResponseDTO;
import cn.com.glsx.wechatbuild.manager.WorkWechatDepartmentManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/wechat/department/")
public class WorkWechatDepartmentController {
@Autowired
private WorkWechatDepartmentManager workWechatDepartmentManager;
@PostMapping("/get")
public WorkWechatDepartmentListResponseDTO departmentInfo(@RequestBody GetWorkWechatDepartmentListRequestDTO departmentInfoRequestDTO) {
WorkWechatDepartmentListResponseDTO dto = new WorkWechatDepartmentListResponseDTO();
try {
dto = workWechatDepartmentManager.departmentInfo(departmentInfoRequestDTO);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
}
package cn.com.glsx.wechatbuild.controller;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.media.response.GetWorkWechatMediaResponseDTO;
import cn.com.glsx.scrm.wechat.enums.WechatErrorEnum;
import cn.com.glsx.wechatbuild.manager.WorkWechatMediaManager;
import cn.com.glsx.wechatbuild.model.request.oa.*;
import cn.com.glsx.wechatbuild.model.response.oa.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Objects;
@Slf4j
@RestController
@RequestMapping("/wechat/media/")
public class WorkWechatMediaController {
@Autowired
private WorkWechatMediaManager workWechatMediaManager;
@PostMapping("uploadMediaUrl")
public UploadWorkWechatMediaResponseDTO uploadMediaUrl(@RequestBody UploadWorkWechatMediaRequestDTO requestBody) {
UploadWorkWechatMediaResponseDTO dto = new UploadWorkWechatMediaResponseDTO();
try {
String fileUrl = requestBody.getFileUrl();
requestBody.setData(downloadFileToBytes(fileUrl));
dto = workWechatMediaManager.uploadMedia(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
} catch (Exception e) {
throw new RuntimeException(e);
}
return dto;
}
@PostMapping("uploadMedia")
public UploadWorkWechatMediaResponseDTO uploadMedia(@RequestBody UploadWorkWechatMediaRequestDTO requestBody) {
UploadWorkWechatMediaResponseDTO dto = new UploadWorkWechatMediaResponseDTO();
try {
dto = workWechatMediaManager.uploadMedia(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
@PostMapping("getMedia")
public GetWorkWechatMediaResponseDTO getMedia(@RequestBody GetWorkWechatMediaRequestDTO requestBody) {
GetWorkWechatMediaResponseDTO dto = new GetWorkWechatMediaResponseDTO();
try {
dto = workWechatMediaManager.getMedia(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
/**
* 自动上传oss,返回文件url
*
* @param requestBody
* @return
*/
@PostMapping("getMediaUrl")
public GetWorkWechatMediaResponseDTO getMediaUrl(@RequestBody cn.com.glsx.scrm.wechat.dto.workwechat.media.request.GetWorkWechatMediaRequestDTO requestBody) {
GetWorkWechatMediaResponseDTO dto = new GetWorkWechatMediaResponseDTO();
Integer merchantId = requestBody.getMerchantId();
String mediaId = requestBody.getMediaId();
String endpoint = requestBody.getEndpoint();
String bucketName = requestBody.getBucketName();
String accessKeyId = requestBody.getAccessKeyId();
String accessKeySecret = requestBody.getAccessKeySecret();
if (Objects.isNull(merchantId) || StringUtils.isAnyBlank(mediaId, endpoint, bucketName, accessKeyId, accessKeySecret)) {
log.info("参数错误,请检查:merchantId、mediaId, endpoint, bucketName, accessKeyId, accessKeySecret 都不能为空");
dto.setErrCode(Integer.valueOf(WechatErrorEnum.PARAMETER_NULL.getValue()));
dto.setErrMsg(WechatErrorEnum.PARAMETER_NULL.getDisplayName());
return dto;
}
try {
dto = workWechatMediaManager.getMediaUrl(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
public static byte[] downloadFileToBytes(String fileUrl) throws Exception {
URL url = new URL(fileUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置请求方法和超时
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000); // 连接超时
connection.setReadTimeout(10000); // 读取超时
// 检查 HTTP 响应码
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("HTTP request failed with code: " + responseCode);
}
// 读取输入流为 byte[]
try (InputStream inputStream = connection.getInputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
return outputStream.toByteArray();
}
}
}
package cn.com.glsx.wechatbuild.controller;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO;
import cn.com.glsx.wechatbuild.manager.WorkWechatMessageManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/wechat/message/")
public class WorkWechatMessageController {
@Autowired
private WorkWechatMessageManager workWechatMessageManager;
@PostMapping("sendMessage")
public SendWorkWechatMessageResponseDTO sendMessage(@RequestBody SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
SendWorkWechatMessageResponseDTO dto = new SendWorkWechatMessageResponseDTO();
try {
dto = workWechatMessageManager.sendMessage(sendWorkWechatMessageRequestDTO);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
}
package cn.com.glsx.wechatbuild.controller;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.wechatbuild.manager.WorkWechatContactUserCheckInManager;
import cn.com.glsx.wechatbuild.manager.WorkWechatOAManager;
import cn.com.glsx.wechatbuild.model.GetWorkWechatUserCheckInDataRequestDTO;
import cn.com.glsx.wechatbuild.model.GetWorkWechatUserCheckInDayDataRequestDTO;
import cn.com.glsx.wechatbuild.model.WorkWechatUserCheckInDataResponseDTO;
import cn.com.glsx.wechatbuild.model.WorkWechatUserCheckInDayDataResponseDTO;
import cn.com.glsx.wechatbuild.model.request.oa.*;
import cn.com.glsx.wechatbuild.model.request.oa.approval.GetWorkWechatApprovalInfoRequestDTO;
import cn.com.glsx.wechatbuild.model.response.oa.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/wechat/oa/")
public class WorkWechatOAController {
@Autowired
private WorkWechatOAManager workWechatOAManager;
@PostMapping("getTemplateDetail")
public WorkWechatOAGetTemplateDetailResponseDTO getTemplateDetail(@RequestBody WorkWechatOAGetTemplateDetailRequestDTO requestBody) {
WorkWechatOAGetTemplateDetailResponseDTO dto = new WorkWechatOAGetTemplateDetailResponseDTO();
try {
dto = workWechatOAManager.getTemplateDetail(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
@PostMapping("applyEvent")
public WorkWechatOAApplyEventResponseDTO getTemplateDetail(@RequestBody WorkWechatOAApplyEventRequestDTO requestBody) {
WorkWechatOAApplyEventResponseDTO dto = new WorkWechatOAApplyEventResponseDTO();
try {
dto = workWechatOAManager.applyEvent(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
@PostMapping("getApprovalDetail")
public WorkWechatOAGetApprovalDetailResponseDTO getApprovalDetail(@RequestBody WorkWechatOAGetApprovalDetailRequestDTO requestBody) {
WorkWechatOAGetApprovalDetailResponseDTO dto = new WorkWechatOAGetApprovalDetailResponseDTO();
try {
dto = workWechatOAManager.getApprovalDetail(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
@PostMapping("getuserid")
public UploadWorkUserGetuseridResponseDTO getuserid(@RequestBody WorkWechatUserGetuseridRequestDTO requestBody) {
UploadWorkUserGetuseridResponseDTO dto = new UploadWorkUserGetuseridResponseDTO();
try {
dto = workWechatOAManager.getuserid(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
@PostMapping("getapprovalinfo")
public WorkWechatOAApprovalInfoResponseDTO getapprovalinfo(@RequestBody GetWorkWechatApprovalInfoRequestDTO getWorkWechatApprovalInfoRequestDTO) {
WorkWechatOAApprovalInfoResponseDTO dto = new WorkWechatOAApprovalInfoResponseDTO();
try {
dto = workWechatOAManager.getapprovalinfo(getWorkWechatApprovalInfoRequestDTO);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
@PostMapping("getApprovalDetailsingle")
public WorkWechatOAGetApprovalDetailSingleResponseDTO getApprovalDetailSingle(@RequestBody WorkWechatOAGetApprovalDetailRequestDTO requestBody) {
WorkWechatOAGetApprovalDetailSingleResponseDTO dto = new WorkWechatOAGetApprovalDetailSingleResponseDTO();
try {
dto = workWechatOAManager.getApprovalDetailSingle(requestBody);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
}
package cn.com.glsx.wechatbuild.controller;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.user.request.GetWorkWechatUserRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.user.response.WorkWechatUserResponseDTO;
import cn.com.glsx.wechatbuild.manager.WorkWechatUserManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/wechat/user/")
public class WorkWechatUserController {
@Autowired
private WorkWechatUserManager workWechatUserManager;
@PostMapping("userInfo")
public WorkWechatUserResponseDTO userInfo(@RequestBody GetWorkWechatUserRequestDTO getWorkWechatUserRequestDTO) {
WorkWechatUserResponseDTO dto = new WorkWechatUserResponseDTO();
try {
dto = workWechatUserManager.getUser(getWorkWechatUserRequestDTO);
} catch (RpcServiceException e) {
ErrorEnum error = e.getError();
dto.setErrCode(Integer.valueOf(error.getValue()));
dto.setErrMsg(error.getDisplayName());
}
return dto;
}
}
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.wechatbuild.model.*;
import cn.com.glsx.wechatbuild.util.CacheUtil;
import cn.com.glsx.wechatbuild.util.HttpUtils;
import com.alibaba.fastjson.JSONObject;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.oreframework.util.http.HttpUtil;
import org.oreframework.util.json.JacksonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class TokenManager {
private static final String GET_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=YOUR_CORP_ID&corpsecret=YOUR_CORP_SECRET";
@Autowired
private Environment environment;
private final String WORK_WECHAT_ACCESS_TOKEN = "SCRM_WORK_WECHAT_ACCESS_TOKEN";
@Autowired
private RedisTemplate<String, Object> redisTemplate;
public String getAccessToken(WorkWechatBaseRequestDTO workWechatBaseRequestDTO) {
String url = getUrl(workWechatBaseRequestDTO);
// 授权方接口调用凭据(有效期2小时)
Object accessToken = redisTemplate.opsForValue().get(
CacheUtil.getCacheKey(WORK_WECHAT_ACCESS_TOKEN, workWechatBaseRequestDTO.getCorpId(),
workWechatBaseRequestDTO.getCorpSecret()));
if (accessToken != null) {
return accessToken.toString();
}
try {
log.info("get work wechat access token request url:{}", url);
String response = HttpUtil.get(url, null);
log.info("get work wechat access token response:{}", response);
// 解析json获取access_token
JSONObject object = JSONObject.parseObject(response);
Integer errcode = object.getInteger("errcode");
if (errcode != null && errcode != 0) {
throw new RpcServiceException(errcode + "", object.getString("errmsg"));
}
accessToken = object.getString("access_token");
int expiresIn = object.getIntValue("expires_in");
// 授权方接口调用凭据(有效期2小时)
redisTemplate.opsForValue().set(
CacheUtil.getCacheKey(WORK_WECHAT_ACCESS_TOKEN, workWechatBaseRequestDTO.getCorpId(),
workWechatBaseRequestDTO.getCorpSecret()), accessToken, expiresIn - 600,
TimeUnit.SECONDS);
return accessToken.toString();
// 处理响应内容,例如解析access_token
} catch (IOException e) {
log.error("get work wechat access token error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
private String getUrl(WorkWechatBaseRequestDTO workWechatBaseRequestDTO) {
String corp_id = null;
String your_corp_secret = null;
Integer merchantId = workWechatBaseRequestDTO.getMerchantId();
String property = environment.getProperty("corpid.config");
if (StringUtils.isNotEmpty(property)) {
List<Map> maps = JSONObject.parseArray(property, Map.class);
for (Map map : maps) {
Integer o = Integer.parseInt(map.get("merchant_id") + "");
if (merchantId.intValue() == o.intValue()) {
corp_id = map.get("corp_id") + "";
your_corp_secret = map.get("corp_secret") + "";
workWechatBaseRequestDTO.setCorpId(corp_id);
workWechatBaseRequestDTO.setCorpSecret(your_corp_secret);
}
}
}
return GET_TOKEN_URL.replace("YOUR_CORP_ID", corp_id)
.replace("YOUR_CORP_SECRET", your_corp_secret);
}
private String getUrl(WechatTokenBaseRequestDTO request) {
String corp_id = null;
String your_corp_secret = null;
String agentId = request.getAgentId();
String property = environment.getProperty("base.corpid.config");
if (StringUtils.isNotEmpty(property)) {
List<Map> maps = JSONObject.parseArray(property, Map.class);
for (Map map : maps) {
String configAgentId = map.get("agent_id") + "";
if (agentId.equals(configAgentId)) {
corp_id = map.get("corp_id") + "";
your_corp_secret = map.get("corp_secret") + "";
request.setCorpId(corp_id);
request.setCorpSecret(your_corp_secret);
}
}
}
if (StringUtils.isEmpty(corp_id) || StringUtils.isEmpty(your_corp_secret)) {
throw new RpcServiceException(WechatErrorEnum.SERVICE_ERROR, "未找微信到配置");
}
return GET_TOKEN_URL.replace("YOUR_CORP_ID", corp_id)
.replace("YOUR_CORP_SECRET", your_corp_secret);
}
public String getAccessToken(WechatTokenBaseRequestDTO request) {
String url = getUrl(request);
// 授权方接口调用凭据(有效期2小时)
Object accessToken = redisTemplate.opsForValue().get(
CacheUtil.getCacheKey(WORK_WECHAT_ACCESS_TOKEN, request.getCorpId(),
request.getCorpSecret()));
if (accessToken != null) {
return accessToken.toString();
}
try {
log.info("get work wechat access token request url:{}", url);
String response = HttpUtils.get(url);
log.info("get work wechat access token response:{}", response);
// 解析json获取access_token
JSONObject object = JSONObject.parseObject(response);
Integer errcode = object.getInteger("errcode");
if (errcode != null && errcode != 0) {
throw new RpcServiceException(errcode + "", object.getString("errmsg"));
}
accessToken = object.getString("access_token");
int expiresIn = object.getIntValue("expires_in");
// 授权方接口调用凭据(有效期2小时)
redisTemplate.opsForValue().set(
CacheUtil.getCacheKey(WORK_WECHAT_ACCESS_TOKEN, request.getCorpId(),
request.getCorpSecret()), accessToken, expiresIn - 600,
TimeUnit.SECONDS);
return accessToken.toString();
// 处理响应内容,例如解析access_token
} catch (IOException e) {
log.error("get work wechat access token io error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVICE_ERROR, e.getMessage());
} catch (Exception e) {
log.error("get work wechat access token system error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
}
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.wechatbuild.config.WechatApiUrlConfig;
import cn.com.glsx.wechatbuild.model.BaseResponseDTO;
import cn.com.glsx.wechatbuild.model.GetWorkWechatUserCheckInDataRequestDTO;
import cn.com.glsx.wechatbuild.model.GetWorkWechatUserCheckInDayDataRequestDTO;
import cn.com.glsx.wechatbuild.model.WechatErrorEnum;
import cn.com.glsx.wechatbuild.model.WorkWechatUserCheckInDataResponseDTO;
import cn.com.glsx.wechatbuild.model.WorkWechatUserCheckInDayDataResponseDTO;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.rpc.RpcException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.oreframework.util.http.HttpUtil;
import org.oreframework.util.json.JacksonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author yelq
* @version V1.0
* @Title: WorkWechatContactUserCheckInManager.java
* @Description: 打卡
* @date 2024年4月9日20点27分
*/
@Component
@Slf4j
public class WorkWechatContactUserCheckInManager {
@Autowired
private TokenManager tokenManager;
/**
* 获取打卡日报数据
*
* @param request
* @return
* @author yelq
* @date 024年4月9日20点27分
*/
public WorkWechatUserCheckInDayDataResponseDTO getUserCheckInDayData(
GetWorkWechatUserCheckInDayDataRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(
WorkWechatUserCheckInApiConstants.GET_CHECK_IN_DAY_DATA_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("get work wechat user check in day data request url:{},body:{}", url, body);
String response = HttpUtil.post(url, body);
log.info("get work wechat user check in day data response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatUserCheckInDayDataResponseDTO.class);
} catch (IOException e) {
log.error("get work wechat user check in day data error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR,e.getMessage());
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(),e.getMessage());
}
}
public WorkWechatUserCheckInDataResponseDTO getUserCheckInData(
GetWorkWechatUserCheckInDataRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(
WorkWechatUserCheckInApiConstants.GET_CHECK_IN_DATA_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("get work wechat user check in data request url:{},body:{}", url, body);
String response = HttpUtil.post(url, body);
log.info("get work wechat user check in data response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatUserCheckInDataResponseDTO.class);
} catch (IOException e) {
log.error("get work wechat user check in data error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR,e.getMessage());
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(),e.getMessage());
}
}
}
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.department.request.GetWorkWechatDepartmentListRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.department.response.WorkWechatDepartmentListResponseDTO;
import cn.com.glsx.wechatbuild.Constants.oa.WorkWechatOAConstants;
import cn.com.glsx.wechatbuild.config.WechatApiUrlConfig;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import cn.com.glsx.wechatbuild.util.HttpUtils;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class WorkWechatDepartmentManager {
@Autowired
private TokenManager tokenManager;
/**
* 获取单个部门详情
*
* @param request
* @return
*/
public WorkWechatDepartmentListResponseDTO departmentInfo(GetWorkWechatDepartmentListRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatOAConstants.WW_GET_DEPARTMENT_INFO_PATH, tokenManager.getAccessToken(new WorkWechatBaseRequestDTO(request.getMerchantId())), request.getId());
log.info("get work wechat department request url:{}", url);
String response = HttpUtils.get(url);
log.info("get work wechat department response:{}", response);
return JSON.parseObject(response, WorkWechatDepartmentListResponseDTO.class);
} catch (Exception e) {
log.error("get work wechat department error:{}", e.getMessage(), e);
throw new RpcServiceException(cn.com.glsx.scrm.wechat.enums.WechatErrorEnum.GET_WORK_WECHAT_DEPARTMENT_FAILED, e);
}
}
}
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.media.response.GetWorkWechatMediaResponseDTO;
import cn.com.glsx.scrm.wechat.enums.WorkWechatMediaTypeEnum;
import cn.com.glsx.wechatbuild.Constants.oa.WorkWechatMediaConstants;
import cn.com.glsx.wechatbuild.config.WechatApiUrlConfig;
import cn.com.glsx.wechatbuild.model.WechatErrorEnum;
import cn.com.glsx.wechatbuild.model.request.oa.*;
import cn.com.glsx.wechatbuild.model.response.oa.*;
import cn.com.glsx.wechatbuild.service.FileUploadService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.util.json.JacksonUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.Objects;
import java.util.UUID;
/**
* @author chizw
* @version ver.1.0.0
* @Description
* @create 2025/2/13 16:32
*/
@Component
@Slf4j
public class WorkWechatMediaManager {
@Autowired
private TokenManager tokenManager;
@Autowired
private FileUploadService fileUploadService;
private static final int BUFFER_SIZE = 1024 * 1024;
/**
* @Description 上传临时素材
* @author chizw
* @create 2025/2/17 16:10
* @version ver.1.0.0
*/
public UploadWorkWechatMediaResponseDTO uploadMedia(UploadWorkWechatMediaRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatMediaConstants.MEDIA_UPLOAD_PATH,
tokenManager.getAccessToken(request), request.getMediaType().getValue());
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
File file = null;
long l = System.currentTimeMillis();
if (WorkWechatMediaTypeEnum.FILE.equals(request.getMediaType())) {
// file = byteArrayToFileNew(request.getData(), request.getFileName().substring(request.getFileName().indexOf("-") + 1));
file = streamToFile(request.getData(), request.getFileName().substring(request.getFileName().indexOf("-") + 1));
}else {
file = bytesToFile(request.getData(), request.getFileName().substring(request.getFileName().indexOf(".") + 1));
}
log.info("文件转换处理时长:{}", System.currentTimeMillis() - l);
FileSystemResource fileSystemResource = new FileSystemResource(file);
MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
form.add("file", fileSystemResource);
form.add("filename", request.getFileName());
HttpEntity<MultiValueMap<String, Object>> files = new HttpEntity<>(form, headers);
log.info("work wechat uploadMedia request url:{},files:{}", url, files);
String response = restTemplate.postForObject(url, files, String.class);
log.info("work wechat uploadMedia response:{}", response);
return JacksonUtils.jsonCastBean(response, UploadWorkWechatMediaResponseDTO.class);
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(), e.getMessage());
} catch (Exception e) {
log.error("work wechat uploadMedia error:{}", e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
/**
* 获取附件地址(文件oss地址)
*
* @param request
* @return
*/
public GetWorkWechatMediaResponseDTO getMediaUrl(cn.com.glsx.scrm.wechat.dto.workwechat.media.request.GetWorkWechatMediaRequestDTO request){
GetWorkWechatMediaRequestDTO qwFileDataRequest = new GetWorkWechatMediaRequestDTO();
BeanUtils.copyProperties(request, qwFileDataRequest);
GetWorkWechatMediaResponseDTO media = this.getMedia(qwFileDataRequest);
if (Objects.isNull(media) || !media.isSuccess()) {
log.error("获取附件mediaId:{} 异常", qwFileDataRequest.getMediaId());
throw new RpcServiceException(cn.com.glsx.scrm.wechat.enums.WechatErrorEnum.GET_WORK_WECHAT_MEDIA_FAILED, "获取附件失败 mediaId:" + qwFileDataRequest.getMediaId());
}
String fileSizeStr = cn.com.glsx.wechatbuild.util.FileUtils.formatFileSize(media.getFileData());
media.setFileSizeStr(fileSizeStr);
String fileUrl = uploadMediaToOSS(media, request);
media.setFileUrl(fileUrl);
media.setFileData(null);
return media;
}
/**
* 上传附件到oss
*
* @param media
* @param request
* @return
*/
public String uploadMediaToOSS(GetWorkWechatMediaResponseDTO media, cn.com.glsx.scrm.wechat.dto.workwechat.media.request.GetWorkWechatMediaRequestDTO request) {
String fileName = media.getFileName();
byte[] fileData = media.getFileData();
InputStream inputStream = new ByteArrayInputStream(fileData);
String objectName = UUID.randomUUID().toString() + "_" + fileName;
String objectNameCustom = request.getObjectName();
if (StringUtils.isNotBlank(objectNameCustom)) {
objectName = objectNameCustom;
}
return fileUploadService.uploadFileInputStreamToOss(inputStream, objectName, request.getEndpoint(), request.getBucketName(), request.getAccessKeyId(), request.getAccessKeySecret());
}
public GetWorkWechatMediaResponseDTO getMedia(GetWorkWechatMediaRequestDTO request){
try{
String url = WechatApiUrlConfig.getApi(WorkWechatMediaConstants.MEDIA_GET_PATH,
tokenManager.getAccessToken(request), request.getMediaId());
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
log.info("get media url:{}", url);
ResponseEntity<byte[]> entity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(headers), byte[].class);
byte[] body = entity.getBody();
log.info("get media response:{}", entity);
if(HttpStatus.OK.equals(entity.getStatusCode()) && !entity.getHeaders().containsKey("error-code")){
GetWorkWechatMediaResponseDTO response = new GetWorkWechatMediaResponseDTO();
response.setFileData(body);
String contentDispositionHeader = entity.getHeaders().getFirst(HttpHeaders.CONTENT_DISPOSITION);
log.info("contentDispositionHeader:{}", contentDispositionHeader);
String fileName = extractFileName(contentDispositionHeader);
log.info("fileName:{}", fileName);
response.setFileName(fileName);
response.setFileSize(entity.getHeaders().getContentLength());
response.setMediaType(WorkWechatMediaTypeEnum.get(entity.getHeaders().getContentType().getType()));
return response;
}else{
return JacksonUtils.jsonCastBean(new String(body), GetWorkWechatMediaResponseDTO.class);
}
}catch(Exception e){
log.error("get media error:{}", e.getMessage(), e);
throw new RpcServiceException(cn.com.glsx.scrm.wechat.enums.WechatErrorEnum.UPLOAD_WORK_WECHAT_MEDIA_FAILED, e);
}
}
private String extractFileName(String contentDispositionHeader) {
if (StringUtils.isBlank(contentDispositionHeader)) return null;
String contentDispositionField = null;
String[] split = contentDispositionHeader.split(";");
for (String field : split) {
if (field.contains("filename*=")) {
contentDispositionField = field.trim();
}
}
if (StringUtils.isBlank(contentDispositionField)) {
for (String field : split) {
if (field.contains("filename=")) {
contentDispositionField = field.trim();
}
}
}
if (StringUtils.isBlank(contentDispositionField)) return null;
try {
// 优先 filename*= 形式
if (contentDispositionField.contains("filename*=")) {
String encoded = contentDispositionField.split("filename\\*=")[1].trim();
if (encoded.contains("''")) {
encoded = encoded.substring(encoded.indexOf("''") + 2);
return URLDecoder.decode(encoded, StandardCharsets.UTF_8.name());
}
} else if (contentDispositionField.contains("filename=")) {
String filename = contentDispositionField.split("filename=")[1].trim();
return filename.replaceAll("\"", "");
}
} catch (Exception e) {
log.error("extractFileName error:{}", e.getMessage(), e);
}
return null;
}
/**
* 按文件名生成文件(后期如果企微支持会话中展示自定义fileName时候,可不用这个方法)
* @param bytes
* @param fileName
* @return
* @throws IOException
*/
public static File byteArrayToFile(byte[] bytes, String fileName) throws IOException {
File tempFile = Files.createTempDirectory("tempFile").toFile();
String filePath = tempFile.getPath() + "/" + UUID.randomUUID().toString();
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
try {
file = new File(filePath + "/" + fileName);
//虚拟机结束后删除临时文件
file.deleteOnExit();
if (!file.getParentFile().exists()){
//文件夹不存在 生成
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(bytes);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bos != null) {
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return file;
}
private File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException {
File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile);
resultFile.deleteOnExit();
FileUtils.copyInputStreamToFile(inputStream, resultFile);
return resultFile;
}
private File bytesToFile(byte[] bytes, String fileType) throws IOException {
return createTmpFile(new ByteArrayInputStream(bytes),
UUID.randomUUID().toString(),
fileType,
Files.createTempDirectory("tempFile").toFile());
}
public static void main(String[] args) throws IOException {
String filePath = "D:\\360MoveData\\Users\\chizw\\Desktop\\【业财一体化】V1.3.0-待付清单(付款单)&OA审批节点&退款回单&账户余额&到账伴侣通知功能-0610-PRD.docx";
byte[] bytes = Files.readAllBytes(Paths.get(filePath));
byteArrayToFile(bytes, "test.txt");
long l = System.currentTimeMillis();
File file = byteArrayToFile(bytes, "test.txt");
long l1 = System.currentTimeMillis();
System.out.println(l1 - l);
File file2 = byteArrayToFileNew(bytes, "test.txt");
long l2 = System.currentTimeMillis();
System.out.println(l2 - l1);
File file3 = streamToFile(bytes, "test.txt");
System.out.println(System.currentTimeMillis() - l2);
}
public static File byteArrayToFileNew(byte[] bytes, String fileName) throws IOException {
if (fileName == null || fileName.trim().isEmpty()) {
throw new IllegalArgumentException("File name cannot be null or empty.");
}
Path tempDirPath = Files.createTempDirectory("tempFile");
File tempDir = tempDirPath.toFile();
File uniqueDir = new File(tempDir, "dir-" + UUID.randomUUID());
if (!uniqueDir.exists() && !uniqueDir.mkdirs()) {
throw new IOException("Failed to create directory: " + uniqueDir.getAbsolutePath());
}
if (!uniqueDir.exists() || !uniqueDir.isDirectory() || !uniqueDir.canWrite()) {
throw new IOException("Unique directory is not accessible for writing.");
}
File file = new File(uniqueDir, fileName);
try {
Files.write(file.toPath(), bytes);
} catch (IOException e) {
boolean deleted = file.delete();
if (!deleted) {
log.warn("Failed to delete corrupted file: {}", file.getAbsolutePath());
}
throw e;
}
file.deleteOnExit();
return file;
}
public static File streamToFile(byte[] bytes, String fileName) {
try (InputStream inputStream = new ByteArrayInputStream(bytes)){
if (fileName == null || fileName.trim().isEmpty()) {
throw new IllegalArgumentException("File name cannot be null or empty.");
}
Path tempDirPath = Files.createTempDirectory("tempFile");
File tempDir = tempDirPath.toFile();
File uniqueDir = new File(tempDir, "dir-" + UUID.randomUUID());
if (!uniqueDir.exists() && !uniqueDir.mkdirs()) {
deleteDirectoryRecursively(tempDir);
throw new IOException("Failed to create directory: " + uniqueDir.getAbsolutePath());
}
File file = new File(uniqueDir, fileName);
try (OutputStream fos = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
fos.write(buffer, 0, bytesRead);
}
} catch (IOException e) {
boolean deleted = file.delete();
if (!deleted) {
log.warn("Failed to delete corrupted file: {}", file.getAbsolutePath());
}
deleteDirectoryRecursively(tempDir);
throw e;
}
addShutdownHookToDelete(tempDir);
return file;
} catch (Exception e) {
log.error("Failed to create file: {}", fileName, e);
throw new RuntimeException(e);
}
}
/**
* 添加 JVM 钩子,在程序退出时尝试删除临时目录
*/
private static void addShutdownHookToDelete(File dir) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
deleteDirectoryRecursively(dir);
} catch (IOException e) {
log.warn("Failed to delete temporary directory during shutdown: {}", dir.getAbsolutePath(), e);
}
}));
}
/**
* 递归删除目录及其所有内容
*/
private static void deleteDirectoryRecursively(File dir) throws IOException {
if (dir == null || !dir.exists()) return;
Files.walk(dir.toPath())
.sorted(Comparator.reverseOrder())
.forEach(path -> {
try {
Files.deleteIfExists(path);
} catch (IOException ignored) {
// 忽略删除失败的情况
}
});
}
}
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO;
import cn.com.glsx.scrm.wechat.enums.WechatErrorEnum;
import cn.com.glsx.wechatbuild.Constants.oa.WorkWechatOAConstants;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import cn.com.glsx.wechatbuild.util.HttpUtils;
import java.text.MessageFormat;
import lombok.extern.slf4j.Slf4j;
import org.oreframework.util.http.HttpUtil;
import org.oreframework.util.json.JacksonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class WorkWechatMessageManager {
@Autowired
private TokenManager tokenManager;
/**
* 发送应用消息
* @param request
* @return
*/
public SendWorkWechatMessageResponseDTO sendMessage(SendWorkWechatMessageRequestDTO request){
try{
String url = MessageFormat.format(WorkWechatOAConstants.WW_SEND_MESSAGE_PATH, tokenManager.getAccessToken(new WorkWechatBaseRequestDTO(request.getMerchantId())));
String body = JacksonUtils.beanToJson(request);
log.info("send work wechat message request url:{}, body:{}", url, body);
String response = HttpUtils.post(url, body,null);
log.info("send work wechat message response:{}", response);
return JacksonUtils.jsonCastBean(response, SendWorkWechatMessageResponseDTO.class);
}catch(Exception e){
log.error("send work wechat message error:{}", e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SEND_WORK_WECHAT_MESSAGE_FAILED, e);
}
}
}
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.media.response.GetWorkWechatMediaResponseDTO;
import cn.com.glsx.scrm.wechat.enums.WorkWechatMediaTypeEnum;
import cn.com.glsx.wechatbuild.Constants.oa.WorkWechatOAConstants;
import cn.com.glsx.wechatbuild.config.WechatApiUrlConfig;
import cn.com.glsx.wechatbuild.model.*;
import cn.com.glsx.wechatbuild.model.request.oa.*;
import cn.com.glsx.wechatbuild.model.request.oa.approval.GetWorkWechatApprovalInfoRequestDTO;
import cn.com.glsx.wechatbuild.model.response.oa.*;
import cn.com.glsx.wechatbuild.util.HttpUtils;
import com.alibaba.fastjson.JSON;
import java.text.MessageFormat;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.oreframework.util.http.HttpUtil;
import org.oreframework.util.json.JacksonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.nio.file.Files;
import java.util.UUID;
/**
* @author chizw
* @version ver.1.0.0
* @Description
* @create 2025/2/13 16:32
*/
@Component
@Slf4j
public class WorkWechatOAManager {
@Autowired
private TokenManager tokenManager;
/**
* @Description 获取审批模板详情
* @author chizw
* @create 2025/2/13 16:59
* @version ver.1.0.0
*/
public WorkWechatOAGetTemplateDetailResponseDTO getTemplateDetail(
WorkWechatOAGetTemplateDetailRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatOAConstants.OA_GET_TEMPLATE_DETAIL_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("work wechat oa get template detail request url:{},body:{}", url, body);
String response = HttpUtils.post(url, body,null);
log.info("work wechat oa get template detail response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatOAGetTemplateDetailResponseDTO.class);
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(), e.getMessage());
} catch (Exception e) {
log.error("work wechat oa get template detail error:{}", e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
/**
* @Description 提交审批申请
* @author chizw
* @create 2025/2/17 16:10
* @version ver.1.0.0
*/
public WorkWechatOAApplyEventResponseDTO applyEvent(
WorkWechatOAApplyEventRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatOAConstants.OA_APPLY_EVENT_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("work wechat oa apply event request url:{},body:{}", url, body);
String response = HttpUtils.post(url, body,null);
log.info("work wechat oa apply event response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatOAApplyEventResponseDTO.class);
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(), e.getMessage());
} catch (Exception e) {
log.error("work wechat oa apply event error:{}", e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
public static void main(String[] args) throws IOException {
String token = "zcOftjvhm-rPlsqrB6N2rmXYGrxXUYd3spCBThEfj22HpcbPNfgY_mtK87nvQUA9lHZ3iPme-9Wa_W1zIeCfrlxhzFhgjWgcVNx77_gf6INqdga3fabPt8Q-8LhAushhUJJMGukMnxMaA6ZlRNP-5AdHxc3A1MvFdEmKa5zgy7zXUY0Cg5L9lTTzSRKxLi5Rlci3GG_StdadFD2slxosmw";
String url = "https://qyapi.weixin.qq.com/cgi-bin/oa/getapprovaldetail?access_token=" + token;
String body = "{\"sp_no\":\"202504220009\"}";
String response = HttpUtil.post(url, body);
System.out.println(JSON.toJSONString(response));
WorkWechatOAGetApprovalDetailResponseDTO dto = JacksonUtils.jsonCastBean(response, WorkWechatOAGetApprovalDetailResponseDTO.class);
System.out.println(JSON.toJSONString(dto));
}
/**
* @Description 获取审批申请详情
* @author chizw
* @create 2025/2/17 16:10
* @version ver.1.0.0
*/
public WorkWechatOAGetApprovalDetailResponseDTO getApprovalDetail(
WorkWechatOAGetApprovalDetailRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatOAConstants.OA_GET_APPROVAL_DETAIL_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("work wechat oa get approval detail request url:{},body:{}", url, body);
String response = HttpUtils.post(url, body,null);
log.info("work wechat oa get approval detail response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatOAGetApprovalDetailResponseDTO.class);
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(), e.getMessage());
} catch (Exception e) {
log.error("work wechat oa get approval detail error:{}", e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
/**
* @Description 获取审批申请详情
* @author chizw
* @create 2025/2/17 16:10
* @version ver.1.0.0
*/
public UploadWorkUserGetuseridResponseDTO getuserid(WorkWechatUserGetuseridRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatOAConstants.GET_USERID_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("work wechat user getuserid request url:{},body:{}", url, body);
String response = HttpUtils.post(url, body, null);
log.info("work wechat user getuserid detail response:{}", response);
return JacksonUtils.jsonCastBean(response, UploadWorkUserGetuseridResponseDTO.class);
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(), e.getMessage());
} catch (Exception e) {
log.error("work wechat user getuserid detail error:{}", e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
public WorkWechatOAApprovalInfoResponseDTO getapprovalinfo(
GetWorkWechatApprovalInfoRequestDTO getWorkWechatApprovalInfoRequestDTO) {
try{
String url = MessageFormat.format(WorkWechatOAConstants.WW_GETAPPROVALINFO_PATH, tokenManager.getAccessToken(new WorkWechatBaseRequestDTO(getWorkWechatApprovalInfoRequestDTO.getMerchantId())));
String body = JacksonUtils.beanToJson(getWorkWechatApprovalInfoRequestDTO);
log.info("send work wechat message request url:{}, body:{}", url, body);
String response = HttpUtils.post(url, body,null);
log.info("send work wechat message response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatOAApprovalInfoResponseDTO.class);
}catch(Exception e){
log.error("send work wechat message error:{}", e.getMessage(), e);
throw new RpcServiceException(cn.com.glsx.scrm.wechat.enums.WechatErrorEnum.SEND_WORK_WECHAT_MESSAGE_FAILED, e);
}
}
/**
* @Description 获取审批申请详情独立
* @author chizw
* @create 2025/2/17 16:10
* @version ver.1.0.0
*/
public WorkWechatOAGetApprovalDetailSingleResponseDTO getApprovalDetailSingle(
WorkWechatOAGetApprovalDetailRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatOAConstants.OA_GET_APPROVAL_DETAIL_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("work wechat oa get approval detail request url:{},body:{}", url, body);
String response = HttpUtil.post(url, body);
log.info("work wechat oa get approval detail response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatOAGetApprovalDetailSingleResponseDTO.class);
} catch (RpcServiceException e) {
throw new RpcServiceException(e.getErrId(), e.getMessage());
} catch (Exception e) {
log.error("work wechat oa get approval detail error:{}", e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
}
package cn.com.glsx.wechatbuild.manager;
/**
* @author yelq
* @version V1.0
* @Title: WorkWechatUserCheckInApiConstants.java
* @Description:企微打卡 URL
* @date 2024年4月9日19点37分
*/
public interface WorkWechatUserCheckInApiConstants {
/**
* 获取打卡日报数据
*/
public final static String GET_CHECK_IN_DAY_DATA_PATH = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckin_daydata?access_token={0}";
/**
* 获取打卡日报数据
*/
public final static String GET_CHECK_IN_DATA_PATH = "https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token={0}";
}
package cn.com.glsx.wechatbuild.manager;
/**
* 企微-用户信息api
*/
public interface WorkWechatUserInfoApiConstants {
/**
* 获取用户敏感信息
*/
public final static String GET_DETAIL_USER_INFO_PATH = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserdetail?access_token={0}";
/**
* 获取用户基础信息
*/
public final static String GET_BASE_USER_INFO_PATH = "https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token={0}&code={1}";
/**
* 读取成员GET
*/
public final static String WW_GET_USER_PATH = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={0}&userid={1}";
}
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.user.response.WorkWechatUserResponseDTO;
import cn.com.glsx.wechatbuild.Constants.oa.WorkWechatOAConstants;
import cn.com.glsx.wechatbuild.config.WechatApiUrlConfig;
import cn.com.glsx.wechatbuild.model.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.util.http.HttpUtil;
import org.oreframework.util.json.JacksonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.com.glsx.wechatbuild.util.HttpUtils;
import java.io.IOException;
@Component
@Slf4j
public class WorkWechatUserManager {
@Autowired
private TokenManager tokenManager;
public WorkWechatUserInfoResponseDTO getUserInfo(GetWorkWechatUserRequestDTO request) {
//先根据code 获取用户userid
WorkWechatUserInfoResponseDTO baseInfo = getBaseUserInfo(request);
return baseInfo;
}
public WorkWechatBookUserInfoResponseDTO getBookUserInfo(GetWorkWechatUserRequestDTO request, String userId) {
try {
String url = WechatApiUrlConfig.getApi(
WorkWechatUserInfoApiConstants.WW_GET_USER_PATH,
tokenManager.getAccessToken(request), userId);
log.info("get work wechat user book info request url:{}, body:{}", url, request);
String response = HttpUtil.get(url, null);
log.info("get work wechat user book info response :{}", response);
WorkWechatBookUserInfoResponseDTO bookUserInfo = JacksonUtils.jsonCastBean(response, WorkWechatBookUserInfoResponseDTO.class);
if (bookUserInfo == null) {
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, "获取用户详细信息为空!");
}
return bookUserInfo;
} catch (IOException e) {
log.error("get work wechat user book info error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
} catch (Exception e) {
log.error("get work wechat user book info system error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
public WorkWechatUserInfoResponseDTO getBaseUserInfo(GetWorkWechatUserRequestDTO request) {
try {
//先根据code 获取用户userid
String url = WechatApiUrlConfig.getApi(
WorkWechatUserInfoApiConstants.GET_BASE_USER_INFO_PATH,
tokenManager.getAccessToken(request), request.getCode());
log.info("get work wechat user base info request url:{}, body:{}", url, request);
String response = HttpUtils.get(url);
log.info("get work wechat user base info response:{}", response);
WorkWechatUserInfoResponseDTO baseInfo = JacksonUtils.jsonCastBean(response, WorkWechatUserInfoResponseDTO.class);
return baseInfo;
} catch (IOException e) {
log.error("get work wechat base user info error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
} catch (Exception e) {
log.error("get work wechat base user info system error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
public WorkWechatUserDetailInfoResponseDTO getDetailUserInfo(GetWorkWechatUserDetailRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(
WorkWechatUserInfoApiConstants.GET_DETAIL_USER_INFO_PATH,
tokenManager.getAccessToken(request));
String body = JacksonUtils.beanToJson(request);
log.info("get work wechat user detail info request url:{}, body:{}", url, body);
String response = HttpUtil.post(url, body);
log.info("get work wechat user detail info response:{}", response);
WorkWechatUserDetailInfoResponseDTO detailInfo = JacksonUtils.jsonCastBean(response, WorkWechatUserDetailInfoResponseDTO.class);
if (detailInfo == null) {
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, "获取用户敏感信息为空!");
}
return detailInfo;
} catch (IOException e) {
log.error("get work wechat detail user info error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
} catch (Exception e) {
log.error("get work wechat detail user info system error:" + e.getMessage(), e);
throw new RpcServiceException(WechatErrorEnum.SERVER_ERROR, e.getMessage());
}
}
/**
* 读取成员
* 在通讯录同步助手中此接口可以读取企业通讯录的所有成员的信息,而自建应用可以读取该应用设置的可见范围内的成员信息
*
* @param request
* @return
*/
public WorkWechatUserResponseDTO getUser(
cn.com.glsx.scrm.wechat.dto.workwechat.user.request.GetWorkWechatUserRequestDTO request) {
try {
String url = WechatApiUrlConfig.getApi(WorkWechatOAConstants.WW_GET_USER_PATH, tokenManager.getAccessToken(new WorkWechatBaseRequestDTO(request.getMerchantId())), request.getUserId());
log.info("get work wechat user request url:{}", url);
String response = HttpUtils.get(url);
log.info("get work wechat user response:{}", response);
return JacksonUtils.jsonCastBean(response, WorkWechatUserResponseDTO.class);
} catch (Exception e) {
log.error("get work wechat user error:{}", e.getMessage(), e);
throw new RpcServiceException(cn.com.glsx.scrm.wechat.enums.WechatErrorEnum.GET_WORK_WECHAT_USER_FAILED, e);
}
}
}
package cn.com.glsx.wechatbuild.model;
import java.io.Serializable;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @Title: BaseResponseDTO.java
* @Description:
* @author Alvin
* @date 2019年3月23日 下午4:47:17
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
public class BaseResponseDTO implements Serializable{
private static final long serialVersionUID = 1L;
@JsonProperty("errcode")
private Integer errCode;
@JsonProperty("errmsg")
private String errMsg;
public Integer getErrCode() {
return errCode;
}
public String getErrMsg() {
return errMsg;
}
public void setErrCode(Integer errCode) {
this.errCode = errCode;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public boolean isSuccess(){
return errCode == null || 0 == errCode;
}
public static BaseResponseDTO error(Integer errCode, String errMsg){
BaseResponseDTO response = new BaseResponseDTO();
response.setErrCode(errCode);
response.setErrMsg(errMsg);
return response;
}
}
package cn.com.glsx.wechatbuild.model;
import java.util.List;
import javax.validation.constraints.NotEmpty;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @author yelq
* @version V1.0
* @Title: GetWorkWechatUserCheckInDayDataRequestDTO.java
* @Description:获取打卡日报数据
* @date 2024年4月9日 16点22分
*/
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public class GetWorkWechatUserCheckInDataRequestDTO extends WorkWechatBaseRequestDTO{
private static final long serialVersionUID = -1694960107385L;
/**
* 获取日报的开始时间。0点Unix时间戳
*/
@NonNull
@JsonProperty("starttime")
private long starttime;
/**
* 获取日报的结束时间。0点Unix时间戳
*/
@NonNull
@JsonProperty("endtime")
private long endtime;
@NotEmpty(message = "获取日报的userid列表。\n" +
"单个userid不少于1字节,不多于64字节\n" +
"可填充个数:1 ~ 100")
@JsonProperty("useridlist")
private List<String> useridlist;
/**
* 获取日报的结束时间。0点Unix时间戳
*/
@NonNull
@JsonProperty("opencheckindatatype")
private Integer opencheckindatatype;
}
package cn.com.glsx.wechatbuild.model;
import java.util.List;
import javax.validation.constraints.NotEmpty;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @author yelq
* @version V1.0
* @Title: GetWorkWechatUserCheckInDayDataRequestDTO.java
* @Description:获取打卡日报数据
* @date 2024年4月9日 16点22分
*/
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public class GetWorkWechatUserCheckInDayDataRequestDTO extends WorkWechatBaseRequestDTO{
private static final long serialVersionUID = -1694960107385L;
/**
* 获取日报的开始时间。0点Unix时间戳
*/
@NonNull
@JsonProperty("starttime")
private long startTime;
/**
* 获取日报的结束时间。0点Unix时间戳
*/
@NonNull
@JsonProperty("endtime")
private long endTime;
@NotEmpty(message = "获取日报的userid列表。\n" +
"单个userid不少于1字节,不多于64字节\n" +
"可填充个数:1 ~ 100")
@JsonProperty("useridlist")
private List<String> useridlist;
}
package cn.com.glsx.wechatbuild.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.dubbo.apidocs.annotations.RequestParam;
import org.codehaus.jackson.annotate.JsonProperty;
import javax.validation.constraints.NotEmpty;
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public class GetWorkWechatUserDetailRequestDTO extends WechatTokenBaseRequestDTO {
/**
* 用户票据
*/
@NotEmpty(message = "用户票据")
@JsonProperty("user_ticket")
@RequestParam(value = "user_ticket", description = "user_ticket", required = true)
private String user_ticket;
}
package cn.com.glsx.wechatbuild.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotEmpty;
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public class GetWorkWechatUserRequestDTO extends WechatTokenBaseRequestDTO {
@NotEmpty(message = "code不能为空")
@ApiModelProperty(name = "code", notes = "企微授权code", example = "1000136", required = true)
private String code;
}
package cn.com.glsx.wechatbuild.model;
import cn.com.glsx.framework.core.enums.ErrorEnum;
import java.util.HashMap;
import java.util.Map;
/**
* 微信错误码定义枚举
* <P>Description: </P>
*
* @author Alvin
* @version 1.0
*/
public enum WechatErrorEnum implements ErrorEnum {
// 服务器异常
SERVER_ERROR("1001", "服务器异常"),
// 业务异常
SERVICE_ERROR("1002", "业务异常"),
// 授权回调异常
AUTH_CALLBACK_ERROR("100201", "授权回调异常"),
// 快速注册小程序回调异常
FAST_REGISTER_CALLBACK_ERROR("100202", "快速注册小程序回调异常"),
// 修改小程序服务器域名异常
WEAPP_MODIFY_DOMAIN_ERROR("100203", "修改小程序服务器域名异常"),
// 设置小程序业务域名异常
WEAPP_SET_WEBVIEW_DOMAIN_ERROR("100204", "设置小程序业务域名异常"),
// 生成小程序码异常
CREATE_WEAPP_QRCODE_ERROR("100205", "生成小程序码异常"),
// 小程序版本状态异常
WEAPP_VERSION_STATUS_ERROR("100206", "小程序版本状态异常"),
// 小程序未授权
WEAPP_NOT_ACCESS_ERROR("100207", "小程序未授权"),
// 获取临时素材失败
GET_WECHAT_MEDIA_ERROR("100208", "获取临时素材失败"),
// 创建直播间失败
WEAPP_CREATE_LIVE_ROOM_ERROR("100209", "创建直播间失败"),
// 获取直播间失败
WEAPP_GET_LIVE_INFO_ERROR("100210", "获取直播间失败"),
// 获取直播回放失败
WEAPP_GET_LIVE_REPALY_ERROR("100211", "获取直播回放失败"),
// 添加直播商品失败
LIVER_GOODS_ADD_ERROR("100301", "添加直播商品失败"),
// 撤销直播商品审核失败
LIVER_GOODS_RESET_AUDIT_ERROR("100302", "撤销直播商品审核失败"),
// 重新审核直播商品失败
LIVER_GOODS_AUDIT_ERROR("100303", "重新审核直播商品失败"),
// 删除直播商品失败
LIVER_GOODS_DELETE_ERROR("100304", "删除直播商品失败"),
// 更新直播商品失败
LIVER_GOODS_UPDATED_ERROR("100305", "更新直播商品失败"),
// 获取直播商品状态失败
LIVER_GOODS_WAREHOUSE_ERROR("100306", "获取直播商品状态失败"),
// 获取直播商品列表失败
LIVER_GOODS_APPROVED_ERROR("100307", "获取直播商品列表失败"),
// 直播间导入商品失败
LIVER_ADD_GOODS_ERROR("100308", "直播间导入商品失败"),
// 验签失败
VALIDATE_FAILED("2001", "验签失败"),
// 获取接口调用令牌失败
GET_AUTHORIZER_TOKEN_FAILED("200101", "获取接口调用令牌失败"),
// 获取开放平台应用ID失败
GET_OPEN_PLATFORM_APPID_FAILED("200102", "获取开放平台应用ID失败"),
// 解绑开放平台失败
UNBIND_OPEN_PLATFORM_FAILED("200103", "解绑开放平台失败"),
// 绑定开放平台失败
BIND_OPEN_PLATFORM_FAILED("200104", "绑定开放平台失败"),
// 创建开放平台账号失败
CREATE_OPEN_PLATFORM_APPID_FAILED("200105", "创建开放平台账号失败"),
// 获取第三方平台授权账号列表失败
GET_AUTHORIZER_LIST_FAILED("200106", "获取第三方平台授权账号列表失败"),
// 微信素材上传失败
WECHAT_MEDIA_UPLOAD_FAILED("200107", "微信素材上传失败"),
// 微信素材获取失败
WECHAT_MEDIA_GET_FAILED("200108", "微信素材获取失败"),
GET_CHECK_IN_DAY_DATA_FAIL("600112", "获取打卡日报数据失败!"),
;
private String value;
private String displayName;
static Map<String, WechatErrorEnum> enumMap = new HashMap<String, WechatErrorEnum>();
static {
for (WechatErrorEnum code : WechatErrorEnum.values()) {
enumMap.put(code.getValue(), code);
}
}
WechatErrorEnum(String value, String displayName) {
this.value = value;
this.displayName = displayName;
}
@Override
public String getValue() {
return value;
}
@Override
public String getDisplayName() {
return displayName;
}
public static WechatErrorEnum getEnum(String value) {
return enumMap.get(value);
}
@Override
public String toString() {
return this.name().concat("[value:").concat(getValue()).concat(", displayName:").concat(getDisplayName()).concat("]");
}
}
package cn.com.glsx.wechatbuild.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@NoArgsConstructor
public class WechatTokenBaseRequestDTO implements Serializable {
@NotEmpty(message = "corpId不能为空")
@ApiModelProperty(name = "corpId", notes = "企业的CorpID", example = "wx51bda2e574d24a91", required = true)
private String corpId;
private String corpSecret;
@NotEmpty(message = "agentId不能为空")
@ApiModelProperty(name = "agentId", notes = "企微自建应用id", example = "100010", required = true)
private String agentId;
}
package cn.com.glsx.wechatbuild.model;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
/**
* @Title: BaseRequestDTO.java
* @Description:
* @author Alvin
* @date 2021年9月15日 下午5:34:44
* @version V1.0
*/
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@NoArgsConstructor
public class WorkWechatBaseRequestDTO implements Serializable{
@Setter(AccessLevel.NONE)
@Getter(AccessLevel.NONE)
private static final long serialVersionUID = -8748996888906556828L;
/**
* 商户号
*/
@NotNull(message = "商户号不能为空")
@ApiModelProperty(name = "merchantId", notes = "商户号", example = "10001000", required = true)
@JsonIgnore
private Integer merchantId;
private String corpId;
private String corpSecret;
public WorkWechatBaseRequestDTO(Integer merchantId) {
this.merchantId = merchantId;
}
}
package cn.com.glsx.wechatbuild.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatBookUserInfoResponseDTO extends BaseResponseDTO {
/**
* 成员UserID
*/
@JsonProperty("userid")
@ApiModelProperty(name = "userId", notes = "成员UserID")
private String userId;
/**
* 成员名称
*/
@JsonProperty("name")
@ApiModelProperty(name = "name", notes = "成员名称")
private String name;
/**
* 成员所属部门id列表,仅返回该应用有查看权限的部门id;成员授权模式下,固定返回根部门id,即固定为1
*/
@JsonProperty("department")
@ApiModelProperty(name = "department", notes = "成员所属部门id列表,仅返回该应用有查看权限的部门id;成员授权模式下,固定返回根部门id,即固定为1")
private Integer[] department;
/**
* 主部门
*/
@JsonProperty("main_department")
@ApiModelProperty(name = "mainDepartment", notes = "主部门")
private Integer mainDepartment;
/**
* 表示所在部门是否为上级,0-否,1-是,顺序与Department字段的部门逐一对应
*/
@JsonProperty("is_leader_in_dept")
@ApiModelProperty(name = "isLeaderInDept", notes = "表示所在部门是否为上级,0-否,1-是,顺序与Department字段的部门逐一对应")
private Integer isLeaderInDept[];
/**
* 职位信息。长度为0~64个字节
*/
@JsonProperty("position")
@ApiModelProperty(name = "position", notes = "职位信息。长度为0~64个字节")
private String position;
/**
* 手机号码
*/
@JsonProperty("mobile")
@ApiModelProperty(name = "mobile", notes = "手机号码")
private String mobile;
/**
* 性别,1表示男性,2表示女性
*/
@JsonProperty("gender")
@ApiModelProperty(name = "gender", notes = "性别,1表示男性,2表示女性")
private String gender;
/**
* 邮箱
*/
@JsonProperty("email")
@ApiModelProperty(name = "email", notes = "邮箱")
private String email;
/**
* 激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号)5=成员退出
*/
@JsonProperty("status")
@ApiModelProperty(name = "status", notes = "激活状态:1=已激活 2=已禁用 4=未激活 已激活代表已激活企业微信或已关注微工作台(原企业号)5=成员退出")
private Integer status;
/**
* 头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可。
*/
@JsonProperty("avatar")
@ApiModelProperty(name = "avatar", notes = "头像url。注:如果要获取小图将url最后的”/0”改成”/100”即可。")
private String avatar;
/**
* 头像缩略图url
*/
@JsonProperty("thumb_avatar")
@ApiModelProperty(name = "thumbAvatar", notes = "头像缩略图url")
private String thumbAvatar;
/**
* 成员别名
*/
@JsonProperty("Alias")
@ApiModelProperty(name = "alias", notes = "成员别名")
private String alias;
/**
* 座机
*/
@JsonProperty("telephone")
@ApiModelProperty(name = "telephone", notes = "座机")
private String telephone;
/**
* 地址
*/
@JsonProperty("address")
@ApiModelProperty(name = "address", notes = "地址")
private String address;
/**
* 员工个人二维码,扫描可添加为外部联系人(注意返回的是一个url,可在浏览器上打开该url以展示二维码);第三方仅通讯录应用可获取;对于非第三方创建的成员,第三方通讯录应用也不可获取
*/
@JsonProperty("qr_code")
@ApiModelProperty(name = "qrCode", notes = "员工个人二维码,扫描可添加为外部联系人")
private String qrCode;
}
package cn.com.glsx.wechatbuild.model;
import java.util.List;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @author yelq
* @version V1.0
* @Title: WorkWechatUserCheckInDataResponseDTO.java
* @Description:获取打卡记录数据
* @date 2024年4月9日19点37分
*/
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatUserCheckInDataResponseDTO extends BaseResponseDTO {
private static final long serialVersionUID = 65436547645740473L;
/**
* 打卡记录数据
*/
@JsonProperty("checkindata")
private List<CheckInRecord> checkindata;
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public static class CheckInRecord {
/**
* 用户id
*/
@JsonProperty("userid")
private String userId;
/**
* 打卡规则名称
*/
@JsonProperty("groupname")
private String groupName;
/**
* 打卡类型。字符串,目前有:上班打卡,下班打卡,外出打卡
*/
@JsonProperty("checkin_type")
private String checkinType;
/**
* 异常类型,字符串,包括:时间异常,地点异常,未打卡,wifi异常,非常用设备。如果有多个异常,以分号间隔
*/
@JsonProperty("exception_type")
private String exceptionType;
/**
* 打卡时间,时间戳
*/
@JsonProperty("checkin_time")
private long checkinTime;
/**
* 打卡地点title
*/
@JsonProperty("location_title")
private String locationTitle;
/**
* 打卡地点详情
*/
@JsonProperty("location_detail")
private String locationDetail;
/**
* 打卡wifi名称
*/
@JsonProperty("wifiname")
private String wifiName;
/**
* 打卡备注
*/
@JsonProperty("notes")
private String notes;
/**
* 打卡的MAC地址/bssid
*/
@JsonProperty("wifimac")
private String wifiMac;
/**
* 打卡的附件media_id,可使用media/get获取附件
*/
@JsonProperty("mediaids")
private List<String> mediaIds;
/**
* 位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
*/
@JsonProperty("lat")
private Integer lat;
/**
* 位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
*/
@JsonProperty("lng")
private Integer lng;
/**
* 打卡设备id
*/
@JsonProperty("deviceid")
private String deviceId;
/**
* 标准打卡时间,指此次打卡时间对应的标准上班时间或标准下班时间
*/
@JsonProperty("sch_checkin_time")
private Long schCheckInTime;
/**
* 规则id,表示打卡记录所属规则的id
*/
@JsonProperty("groupid")
private Integer groupId;
/**
* 班次id,表示打卡记录所属规则中,所属班次的id
*/
@JsonProperty("schedule_id")
private Integer scheduleId;
/**
* 时段id,表示打卡记录所属规则中,某一班次中的某一时段的id,如上下班时间为9:00-12:00、13:00-18:00的班次中,9:00-12:00为其中一组时段
*/
@JsonProperty("timeline_id")
private Integer timelineId;
}
}
package cn.com.glsx.wechatbuild.model;
import java.io.Serializable;
import java.util.List;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @author yelq
* @version V1.0
* @Title: WorkWechatUserCheckInDayDataResponseDTO.java
* @Description:获取打卡日报数据
* @date 2024年4月9日19点37分
*/
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatUserCheckInDayDataResponseDTO extends BaseResponseDTO {
private static final long serialVersionUID = 65436547645740473L;
/**
* 日报数据列表
*/
@JsonProperty("datas")
private List<Data> datas;
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public static class Data implements Serializable {
/**
* 基础信息
*/
@JsonProperty("base_info")
private BaseInfo baseInfo;
/**
* 汇总信息
*/
@JsonProperty("summary_info")
private SummaryInfo summaryInfo;
/**
* 假勤相关信息
*/
@JsonProperty("holiday_infos")
private List<HolidayInfo> holidayInfos;
/**
* 校准状态信息
*/
@JsonProperty("exception_infos")
private List<ExceptionInfo> exceptionInfos;
/**
* 加班信息
*/
@JsonProperty("ot_info")
private OTInfo otInfo;
/**
* 假勤统计信息
*/
@JsonProperty("sp_items")
private List<SpItem> spItems;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class SpItem implements Serializable{
/**
* 当日假勤次数
*/
@JsonProperty("count")
private Integer count;
/**
* 当日假勤时长秒数,时长单位为天直接除以86400即为天数,单位为小时直接除以3600即为小时数
*/
@JsonProperty("duration")
private Integer duration;
/**
* 时长单位:0-按天 1-按小时
*/
@JsonProperty("time_type")
private Integer timeType;
/**
* 类型:1-请假;2-补卡;3-出差;4-外出;100-外勤
*/
@JsonProperty("type")
private Integer type;
/**
* 具体请假类型,当type为1请假时,具体的请假类型id,可通过审批相关接口获取假期详情
*/
@JsonProperty("vacation_id")
private Integer vacationId;
/**
* 统计项名称
*/
@JsonProperty("name")
private String name;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class OTInfo implements Serializable{
/**
* 状态:0-无加班;1-正常;2-缺时长
*/
@JsonProperty("ot_status")
private Integer otStatus;
/**
* 加班时长
*/
@JsonProperty("ot_duration")
private Integer otDuration;
/**
* ot_status为2下,加班不足的时长
*/
@JsonProperty("exception_duration")
private List<Integer> exceptionDuration;
/**
* 工作日加班记为调休,单位秒
*/
@JsonProperty("workday_over_as_vacation")
private Integer workdayOverAsVacation;
/**
* 工作日加班记为加班费,单位秒
*/
@JsonProperty("workday_over_as_money")
private Integer workdayOverAsMoney;
/**
* 休息日加班记为调休,单位秒
*/
@JsonProperty("restday_over_as_vacation")
private Integer restdayOverAsVacation;
/**
* 休息日加班记为加班费,单位秒
*/
@JsonProperty("restday_over_as_money")
private Integer restdayOverAsMoney;
/**
* 节假日加班记为调休,单位秒
*/
@JsonProperty("holiday_over_as_vacation")
private Integer holidayOverAsVacation;
/**
* 节假日加班记为加班费,单位秒
*/
@JsonProperty("holiday_over_as_money")
private Integer holidayOverAsMoney;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class ExceptionInfo implements Serializable{
/**
* 当日此异常的次数
*/
@JsonProperty("count")
private Integer count;
/**
* 当日此异常的时长(迟到/早退/旷工才有值)
*/
@JsonProperty("duration")
private Integer duration;
/**
* 校准状态类型:1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常
*/
@JsonProperty("exception")
private Integer exception;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class HolidayInfo implements Serializable{
/**
* 假勤信息摘要-描述信息
*/
@JsonProperty("sp_description")
private SpDescription spDescription;
/**
* 假勤申请id,即当日关联的假勤审批单id
*/
@JsonProperty("sp_number")
private String spNumber;
/**
* 假勤信息摘要-标题信息
*/
@JsonProperty("sp_title")
private SpTitle spTitle;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class SpDescription implements Serializable{
/**
* 多种语言描述,目前只有中文一种
*/
@JsonProperty("data")
private List<SpText> data;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class SpText implements Serializable{
/**
* 假勤信息摘要-标题文本
*/
@JsonProperty("lang")
private String lang;
/**
* 语言类型:"zh_CN"
*/
@JsonProperty("text")
private String text;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class SpTitle implements Serializable{
/**
* 多种语言描述,目前只有中文一种
*/
@JsonProperty("date")
private List<SpText> data;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class BaseInfo implements Serializable{
/**
* 日报日期
*/
@JsonProperty("date")
private long date;
/**
* 记录类型:1-固定上下班;2-外出(此报表中不会出现外出打卡数据);3-按班次上下班;4-自由签到;5-加班;7-无规则
*/
@JsonProperty("record_type")
private Integer recordType;
/**
* 打卡人员姓名
*/
@JsonProperty("name")
private String name;
/**
* 打卡人员别名
*/
@JsonProperty("name_ex")
private String nameEx;
/**
* 打卡人员所在部门,会显示所有所在部门
*/
@JsonProperty("departs_name")
private String departsName;
/**
* 打卡人员账号,即userid
*/
@JsonProperty("acctid")
private String acctid;
/**
* 打卡人员所属规则信息
*/
@JsonProperty("rule_info")
private RuleInfo ruleInfo;
/**
* 日报类型:0-工作日日报;1-休息日日报
*/
@JsonProperty("day_type")
private Integer dayType;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class SummaryInfo implements Serializable{
/**
* 当日打卡次数
*/
@JsonProperty("checkin_count")
private Integer checkinCount;
/**
* 当日实际工作时长,单位:秒
*/
@JsonProperty("regular_work_sec")
private Integer regularWorkSec;
/**
* 当日标准工作时长,单位:秒
*/
@JsonProperty("standard_work_sec")
private Integer standardWorkSec;
/**
* 当日最早打卡时间
*/
@JsonProperty("earliest_time")
private Integer earliestTime;
/**
* 当日最晚打卡时间
*/
@JsonProperty("lastest_time")
private Integer latestTime;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class RuleInfo implements Serializable{
/**
* 所属规则的id
*/
@JsonProperty("groupid")
private Integer groupid;
/**
* 打卡规则名
*/
@JsonProperty("groupname")
private String groupname;
/**
* 当日所属班次id,仅按班次上下班才有值,显示在打卡日报-班次列
*/
@JsonProperty("scheduleid")
private Integer scheduleid;
/**
* 当日所属班次名称,仅按班次上下班才有值,显示在打卡日报-班次列
*/
@JsonProperty("schedulename")
private String schedulename;
/**
* 当日打卡时间,仅固定上下班规则有值,显示在打卡日报-班次列
*/
@JsonProperty("checkintime")
private List<CheckInTime> checkInTime;
}
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public static class CheckInTime {
/**
* 上班时间,为距离0点的时间差
*/
@JsonProperty("work_sec")
private Integer workSec;
/**
* 下班时间,为距离0点的时间差
*/
@JsonProperty("off_work_sec")
private Integer offWorkSec;
}
}
package cn.com.glsx.wechatbuild.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatUserDetailInfoResponseDTO extends BaseResponseDTO {
/**
* 成员UserID。若需要获得用户详情信息,可调用通讯录接口:读取成员。如果是互联企业/企业互联/上下游,则返回的UserId格式如:CorpId/userid
*/
@JsonProperty("userid")
@ApiModelProperty(name = "userid", notes = "成员UserID")
private String userid;
/**
* 性别。0表示未定义,1表示男性,2表示女性。仅在用户同意snsapi_privateinfo授权时返回真实值,否则返回0.
*/
@JsonProperty("gender")
@ApiModelProperty(name = "gender", notes = "手机设备号")
private String gender;
/**
* 仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取
*/
@JsonProperty("address")
@ApiModelProperty(name = "address", notes = "成员票据")
private String address;
/**
* 企业邮箱,仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取
*/
@JsonProperty("biz_mail")
@ApiModelProperty(name = "address", notes = "企业邮箱")
private String bizMail;
/**
* 邮箱,仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取
*/
@JsonProperty("email")
@ApiModelProperty(name = "email", notes = "邮箱")
private String email;
/**
* 仅在用户同意snsapi_privateinfo授权时返回,第三方应用不可获取
*/
@JsonProperty("mobile")
@ApiModelProperty(name = "mobile", notes = "手机")
private String mobile;
/**
* 员工个人二维码(扫描可添加为外部联系人),仅在用户同意snsapi_privateinfo授权时返回
*/
@JsonProperty("qr_code")
@ApiModelProperty(name = "qrCode", notes = "员工个人二维码")
private String qrCode;
/**
* 头像url。仅在用户同意snsapi_privateinfo授权时返回
*/
@JsonProperty("avatar")
@ApiModelProperty(name = "avatar", notes = "头像url")
private String avatar;
}
package cn.com.glsx.wechatbuild.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@Setter
@Getter
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatUserInfoResponseDTO extends BaseResponseDTO {
/**
* 成员UserID。若需要获得用户详情信息,可调用通讯录接口:读取成员。如果是互联企业/企业互联/上下游,则返回的UserId格式如:CorpId/userid
*/
@JsonProperty("userid")
@ApiModelProperty(name = "userId", notes = "成员UserID")
private String userId;
/**
* 手机设备号(由企业微信在安装时随机生成,删除重装会改变,升级不受影响)
*/
@JsonProperty("DeviceId")
@ApiModelProperty(name = "deviceId", notes = "手机设备号")
private String deviceId;
/**
* 成员票据,最大为512字节。
* scope为snsapi_privateinfo,且用户在应用可见范围之内时返回此参数。
* 后续利用该参数可以获取用户信息或敏感信息,参见"获取访问用户敏感信息"。暂时不支持上下游或/企业互联场景
*/
@JsonProperty("user_ticket")
@ApiModelProperty(name = "userTicket", notes = "成员票据")
private String userTicket;
}
package cn.com.glsx.wechatbuild.model.request.oa;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.dubbo.apidocs.annotations.RequestParam;
import javax.validation.constraints.NotEmpty;
/**
* @Title: GetWorkWechatMediaRequestDTO.java
* @Description:
* @author Alvin
* @date 2021年10月27日 下午7:10:09
* @version V1.0
*/
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public class GetWorkWechatMediaRequestDTO extends WorkWechatBaseRequestDTO {
private static final long serialVersionUID = 5965689134793447641L;
/**
* 媒体文件ID
*/
@NotEmpty(message = "媒体文件ID不能为空")
@RequestParam(value = "mediaId", description = "媒体文件ID", required = true)
private String mediaId;
}
package cn.com.glsx.wechatbuild.model.request.oa;
import cn.com.glsx.scrm.wechat.enums.WorkWechatMediaTypeEnum;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.dubbo.apidocs.annotations.RequestParam;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* @Title: UploadWorkWechatMediaRequestDTO.java
* @Description:
* @author Alvin
* @date 2021年10月27日 下午7:10:09
* @version V1.0
*/
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public class UploadWorkWechatMediaRequestDTO extends WorkWechatBaseRequestDTO {
private static final long serialVersionUID = 5965689134793447641L;
/**
* 媒体文件内容
*/
@NotNull(message = "媒体文件内容不能为空")
@RequestParam(value = "data", description = "媒体文件内容字节数组", required = true)
private byte[] data;
/**
* 媒体文件名
*/
@NotEmpty(message = "媒体文件名不能为空")
@RequestParam(value = "fileName", description = "媒体文件名", required = true)
private String fileName;
/**
* 媒体文件类型,分别有图片(image)、语音(voice)、视频(video),普通文件(file)
*/
@NotNull(message = "媒体文件类型不能为空")
@RequestParam(value = "mediaType", description = "图片内容字节数组", required = true)
private WorkWechatMediaTypeEnum mediaType;
@RequestParam(value = "fileUrl", description = "文件地址")
private String fileUrl;
}
package cn.com.glsx.wechatbuild.model.request.oa;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
import java.util.List;
/**
* @Description 提交审批申请
* @author chizw
* @create 2025/2/14 15:28
* @version ver.1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(includeFieldNames = true, callSuper = true)
public class WorkWechatOAApplyEventRequestDTO extends WorkWechatBaseRequestDTO {
private static final long serialVersionUID = -1694960107385L;
/**
* 申请人userid
*/
@JsonProperty("creator_userid")
private String creatorUserid;
/**
* 模板id
*/
@JsonProperty("template_id")
private String templateId;
/**
* 审批人模式
*/
@JsonProperty("use_template_approver")
private Integer useTemplateApprover;
/**
* 提单者提单部门id,不填默认为主部门
*/
@JsonProperty("choose_department")
private String chooseDepartment;
/**
* 审批申请数据
*/
@JsonProperty("apply_data")
private ApplyData applyData;
/**
* 摘要信息
*/
@JsonProperty("summary_list")
private List<Summary> summaryList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Summary implements Serializable {
/**
* 摘要行信息
*/
@JsonProperty("summary_info")
private List<SummaryInfo> summaryInfo;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class SummaryInfo implements Serializable {
/**
* 摘要行显示文字
*/
@JsonProperty("text")
private String text;
/**
* 摘要行显示语言
*/
@JsonProperty("lang")
private String lang;
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class ApplyData implements Serializable {
/**
* 审批申请详情
*/
@JsonProperty("contents")
private List<Content> contents;
/**
* 新版流程列表
*/
@JsonProperty("process")
private Process process;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Process implements Serializable {
/**
* 流程节点
*/
@JsonProperty("node_list")
private List<Node> nodeList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Node implements Serializable {
/**
* 节点类型 1:审批人 2:抄送人 3:办理人
*/
@JsonProperty("type")
private Integer type;
/**
* 多人审批方式 1-会签;2-或签 3-依次审批
*/
@JsonProperty("apv_rel")
private Integer apvRel;
/**
* 用户id
*/
@JsonProperty("userid")
private String userid;
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Content implements Serializable {
/**
* 控件类型
*/
@JsonProperty("control")
private String control;
/**
* 审批申请详情
*/
@JsonProperty("id")
private String id;
/**
* 控件值
*/
@JsonProperty("value")
private Value value;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Value implements Serializable {
/**
* 文本/多行文本控件(control参数为Text或Textarea)
*/
@JsonProperty("text")
private String text;
/**
* 数字控件(control参数为Number)
*/
@JsonProperty("new_number")
private String newNumber;
/**
* 金额控件(control参数为Money)
*/
@JsonProperty("new_money")
private String newMoney;
/**
* 日期/日期+时间控件(control参数为Date)
*/
@JsonProperty("date")
private Date date;
/**
* 单选/多选控件(control参数为Selector)
*/
@JsonProperty("selector")
private Selector selector;
/**
* 成员控件(control参数为Contact,且value参数为members)
*/
@JsonProperty("members")
private List<Member> members;
/**
* 部门控件(control参数为Contact,且value参数为departments)
*/
@JsonProperty("departments")
private List<Department> departments;
/**
* 附件控件(control参数为File,且value参数为files)
*/
@JsonProperty("files")
private List<File> files;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class File implements Serializable {
/**
* 文件id,该id为临时素材上传接口返回的的media_id
*/
@JsonProperty("file_id")
private String fileId;
/**
* 文件名称
*/
@JsonProperty("file_name")
private String fileName;
/**
* 文件大小
*/
@JsonProperty("file_size")
private Integer fileSize;
/**
* 文件类型
*/
@JsonProperty("file_type")
private String fileType;
/**
* 文件地址
*/
@JsonProperty("file_url")
private String fileUrl;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Department implements Serializable {
/**
* 所选部门id
*/
@JsonProperty("openapi_id")
private String openapiId;
/**
* 所选部门名
*/
@JsonProperty("name")
private String name;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Member implements Serializable {
/**
* 所选成员的userid
*/
@JsonProperty("userid")
private String userid;
/**
* 成员名
*/
@JsonProperty("name")
private String name;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Selector implements Serializable {
/**
* 选择方式:single-单选;multi-多选
*/
@JsonProperty("type")
private String type;
/**
* 多选选项,多选属性的选择控件允许输入多个
*/
@JsonProperty("options")
private List<option> options;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class option implements Serializable {
/**
* 选项key
*/
@JsonProperty("key")
private String key;
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Date implements Serializable {
/**
* 时间展示类型:day-日期;hour-日期+时间 ,和对应模板控件属性一致
*/
@JsonProperty("date")
private String date;
/**
* 时间戳-字符串类型,在此填写日期/日期+时间控件的选择值,以此为准
*/
@JsonProperty("s_timestamp")
private String sTimestamp;
}
}
}
}
}
package cn.com.glsx.wechatbuild.model.request.oa;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @Description 获取审批模板详情
* @author chizw
* @create 2025/2/14 15:28
* @version ver.1.0.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ToString(includeFieldNames = true, callSuper = true)
public class WorkWechatOAGetApprovalDetailRequestDTO extends WorkWechatBaseRequestDTO {
private static final long serialVersionUID = -1694960107385L;
/**
* 审批单编号
*/
@JsonProperty("sp_no")
private String spNo;
}
package cn.com.glsx.wechatbuild.model.request.oa;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import com.alibaba.fastjson.annotation.JSONField;
import io.prometheus.client.Summary;
import lombok.*;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.List;
/**
* @Description 获取审批模板详情
* @author chizw
* @create 2025/2/14 15:28
* @version ver.1.0.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ToString(includeFieldNames = true, callSuper = true)
public class WorkWechatOAGetTemplateDetailRequestDTO extends WorkWechatBaseRequestDTO {
private static final long serialVersionUID = -1694960107385L;
/**
* 模板的唯一标识id
*/
@JsonProperty("template_id")
private String templateId;
}
package cn.com.glsx.wechatbuild.model.request.oa;
import cn.com.glsx.wechatbuild.model.WorkWechatBaseRequestDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @Description 手机号获取userid
* @author chizw
* @create 2025/2/14 15:28
* @version ver.1.0.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ToString(includeFieldNames = true, callSuper = true)
public class WorkWechatUserGetuseridRequestDTO extends WorkWechatBaseRequestDTO {
private static final long serialVersionUID = -1694960107385L;
/**
* 用户在企业微信通讯录中的手机号码
*/
@JsonProperty("mobile")
private String mobile;
}
package cn.com.glsx.wechatbuild.model.request.oa.approval;
import cn.com.glsx.scrm.wechat.dto.workwechat.WorkWechatBaseRequestDTO;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.dubbo.apidocs.annotations.RequestParam;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@Setter
@Getter
@ToString(includeFieldNames = true, callSuper = true)
public class GetWorkWechatApprovalInfoRequestDTO extends WorkWechatBaseRequestDTO {
private static final long serialVersionUID = -5243018292083362203L;
/**
* 朋友圈记录开始时间。Unix时间戳
*/
@JsonProperty("starttime")
@NotNull
@RequestParam(value = "starttime", description = "朋友圈记录开始时间。Unix时间戳", required = true)
private Long startTime;
/**
* 朋友圈记录结束时间。Unix时间戳
*/
@JsonProperty("endtime")
@NotNull
@RequestParam(value = "endtime", description = "朋友圈记录结束时间。Unix时间戳", required = true)
private Long endTime;
/**
* 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
*/
@JsonProperty("new_cursor")
@RequestParam(value = "newCursor", description = "分页查询游标,默认为空串,后续使用返回的new_next_cursor进行分页拉取")
@NotNull
private String newCursor;
/**
* 返回的最大记录数,整型,最大值20,默认值20,超过最大值时取默认值
*/
@JsonProperty("size")
@RequestParam(value = "size", description = "返回的最大记录数,整型,最大值100,默认值100,超过最大值时取默认值")
@NotNull
private Integer size=100;
/**
* 筛选类型,包括:
* template_id - 模板类型/模板id;
* creator - 申请人;
* department - 审批单提单者所在部门;
* sp_status - 审批状态;
* record_type - 审批单类型属性,1-请假;2-打卡补卡;3-出差;4-外出;5-加班; 6- 调班;7-会议室预定;8-退款审批;9-红包报销审批
*
* 注意:
* 1、仅“部门”支持同时配置多个筛选条件。
* 2、不同类型的筛选条件之间为“与”的关系,同类型筛选条件之间为“或”的关系
* 3、record_type筛选类型仅支持2021/05/31以后新提交的审批单,历史单不支持表单类型属性过滤
* 筛选值,对应为:template_id-模板id;creator-申请人userid ;department-所在部门id;sp_status-审批单状态(1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付)
*
*/
@JsonProperty("filters")
@RequestParam(value = "size", description = "返回的最大记录数,整型,最大值100,默认值100,超过最大值时取默认值")
private List<Filter> filters;
public static class Filter {
private String key;
private String value;
// Getters and Setters
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
package cn.com.glsx.wechatbuild.model.response.oa;
import cn.com.glsx.scrm.wechat.dto.BaseResponseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @Description 手机号获取userid
* @author chizw
* @create 2025/2/28 2:25
* @version ver.1.0.0
*/
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
public class UploadWorkUserGetuseridResponseDTO extends BaseResponseDTO {
private static final long serialVersionUID = -3849867089877210048L;
@JsonProperty("userid")
private String userid;
}
package cn.com.glsx.wechatbuild.model.response.oa;
import cn.com.glsx.scrm.wechat.dto.BaseResponseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @Title: UploadWorkWechatMediaResponseDTO.java
* @Description:
* @author Alvin
* @date 2021年10月27日 下午7:16:07
* @version V1.0
*/
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
public class UploadWorkWechatMediaResponseDTO extends BaseResponseDTO {
private static final long serialVersionUID = -3849867089877210048L;
@JsonProperty("type")
private String type;
@JsonProperty("media_id")
private String mediaId;
@JsonProperty("created_at")
private String createdAt;
}
package cn.com.glsx.wechatbuild.model.response.oa;
import cn.com.glsx.wechatbuild.model.BaseResponseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
import java.util.List;
/**
* @Description 提交审批申请
* @author chizw
* @create 2025/2/14 16:19
* @version ver.1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatOAApplyEventResponseDTO extends BaseResponseDTO implements Serializable{
private static final long serialVersionUID = 65436547645740473L;
/**
* 表单提交成功后,返回的表单编号
*/
@JsonProperty("sp_no")
private String spNo;
}
package cn.com.glsx.wechatbuild.model.response.oa;
import cn.com.glsx.wechatbuild.model.BaseResponseDTO;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @Description 提交审批申请
* @author chizw
* @create 2025/2/14 16:19
* @version ver.1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatOAApprovalInfoResponseDTO extends BaseResponseDTO implements Serializable{
private static final long serialVersionUID = 65436547645740473L;
/**
* 审批单号列表,包含满足条件的审批申请
*/
@JsonProperty("sp_no_list")
private List<String> spNoList;
/**
* 后续请求查询的游标,当返回结果没有该字段时表示审批单已经拉取完
*/
@JsonProperty("new_next_cursor")
private String newNextCursor;
}
package cn.com.glsx.wechatbuild.model.response.oa;
import cn.com.glsx.scrm.wechat.dto.BaseResponseDTO;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
import java.util.List;
/**
* @Description 获取审批申请详情
* @author chizw
* @create 2025/2/14 16:19
* @version ver.1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatOAGetApprovalDetailResponseDTO extends BaseResponseDTO implements Serializable{
private static final long serialVersionUID = 65436547645740473L;
/**
* 信息
*/
@JsonProperty("info")
private Info info;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Info{
/**
* 审批编号
*/
@JsonProperty("sp_no")
private String spNo;
/**
* 审批申请类型名称(审批模板名称)
*/
@JsonProperty("sp_name")
private String spName;
/**
* 申请单状态:1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 审批模板id
*/
@JsonProperty("template_id")
private String templateId;
/**
* 审批申请提交时间,Unix时间戳
*/
@JsonProperty("apply_time")
private Long applyTime;
/**
* 申请人信息
*/
@JsonProperty("applyer")
private Applyer applyer;
/**
* 批量申请人信息(和applyer字段互斥)
*/
// @JsonProperty("batch_applyer")
// private BatchApplyer batchApplyer;
/**
* 审批流程信息,可能有多个审批节点。
*/
@JsonProperty("sp_record")
private List<SpRecord> spRecord;
/**
* 抄送信息,可能有多个抄送节点
*/
@JsonProperty("notifyer")
private List<Notifyer> notifyer;
/**
* 审批申请数据
*/
@JsonProperty("apply_data")
private ApplyData applyData;
/**
* 审批申请备注信息,可能有多个备注节点
*/
@JsonProperty("comments")
private List<JSONObject> comments;
/**
* 审批流程列表
*/
@JsonProperty("process_list")
private Process processList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Notifyer implements Serializable {
/**
* 节点抄送人userid
*/
@JsonProperty("userid")
private String userid;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Process implements Serializable {
/**
* 流程节点
*/
@JsonProperty("node_list")
private List<Process.Node> nodeList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Node implements Serializable {
/**
* 节点类型 1 审批人 2 抄送人 3办理人
*/
@JsonProperty("node_type")
private Integer nodeType;
/**
* 节点状态 1-审批中;2-同意;3-驳回;4-转审;11-退回给指定审批人;12-加签;13-同意并加签;14-办理;15-转交
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 多人办理方式 1-会签;2-或签 3-依次审批
*/
@JsonProperty("apv_rel")
private Integer apvRel;
/**
* 子节点列表
*/
@JsonProperty("sub_node_list")
private List<Process.Node.SubNode> subNodeList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class SubNode implements Serializable {
/**
* 处理人信息
*/
@JsonProperty("userid")
private String userid;
/**
* 审批/办理意见
*/
@JsonProperty("speech")
private String speech;
/**
* 子节点状态 1-审批中;2-同意;3-驳回;4-转审;11-退回给指定审批人;12-加签;13-同意并加签;14-办理;15-转交
*/
@JsonProperty("sp_yj")
private Integer spYj;
/**
* 操作时间
*/
@JsonProperty("sptime")
private Long sptime;
/**
* 附件
*/
@JsonProperty("media_ids")
private List<String> mediaIds;
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class SpRecord implements Serializable {
/**
* 审批节点状态:1-审批中;2-已同意;3-已驳回;4-已转审;11-已退回;12-已加签;13-已同意并加签
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 节点审批方式:1-或签;2-会签
*/
@JsonProperty("approverattr")
private Integer approverattr;
/**
* 节点审批方式:1-或签;2-会签
*/
@JsonProperty("details")
private List<SpRecord.Detail> details;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Detail implements Serializable {
/**
* 分支审批人
*/
@JsonProperty("approver")
private SpRecord.Detail.Approver approver;
/**
* 审批意见
*/
@JsonProperty("speech")
private String speech;
/**
* 分支审批人审批状态:1-审批中;2-已同意;3-已驳回;4-已转审;11-已退回;12-已加签;13-已同意并加签
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 节点分支审批人审批操作时间戳,0表示未操作
*/
@JsonProperty("sptime")
private Long sptime;
/**
* 备注附件id
*/
@JsonProperty("media_id")
private List<String> mediaId;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Approver implements Serializable {
/**
* 分支审批人userid
*/
@JsonProperty("userid")
private String userid;
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class BatchApplyer implements Serializable {
/**
* 申请人userid
*/
@JsonProperty("userid")
private String userid;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Applyer implements Serializable {
/**
* 申请人userid
*/
@JsonProperty("userid")
private String userid;
/**
* 申请人所在部门id
*/
@JsonProperty("partyid")
private String partyid;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class ApplyData implements Serializable {
/**
* 模板控件数组
*/
@JsonProperty("contents")
private List<ApplyData.Content> contents;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Content implements Serializable {
/**
* 控件类型
*/
@JsonProperty("control")
private String control;
/**
* 控件id
*/
@JsonProperty("id")
private String id;
/**
* 控件名称
*/
@JsonProperty("title")
private List<ApplyData.Content.Title> title;
/**
* 控件名称
*/
@JsonProperty("value")
private ContentValue value;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class ContentValue implements Serializable {
/**
* 文本/多行文本控件
*/
@JsonProperty("text")
private String text;
/**
* control参数为Number
*/
@JsonProperty("new_number")
private String newNumber;
/**
* control参数为Money
*/
@JsonProperty("new_money")
private String newMoney;
/**
* 假勤组件-请假组件(control参数为Vacation)
*/
@JsonProperty("vacation")
private Vacation vacation;
/**
* 假勤组件-出差/外出/加班组件(control参数为Attendance)
*/
@JsonProperty("attendance")
private Attendance attendance;
/**
* 补卡组件(control参数为PunchCorrection)
*/
@JsonProperty("punch_correction")
private PunchCorrection punchCorrection;
/**
* control参数为Selector
*/
@JsonProperty("selector")
private Selector selector;
/**
* control参数为File
*/
@JsonProperty("files")
private List<FileId> files;
/**
* control参数为Table
*/
@JsonProperty("children")
private List<Children> children;
/**
* control参数为Table
*/
@JsonProperty("sum_field")
private List<SumField> sumField;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class FileId implements Serializable {
@JsonProperty("file_id")
private String fileId;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Children implements Serializable {
@JsonProperty("list")
private List<Content> list;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class SumField implements Serializable {
/**
* 控件类型
*/
@JsonProperty("control")
private String control;
/**
* 控件id
*/
@JsonProperty("id")
private String id;
/**
* 控件名称
*/
@JsonProperty("title")
private List<ApplyData.Content.Title> title;
/**
* 值
*/
@JsonProperty("value")
private String value;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class PunchCorrection implements Serializable {
/**
* 异常状态说明
*/
@JsonProperty("state")
private String state;
/**
* 补卡时间,Unix时间戳
*/
@JsonProperty("time")
private Long time;
/**
* 版本标识,为1的时候为新版补卡,daymonthyear有值
*/
@JsonProperty("version")
private Integer version;
/**
* 补卡日期0点Unix时间戳
*/
@JsonProperty("daymonthyear")
private Long daymonthyear;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Vacation implements Serializable {
/**
* 请假类型,所选选项与假期管理关联,为假期管理中的假期类型
*/
@JsonProperty("selector")
private Selector selector;
/**
* 假勤组件
*/
@JsonProperty("attendance")
private Attendance attendance;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Attendance implements Serializable {
/**
* 假勤组件时间选择范围
*/
@JsonProperty("date_range")
private DateRange dateRange;
/**
* 假勤组件类型:1-请假;2-补卡;3-出差;4-外出;5-加班
*/
@JsonProperty("type")
private Integer type;
/**
* 时长支持按天分片信息
*/
@JsonProperty("slice_info")
private SliceInfo sliceInfo;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class SliceInfo implements Serializable {
/**
* 总时长,单位是秒
*/
@JsonProperty("duration")
private Long duration;
/**
* 时长计算来源类型: 1--系统自动计算;2--用户修改
*/
@JsonProperty("state")
private Integer state;
/**
* 时长支持按天分片信息
*/
@JsonProperty("day_items")
private List<DayItem> dayItems;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class DayItem implements Serializable {
/**
* 日期的00:00:00时间戳,Unix时间
*/
@JsonProperty("daytime")
private Long daytime;
/**
* 分隔当前日期的时长秒数
*/
@JsonProperty("duration")
private Long duration;
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class DateRange implements Serializable {
/**
* 时间展示类型:halfday-日期;hour-日期+时间
*/
@JsonProperty("type")
private String type;
/**
* 开始时间,unix时间戳
*/
@JsonProperty("new_begin")
private Long newBegin;
/**
* 结束时间,unix时间戳
*/
@JsonProperty("new_end")
private Long newEnd;
/**
* 时长范围, 单位秒
*/
@JsonProperty("new_duration")
private Long newDuration;
/**
* 时区信息,只有在非UTC+8的情况下会返回
*/
@JsonProperty("timezone_info")
private TimezoneInfo timezoneInfo;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class TimezoneInfo implements Serializable {
/**
* 时区偏移量
*/
@JsonProperty("zone_offset")
private String zoneOffset;
/**
* 时区描述
*/
@JsonProperty("zone_desc")
private String zoneDesc;
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Selector implements Serializable {
/**
* 选择类型:single-单选;multi-多选
*/
@JsonProperty("type")
private String type;
/**
* 选项,包含单选/多选控件中的所有选项,可能有多个
*/
@JsonProperty("options")
private List<Option> options;
@JsonProperty("exp_type")
private String expType;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Option implements Serializable {
/**
* 选项key,选项的唯一id
*/
@JsonProperty("key")
private String key;
/**
* 选项值
*/
@JsonProperty("value")
private List<Value> value;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Value implements Serializable {
/**
* 若配置了多语言则会包含中英文的选项值
*/
@JsonProperty("text")
private String text;
/**
* 默认为zh_CN中文
*/
@JsonProperty("lang")
private String lang;
}
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Title implements Serializable {
/**
* 若配置了多语言则会包含中英文的控件名称
*/
@JsonProperty("text")
private String text;
/**
* 默认为zh_CN中文
*/
@JsonProperty("lang")
private String lang;
}
}
}
}
}
package cn.com.glsx.wechatbuild.model.response.oa;
import cn.com.glsx.scrm.wechat.dto.BaseResponseDTO;
import com.alibaba.fastjson.JSONObject;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* @Description 获取审批申请详情
* @author chizw
* @create 2025/2/14 16:19
* @version ver.1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatOAGetApprovalDetailSingleResponseDTO extends BaseResponseDTO implements Serializable{
private static final long serialVersionUID = 65436547645740473L;
/**
* 信息
*/
@JsonProperty("info")
private Info info;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Info{
/**
* 审批编号
*/
@JsonProperty("sp_no")
private String spNo;
/**
* 审批申请类型名称(审批模板名称)
*/
@JsonProperty("sp_name")
private String spName;
/**
* 申请单状态:1-审批中;2-已通过;3-已驳回;4-已撤销;6-通过后撤销;7-已删除;10-已支付
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 审批模板id
*/
@JsonProperty("template_id")
private String templateId;
/**
* 审批申请提交时间,Unix时间戳
*/
@JsonProperty("apply_time")
private Long applyTime;
/**
* 申请人信息
*/
@JsonProperty("applyer")
private Applyer applyer;
/**
* 批量申请人信息(和applyer字段互斥)
*/
// @JsonProperty("batch_applyer")
// private BatchApplyer batchApplyer;
/**
* 审批流程信息,可能有多个审批节点。
*/
@JsonProperty("sp_record")
private List<SpRecord> spRecord;
/**
* 抄送信息,可能有多个抄送节点
*/
@JsonProperty("notifyer")
private List<Notifyer> notifyer;
/**
* 审批申请数据
*/
@JsonProperty("apply_data")
private JSONObject applyData;
/**
* 审批申请备注信息,可能有多个备注节点
*/
@JsonProperty("comments")
private List<JSONObject> comments;
/**
* 审批流程列表
*/
@JsonProperty("process_list")
private Process processList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Notifyer implements Serializable {
/**
* 节点抄送人userid
*/
@JsonProperty("userid")
private String userid;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Process implements Serializable {
/**
* 流程节点
*/
@JsonProperty("node_list")
private List<Node> nodeList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Node implements Serializable {
/**
* 节点类型 1 审批人 2 抄送人 3办理人
*/
@JsonProperty("node_type")
private Integer nodeType;
/**
* 节点状态 1-审批中;2-同意;3-驳回;4-转审;11-退回给指定审批人;12-加签;13-同意并加签;14-办理;15-转交
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 多人办理方式 1-会签;2-或签 3-依次审批
*/
@JsonProperty("apv_rel")
private Integer apvRel;
/**
* 子节点列表
*/
@JsonProperty("sub_node_list")
private List<SubNode> subNodeList;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class SubNode implements Serializable {
/**
* 处理人信息
*/
@JsonProperty("userid")
private String userid;
/**
* 审批/办理意见
*/
@JsonProperty("speech")
private String speech;
/**
* 子节点状态 1-审批中;2-同意;3-驳回;4-转审;11-退回给指定审批人;12-加签;13-同意并加签;14-办理;15-转交
*/
@JsonProperty("sp_yj")
private Integer spYj;
/**
* 操作时间
*/
@JsonProperty("sptime")
private Long sptime;
/**
* 附件
*/
@JsonProperty("media_ids")
private List<String> mediaIds;
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class SpRecord implements Serializable {
/**
* 审批节点状态:1-审批中;2-已同意;3-已驳回;4-已转审;11-已退回;12-已加签;13-已同意并加签
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 节点审批方式:1-或签;2-会签
*/
@JsonProperty("approverattr")
private Integer approverattr;
/**
* 节点审批方式:1-或签;2-会签
*/
@JsonProperty("details")
private List<Detail> details;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Detail implements Serializable {
/**
* 分支审批人
*/
@JsonProperty("approver")
private Approver approver;
/**
* 审批意见
*/
@JsonProperty("speech")
private String speech;
/**
* 分支审批人审批状态:1-审批中;2-已同意;3-已驳回;4-已转审;11-已退回;12-已加签;13-已同意并加签
*/
@JsonProperty("sp_status")
private Integer spStatus;
/**
* 节点分支审批人审批操作时间戳,0表示未操作
*/
@JsonProperty("sptime")
private Long sptime;
/**
* 备注附件id
*/
@JsonProperty("media_id")
private List<String> mediaId;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Approver implements Serializable {
/**
* 分支审批人userid
*/
@JsonProperty("userid")
private String userid;
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class BatchApplyer implements Serializable {
/**
* 申请人userid
*/
@JsonProperty("userid")
private String userid;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Applyer implements Serializable {
/**
* 申请人userid
*/
@JsonProperty("userid")
private String userid;
/**
* 申请人所在部门id
*/
@JsonProperty("partyid")
private String partyid;
}
}
}
package cn.com.glsx.wechatbuild.model.response.oa;
import cn.com.glsx.wechatbuild.model.BaseResponseDTO;
import lombok.*;
import org.apache.poi.sl.usermodel.Placeholder;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonMethod;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @author chizw
* @create 2025/2/14 16:19
* @version ver.1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(callSuper = true, includeFieldNames = true)
public class WorkWechatOAGetTemplateDetailResponseDTO extends BaseResponseDTO implements Serializable{
private static final long serialVersionUID = 65436547645740473L;
/**
* 模板名称
*/
@JsonProperty("template_names")
private List<TemplateName> templateNames;
/**
* 模板控件信息
*/
@JsonProperty("template_content")
private TemplateContent templateContent;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class TemplateContent implements Serializable {
/**
* 模板控件数组
*/
@JsonProperty("controls")
private List<Control> controls;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Control implements Serializable {
/**
* 模板控件属性
*/
@JsonProperty("property")
private Property property;
/**
* 模板控件配置
*/
@JsonProperty("config")
private Config config;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Config implements Serializable {
/**
* Selector控件
*/
@JsonProperty("selector")
private Selector selector;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Selector implements Serializable {
/**
* 选择类型:single-单选;multi-多选
*/
@JsonProperty("type")
private String type;
/**
* 选项,包含单选/多选控件中的所有选项,可能有多个
*/
@JsonProperty("options")
private List<Option> options;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Option implements Serializable {
/**
* 选项key,选项的唯一id
*/
@JsonProperty("key")
private String key;
/**
* 选项值
*/
@JsonProperty("value")
private List<Value> value;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Value implements Serializable {
/**
* 若配置了多语言则会包含中英文的选项值
*/
@JsonProperty("text")
private String text;
/**
* 默认为zh_CN中文
*/
@JsonProperty("lang")
private String lang;
}
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Property implements Serializable {
/**
* 控件类型
*/
@JsonProperty("control")
private String control;
/**
* 控件id
*/
@JsonProperty("id")
private String id;
/**
* 控件名称
*/
@JsonProperty("title")
private List<Title> title;
/**
* 控件说明
*/
@JsonProperty("placeholder")
private List<Placeholder> placeholder;
/**
* 是否必填:1-必填;0-非必填
*/
@JsonProperty("require")
private Integer require;
/**
* 是否参与打印:1-不参与打印;0-参与打印
*/
@JsonProperty("un_print")
private Integer unPrint;
@JsonProperty("un_replace")
private Integer unReplace;
@JsonProperty("display")
private Integer display;
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Placeholder implements Serializable {
/**
* 若配置了多语言则会包含中英文的控件说明
*/
@JsonProperty("text")
private String text;
/**
* 默认为zh_CN中文
*/
@JsonProperty("lang")
private String lang;
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class Title implements Serializable {
/**
* 若配置了多语言则会包含中英文的控件名称
*/
@JsonProperty("text")
private String text;
/**
* 默认为zh_CN中文
*/
@JsonProperty("lang")
private String lang;
}
}
}
}
@Data
@NoArgsConstructor
@JsonAutoDetect(JsonMethod.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(includeFieldNames = true, callSuper = true)
public static class TemplateName implements Serializable {
/**
* 若配置了多语言则会包含中英文的模板名称
*/
@JsonProperty("text")
private String text;
/**
* 默认为zh_CN中文
*/
@JsonProperty("lang")
private String lang;
}
}
package cn.com.glsx.wechatbuild.service;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.common.auth.CredentialsProvider;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.InputStream;
/**
* @Title:
* @Description: 文件上传服务
* @Author xiehx
* @Date 2025/7/18
**/
@Slf4j
@Service
public class FileUploadService {
/**
* 上传文件流到阿里oss
*
* @param inputStream 文件流
* @param objectName 文件名
* @param endpointPost oss端点
* @param bucketName oss桶
* @param accessKeyId oss key
* @param accessKeySecret oss 秘钥
* @return
*/
public String uploadFileInputStreamToOss(InputStream inputStream,
String objectName,
String endpointPost,
String bucketName,
String accessKeyId,
String accessKeySecret) {
String fileUrl=null;
String endpoint = "https://"+ endpointPost;
if (org.apache.commons.lang3.StringUtils.isAnyBlank(endpointPost, bucketName, accessKeyId, accessKeySecret)) {
log.info("oss 配置存在缺失,请检查");
return "";
}
CredentialsProvider credentialsProvider = new DefaultCredentialProvider(accessKeyId, accessKeySecret);
OSS ossClient = new OSSClientBuilder().build(endpoint, credentialsProvider);
try {
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, inputStream);
PutObjectResult result = ossClient.putObject(putObjectRequest);
log.info("Object upload successfully,object url is:{}", JSONObject.toJSONString(result));
fileUrl="https://" + bucketName + "." + endpointPost + "/" + objectName;
} catch (OSSException oe) {
log.info("Error Message:{}",oe.getErrorMessage());
log.info("Error Code:{}", oe.getErrorCode());
log.info("Request ID:{}",oe.getRequestId());
log.info("Host ID:{}",oe.getHostId());
} catch (ClientException ce) {
log.info("Error Message:{}",ce.getMessage());
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
return fileUrl;
}
}
package cn.com.glsx.wechatbuild.util;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class BatchGetUserIds {
// 定义请求的 URL
private static final String URL = "http://192.168.5.4:8856/wechat-build-server/wechat/oa/getuserid";
private static final int MERCHANT_ID = 44211276; // 商户 ID
public static void main(String[] args) {
// 输入参数:由逗号分隔的手机号字符串
String mobileNumbers = "18676666516,\n"
+ "13802229598,\n"
+ "13919272907,\n"
+ "18566760303,\n"
+ "13526701628,\n"
+ "18682180325,\n"
+ "13728711329,\n"
+ "19902905889,\n"
+ "13652364839,\n"
+ "13510950533,\n"
+ "18581101077,\n"
+ "13724315942,\n"
+ "13760137906,\n"
+ "13632791593,\n"
+ "15816882305,\n"
+ "18118758708,\n"
+ "18680331654,\n"
+ "18682474862,\n"
+ "18665871042,\n"
+ "18908415199,\n"
+ "15018517717,\n"
+ "13632614859,\n"
+ "13480792980,\n"
+ "18823398223,\n"
+ "13682565704,\n"
+ "13553354585,\n"
+ "18824231191,\n"
+ "13510709443,\n"
+ "15989449484,\n"
+ "18996176130,\n"
+ "15234057707,\n"
+ "13631653672,\n"
+ "18919005480,\n"
+ "15818722524,\n"
+ "17603040301,\n"
+ "13510769158,\n"
+ "13999188852,\n"
+ "18129809927,\n"
+ "13714501965,\n"
+ "13418902274,\n"
+ "15207557473,\n"
+ "13410512690,\n"
+ "18873336682,\n"
+ "13410260372,\n"
+ "13825236036,\n"
+ "13570899179,\n"
+ "13714966184,\n"
+ "13084995463,\n"
+ "13888061059,\n"
+ "15920068599,\n"
+ "13510892076,\n"
+ "15889357022,\n"
+ "15398879285,\n"
+ "15718122929,\n"
+ "13480758420,\n"
+ "18906352768,\n"
+ "13750094813,\n"
+ "13387572660,\n"
+ "18529534556,\n"
+ "18565743895,\n"
+ "13229655547,\n"
+ "13826510577,\n"
+ "18207493352,\n"
+ "17665387186,\n"
+ "15017915884,\n"
+ "13823254902,\n"
+ "17620387810,\n"
+ "15626599735,\n"
+ "13476670746,\n"
+ "13027947509,\n"
+ "18565882751,\n"
+ "13544162147,\n"
+ "18723016068,\n"
+ "13428582370,\n"
+ "13530356814,\n"
+ "18211271651,\n"
+ "18520855727,\n"
+ "13560142275,\n"
+ "13692232975,\n"
+ "18978849947,\n"
+ "13686451207,\n"
+ "13725594447,\n"
+ "18126301457,\n"
+ "18925261040,\n"
+ "18588459791,\n"
+ "15521063171,\n"
+ "15816539334,\n"
+ "13602576682,\n"
+ "13640414684,\n"
+ "13164067126,\n"
+ "13510080191,\n"
+ "15814019200,\n"
+ "15986611271,\n"
+ "15002093718,\n"
+ "18098972608,\n"
+ "13480670943,\n"
+ "13729407587,\n"
+ "13113615137,\n"
+ "13590474377,\n"
+ "13132112126,\n"
+ "17718004057,\n"
+ "15029223187,\n"
+ "13825207633,\n"
+ "15091195572,\n"
+ "13923832622,\n"
+ "13650810420,\n"
+ "13560435936,\n"
+ "15914132780,\n"
+ "15218375798,\n"
+ "15130200650,\n"
+ "13632814608,\n"
+ "13428794434,\n"
+ "18750768529,\n"
+ "15811800411,\n"
+ "19842779228,\n"
+ "17717113018,\n"
+ "15019903579,\n"
+ "13714250690,\n"
+ "13367011268,\n"
+ "18608638562,\n"
+ "15814684652,\n"
+ "13145829752,\n"
+ "15728669308,\n"
+ "15765100646,\n"
+ "13971818453,\n"
+ "15121903206,\n"
+ "18778661361,\n"
+ "17363923696,\n"
+ "13333970369,\n"
+ "15348433022,\n"
+ "13545099802,\n"
+ "13924651037,\n"
+ "18845036713,\n"
+ "17875511834,\n"
+ "13811039666,\n"
+ "13437112703,\n"
+ "15007612682,\n"
+ "13919196474,\n"
+ "13641460319,\n"
+ "14776593605,\n"
+ "17723810309,\n"
+ "18312008906,\n"
+ "13603070903,\n"
+ "15599117475,\n"
+ "15974485939,\n"
+ "18372203315,\n"
+ "18777537522,\n"
+ "15926409442,\n"
+ "18501960271,\n"
+ "18991371609,\n"
+ "17320505265,\n"
+ "15060463550,\n"
+ "15619023691,\n"
+ "13114808777,\n"
+ "17279285915,\n"
+ "18918071512,\n"
+ "15243552261,\n"
+ "17730566070,\n"
+ "13699753087,\n"
+ "13823275167,\n"
+ "13477802110,\n"
+ "15118075090,\n"
+ "13336542373,\n"
+ "17388809098,\n"
+ "17608426680,\n"
+ "13410574821,\n"
+ "13798241069,\n"
+ "18476546702,\n"
+ "18923029556,\n"
+ "13662232548,\n"
+ "15018500224,\n"
+ "15012971497,\n"
+ "15213642943,\n"
+ "16620140401,\n"
+ "15897150260,\n"
+ "19144475436,\n"
+ "19146473576,\n"
+ "13502026987,\n"
+ "13750327261,\n"
+ "15302793173,\n"
+ "18055827902,\n"
+ "15288110710,\n"
+ "15218742455,\n"
+ "13872331184,\n"
+ "18937619155,\n"
+ "15549042039,\n"
+ "18172379350,\n"
+ "15189464150,\n"
+ "15989792150,\n"
+ "13631278800,\n"
+ "15056333678,\n"
+ "17820774214,\n"
+ "13794566101,\n"
+ "18088803701,\n"
+ "13192910803,\n"
+ "13754841667,\n"
+ "18589053739,\n"
+ "1360201245,\n"
+ "18829958191,\n"
+ "13692759494,\n"
+ "13472209000,\n"
+ "13553723351,\n"
+ "15768618575,\n"
+ "13824226277,\n"
+ "13928455491,\n"
+ "15035677790,\n"
+ "15766901106,\n"
+ "18048516825,\n"
+ "18993509794,\n"
+ "13829913982,\n"
+ "18337408707,\n"
+ "18218808652,\n"
+ "17640559222,\n"
+ "13530954435,\n"
+ "15221101760,\n"
+ "17754026554,\n"
+ "18502669991,\n"
+ "18670052366,\n"
+ "15907124293,\n"
+ "19575361116,\n"
+ "15609207271,\n"
+ "18651630115,\n"
+ "18503817906,\n"
+ "15537622080,\n"
+ "18963987451,\n"
+ "19353601481,\n"
+ "13210038756,\n"
+ "18671398843,\n"
+ "13039586474,\n"
+ "18553927659,\n"
+ "15038286098,\n"
+ "13848877213,\n"
+ "18570062288,\n"
+ "18638692652,\n"
+ "17388657712,\n"
+ "13852289577,\n"
+ "1392273926,\n"
+ "15148078508,\n"
+ "13080667702,\n"
+ "13560114686,\n"
+ "13215017737,\n"
+ "18061660551";
// 分割手机号字符串
String[] mobileArray = mobileNumbers.split(",");
List<String> list= new ArrayList<>();
// 遍历每个手机号并发送请求
for (String mobile : mobileArray) {
try {
String response = sendPostRequest(mobile.trim(), MERCHANT_ID);
String s = parseAndPrintResponse(response, mobile.trim());
list.add(s);
} catch (Exception e) {
System.err.println("请求失败,手机号:" + mobile + ",错误信息:" + e.getMessage());
}
}
for (String s : list){
System.out.println(s);
}
}
/**
* 发送 HTTP POST 请求
*
* @param mobile 手机号
* @param merchantId 商户 ID
* @return 响应内容字符串
* @throws Exception 如果请求失败或出现异常
*/
private static String sendPostRequest(String mobile, int merchantId) throws Exception {
// 创建 HttpClient 实例
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// 创建 POST 请求
HttpPost httpPost = new HttpPost(URL);
// 设置请求体
JsonObject jsonBody = new JsonObject();
jsonBody.addProperty("mobile", mobile);
jsonBody.addProperty("merchantId", merchantId);
StringEntity entity = new StringEntity(jsonBody.toString(), "UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
// 执行请求并获取响应
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
return EntityUtils.toString(response.getEntity(), "UTF-8");
}
}
}
/**
* 解析响应并打印结果
*
* @param jsonResponse 响应内容字符串
* @param mobile 手机号
*/
private static String parseAndPrintResponse(String jsonResponse, String mobile) {
try {
// 解析 JSON 响应
JSONObject jsonObject = JSONObject.parseObject(jsonResponse);
// 获取 errCode 和 errMsg
int errCode = (int) jsonObject.get("errCode");
String errMsg = (String) jsonObject.get("errMsg");
if (errCode == 0) { // 请求成功
String userId = (String) jsonObject.get("userid");
return mobile + " " + userId;
} else {
System.err.println("请求失败,手机号:" + mobile + ",错误信息:" + errMsg);
return mobile;
}
} catch (Exception e) {
System.err.println("解析响应失败,手机号:" + mobile + ",错误信息:" + e.getMessage());
return mobile;
}
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.wechatbuild.util;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.apache.dubbo.common.utils.ArrayUtils;
/**
* @Title: CacheUtil.java
* @Description:
* @author Alvin
* @date 2020年10月20日 下午6:52:24
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
public class CacheUtil {
public final static String SEPARATOR_COLON = ":";
public static String getCacheKey(String prefix, String...keys){
String cacheKey = prefix;
if(ArrayUtils.isNotEmpty(keys)){
cacheKey = cacheKey.concat(SEPARATOR_COLON).concat(Arrays.asList(keys).stream().collect(Collectors.joining(SEPARATOR_COLON)));
}
return cacheKey;
}
}
package cn.com.glsx.wechatbuild.util;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import javax.validation.constraints.NotBlank;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.UUID;
/**
* @author huangch
* @version V1.0
* @Title: FileUtils
* @Description:
* @Company: Didihu.com.cn
* @Date 2024/3/14 10:33
*/
@Slf4j
@UtilityClass
public class FileUtils {
/**
* 根据文件的URL读取文件内容
* @param fileUrl:
* @return java.lang.String
* @author huangch
* @date 2024/3/14 10:35
*/
public static String readFile(String fileUrl) throws Exception{
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(fileUrl).openStream(), "UTF-8"));
StringBuilder contentBuilder = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
contentBuilder.append(line);
contentBuilder.append(System.lineSeparator());
}
return contentBuilder.toString().trim();
}
/**
* 获取文件到本地临时目录下
*
* @param fileUrl 文件url
* @return 文件路径,出现异常返回null
*/
public static String getFileToLocal(@NotBlank String fileUrl, @NotBlank String tempDir, @NotBlank String fileType) {
try {
Path directory = Paths.get(tempDir);
Files.createDirectories(directory);
URL url = new URL(fileUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
log.error("Failed to connect. Response code: {}", connection.getResponseCode());
return null;
}
String fileName = UUID.randomUUID().toString();
String filePath = tempDir + File.separator + fileName + "." + fileType;
try (InputStream inputStream = new BufferedInputStream(connection.getInputStream());
OutputStream fileOutputStream = new BufferedOutputStream(Files.newOutputStream(Paths.get(filePath)))) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, bytesRead);
}
}
return filePath;
} catch (Exception e) {
log.error("Failed to get file from URL: {}", fileUrl, e);
return null;
}
}
/**
* 通过文件url获取文件Base64 编码的字符串
*
* @param fileUrl
* @return
*/
public String getFileAsBase64(String fileUrl) {
try {
URL url = new URL(fileUrl);
try (InputStream inputStream = url.openStream()) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, length);
}
byte[] fileBytes = byteArrayOutputStream.toByteArray();
return Base64.getEncoder().encodeToString(fileBytes);
}
} catch (IOException e) {
log.error("获取文件内容异常,error:{}", e.getMessage(), e);
return null;
}
}
/**
* 通过文件url获取文件内容字节数组
*
* @param fileUrl
* @return
*/
public byte[] getFileAsByteArr(String fileUrl) {
try {
URL url = new URL(fileUrl);
try (InputStream inputStream = url.openStream()) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, length);
}
return byteArrayOutputStream.toByteArray();
}
} catch (IOException e) {
log.error("获取文件内容字节数组异常,error:{}", e.getMessage(), e);
return null;
}
}
/**
* 创建目录
*
* @param dirPath
* @return 创建目录成功 返回true,否则返回false
*/
public boolean makeDir(String dirPath) {
File dir = new File(dirPath);
if (!dir.exists()) {
return dir.mkdirs();
}
return true;
}
/**
* 移除本地临时文件
*
* @param filePath
* @return
*/
public boolean removeLocalFile(String filePath) {
try {
File tempFile = new File(filePath);
return tempFile.delete();
} catch (Exception e) {
log.error("Failed to remove local file: {}", filePath, e);
return false;
}
}
public static byte[] fileToByteArray(File file) {
// 检查文件是否存在
if (!file.exists()) {
log.error("File does not exist.");
return null;
}
// 创建一个字节数组输出流
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try (FileInputStream fileInputStream = new FileInputStream(file)) {
byte[] buffer = new byte[1024];
int bytesRead;
// 循环读取文件内容到缓冲区,并写入到字节数组输出流
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, bytesRead);
}
} catch (IOException e) {
log.error("获取文件内容异常,error:{}", e.getMessage(), e);
return null;
}
// 获取字节数组输出流中的字节数组
return byteArrayOutputStream.toByteArray();
}
/**
* 计算文件大小
*
* @param fileData
* @return
*/
public String formatFileSize(byte[] fileData) {
if (fileData == null || fileData.length <= 0) {
return "0 B";
}
Double size = Double.valueOf(fileData.length);
final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
int index = 0;
while (size >= 1024 && index < units.length - 1) {
size /= 1024.0;
index++;
}
return String.format("%.2f %s", size, units[index]);
}
}
package cn.com.glsx.wechatbuild.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.config.RequestConfig;
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.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class HttpUtils {
/**
* 发送 HTTP POST 请求,并强制使用 TLS 1.2
*
* @param url 请求的目标 URL
* @param entity 请求体内容(JSON、XML 等)
* @param timeout 超时时间(单位:毫秒)
* @param headers 请求头参数
* @return 响应内容字符串
* @throws Exception 如果请求失败或出现异常
*/
public static String post(String url, String entity, Map<String, String> headers) throws Exception {
// 强制使用 TLS 1.2
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);
// 创建支持 TLS 1.2 的 SSL 连接工厂
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
sslContext,
new String[]{"TLSv1.2"}, // 强制使用 TLS 1.2
null,
SSLConnectionSocketFactory.getDefaultHostnameVerifier()
);
// 使用自定义的 SSL 连接工厂创建 HttpClient
try (CloseableHttpClient httpClient = HttpClients.custom()
.setSSLSocketFactory(sslSocketFactory)
.build()) {
// 创建 POST 请求
HttpPost httpPost = new HttpPost(url);
// 设置请求体
if (entity != null && !entity.isEmpty()) {
StringEntity requestEntity = new StringEntity(entity, "UTF-8");
requestEntity.setContentType("application/json"); // 默认设置为 JSON 格式
httpPost.setEntity(requestEntity);
}
// 设置请求头
if (headers != null && !headers.isEmpty()) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
}
// 设置超时时间
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(60000) // 连接超时时间
.setSocketTimeout(60000) // 读取超时时间
.build();
httpPost.setConfig(requestConfig);
// 执行请求并获取响应
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
return EntityUtils.toString(response.getEntity(), "UTF-8");
}
}
}
public static String get(String url) throws Exception {
// 强制使用 TLS 1.2
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);
// 创建支持 TLS 1.2 的 SSL 连接工厂
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(
sslContext,
new String[]{"TLSv1.2"}, // 强制使用 TLS 1.2
null,
SSLConnectionSocketFactory.getDefaultHostnameVerifier()
);
// 使用自定义的 SSL 连接工厂创建 HttpClient
try (CloseableHttpClient httpClient = HttpClients.custom()
.setSSLSocketFactory(sslSocketFactory)
.build()) {
// 创建 POST 请求
HttpGet httpGet = new HttpGet(url);
// 设置超时时间
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(60000) // 连接超时时间
.setSocketTimeout(60000) // 读取超时时间
.build();
httpGet.setConfig(requestConfig);
httpGet.setHeader("accept", "application/json");
// 执行请求并获取响应
ResponseHandler<String> responseHandler = new BasicResponseHandler();
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
return responseHandler.handleResponse(response);
}
}
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.wechatbuild.util;
\ No newline at end of file \ No newline at end of file
# framework-archetype-rpc
RPC服务项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─org.example.config 配置层
├─org.example.manager 通用处理层
├─org.example.mapper Dao映射层
├─org.example.remote RPC接口实现层
├─org.example.service 业务层
├─org.example.util 工具包
└─cn.com.glsx.wechatbuild.Main.java 程序入口
├─resources 资源文件目录
├─config
├─application.properties 应用配置文件
├─META-INF
└─orm SQL配置文件
├─templates 模板目录
└─*.flt freemarker模板,(可用于邮件模板)
└─logback.xml 日志配置文件
└─webapp web前端文件目录
└─WEB-INF
└─bin shell脚本文件(包含启动、停止、重启等)
└─test 测试目录
├─java
└─org.example/service 测试代码
└─resources 测试资源目录
└─pom.xml pom文件
二、使用说明:
1、运行项目前需在配置中心创建配置信息,配置内容参考三配置说明:
1.1> dataId : application.properties --> ore.diamond.dataId + ore.diamond.env
1.2> group : application.properties --> ore.diamond.group
1.3> content : 参考三配置说明
2、生成mybatis文件的插件,使用说明:
1.1> 生成之后可以删掉插件
1.2> IDEA内:点击右侧Maven Projects > 项目 plugins > mybatis-generator 运行
1.3> ECLIPSE内:右键点击项目,选择RUN AS maven build > 输入maven命令:
mybatis-generator:generate -e > 运行
3、Bean转换器mapstruct使用说明:
1.1> 在converter包内建立Bean转换对应的转换器,传入source和target的类型。
1.2> 在remote内使用spring的方式引入bean。
1.3> Bean的属性名一样的情况下,不需要重写方法。
4、自定义过滤器加入方式:
1.1> 在src.main.resources.META-INF.dubbo文件夹下新建文件com.alibaba.dubbo.rpc.Filter
1.2> 在该文件内写入自定义过滤器类的完整地址,以键值对的形式加入,左边为key名称,例如:
dubboAuthorizeFilter=cn.com.glsx.payment.roof.filter.DubboAuthorizeFilter
1.3> 在钻石配置中加入dubbo过滤器的配置,名字为key,例如:
ore.dubbo.provider.enabled=true
ore.dubbo.provider.filter=dubboAuthorizeFilter
三、配置说明:
#----------------------------------------------------------------------------------------------------------
# dubbo配置
# dubbo应用名称
ore.dubbo.application.name=wechat-build-server
# dubbo应用所有者
ore.dubbo.application.owner=deployer name
# dubbo服务注册地址
ore.dubbo.registry.address=zookeeper://192.168.3.206:2181
# dubbo服务注册超时时间
ore.dubbo.registry.timeout=30000
# 默认协议:dubbo
ore.dubbo.protocol.name=dubbo
# dubbo服务扫描包路径
ore.dubbo.scan=org.example.remote
# dubbo服务监控
ore.dubbo.monitor.protocol=registry
# dubbo服务统计
ore.dubbo.provider.filter=metrics
# dubbo配置中心
ore.dubbo.config-center.address=zookeeper://192.168.3.206:2181
# dubbo元数据中心
ore.dubbo.metadata-report.address=zookeeper://192.168.3.206:2181
┌------------------------------------------------------------┐
注:如需在RPC服务里面支持REST风格的服务
1、需在pom中添加如下依赖:
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-dubbo-rest</artifactId>
</dependency>
2、修改钻石配置
# dubbo协议配置(二选一)
#ore.dubbo.protocol.name=dubbo
#ore.dubbo.protocol.port=20880
# dubbo协议配置(二选一)
ore.dubbo.protocols.dubbo.name=dubbo
ore.dubbo.protocols.dubbo.port=20880
# REST协议配置
ore.dubbo.protocols.rest.name=rest
# 应用服务器(默认jetty)
ore.dubbo.protocols.rest.server=jetty
# 服务端口
ore.dubbo.protocols.rest.port=8080
# 最大连接数
ore.dubbo.protocols.rest.accepts=500
# 线程池大小
ore.dubbo.protocols.rest.threads=100
# 基础相对路径
ore.dubbo.protocols.rest.contextpath=rest-api
3、Java示例代码:
@Service //dubbo注解,注册服务
@Path("users") //JAX-RS注解
public class UserServiceRemoteImpl implements UserServiceRemote {
@POST //JAX-RS注解
@Path("register") //JAX-RS注解
@Consumes({MediaType.APPLICATION_JSON}) //JAX-RS注解
public void registerUser(User user) {
// save the user...
}
}
4、访问示例:
http://localhost:8080/rest-api/users/register
5、参考资料
resteasy框架使用介绍,参阅官方文档,地址:http://docs.jboss.org/resteasy/docs/3.6.0.Final/userguide/html/index.html
dubbo rest协议说明,参阅官方文档,地址:http://dubbo.apache.org/zh-cn/docs/user/references/protocol/rest.html
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# druid连接池及数据源配置
ore.druid.url=jdbc:mysql://host:port/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
ore.druid.driver-class=com.mysql.jdbc.Driver
ore.druid.username=用户名
ore.druid.password=密码
ore.druid.initial-size=1
ore.druid.min-idle=1
ore.druid.max-active=20
ore.druid.test-on-borrow=true
# druid连接池监控配置
# 是否开启监控
ore.druid.monitor.enabled=true
# 监控后台用户名,默认:admin
ore.druid.monitor.login-username=admin
# 监控后台密码,默认:admin123
ore.druid.monitor.login-password=admin123
# 监控访问路径匹配规则,默认:/druid/*
ore.druid.monitor.url-mappings=/druid/*
# 监控访问IP白名单,多个以英文逗号“,”隔开,默认:127.0.0.1
ore.druid.monitor.allow=127.0.0.1
# 监控访问IP黑名单(存在共同时,deny优先于allow),多个以英文逗号“,”隔开
ore.druid.monitor.deny=192.168.0.1
# 是否能够重置数据,默认:false,则隐藏页面重置按钮
ore.druid.monitor.reset-enable=false
# 开启SQL监控
ore.druid.filter.stat.enabled=true
# 数据库类型
ore.druid.filter.stat.db-type=mysql
# 是否合并sql
ore.druid.filter.stat.merge-sql=true
# 是否记录慢查询
ore.druid.filter.stat.log-slow-sql=true
# 慢查询时间:200毫秒(默认3000毫秒)
ore.druid.filter.stat.slow-sql-millis=200
# 开启日志监控
ore.druid.filter.slf4j.enabled=true
ore.druid.filter.slf4j.data-source-log-enabled=true
ore.druid.filter.slf4j.statement-executable-sql-log-enable=true
# 开启Spring监控
ore.druid.monitor.spring.enabled=true
# 扫描的包路径,可配置多个,以逗号‘,’隔开
ore.druid.monitor.scanPackages=org.example.mapper.*,org.example.service.*
┌------------------------------------------------------------┐
注:如需使用SQL监控需在pom中添加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# mybatis配置
# 实体模型包
mybatis.type-aliases-package=org.example.model
# SQL脚本文件路径
mybatis.mapper-locations=classpath:/META-INF/orm/*Mapper.xml
# 开启mybatis sql打印
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mapper.mappers=org.oreframework.datasource.mybatis.mapper.OreMapper
mapper.not-empty=false
mapper.identity=MYSQL
# 多数据源配置(主库/读写)
#----------------------------------------------------------------------------------------------------------
# druid连接池及数据源配置
ore.primary.druid.url=jdbc:mysql://主库host:主库port/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
ore.primary.druid.driver-class=com.mysql.jdbc.Driver
ore.primary.druid.username=用户名
ore.primary.druid.password=密码
ore.primary.druid.initial-size=1
ore.primary.druid.min-idle=1
ore.primary.druid.max-active=20
ore.primary.druid.test-on-borrow=true
# mybatis配置
# 实体模型包
ore.primary.mybatis.type-aliases-package=org.example.model
# SQL脚本文件路径
ore.primary.mybatis.mapper-locations=classpath:/META-INF/orm/*Mapper.xml
ore.primary.mapper.mappers=org.oreframework.datasource.mybatis.mapper.OreMapper
ore.primary.mapper.not-empty=false
ore.primary.mapper.identity=MYSQL
┌------------------------------------------------------------┐
使用说明:
方式一:
1、引入SqlSessionTemplate
@Resource(name = "primarySqlSessionTemplate")
private SqlSessionTemplate primarySqlSessionTemplate;
2、获取XxMapper
XxMapper mapper = primarySqlSessionTemplate.getMapper(XxMapper.class);
3、调用
mapper.insert(record);
mapper.delete(record);
......
方式二:
1、XxMapper类上添加注解@PrimaryMapper
2、普通方式调用
└------------------------------------------------------------┘
# 多数据源配置(从库/只读)
#----------------------------------------------------------------------------------------------------------
# druid连接池及数据源配置
ore.secondary.druid.url=jdbc:mysql://从库host:从库port/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
ore.secondary.druid.driver-class=com.mysql.jdbc.Driver
ore.secondary.druid.username=用户名
ore.secondary.druid.password=密码
ore.secondary.druid.initial-size=1
ore.secondary.druid.min-idle=1
ore.secondary.druid.max-active=20
ore.secondary.druid.test-on-borrow=true
# mybatis配置
# 实体模型包
ore.secondary.mybatis.type-aliases-package=org.example.model
# SQL脚本文件路径
ore.secondary.mybatis.mapper-locations=classpath:/META-INF/orm/*Mapper.xml
ore.secondary.mapper.mappers=org.oreframework.datasource.mybatis.mapper.OreMapper
ore.secondary.mapper.not-empty=false
ore.secondary.mapper.identity=MYSQL
┌------------------------------------------------------------┐
使用说明:
方式一:
1、引入SqlSessionTemplate
@Resource(name = "secondarySqlSessionTemplate")
private SqlSessionTemplate secondarySqlSessionTemplate;
2、获取XxMapper
XxMapper mapper = secondarySqlSessionTemplate.getMapper(XxMapper.class);
3、调用
mapper.insert(record);
mapper.delete(record);
......
方式二:
1、XxMapper类上添加注解@SecondaryMapper
2、普通方式调用
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# 分页配置
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
#----------------------------------------------------------------------------------------------------------
# Dubbo Swagger配置
# 是否启用swagger-dubbo,默认为true
swagger.dubbo.enable=true
# http请求地址,默认为http://ip:port/h/com.XXX.XxService/method
#swagger.dubbo.http=h
# rpc zk调用 or 本地调用,默认为rpc
#swagger.dubbo.cluster=rpc
# dubbo 服务版本号,可不配置
swagger.dubbo.application.version=1.0-SNAPSHOT
# dubbo服务groupId,可不配置
swagger.dubbo.application.groupId=org.example
# dubbo服务artifactId,可不配置
swagger.dubbo.application.artifactId=wechat-build-server
┌------------------------------------------------------------┐
使用说明:
1、接口或实现类的方法上添加Swagger注解@ApiOperation(nickname = "queryBy**", value = "查询**", notes = "根据**查询**", httpMethod="GET")[非必须]
2、接口参数添加Swagger注解@ApiParam(value = "参数名称", required=true)[非必须]
3、对象属性添加Swagger注解@ApiModelProperty(value = "属性名称")[非必须]
注意事项:
1、对于服务接口方法重载,为了在http请求中唯一确认一个方法,需要使用注解@ApiOperation(nickname = "byId"),通过nickname标记唯一路径(如果不填写,将只显示一个方法)。
此时,rest的请求地址为:http://ip:port/h/com.XXX.XxService/method/byId
2、Object对象作为http请求参数为json string格式
3、swagger注解既可以写在接口上,也可以写在实现类上
4、原生类型作为http请求参数为必填
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# Freemarker模板配置
# 模板存放路径
spring.freemarker.template-loader-path=classpath:/templates/
# 是否开启模板缓存,默认是开启,开发时请关闭
spring.freemarker.cache=false
# 模板的编码设置,默认UTF-8
spring.freemarker.charset=UTF-8
# 是否检测模板已存在本地
spring.freemarker.check-template-location=true
# 模板的媒体类型设置,默认为text/html
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
# 后缀设置,默认为.ftl
spring.freemarker.suffix=.ftl
┌------------------------------------------------------------┐
注:如需使用freemarker需在pom中添加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# kafka生产者配置
spring.kafka.producer.metadata.broker.list=192.168.3.207:9092
spring.kafka.producer.topic=消息主题
spring.kafka.producer.serializer.class=kafka.serializer.DefaultEncoder
spring.kafka.producer.type=async
spring.kafka.producer.request.required.acks=1
┌------------------------------------------------------------┐
注:如需使用kafka发送消息需在pom中添加如下依赖
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-jms</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# kafka消费者配置
spring.kafka.consumer.group.id=wechat-build-server-consumer
spring.kafka.consumer.zookeeper.connect=192.168.3.207:2181
spring.kafka.consumer.zookeeper.connection.timeout.ms=15000
spring.kafka.consumer.zookeeper.session.timeout.ms=15000
spring.kafka.consumer.auto.commit.interval.ms=1000
spring.kafka.consumer.auto.offset.reset=largest
spring.kafka.consumer.topic=消息主题
# 默认分区消费线程数
spring.kafka.consumer.partitionsNum=6
# 指定主题分区消费线程数
spring.kafka.consumer.消息主题.partitionsNum=2
┌------------------------------------------------------------┐
注:如需使用kafka接收消息需在pom中添加如下依赖
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-jms</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# redis配置
ore.redis.hostName=192.168.3.207
ore.redis.port=6379
ore.redis.password=
ore.redis.pool.maxActive=600
ore.redis.pool.maxWait=10000
ore.redis.pool.maxTotal=300
ore.redis.pool.maxIdle=300
ore.redis.pool.minIdle=0
ore.redis.timeout=30000
┌------------------------------------------------------------┐
注:如需使用redis,需在pom中添加如下依赖
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-redis</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# 雪花算法
# 开启雪花算法
ore.snowflake.enabled=true
# 数据中心ID(0~31)
ore.snowflake.data-center-id=1
# 工作节点ID(0~31)
ore.snowflake.worker-id=1
┌------------------------------------------------------------┐
使用说明:
1、注入SnowflakeWorker
@Autowired
private SnowflakeWorker snowflakeWorker;
2、调用本地方法
long randomId = snowflakeWorker.nextId();
└------------------------------------------------------------┘
server.port=8080
server.display-name=wechat-build-server
server.servlet.context-path=/wechat-build-server
server.servlet.application-display-name=wechat-build-server
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/wechat-build-server/wechat-build-server.log
logging.level.root=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=wechat-build-server
ore.diamond.env=release
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property resource="config/application.properties" />
<property name="APP_NAME" value="${server.display-name}" />
<property name="LOG_PATH" value="${logging.path}" />
<property name="LOG_LEVEL" value="${logging.level}" />
<contextName>${APP_NAME}</contextName>
<turboFilter class="org.oreframework.boot.logging.logback.OreBootTurboFilter">
<Marker>oreframework</Marker>
</turboFilter>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</pattern>
</layout>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding> Label Old version of this label can not be used -->
<!-- <Encoding>UTF-8</Encoding> -->
<File>${LOG_PATH}</File>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_PATH}.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
<layout class="org.oreframework.commons.log.OrePatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%traceid] [%thread] %-5level [%logger{36}.%method %line] - %msg%n</pattern>
</layout>
<!-- 根据文件大小滚动,不支持 SizeBasedTriggeringPolicy 这种配置-->
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>200MB</MaxFileSize>
</triggeringPolicy> -->
</appender>
<!-- druid连接池慢查询日志记录 -->
<appender name="DruidFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${LOG_PATH}.druid_slow_sql</file>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 归档的日志文件的路径,例如今天是2020-01-01日志,当前写的日志文件路径为file节点指定,可以将此文件与file指定文件路径设置为不同路径,从而将当前日志文件或归档日志文件置不同的目录。
而2020-01-01的日志文件在由fileNamePattern指定。%d{yyyy-MM-dd}指定日期格式,%i指定索引 -->
<fileNamePattern>${LOG_PATH}.druid_slow_sql-%d{yyyy-MM-dd}.%i</fileNamePattern>
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,命名日志文件,例如log-error-2020-01-01.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>200MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- 追加方式记录日志 -->
<append>true</append>
<!-- 日志文件的格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- 此日志文件只记录级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<appender-ref ref="DruidFILE" />
</root>
</configuration>
\ No newline at end of file \ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/name="LOG_PATH"/!d;s/.*value="\(.*\)".*/\1/g' classes/logback.xml`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
DUMP_DIR=$LOGS_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
./stop.sh
./start.sh $ENV
\ No newline at end of file \ No newline at end of file
#!/bin/bash
cd `dirname $0`
if [ "$1" = "start" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV
else
if [ "$1" = "stop" ]; then
./stop.sh
else
if [ "$1" = "debug" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV debug
else
if [ "$1" = "restart" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./restart.sh $ENV
else
if [ "$1" = "dump" ]; then
./dump.sh
else
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
exit 1
fi
fi
fi
fi
fi
#!/bin/bash
JAVA_HOME="/app/soft/jdk1.8.0_20"
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/server.display-name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
SERVER_PORT=`sed '/server.port/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/logging.path/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
echo "server name is $SERVER_NAME"
echo "server port is $SERVER_PORT"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$2" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$2" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
COUNT=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
fi
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
#if [ "$1" != "skip" ]; then
#$BIN_DIR/dump.sh
#fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
package cn.com.glsx.wechatbuild.manager;
import cn.com.glsx.wechatbuild.model.GetWorkWechatUserRequestDTO;
import cn.com.glsx.wechatbuild.model.WorkWechatBookUserInfoResponseDTO;
import cn.com.glsx.wechatbuild.model.WorkWechatUserDetailInfoResponseDTO;
import cn.com.glsx.wechatbuild.model.WorkWechatUserInfoResponseDTO;
import cn.com.glsx.wechatbuild.service.BaseServiceTest;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class WorkWechatUserManagerTest extends BaseServiceTest {
@Autowired
private WorkWechatUserManager workWechatUserManager;
@Test
public void testGetUserInfo() {
GetWorkWechatUserRequestDTO request = new GetWorkWechatUserRequestDTO();
request.setCode("fjklskd");
request.setCorpId("wx51bda2e574d24a91");
request.setAgentId("1000046");
WorkWechatUserInfoResponseDTO userInfo = workWechatUserManager.getUserInfo(request);
System.out.println(JSON.toJSONString(userInfo));
}
@Test
public void testCalculateGradeSort() {
System.out.println("A:" + calculateGradeSort("A"));
System.out.println("Z:" + calculateGradeSort("Z"));
System.out.println("A1:" + calculateGradeSort("A1"));
System.out.println("Z1:" + calculateGradeSort("Z1"));
System.out.println("A2:" + calculateGradeSort("A2"));
System.out.println("Z2:" + calculateGradeSort("Z2"));
}
public int calculateGradeSort(String input) {
if (StringUtils.isBlank(input)) return 0;
int index = 0;
// 找到字母部分和数字部分的分割点
while (index < input.length() && Character.isLetter(input.charAt(index))) {
index++;
}
int letterToNumber = 0;
String letters = input.substring(0, index);
String numbers = input.substring(index);
if (StringUtils.isNotBlank(letters)) {
letterToNumber = letters.charAt(0) - 'A' + 1;
}
//数字部分,A1>2, A2> Z1
if (StringUtils.isNotBlank(numbers)) {
int number = Integer.parseInt(numbers);
letterToNumber = letterToNumber + 25 * number + number;
}
return letterToNumber;
}
}
package cn.com.glsx.wechatbuild.remote;
import cn.com.glsx.wechatbuild.Main;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @Title: BaseRemoteTest.java
* @Description:
* @author deployer name
* @date 2018年1月6日 下午3:58:33
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class BaseRemoteTest {
}
//package cn.com.glsx.wechatbuild.remote;
//
//import org.junit.Assert;
//import org.junit.Test;
//import org.apache.dubbo.config.annotation.DubboReference;
//import org.example.model.DemoModel;
//
///**
// * @Title: DemoRemoteTest.java
// * @Description:
// * @author deployer name
// * @version V1.0
// * @Company: Didihu.com.cn
// * @Copyright Copyright (c) 2017
// */
//public class DemoRemoteTest extends BaseRemoteTest{
//
//// @DubboReference
//// private DemoRemote demoRemote;
////
//// @Test
//// public void load(){
//// DemoModel model = demoRemote.get("name");
//// Assert.assertNotNull(model);
//// }
//}
package cn.com.glsx.wechatbuild.service;
import cn.com.glsx.scrm.wechat.dto.workwechat.media.response.GetWorkWechatMediaResponseDTO;
import cn.com.glsx.wechatbuild.Main;
import com.alibaba.fastjson.JSON;
import org.junit.runner.RunWith;
import org.oreframework.util.http.HttpUtil;
import org.oreframework.util.json.JacksonUtils;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.IOException;
/**
* @Title: BaseServiceTest.java
* @Description:
* @author deployer name
* @date 2018年1月6日 下午1:23:03
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class BaseServiceTest {
public static void main1(String[] args) throws IOException {
String token = "pkE7tW6GgGR0XI-OpLWOA_tAKNEhSVe3G25Sx6cdMtdDe_1jLzpUu9t0hlWugXP2UNGKLbeBjSnlMgqA3uJ5m51yavC5BOB8v_cX1--wmdkoJv1Wzd3esOgrdu87IPvIJLqtMVUcLY79DXeZxLiPPfoLvSz8zYD8W3VSg58eDhPic4unnWVPWw9K-iwEQeQl3uI6q_XH6KOYOm_elPksBQ";
String url = "https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=" + token + "&media_id=" + "WWME_I3njHwAALePR83PZEGFzHbmKoxX1vA";
String body = "{\"merchantId\":44210895,\"useridlist\":[\"Pun.ch\"],\"endtime\":1743523199,\"starttime\":1743436800}";
String response = HttpUtil.post(url, body);
System.out.println(JSON.toJSONString(response));
GetWorkWechatMediaResponseDTO dto = JacksonUtils.jsonCastBean(response, GetWorkWechatMediaResponseDTO.class);
System.out.println(JSON.toJSONString(dto));
}
}
package cn.com.glsx.wechatbuild.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.junit.Assert;
import org.junit.Test;
/**
* @Title: DemoServiceTest.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
public class DemoServiceTest extends BaseServiceTest{
// @Autowired
// private DemoService demoService;
//
// @Test
// public void load(){
// DemoModel model = demoService.load();
// Assert.assertNotNull(model);
// }
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<!-- 确保已安装mybatis generator eclipse插件 -->
<generatorConfiguration>
<context id="DB2Tables" targetRuntime="MyBatis3">
<property name="javaFileEncoding" value="UTF-8"/>
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="org.oreframework.datasource.mybatis.mapper.OreMapper"/>
<property name="caseSensitive" value="true"/>
<property name="useActualColumnNames" value="true" />
<!--<property name="beginningDelimiter" value="`"/>-->
<!--<property name="endingDelimiter" value="`"/>-->
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.227:3306/数据库名?characterEncoding=utf8" userId="dev_admin" password="1f7e1ed2" />
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<javaModelGenerator targetPackage="org.example.model" targetProject="../wechat-build-server-api/src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="META-INF/orm" targetProject="src/main/resources">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator targetPackage="org.example.mapper" targetProject="MAVEN" type="XMLMAPPER">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- 可配置多个 -->
<table tableName="数据库表名" domainObjectName="Java数据模型名" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
</context>
</generatorConfiguration>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!