tangxu
2023-03-20 3bf8bf5179de8b83bbd6ad997e82d98302abd1c3
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
using Microsoft.AspNetCore.Mvc;
using IStation.Model.Api;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
 
namespace IStation.WebApi.Controllers.V1
{
    /// <summary>
    /// EmployeeRemark 标准Api
    /// </summary>
    [ApiController]
    [Route("V1/Standard/EmployeeRemark")]
    [ApiExplorerSettings(GroupName = "V1")]
    public class EmployeeRemark_StandardController : ControllerBase
    {
        private readonly Service.EmployeeRemark _service = new Service.EmployeeRemark();
 
        #region Query
 
        /// <summary>
        /// 通过 CorpID 获取
        /// </summary>
        [Route("GetByCorpID")]
        [HttpGet]
        public Result GetByCorpID(long CorpID)
        {
            if (CorpID < 1)
            {
                return new Result(Code.Error, "CorpID 参数错误");
            }
            var list = _service.GetByCorpID(CorpID);
 
            return new Result<List<Model.EmployeeRemark>>(list);
        }
 
        /// <summary>
        /// 通过 ID 获取
        /// </summary>
        [Route("GetByID")]
        [HttpGet]
        public Result GetByID(long CorpID, long ID)
        {
            if (CorpID < 1)
            {
                return new Result(Code.Error, "CorpID 参数错误");
            }
            if (ID < 1)
            {
                return new Result(Code.Error, "ID 参数错误");
            }
 
            var model = _service.GetByID(CorpID, ID);
            return new Result<Model.EmployeeRemark>(model);
        }
 
        /// <summary>
        /// 通过 Ids 获取
        /// </summary>
        [Route("GetByIds")]
        [HttpGet]
        public Result GetByIds(long CorpID, string Ids)
        {
            if (CorpID < 1)
            {
                return new Result(Code.Error, "CorpID 参数错误");
            }
            var ids = LongListHelper.ToList(Ids);
            if (ids == null || ids.Count < 1)
            {
                return new Result(Code.Error, "Ids 参数错误");
            }
 
            var list = _service.GetByIds(CorpID, ids);
            return new Result<List<Model.EmployeeRemark>>(list);
        }
 
        /// <summary>
        /// 通过 BelongType and BelongID获取
        /// </summary>
        [Route("GetByBelongTypeAndBelongID")]
        [HttpGet]
        public Result GetByBelongTypeAndBelongID(long CorpID, string BelongType, long BelongID)
        {
            if (CorpID < 1)
            {
                return new Result(Code.Error, "CorpID 参数错误");
            }
            if (string.IsNullOrEmpty(BelongType))
            {
                return new Result(Code.Error, "BelongType 参数错误");
            }
            if (BelongID < 1)
            {
                return new Result(Code.Error, "BelongID 参数错误");
            }
            var list = _service.GetByBelongTypeAndBelongID(CorpID, BelongType, BelongID);
            return new Result<List<Model.EmployeeRemark>>(list);
        }
 
        #endregion
 
        #region Insert
 
        /// <summary>
        /// 添加一条
        /// </summary>
        [Route("Insert")]
        [HttpPost]
        public Result Insert(Model.EmployeeRemark model)
        {
            if (model == null)
            {
                return new Result(Code.Error, "参数错误");
            }
            var id = _service.Insert(model);
            return new Result<long>(id);
        }
 
        /// <summary>
        /// 批量添加
        /// </summary>
        [Route("Inserts")]
        [HttpPost]
        public Result Inserts(List<Model.EmployeeRemark> list)
        {
            if (list == null || list.Count() < 1)
            {
                return new Result(Code.Error, "参数错误");
            }
 
            var bol = _service.Inserts(list);
            return new Result<bool>(bol);
        }
 
        #endregion
 
        #region Update
 
        /// <summary>
        /// 更新一条
        /// </summary>
        [Route("Update")]
        [HttpPut]
        public Result Update(Model.EmployeeRemark model)
        {
            if (model == null)
            {
                return new Result(Code.Error, "参数错误");
            }
            var bol = _service.Update(model);
            return new Result<bool>(bol);
        }
 
        /// <summary>
        /// 更新多条
        /// </summary>
        [Route("Updates")]
        [HttpPut]
        public Result Updates(List<Model.EmployeeRemark> list)
        {
            if (list == null || list.Count() < 1)
            {
                return new Result(Code.Error, "参数错误");
            }
            var bol = _service.Updates(list);
            return new Result<bool>(bol);
        }
 
        #endregion
 
        #region Delete
 
        /// <summary>
        /// 删除
        /// </summary>
        [Route("DeleteByID")]
        [HttpDelete]
        public Result DeleteByID(long CorpID, long ID)
        {
            if (CorpID < 1)
            {
                return new Result(Code.Error, "CorpID 参数错误");
            }
            if (ID < 1)
            {
                return new Result("ID 参数错误");
            }
            var bol = _service.DeleteByID(CorpID, ID, out string Msg);
            return new ResultReason<bool>(bol, Msg);
        }
 
        #endregion
 
 
 
 
 
 
 
 
    }
}