songjun
2024-09-04 cc908053e0b5075fbfd27350b6da4b39bca9e550
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
 
namespace BatchService.Framework.Utility
{
    public class JsonResultCommon
    {
        public int Id { get; set; }
        public int ResultCode { get; set; }
        public string Message { get; set; }
 
        public JsonResultCommon OK(string message)
        {
            return new JsonResultCommon()
            {
                Id = 0,
                ResultCode = 0,
                Message = message == null ? "" : message,
            };
        }
        public JsonResultCommon OK<T>(List<T> array)
        {
            string parseString = JsonConvert.SerializeObject(array);
            return new JsonResultCommon()
            {
                Id = 0,
                ResultCode = 0,
                Message = parseString == null ? "" : parseString, 
            };
        }
        public JsonResultCommon Error(int resultCode, string message)
        {
            return new JsonResultCommon()
            {
                Id = -1,
                ResultCode = resultCode,
                Message = message == null ? "" : message,
            };
        }
    }
}