ningshuxia
2022-12-12 e81ca048ef4e9345e904b74ffffd3e8413d18a7e
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
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>
    /// UserGroupUserMapping 标准Api
    /// </summary>
    [ApiController]
    [Route("v1/Standard/UserGroupUserMapping")]
    [ApiExplorerSettings(GroupName = "v1")]
    public class UserGroupUserMapping_StandardController : ControllerBase 
    {
        private readonly Service.UserGroupUserMapping _service = new Service.UserGroupUserMapping();
 
        #region Query
 
        /// <summary>
        /// 获取所有
        /// </summary>
        [Route("GetAll")]
        [HttpGet]
        public Result GetAll()
        {
            var list = _service.GetAll();
            return new Result<List<Model.UserGroupUserMapping>>(list);
        }
 
        /// <summary>
        /// 通过 ID 获取
        /// </summary>
        [Route("GetByID")]
        [HttpGet]
        public Result GetByID(long ID)
        {
            if (ID < 1)
            {
                return new Result(Code.Error, "ID 参数错误");
            }
            var model = _service.GetByID(ID);
            return new Result<Model.UserGroupUserMapping>(model);
        }
 
        /// <summary>
        /// 通过 Ids 获取
        /// </summary>
        [Route("GetByIds")]
        [HttpGet]
        public Result GetByIds(string Ids)
        {
            var ids = LongListHelper.ToList(Ids);
            if (ids == null || ids.Count() < 1)
            {
                return new Result(Code.Error, "Ids 参数错误");
            }
            var list = _service.GetByIds(ids);
            return new Result<List<Model.UserGroupUserMapping>>(list);
        }
 
        /// <summary>
        /// 通过 UserID 获取
        /// </summary>
        [Route("GetByUserID")]
        [HttpGet]
        public Result GetByUserID(long UserID)
        {
            if (UserID < 1)
            {
                return new Result(Code.Error, "UserID 参数错误");
            }
            var list = _service.GetByUserID(UserID);
            return new Result<List<Model.UserGroupUserMapping>>(list);
        }
 
        /// <summary>
        /// 通过 UserGroupID 获取
        /// </summary>
        [Route("GetByUserGroupID")]
        [HttpGet]
        public Result GetByUserGroupID(long UserGroupID)
        {
            if (UserGroupID < 1)
            {
                return new Result(Code.Error, "UserGroupID 参数错误");
            }
            var list = _service.GetByUserGroupID(UserGroupID);
            return new Result<List<Model.UserGroupUserMapping>>(list);
        }
 
        #endregion
 
        #region Insert
 
        /// <summary>
        /// 插入一条数据
        /// </summary>
        [Route("Insert")]
        [HttpPost]
        public Result Insert(Model.UserGroupUserMappingPure 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.UserGroupUserMappingPure> 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.UserGroupUserMapping 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.UserGroupUserMapping> list)
        {
            if (list == null || list.Count() < 1)
            {
                return new Result(Code.Error, "参数错误");
            }
            var bol = _service.Updates(list);
            return new Result<bool>(bol);
        }
 
        #endregion
 
        #region Set
 
        /// <summary>
        /// 设置
        /// </summary>
        [Route("Set")]
        [HttpPost]
        public Result Set(List<Model.UserGroupUserSelected> list)
        {
            if (list == null || list.Count < 1)
            {
                return new Result(Code.Error, "参数错误");
            }
            var bol = _service.Set(list);
            return new Result<bool>(bol);
        }
 
        #endregion
    }
}