35 changed files with 515 additions and 146 deletions
@ -0,0 +1,3 @@ |
|||||||
|
{ |
||||||
|
"base64": "data:image/jpg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAB2qADAAQAAAABAAAAMgAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/8AAEQgAMgHaAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMADw8PDw8PGg8PGiQaGhokMSQkJCQxPjExMTExPks+Pj4+Pj5LS0tLS0tLS1paWlpaWmlpaWlpdnZ2dnZ2dnZ2dv/bAEMBEhMTHhweNBwcNHtURVR7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t7e3t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OcdOtMbTlEEcMMjRmJtwYc5POc565zQhlCOVpNTnkmXYiwjcp6456+9QN9ritEMvz2bEEj+NVzxz0I/WtyK0SNX8w72l++x79qhNg7L5LzM0XTZgdPTPWmFzRGMcUUUUiT//R7GiiiszMKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/0uxooorMzCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA/9k=" |
||||||
|
} |
||||||
@ -0,0 +1,24 @@ |
|||||||
|
package com.biutag.lan.config; |
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.messaging.simp.config.MessageBrokerRegistry; |
||||||
|
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; |
||||||
|
import org.springframework.web.socket.config.annotation.StompEndpointRegistry; |
||||||
|
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; |
||||||
|
|
||||||
|
@EnableWebSocketMessageBroker |
||||||
|
@Configuration |
||||||
|
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void configureMessageBroker(MessageBrokerRegistry registry) { |
||||||
|
registry.setApplicationDestinationPrefixes("/app"); |
||||||
|
registry.enableSimpleBroker("/topic","/queue"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void registerStompEndpoints(StompEndpointRegistry registry) { |
||||||
|
registry.addEndpoint("/port").setAllowedOriginPatterns("*").withSockJS(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
package com.biutag.lan.domain.bo; |
||||||
|
|
||||||
|
import com.biutag.entity.system.Holiday; |
||||||
|
import jakarta.validation.constraints.NotBlank; |
||||||
|
import jakarta.validation.constraints.NotNull; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class HolidayV1Req { |
||||||
|
|
||||||
|
@NotBlank |
||||||
|
private String date; |
||||||
|
|
||||||
|
@NotBlank |
||||||
|
private String holidayFlag; |
||||||
|
|
||||||
|
@NotNull |
||||||
|
private String detail; |
||||||
|
|
||||||
|
@NotNull |
||||||
|
private Integer year; |
||||||
|
|
||||||
|
public Holiday toEntity() { |
||||||
|
Holiday holiday = new Holiday(); |
||||||
|
BeanUtils.copyProperties(this, holiday); |
||||||
|
return holiday; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
package com.biutag.lan.domain.bo; |
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class MailEvaluateApiV1Req { |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
*/ |
||||||
|
@NotBlank |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 满意读 |
||||||
|
*/ |
||||||
|
@NotBlank |
||||||
|
private String satisfaction; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
package com.biutag.lan.domain.vo; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
@Accessors(chain = true) |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class MailExtensionApprovalVo { |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
private Boolean active; |
||||||
|
|
||||||
|
private Boolean returnFlag; |
||||||
|
|
||||||
|
private String comment; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
package com.biutag.lan.ws; |
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject; |
||||||
|
import com.biutag.core.AjaxResult; |
||||||
|
import org.springframework.messaging.handler.annotation.MessageMapping; |
||||||
|
import org.springframework.messaging.handler.annotation.SendTo; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
|
||||||
|
@Controller |
||||||
|
public class WsController { |
||||||
|
|
||||||
|
@MessageMapping("/hello") |
||||||
|
@SendTo("/topic/greetings") |
||||||
|
public AjaxResult<Void> greeting(JSONObject message) throws Exception { |
||||||
|
return AjaxResult.success(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
package com.biutag.outer.domain; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
@Accessors(chain = true) |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class MailEvaluateEtl { |
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO) |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
private String mailId; |
||||||
|
|
||||||
|
private Boolean success; |
||||||
|
|
||||||
|
private LocalDateTime createTime; |
||||||
|
|
||||||
|
private String errMsg; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,145 @@ |
|||||||
|
package com.biutag.outer.job; |
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil; |
||||||
|
import cn.hutool.crypto.digest.MD5; |
||||||
|
import cn.hutool.http.HttpResponse; |
||||||
|
import cn.hutool.http.HttpUtil; |
||||||
|
import cn.hutool.http.Method; |
||||||
|
import com.alibaba.fastjson2.JSON; |
||||||
|
import com.alibaba.fastjson2.JSONObject; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.biutag.config.Minio; |
||||||
|
import com.biutag.entity.system.Holiday; |
||||||
|
import com.biutag.outer.domain.Mail; |
||||||
|
import com.biutag.outer.domain.MailEtl; |
||||||
|
import com.biutag.outer.domain.MailEvaluateEtl; |
||||||
|
import com.biutag.outer.mapper.HolidayMapper; |
||||||
|
import com.biutag.outer.mapper.MailEtlMapper; |
||||||
|
import com.biutag.outer.mapper.MailEvaluateEtlMapper; |
||||||
|
import com.biutag.outer.mapper.MailMapper; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Slf4j |
||||||
|
@RequiredArgsConstructor |
||||||
|
@Component |
||||||
|
public class Job { |
||||||
|
|
||||||
|
private final MailEtlMapper mailEtlMapper; |
||||||
|
|
||||||
|
private final MailEvaluateEtlMapper mailEvaluateEtlMapper; |
||||||
|
|
||||||
|
private final MailMapper mailMapper; |
||||||
|
|
||||||
|
private final HolidayMapper holidayMapper; |
||||||
|
|
||||||
|
private final Minio minio; |
||||||
|
|
||||||
|
@Value("${mailbox.url}") |
||||||
|
private String mailboxUrl; |
||||||
|
|
||||||
|
private final String key = "mailbox"; |
||||||
|
|
||||||
|
// 30s
|
||||||
|
@Scheduled(fixedRate = 30000) |
||||||
|
public void pushMailData() { |
||||||
|
System.out.println(LocalDateTime.now()); |
||||||
|
List<Mail> mails = mailMapper.listByMailEtl(); |
||||||
|
for (Mail mail : mails) { |
||||||
|
try { |
||||||
|
if (StrUtil.isNotBlank(mail.getAttachments())) { |
||||||
|
List<JSONObject> attachments = JSON.parseArray(mail.getAttachments()).toList(JSONObject.class); |
||||||
|
for (JSONObject attachment : attachments) { |
||||||
|
attachment.put("base64", minio.getBase64(attachment.getString("filepath"))); |
||||||
|
} |
||||||
|
mail.setAttachments(JSON.toJSONString(attachments)); |
||||||
|
} |
||||||
|
long timestamp = new Date().getTime(); |
||||||
|
HttpResponse httpResponse = HttpUtil.createPost(mailboxUrl + "mail") |
||||||
|
.header("timestamp", String.valueOf(timestamp)) |
||||||
|
.auth(MD5.create().digestHex(key + timestamp)) |
||||||
|
.body(JSON.toJSONString(mail)) |
||||||
|
.execute(); |
||||||
|
if (!httpResponse.isOk()) { |
||||||
|
throw new RuntimeException(String.format("httpCode: %s", httpResponse.getStatus())); |
||||||
|
} |
||||||
|
log.info("推送信件内容返回结果:{}", httpResponse.body()); |
||||||
|
JSONObject response = JSONObject.parseObject(httpResponse.body()); |
||||||
|
if (response.getInteger("code") != 200) { |
||||||
|
throw new RuntimeException(response.getString("msg")); |
||||||
|
} |
||||||
|
MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(true).setCreateTime(LocalDateTime.now()); |
||||||
|
mailEtlMapper.insert(mailEtl); |
||||||
|
} catch (RuntimeException e) { |
||||||
|
log.error("推送信件[{}]异常: {}", mail.getId(), e.getMessage(), e); |
||||||
|
MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(false).setCreateTime(LocalDateTime.now()).setErrMsg(e.getMessage()); |
||||||
|
mailEtlMapper.insert(mailEtl); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 推送信件评价 10分钟 |
||||||
|
*/ |
||||||
|
@Scheduled(fixedRate = 600000) |
||||||
|
public void pushMailEvaluate() { |
||||||
|
System.out.println(LocalDateTime.now()); |
||||||
|
List<Mail> mails = mailMapper.listByMailEvaluateEtl(); |
||||||
|
for (Mail mail : mails) { |
||||||
|
try { |
||||||
|
long timestamp = new Date().getTime(); |
||||||
|
HttpResponse httpResponse = HttpUtil.createRequest(Method.PUT, mailboxUrl + "mail/evaluate") |
||||||
|
.header("timestamp", String.valueOf(timestamp)) |
||||||
|
.auth(MD5.create().digestHex(key + timestamp)) |
||||||
|
.body(JSONObject.of("id", mail.getId(), "satisfaction", mail.getSatisfaction()).toJSONString()) |
||||||
|
.execute(); |
||||||
|
if (!httpResponse.isOk()) { |
||||||
|
throw new RuntimeException(String.format("httpCode: %s", httpResponse.getStatus())); |
||||||
|
} |
||||||
|
log.info("推送信件评价返回结果:{}", httpResponse.body()); |
||||||
|
JSONObject response = JSONObject.parseObject(httpResponse.body()); |
||||||
|
if (response.getInteger("code") != 200) { |
||||||
|
throw new RuntimeException(response.getString("msg")); |
||||||
|
} |
||||||
|
MailEvaluateEtl mailEtl = new MailEvaluateEtl().setMailId(mail.getId()).setSuccess(true).setCreateTime(LocalDateTime.now()); |
||||||
|
mailEvaluateEtlMapper.insert(mailEtl); |
||||||
|
} catch (RuntimeException e) { |
||||||
|
log.error("推送信件评价[{}]异常: {}", mail.getId(), e.getMessage(), e); |
||||||
|
MailEvaluateEtl mailEtl = new MailEvaluateEtl().setMailId(mail.getId()).setSuccess(false).setCreateTime(LocalDateTime.now()).setErrMsg(e.getMessage()); |
||||||
|
mailEvaluateEtlMapper.insert(mailEtl); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 每年12月1日 零点执行 |
||||||
|
*/ |
||||||
|
//@Scheduled(cron = "0 0 0 1 12 ? 2024-2099")
|
||||||
|
public void pushHoliday() { |
||||||
|
log.info("开始推送节假日数---------------------------------------"); |
||||||
|
int year = LocalDateTime.now().getYear() + 1; |
||||||
|
List<Holiday> holidays = holidayMapper.selectList(new LambdaQueryWrapper<Holiday>().eq(Holiday::getYear, year)); |
||||||
|
if (holidays.isEmpty()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
long timestamp = new Date().getTime(); |
||||||
|
HttpResponse httpResponse = HttpUtil.createPost(mailboxUrl + "holiday") |
||||||
|
.header("timestamp", String.valueOf(timestamp)) |
||||||
|
.auth(MD5.create().digestHex(key + timestamp)) |
||||||
|
.body(JSON.toJSONString(holidays)) |
||||||
|
.execute(); |
||||||
|
if (!httpResponse.isOk()) { |
||||||
|
log.info("推送节假日数据异常,http code:{}", httpResponse.getStatus()); |
||||||
|
return; |
||||||
|
} |
||||||
|
log.info("推送节假日数据返回结果:{}", httpResponse.body()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,82 +0,0 @@ |
|||||||
package com.biutag.outer.job; |
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil; |
|
||||||
import cn.hutool.crypto.digest.MD5; |
|
||||||
import cn.hutool.http.HttpResponse; |
|
||||||
import cn.hutool.http.HttpUtil; |
|
||||||
import com.alibaba.fastjson2.JSON; |
|
||||||
import com.alibaba.fastjson2.JSONObject; |
|
||||||
import com.biutag.config.Minio; |
|
||||||
import com.biutag.outer.domain.Mail; |
|
||||||
import com.biutag.outer.domain.MailEtl; |
|
||||||
import com.biutag.outer.mapper.MailEtlMapper; |
|
||||||
import com.biutag.outer.mapper.MailMapper; |
|
||||||
import lombok.Data; |
|
||||||
import lombok.RequiredArgsConstructor; |
|
||||||
import lombok.extern.slf4j.Slf4j; |
|
||||||
import org.springframework.beans.factory.annotation.Value; |
|
||||||
import org.springframework.scheduling.annotation.Scheduled; |
|
||||||
import org.springframework.stereotype.Component; |
|
||||||
import org.springframework.transaction.annotation.Transactional; |
|
||||||
|
|
||||||
import java.time.LocalDateTime; |
|
||||||
import java.util.Date; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
@Slf4j |
|
||||||
@RequiredArgsConstructor |
|
||||||
@Component |
|
||||||
public class MailJob { |
|
||||||
|
|
||||||
private final MailEtlMapper mailEtlMapper; |
|
||||||
|
|
||||||
private final MailMapper mailMapper; |
|
||||||
|
|
||||||
private final Minio minio; |
|
||||||
|
|
||||||
@Value("${mailbox.url}") |
|
||||||
private String mailboxUrl; |
|
||||||
|
|
||||||
private final String key = "mailbox"; |
|
||||||
|
|
||||||
// 1分钟
|
|
||||||
@Scheduled(fixedRate = 60000) |
|
||||||
@Transactional(rollbackFor = Exception.class) |
|
||||||
public void pushMailData() { |
|
||||||
System.out.println(LocalDateTime.now()); |
|
||||||
List<Mail> mails = mailMapper.listByMailEtl(); |
|
||||||
for (Mail mail : mails) { |
|
||||||
try { |
|
||||||
if (StrUtil.isNotBlank(mail.getAttachments())) { |
|
||||||
List<JSONObject> attachments = JSON.parseArray(mail.getAttachments()).toList(JSONObject.class); |
|
||||||
for (JSONObject attachment : attachments) { |
|
||||||
attachment.put("base64", minio.getBase64(attachment.getString("filepath"))); |
|
||||||
} |
|
||||||
mail.setAttachments(JSON.toJSONString(attachments)); |
|
||||||
} |
|
||||||
long timestamp = new Date().getTime(); |
|
||||||
HttpResponse httpResponse = HttpUtil.createPost(mailboxUrl + "mail") |
|
||||||
.header("timestamp", String.valueOf(timestamp)) |
|
||||||
.auth(MD5.create().digestHex(key + timestamp)) |
|
||||||
.body(JSON.toJSONString(mail)) |
|
||||||
.execute(); |
|
||||||
if (!httpResponse.isOk()) { |
|
||||||
throw new RuntimeException(String.format("httpCode: %s", httpResponse.getStatus())); |
|
||||||
} |
|
||||||
log.info(httpResponse.body()); |
|
||||||
JSONObject response = JSONObject.parseObject(httpResponse.body()); |
|
||||||
if (response.getInteger("code") != 200) { |
|
||||||
throw new RuntimeException(response.getString("msg")); |
|
||||||
} |
|
||||||
MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(true).setCreateTime(LocalDateTime.now()); |
|
||||||
mailEtlMapper.insert(mailEtl); |
|
||||||
} catch (RuntimeException e) { |
|
||||||
log.error("推送信件[{}]异常: {}", mail.getId(), e.getMessage(), e); |
|
||||||
MailEtl mailEtl = new MailEtl().setMailId(mail.getId()).setSuccess(false).setCreateTime(LocalDateTime.now()).setErrMsg(e.getMessage()); |
|
||||||
mailEtlMapper.insert(mailEtl); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,13 @@ |
|||||||
|
package com.biutag.outer.mapper; |
||||||
|
|
||||||
|
import com.biutag.core.basics.IBaseMapper; |
||||||
|
import com.biutag.entity.system.Holiday; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* 节假日Mapper |
||||||
|
* @author oumyye |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface HolidayMapper extends IBaseMapper<Holiday> { |
||||||
|
} |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
package com.biutag.outer.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.biutag.outer.domain.MailEtl; |
||||||
|
import com.biutag.outer.domain.MailEvaluateEtl; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
@Mapper |
||||||
|
public interface MailEvaluateEtlMapper extends BaseMapper<MailEvaluateEtl> { |
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
package com.biutag.outer; |
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil; |
||||||
|
import com.alibaba.fastjson2.JSON; |
||||||
|
import com.alibaba.fastjson2.JSONObject; |
||||||
|
import com.biutag.util.IOUtil; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.io.InputStream; |
||||||
|
|
||||||
|
public class Base64Test { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void test() { |
||||||
|
String s = FileUtil.readString("D:\\Workspace\\创客\\公安项目\\局长信箱\\mailbox-boot\\flow.json", "UTF-8"); |
||||||
|
JSONObject jsonObject = JSON.parseObject(s); |
||||||
|
String base64 = jsonObject.getString("base64"); |
||||||
|
if (base64.startsWith("data:image/jpg;base64,")) { |
||||||
|
int length = "data:image/jpg;base64,".length(); |
||||||
|
System.out.println(length); |
||||||
|
System.out.println(base64.indexOf(",")); |
||||||
|
base64 = base64.substring(base64.indexOf(",") + 1); |
||||||
|
System.out.println(base64); |
||||||
|
} |
||||||
|
InputStream is = IOUtil.base64ToStream(base64); |
||||||
|
System.out.println(is); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
ALTER TABLE "mailbox"."mail" |
||||||
|
ADD COLUMN "extension_request_id" varchar(20); |
||||||
|
|
||||||
|
COMMENT ON COLUMN "mailbox"."mail"."extension_request_id" IS '申请延期ID'; |
||||||
|
|
||||||
|
ALTER TABLE "mailbox"."mail_extension_approval" |
||||||
|
ADD COLUMN "request_id" varchar(20); |
||||||
|
|
||||||
|
COMMENT ON COLUMN "mailbox"."mail_extension_approval"."request_id" IS '申请延期ID'; |
||||||
Loading…
Reference in new issue