kazelee
2025-05-09 62e3ff7506396fcb7f7737900806e838c2466aa3
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
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
using static HH.WCS.Mobox3.DSZSH.Dtos.Response.BaseResponse;
using static HH.WCS.Mobox3.DSZSH.Dtos.Response.MoboxResponse;
 
namespace HH.WCS.Mobox3.DSZSH.Helpers {
    public class ResultHelper {
        public static Result BuildResult(int code, string message, bool pringLog = true) {
            if (pringLog) {
                LogHelper.Info(message);
            }
            return new Result { Code = code, Message = message };
        }
 
        /// <summary>
        /// 构建 <see cref="SimpleResult"/> 返回值,选择打印日志信息(默认打印)
        /// </summary>
        /// <param name="code"></param>
        /// <param name="message"></param>
        /// <param name="pringLog"></param>
        /// <returns></returns>
        public static SimpleResult BuildSimpleResult(int code, string message, bool pringLog = true) {
            if (pringLog) {
                LogHelper.Info(message);
            }
            return new SimpleResult { Code = code, Message = message };
        }
 
        /// <summary>
        /// 构建 <see cref="SimpleResult"/> 异常返回值,选择打印异常日志信息(默认打印)
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="exCode"></param>
        /// <param name="pringLog"></param>
        /// <returns></returns>
        public static SimpleResult BuildSimpleEx(Exception ex, int exCode = 1, bool pringLog = true) {
            if (pringLog) {
                LogHelper.InfoEx(ex);
            }
            return new SimpleResult { Code = exCode, Message = ex.Message };
        }
    }
}