forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeChatSubController.cs
More file actions
92 lines (90 loc) · 2.92 KB
/
WeChatSubController.cs
File metadata and controls
92 lines (90 loc) · 2.92 KB
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
using System.Threading.Tasks;
using Blog.Core.IServices;
using Blog.Core.Model;
using Blog.Core.Model.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Blog.Core.Controllers
{
/// <summary>
/// WeChatSubController
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public partial class WeChatSubController : Controller
{
readonly IWeChatSubServices _WeChatSubServices;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="iWeChatSubServices"></param>
public WeChatSubController(IWeChatSubServices iWeChatSubServices)
{
_WeChatSubServices = iWeChatSubServices;
}
/// <summary>
/// 获取
/// </summary>
/// <param name="pagination">分页条件</param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<WeChatSub>>> Get([FromQuery] PaginationModel pagination)
{
var data = await _WeChatSubServices.QueryPage(pagination);
return new MessageModel<PageModel<WeChatSub>> { success = true, response = data};
}
/// <summary>
/// 获取(id)
/// </summary>
/// <param name="id">主键ID</param>
/// <returns></returns>
[HttpGet("{id}")]
public async Task<MessageModel<WeChatSub>> Get(string id)
{
var data = await _WeChatSubServices.QueryById(id);
return new MessageModel<WeChatSub> { success = true, response = data };
}
/// <summary>
/// 添加
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<string>> Post([FromBody] WeChatSub obj)
{
await _WeChatSubServices.Add(obj);
return new MessageModel<string> { success = true};
}
/// <summary>
/// 更新
/// </summary>
/// <returns></returns>
[HttpPut]
public async Task<MessageModel<string>> Put([FromBody] WeChatSub obj)
{
await _WeChatSubServices.Update(obj);
return new MessageModel<string> { success = true};
}
/// <summary>
/// 删除
/// </summary>
/// <returns></returns>
[HttpDelete]
public async Task<MessageModel<string>> Delete(string id)
{
await _WeChatSubServices.DeleteById(id);
return new MessageModel<string> { success = true};
}
/// <summary>
/// 批量删除
/// </summary>
/// <returns></returns>
[HttpDelete]
public async Task<MessageModel<string>> BatchDelete(string ids)
{
var i = ids.Split(",");
await _WeChatSubServices.DeleteByIds(i);
return new MessageModel<string> { success = true };
}
}
}