1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.dy.rtuMw.server.local;
 
 
import com.dy.common.mw.protocol.Command;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
 * @Author liurunyu
 * @Date 2023/12/21 15:17
 * @LastEditTime 2023/12/21 15:17
 * @Description
 */
public class ReturnCommand {
 
    private static Logger log = LogManager.getLogger(ReturnCommand.class) ;
 
    /**
     * 处理命令成功
     * @param message
     */
    public static Command successed(String message, String commandId, String code, Object attachment){
        log.info(message) ;
        Command command = new Command().createReturnSuccessCommand(message, commandId, code) ;
        command.setAttachment(attachment) ;
        return command ;
    }
    /**
     * 处理命令成功
     * @param message
     */
    public static Command successed(String message, String commandId, String code){
        log.info(message) ;
        return new Command().createReturnSuccessCommand(message, commandId, code) ;
    }
    /**
     * 处理命令发生错误
     * @param message
     */
    public static Command errored(String message, String commandId, String code){
        log.error(message) ;
        return new Command().createReturnErrorCommand(message, commandId, code) ;
    }
}