Skip to content

Commit

Permalink
fix: DingTalkImpl image url not readable in SpEL
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagi committed Jun 6, 2023
1 parent 32201af commit 1d8063c
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import lombok.extern.slf4j.Slf4j;
import org.cloud.sonic.controller.tools.robot.Message;
import org.cloud.sonic.controller.tools.robot.RobotMessenger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.expression.Expression;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
Expand All @@ -44,14 +46,19 @@
@Service("DingTalkImpl")
public class DingTalkImpl implements RobotMessenger {

@Value("${robot.img.success}")
private String successUrl;
//警告时的图片url
@Value("${robot.img.warning}")
private String warningUrl;
//失败时的图片url
@Value("${robot.img.error}")
private String errorUrl;
@Configuration
static class DingTalkMsgExt {
@Value("${robot.img.success}")
public String successUrl;
//警告时的图片url
@Value("${robot.img.warning}")
public String warningUrl;
//失败时的图片url
@Value("${robot.img.error}")
public String errorUrl;
}
@Autowired
private DingTalkMsgExt ext;

Expression templateTestSuiteMessage = RobotMessenger.parseTemplate("""
#{
Expand Down Expand Up @@ -128,7 +135,7 @@ private void signAndSend(RestTemplate restTemplate, String token, String secret,

@Override
public void sendMessage(RestTemplate restTemplate, String token, String secret, Expression messageTemplate, Message msg) {
msg.ext = this;
msg.ext = ext;
Map<?, ?> content = messageTemplate.getValue(ctx, msg, Map.class);
this.signAndSend(restTemplate, token, secret, content);
}
Expand Down

0 comments on commit 1d8063c

Please sign in to comment.