• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

trydofor / professional-wings / #140

08 Feb 2025 09:13AM UTC coverage: 63.606% (-0.08%) from 63.687%
#140

push

web-flow
Merge pull request #316 from trydofor/develop

release of 3.3.140

242 of 343 new or added lines in 58 files covered. (70.55%)

55 existing lines in 6 files now uncovered.

12926 of 20322 relevant lines covered (63.61%)

0.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.11
/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/controller/MailSendController.java
1
package pro.fessional.wings.tiny.mail.controller;
2

3
import io.swagger.v3.oas.annotations.Operation;
4
import lombok.Data;
5
import lombok.Setter;
6
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.web.bind.annotation.PostMapping;
8
import org.springframework.web.bind.annotation.RequestBody;
9
import org.springframework.web.bind.annotation.ResponseBody;
10
import org.springframework.web.bind.annotation.RestController;
11
import pro.fessional.mirana.data.R;
12
import pro.fessional.wings.silencer.spring.boot.ConditionalWingsEnabled;
13
import pro.fessional.wings.tiny.mail.service.TinyMailPlain;
14
import pro.fessional.wings.tiny.mail.service.TinyMailService;
15
import pro.fessional.wings.tiny.mail.spring.prop.TinyMailEnabledProp;
16
import pro.fessional.wings.tiny.mail.spring.prop.TinyMailUrlmapProp;
17

18
/**
19
 * @author trydofor
20
 * @since 2023-01-13
21
 */
22
@RestController
23
@ConditionalWingsEnabled(abs = TinyMailEnabledProp.Key$mvcSend)
24
public class MailSendController {
1✔
25

26
    @Setter(onMethod_ = { @Autowired })
27
    protected TinyMailService tinyMailService;
28

29
    @Operation(summary = "Create mail and send it sync or async", description = """
30
        # Usage
31
        Create the mail, and auto send it in sync or async way.
32
        ## Params
33
        * @param - request body
34
        ## Returns
35
        * @return {200 | Result(-1)} failure
36
        * @return {200 | Result(0)} sync send
37
        * @return {200 | Result(mills)} async send at mills time
38
        """)
39
    @PostMapping(value = "${" + TinyMailUrlmapProp.Key$sendMail + "}")
40
    @ResponseBody
41
    public R<Long> sendMail(@RequestBody TinyMailPlain mail) {
42
        final long ms = tinyMailService.auto(mail);
×
NEW
43
        return R.ok(ms);
×
44
    }
45

46

47
    @Operation(summary = "Save the mail only, do not send", description = """
48
        # Usage
49
        Save the new mail, return the id.
50
        ## Params
51
        * @param - request body
52
        ## Returns
53
        * @return {200 | Result(id)} mail id
54
        """)
55
    @PostMapping(value = "${" + TinyMailUrlmapProp.Key$sendSave + "}")
56
    @ResponseBody
57
    public R<Long> sendSave(@RequestBody TinyMailPlain mail) {
58
        final long id = tinyMailService.save(mail);
×
NEW
59
        return R.ok(id);
×
60
    }
61

62

63
    @Operation(summary = "sync scan and resend mail async", description = """
64
        # Usage
65
        sync scan the mail to resend, return the count, and send them async
66
        ## Returns
67
        * @return {200 | Result(count)} mail cou t
68
        """)
69
    @PostMapping(value = "${" + TinyMailUrlmapProp.Key$sendScan + "}")
70
    @ResponseBody
71
    public R<Integer> sendScan() {
72
        final int cnt = tinyMailService.scan();
×
NEW
73
        return R.ok(cnt);
×
74
    }
75

76
    @Data
77
    public static class Ins {
78
        /**
79
         * Mail id
80
         */
81
        private long id;
82
        /**
83
         * Whether retry async if fail
84
         */
85
        private boolean retry;
86
        /**
87
         * Whether to check the send condition, otherwise force send
88
         */
89
        private boolean check;
90
    }
91

92

93
    @Operation(summary = "Sync resend failed mail", description = """
94
        # Usage
95
        Sync resend the  failed email, return success/fail, or throw exception
96
        ## Params
97
        * @param - request body
98
        ## Returns
99
        * @return {200 | Result(bool)} success or not
100
        """)
101
    @PostMapping(value = "${" + TinyMailUrlmapProp.Key$sendRetry + "}")
102
    @ResponseBody
103
    public R<Boolean> sendRetry(@RequestBody Ins mail) {
104
        final boolean ok = tinyMailService.send(mail.id, mail.retry, mail.check);
×
NEW
105
        return R.ok(ok);
×
106
    }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc