更新控制器
This commit is contained in:
@@ -33,6 +33,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPost]
|
||||
public async Task<Result> Login(user _user)
|
||||
{
|
||||
if( await _userService.Login(_user))
|
||||
{
|
||||
return Result.Success().SetData(new { _user, token = 123456789 });
|
||||
}
|
||||
return Result.Error();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,8 +58,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Register(user _user, string code)
|
||||
{
|
||||
|
||||
{
|
||||
if (code!=null)
|
||||
{
|
||||
await _userService.Register(_user);
|
||||
}
|
||||
return Result.Error();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,7 +76,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
emailAddress = emailAddress.Trim().ToLower();
|
||||
//先判断邮箱是否被注册使用过,如果被使用过,便不让操作
|
||||
if (!await _userService.mail_exist(emailAddress))
|
||||
if (!await _userService.EmailIsExsit(emailAddress))
|
||||
{
|
||||
string code = RandomHelper.GenerateRandomLetter(6);
|
||||
code = code.ToUpper();//全部转为大写
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MenuController : ControllerBase
|
||||
{
|
||||
private IMenuService _menuService;
|
||||
public MenuController(IMenuService menuService)
|
||||
{
|
||||
_menuService = menuService;
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<Result> GetMenu()
|
||||
{
|
||||
return Result.Success().SetData(await _menuService.GetAllEntitiesTrueAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="_menu"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateMenu(menu _menu)
|
||||
{
|
||||
await _menuService.UpdateAsync(_menu);
|
||||
return Result.Success();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="_ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> DelListMenu(List<int> _ids)
|
||||
{
|
||||
await _menuService.DelListByUpdateAsync(_ids);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="_menu"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> AddMenu(menu _menu)
|
||||
{
|
||||
await _menuService.AddAsync(_menu);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MouldController : ControllerBase
|
||||
{
|
||||
private IMouldService _mouldService;
|
||||
public MouldController(IMouldService mouldService)
|
||||
{
|
||||
_mouldService = mouldService;
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<Result> GetMould()
|
||||
{
|
||||
return Result.Success().SetData(await _mouldService.GetAllEntitiesTrueAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="_mould"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateMould(mould _mould)
|
||||
{
|
||||
await _mouldService.UpdateAsync(_mould);
|
||||
return Result.Success();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="_ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> DelListMould(List<int> _ids)
|
||||
{
|
||||
await _mouldService.DelListByUpdateAsync(_ids);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="_mould"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> AddMould(mould _mould)
|
||||
{
|
||||
await _mouldService.AddAsync(_mould);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class RoleController : ControllerBase
|
||||
{
|
||||
private IRoleService _roleService;
|
||||
public RoleController(IRoleService roleService)
|
||||
{
|
||||
_roleService = roleService;
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<Result> GetURole()
|
||||
{
|
||||
return Result.Success().SetData(await _roleService.GetAllEntitiesTrueAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="_role"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateRole(role _role)
|
||||
{
|
||||
await _roleService.UpdateAsync(_role);
|
||||
return Result.Success();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="_ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> DelListRole(List<int> _ids)
|
||||
{
|
||||
await _roleService.DelListByUpdateAsync(_ids);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="_role"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> AddRole(role _role)
|
||||
{
|
||||
await _roleService.AddAsync(_role);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPost]
|
||||
public async Task<Result> GetMenuMould()
|
||||
{
|
||||
var _user= this.HttpContext.GetCurrentUserInfo();
|
||||
var _user= this.HttpContext.GetCurrentUserInfo();
|
||||
var menu_data = await _userService.GetMenusByUser(_user);
|
||||
return Result.Success().SetData(menu_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,6 @@ namespace Yi.Framework.Interface
|
||||
/// <returns></returns>
|
||||
Task<bool> SetMouldByMenu(int mouldId,int menuId);
|
||||
/// <summary>
|
||||
/// 添加菜单
|
||||
/// </summary>
|
||||
/// <param name="_menu"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddMenu(menu _menu);
|
||||
/// <summary>
|
||||
/// 添加子菜单
|
||||
/// </summary>
|
||||
/// <param name="_menu"></param>
|
||||
|
||||
@@ -33,12 +33,6 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SetMenusByRolesId(List<int> menuIds, int roleId);
|
||||
/// <summary>
|
||||
/// 添加角色
|
||||
/// </summary>
|
||||
/// <param name="_role"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> AddRole(role _role);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SetRolesByUserId(List<int> roleIds,int userId);
|
||||
Task<bool> EmailIsExsit(string emailAddress);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,16 +24,6 @@ namespace Yi.Framework.Service
|
||||
return await AddAsync(_menu);
|
||||
}
|
||||
|
||||
public async Task<bool> AddMenu(menu _menu)
|
||||
{
|
||||
var menu_data = await GetEntityById(_menu.id);
|
||||
if (menu_data == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return await AddAsync(_menu);
|
||||
}
|
||||
|
||||
public async Task<bool> DelListByUpdateAsync(List<int> _ids)
|
||||
{
|
||||
var menuList = await GetEntitiesAsync(u=>_ids.Contains(u.id));
|
||||
|
||||
@@ -27,9 +27,10 @@ namespace Yi.Framework.Service
|
||||
|
||||
public async Task<menu> GetMenuByMould(mould _mould)
|
||||
{
|
||||
throw new Exception();
|
||||
//var mould_data= await _Db.Set<mould>().Include(u=>u.menu).Where(u => u.id == _mould.id&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
|
||||
// return mould_data.menu;
|
||||
|
||||
var menu_data = await _Db.Set<menu>().Include(u => u.mould)
|
||||
.Where(u => u.mould == _mould && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
|
||||
return menu_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,17 +13,7 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
public RoleService(DbContext Db):base(Db)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<bool> AddRole(role _role)
|
||||
{
|
||||
var role_data = await GetEntityById(_role.id);
|
||||
if(role_data==null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return await AddAsync(_role);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> DelListByUpdateAsync(List<int> _ids)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,17 @@ namespace Yi.Framework.Service
|
||||
return await UpdateListAsync(userList);
|
||||
}
|
||||
|
||||
public async Task<bool> EmailIsExsit(string emailAddress)
|
||||
{
|
||||
var userList=await GetAllEntitiesTrueAsync();
|
||||
var is_email= userList.Where(u=>u.email==emailAddress).FirstOrDefault();
|
||||
if (is_email == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<user>> GetAllEntitiesTrueAsync()
|
||||
{
|
||||
return await GetEntitiesAsync(u => u.is_delete == (short)Common.Enum.DelFlagEnum.Normal);
|
||||
|
||||
Reference in New Issue
Block a user