using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Model.ModelDto.SysDto; using Model.ModelVm; using WMS.Entity; using WMS.Entity.SysEntity; using WMS.IBLL.ISysServer; using SqlSugar; using Model.ModelVm.SysVm; using Microsoft.Extensions.FileSystemGlobbing.Internal.PathSegments; using Utility.Tools; using WMS.IBLL.ILogServer; using WMS.Entity.LogEntity; using System.Security.Cryptography; using System.Data; using Model.ModelDto.LogDto; namespace Wms.Controllers { [Route("api/[controller]/[action]")] [ApiController] [Authorize] public class BasisController : ControllerBase { /// /// 依赖注入 /// private readonly ICustomerServer _customerSvc;// 客户Svc private readonly ILogisticsInfoServer _logisticsSvc;//物流Svc private readonly IUnitServer _unitSvc;//单位Svc private readonly IPackagServer _packagSvc; // 包装 private readonly IMaterialsServer _mate; // 包装 private readonly IUserInforServer _userInforServer; //用户 private readonly IRolesServer _rolesServer; //角色 private readonly IRoleRightServer _roleRightServer; //角色权限 private readonly IRBACServer _rBACServer; //RBAC private readonly IDepartmentServer _department; //部门 private readonly IFunSettingServer _setting; //功能设定 private readonly IInterfaceServer _interface;//接口管理 private readonly IOperationSysServer _operation; //操作日志 /// /// 构造函数 /// /// 客户 /// 物流 /// 用户 /// 角色 /// 角色权限 /// RBAC /// 单位 /// 物料 /// 部门 /// 功能设定 /// 操作日志 public BasisController(ICustomerServer customerSvc, ILogisticsInfoServer logisticsSvc, IUserInforServer userInforServer, IRolesServer rolesServer, IRoleRightServer roleRightServer, IRBACServer rBACServer, IUnitServer unitSvc, IPackagServer packagServer, IMaterialsServer mate, IDepartmentServer department, IFunSettingServer setting, IInterfaceServer interfaceS, IOperationSysServer operation) { _customerSvc = customerSvc;//客户Svc _logisticsSvc = logisticsSvc;//物流Svc _userInforServer = userInforServer;//用户 _rolesServer = rolesServer;//角色 _roleRightServer = roleRightServer;//角色权限 _rBACServer = rBACServer;//RBAC _unitSvc = unitSvc;//单位 _packagSvc = packagServer; // 包装 _mate = mate; //物料 _department = department;//部门 _setting = setting; //功能设定 _interface = interfaceS;//接口管理 _operation = operation; //操作日志 } //基本信息管理 #region 用户管理 #region 用户管理 /// /// 获取用户角色信息 /// /// 登录名称 /// 部门号 /// 角色号 /// 状态 /// [HttpGet] public IActionResult GetUserRoleList(string UserName, string DepartmentNo, string RoleNo, string Status) { List userdtolist = _userInforServer.GetUserRoleList(UserName, DepartmentNo, RoleNo, Status); return Ok(new { data = userdtolist, code = 0, mes = "成功" }); } /// /// 根据id获取用户信息列表 /// /// 用户id /// [HttpGet] public IActionResult GetUserinfoListById(int id) { SysUserInfor userinfo = _userInforServer.GetUserInfoById(id); return Ok(new { data = userinfo, code = 0, msg = "成功" }); } /// /// 新增用户信息 /// /// 用户dto模型 /// /// 捕获异常 [HttpPost] public async Task InsertUserinfo(UserInfoDto UserInfoDto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); UserInfoDto.CreateUser = uid; int i = await _userInforServer.InsertUserInfo(UserInfoDto); //判断是否新增成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "新增失败" }); } else if (i == 3) { return Ok(new { data = i, code = 3, msg = "用户名或登录名重复" }); } else { await _operation.InsertOperation("系统设置", "用户管理", UserInfoDto.UserNo, "添加", "添加用户信息 用户号:" + UserInfoDto.UserNo, uid); return Ok(new { data = i, code = 0, msg = "新增成功" }); } } catch (System.Exception ex) { //抛出异常 throw new System.Exception("新增用户异常", ex); } } /// /// 删除\批删用户信息 /// /// 用户id /// /// 异常 [HttpGet] public async Task DeleteUserInfo(int userids) { //异常 try { //获取用户信息 SysUserInfor user = _userInforServer.GetUserInfoById(userids); //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); int i = await _userInforServer.DeleteUserinfo(user); //判断是否删除成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "删除失败" }); } else { await _operation.InsertOperation("系统设置", "用户管理", user.UserNo, "删除", "删除用户信息 用户号:" + user.UserNo, uid); return Ok(new { data = i, code = 0, msg = "删除成功" }); } } catch (System.Exception ex) { //抛出异常 throw new System.Exception("删除用户信息异常", ex); } } /// /// 编辑用户信息 /// /// 用户dto模型 /// /// 捕获异常 [HttpPost] public async Task UpdateUserinfo(UserInfoDto userdto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //userdto.UpdateUser = Convert.ToInt32(userId); //更改人 userdto.UpdateUser = uid; //编辑用户信息 int i = await _userInforServer.UpdateUserinfo(userdto); //判断是否编辑成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "编辑失败" }); } else if (i == 3) { return Ok(new { data = i, code = 1, msg = "用户名或登录名重复" }); } else { await _operation.InsertOperation("系统设置", "用户管理", userdto.UserNo, "修改", "修改用户信息 用户号:" + userdto.UserNo, uid); return Ok(new { data = i, code = 0, msg = "编辑成功" }); } } catch (System.Exception ex) { //抛出异常 throw new System.Exception("编辑用户信息异常", ex); } } #endregion #region 修改密码 /// /// 修改密码 根据id获取用户原密码 /// /// 用户原密码 /// [HttpGet] public int GetUserUptPassById(string PassWord, int userId) { ////获取当前操作用户id //var claimsIdentity = this.User.Identity as ClaimsIdentity; //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; //int uid = Convert.ToInt32(userId); //根据用户id获取用户密码 SysUserInfor user = _userInforServer.GetUserInfoById(userId); //判断原密码是否正确 if (user.PassWord == PassWord) { return 1; } else { return 0; } } ///// 用户id /// /// 修改用户密码 /// /// 原密码 /// 新密码 /// 确认密码 /// /// 捕获异常 [HttpGet] public async Task UptUserPassWord(string pwdOld, string pwdNew, string pwdNewTwo/*, int userId*/) { //捕获异常 try { pwdOld = Md5Tools.CalcMd5(pwdOld); pwdNew = Md5Tools.CalcMd5(pwdNew); pwdNewTwo = Md5Tools.CalcMd5(pwdNewTwo); //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //判断原密码是否正确 int a = GetUserUptPassById(pwdOld, uid); if (a == 1) { //修改密码 int i = await _userInforServer.UptUserPassWord(pwdOld, pwdNew, pwdNewTwo, uid); if (i == 0) { return Ok(new { data = i, code = 1, msg = "修改失败" }); } //判断两次新密码是否一致 else if (i == 3) { return Ok(new { data = i, code = 0, msg = "修改成功 请重新登录" }); } else { return Ok(new { data = i, code = 0, msg = "修改成功 请重新登录" }); } } else { //错误 return Ok(new { data = a, code = 1, msg = "原密码不正确" }); } } catch (Exception ex) { //抛出异常 throw new Exception("修改密码异常", ex); } } /// /// x天后提醒用户修改密码 /// /// [HttpGet] public IActionResult IsPassWordTime() { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //判断原密码是否正确 int a = _userInforServer.IsPassWordTime(uid); return Ok(new { data = a, code = 0, msg = "修改失败" }); } catch (Exception ex) { //抛出异常 throw new Exception("修改密码异常", ex); } } #endregion #endregion #region 角色管理 /// /// 查询角色信息列表 /// /// 角色号 /// 角色名称 /// [HttpGet] public IActionResult GetRolesList(string RoleNo, string RoleName) { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } //查询 List roles = _rolesServer.GetRoleList(RoleNo, RoleName, UserId); //返回数据 return Ok(new { data = roles, code = 0, msg = "获取成功" }); } /// /// 根据id获取角色信息列表 /// /// 角色id /// [HttpGet] public IActionResult GetRolesListById(int roleid) { SysRoles role = _rolesServer.GetRoleInfoById(roleid); return Ok(new { data = role, code = 0, msg = "获取成功" }); } /// /// 新增角色信息 /// /// 角色dto /// /// 捕获异常 [HttpPost] public async Task InsertRoleInfo(RoleDto roledto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //创建人 roledto.CreateUser = uid; int i = await _rolesServer.InsertRoleInfo(roledto); if (i == 0) { return Ok(new { data = i, code = 1, msg = "新增失败" }); } else if (i == 3) { return Ok(new { data = i, code = 3, msg = "角色号必须唯一" }); } else { await _operation.InsertOperation("系统设置", "角色权限", roledto.RoleNo, "添加", "添加角色信息 角色号:" + roledto.RoleNo, uid); return Ok(new { data = i, code = 0, msg = "新增成功" }); } } catch (System.Exception ex) { //抛出异常 throw new System.Exception("角色新增异常", ex); } } /// /// 删除角色信息 /// /// 角色id /// /// [HttpGet] public async Task DeleteRoleInfo(int roleids) { //捕获异常 try { //根据角色id获取角色信息 SysRoles role = _rolesServer.GetRoleInfoById(roleids); //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); role.UpdateUser = uid; int i = await _rolesServer.DeleteRoleInfo(role); //判断是否删除成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "删除失败" }); } else { await _operation.InsertOperation("系统设置", "角色权限", role.RoleNo, "删除", "删除角色信息 角色号:" + role.RoleNo, uid); return Ok(new { data = i, code = 0, msg = "删除成功" }); } } catch (System.Exception ex) { //抛出异常 throw new System.Exception("角色删除异常", ex); } } /// /// 编辑角色信息 /// /// 角色实体模型 /// /// 捕获异常 [HttpPost] public async Task UpdateRolesInfo(SysRoles role) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //更改人 role.UpdateUser = uid; int i = await _rolesServer.UpdateRoleInfo(role); //判断是否编辑成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "编辑失败" }); } else { await _operation.InsertOperation("系统设置", "角色权限", role.RoleNo, "修改", "修改角色信息 角色号:" + role.RoleNo, uid); return Ok(new { data = i, code = 0, msg = "编辑成功" }); } } catch (System.Exception ex) { //抛出异常 throw new System.Exception("编辑角色异常", ex); } } #endregion #region 角色权限管理 /// /// 根据角色id获取当前所拥有权限 /// /// [HttpGet] public IActionResult GetRBACLists(int id) { //List roleright = var obj = _rBACServer.GetMenuByroleIdNew(id); return Ok(new { data = obj, code = 0, msg = "成功" }); } /// /// 根据角色id获取当前所拥有权限 /// /// [HttpGet] public IActionResult GetRoleRightRBAC(int id, string MenuNo) { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } List menudto = _rBACServer.GetRoleRightRBAC(MenuNo, UserId); return Ok(new { data = menudto, code = 0, msg = "成功" }); } /// /// 根据角色id获取当前所拥有权限 /// /// [HttpGet] public IActionResult GetRoleRightLists(int id) { List roleRightDtos = _rBACServer.GetRoleRightList(id); return Ok(new { data = roleRightDtos, code = 0, msg = "成功" }); } /// /// 获取角色权限信息列表 /// 多表:角色权限、角色、菜单 /// /// [HttpGet] public IActionResult GetRoleRightList() { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var roleRightDtos = _roleRightServer.GetRoleMenuList(int.Parse(userId)); return Ok(new { data = roleRightDtos, msg = "成功", code = 0 }); } catch (Exception e) { return Ok(new { msg = e.Message, code = 0 }); } } /// /// 获取角色权限信息列表(单表) /// /// 角色权限id /// [HttpGet] public IActionResult GetRoleRightOneListById(int id) { List roleRights = _roleRightServer.GetRoleRightOneListById(id); return Ok(new { data = roleRights, msg = "成功", core = 0 }); } /// /// 分配角色权限信息 /// /// 菜单号 /// 角色id /// /// 捕获异常 [HttpPost] public async Task InsertRoleRight(string MenuNo, int id) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; //根据Id获取角色号 SysRoles roles = _rolesServer.GetRoleInfoById(id); //保存角色权限信息 int i = await _roleRightServer.InsertRoleRight(MenuNo, roles.RoleNo, userId); //判断是否新增成功 if (i == 0) { return Ok(new { data = i, msg = "分配失败", code = 1 }); } else { await _operation.InsertOperation("系统设置", "角色权限", roles.RoleNo, "修改", "分配角色权限 角色号:" + roles.RoleNo, Convert.ToInt32(userId)); return Ok(new { data = i, msg = "分配成功", code = 0 }); } } catch (Exception ex) { //抛出异常 throw new Exception("新增角色权限信息异常", ex); } } #endregion #region 部门管理 /// /// 获取部门信息列表 /// /// 部门名称 /// 部门号 /// [HttpGet] public IActionResult GetDepartmentList(string DepartmentName, string DepartmentNo) { List departmentlist = _department.GetDepartmentList(DepartmentName, DepartmentNo); return Ok(new { data = departmentlist, code = 0, msg = "获取部门信息列表成功" }); } /// /// 根据id获取部门信息 /// /// 部门id /// [HttpGet] public IActionResult GetDepartmentById(int id) { SysDepartment department = _department.GetDepartmentById(id); return Ok(new { data = department, msg = "成功", code = 0 }); } /// /// 新增部门信息 /// /// 部门dto /// /// 捕获异常 [HttpPost] public async Task AddDepartment(DepartmentDto departmentdto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //更改人 departmentdto.CreateUser = uid; int i = await _department.AddDepartment(departmentdto); //判断是否新增成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "新增失败" }); } else if (i == 3) { return Ok(new { data = i, code = 3, msg = "部门号必须唯一" }); } else { await _operation.InsertOperation("基础信息", "部门管理", departmentdto.DepartmentNo, "添加", "添加部门信息 部门号:" + departmentdto.DepartmentNo, uid); return Ok(new { data = i, code = 0, msg = "新增成功" }); } } catch (Exception ex) { //抛出异常 throw new Exception("新增部门异常", ex); } } /// /// 删除部门信息 /// /// 部门id /// /// 捕获异常 [HttpGet] public async Task DelDepartment(int Id) { //捕获异常 try { SysDepartment department = _department.GetDepartmentById(Id); //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //更改人 department.UpdateUser = uid; int i = await _department.DelDepartment(department); //判断是否删除成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "删除失败" }); } else { await _operation.InsertOperation("基础信息", "部门管理", department.DepartmentNo, "删除", "删除部门信息 部门号:" + department.DepartmentNo, uid); return Ok(new { data = i, code = 0, msg = "删除成功" }); } } catch (Exception ex) { //抛出异常 throw new Exception("删除部门异常", ex); } } /// /// 编辑部门信息 /// /// 部门dto /// /// 捕获异常 [HttpPost] public async Task ExitDepartment(DepartmentDto departmentdto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //更改人 departmentdto.UpdateUser = uid; int i = await _department.ExitDepartment(departmentdto); //判断是否编辑成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "编辑失败" }); } else { await _operation.InsertOperation("基础信息", "部门管理", departmentdto.DepartmentNo, "修改", "编辑部门信息 部门号:" + departmentdto.DepartmentNo, uid); return Ok(new { data = i, code = 0, msg = "编辑成功" }); } } catch (Exception ex) { //抛出异常 throw new Exception("编辑部门异常", ex); } } #endregion #region 功能设定 /// /// 获取功能设定信息列表 /// /// 功能名称 /// 开启状态 /// 组号 /// [HttpGet] public IActionResult GetFunSettingList(string FunSetName, string IsEnable, string GroupNo) { List settinglist = _setting.GetFunSettingList(FunSetName, IsEnable, GroupNo); return Ok(new { data = settinglist, code = 0, msg = "成功" }); } /// /// 根据id查询功能设定信息 /// /// 功能id /// [HttpGet] public IActionResult GetFunSettingById(int id) { SysFunSetting settinglist = _setting.GetFunSettingById(id); return Ok(new { data = settinglist, code = 0, msg = "成功" }); } /// /// 根据编号查询功能设定消息 /// /// 功能编号 /// [HttpGet] public IActionResult GetFunSettingByNo(string funSetNo) { try { var models = _setting.GetFunSettingByNo(funSetNo); return Ok(new { code = 0, msg = "功能设定信息", data = models }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 新增功能信息 /// /// 功能设定dto /// /// 捕获异常 [HttpPost] public async Task AddFunSettings(FunSettingDto settingdto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //创建人 settingdto.CreateUser = uid; //新增 int i = await _setting.AddFunSettings(settingdto); //判断是否新增成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "失败" }); } else if (i == 3) { return Ok(new { data = i, code = 3, msg = "功能号必须唯一" }); } else if (i == 4) { return Ok(new { data = i, code = 4, msg = "显示顺序范围为1---5" }); } else if (i == 5) { return Ok(new { data = i, code = 5, msg = "请输入正确组号" }); } else if (i == 6) { return Ok(new { data = i, code = 6, msg = "每一组只能开启一个功能" }); } else { await _operation.InsertOperation("系统设置", "功能设定", settingdto.FunSetNo, "添加", "添加功能设定 功能号:" + settingdto.FunSetNo, uid); return Ok(new { data = i, code = 0, msg = "成功" }); } } catch (Exception ex) { return Ok(new { data = "", code = 1, msg = "新增功能异常:" + ex.Message }); } } /// /// 删除功能信息 /// /// 功能id /// /// 捕获异常 [HttpGet] public async Task DelFunSettings(int id) { //捕获异常 try { SysFunSetting funSetting = _setting.GetFunSettingById(id); //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //更改人 funSetting.UpdateUser = uid; //删除 int i = await _setting.DelFunSettings(funSetting); //判断是否删除成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "失败" }); } else { await _operation.InsertOperation("系统设置", "功能设定", funSetting.FunSetNo, "删除", "删除功能设定 功能号:" + funSetting.FunSetNo, uid); return Ok(new { data = i, code = 0, msg = "成功" }); } } catch (Exception ex) { //抛出异常 throw new Exception("删除功能异常", ex); } } /// /// 编辑功能信息 /// /// 功能设定dto /// /// 捕获异常 [HttpPost] public async Task ExitFunSettings(FunSettingDto settingdto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //更改人 settingdto.UpdateUser = uid; //编辑 int i = await _setting.ExitFunSettings(settingdto); //判断是否编辑成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "失败" }); } else if (i == 6) { return Ok(new { data = i, code = 6, msg = "每一组只能开启一个功能" }); } else { await _operation.InsertOperation("系统设置", "功能设定", settingdto.FunSetNo, "修改", "修改功能设定 功能号:" + settingdto.FunSetNo, uid); return Ok(new { data = i, code = 0, msg = "成功" }); } } catch (Exception ex) { return Ok(new { data = "", code = 1, msg = "编辑功能异常:" + ex.Message }); } } #endregion #region 物料管理 ///// ///// 查询物料信息 ///// ///// 物料编码视图模型 ///// //[HttpPost] //public IActionResult GetMaterialsList(GetMaterialsVm matevm) //{ // try // { // var bolls = _mate.GetMaterialsList(matevm.SkuNo, matevm.SkuName, matevm.Type, matevm.IsInspect, matevm.Page, matevm.Limit, out int count); // return Ok(new { code = 0, count, msg = "物料信息", data = bolls }); // } // catch (Exception e) // { // return Ok(new { code = 1, msg = e.Message }); // } //} #region yyk #region wms /// /// 获取物料信息列表 /// /// 物料编码 /// 物料名称 /// 审核状态 /// 类型 /// 是否受控 /// 是否免检 /// 存储环境 /// 类别编码 /// [HttpGet] public IActionResult GetMateList(string skuNo, string skuName, string auditStatusNo, string type, string isControlled, string isInspect, string environment, string categoryNo) { List matedto = _mate.GetMateList(skuNo, skuName, auditStatusNo, type, isControlled, isInspect, environment, categoryNo); return Ok(new { data = matedto, code = 0, msg = "成功" }); } /// /// 根据id查询物料信息 /// /// 物料id /// [HttpGet] public IActionResult GetMateById(int id) { SysMaterials mate = _mate.GetMateById(id); return Ok(new { data = mate, code = 0, msg = "成功" }); } /// /// 新增物料信息 /// /// 物料dto /// /// 捕获异常 [HttpPost] public async Task AddMate(MaterialsDto matedto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //创建人 matedto.CreateUser = uid; //新增 int i = await _mate.AddMate(matedto); await _operation.InsertOperation("基础信息", "物料管理", matedto.SkuNo, "添加", "添加物料信息 物料号:" + matedto.SkuNo, uid); return Ok(new { data = i, code = 0, msg = "成功" }); } catch (Exception ex) { //抛出异常 return Ok(new { code = 1, msg = "新增物料异常"+ ex.Message }); } } /// /// 删除物料信息 /// /// 物料id /// /// 捕获异常 [HttpGet] public async Task DelMate(int id) { //捕获异常 try { SysMaterials mate = _mate.GetMateById(id); //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); mate.UpdateUser = uid; //删除 int i = await _mate.DelMate(mate); //判断是否删除成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "失败" }); } else { await _operation.InsertOperation("基础信息", "物料管理", mate.SkuNo, "删除", "删除物料信息 物料号:" + mate.SkuNo, uid); return Ok(new { data = i, code = 0, msg = "成功" }); } } catch (Exception ex) { //抛出异常 throw new Exception("删除物料异常", ex); } } /// /// 编辑物料信息 /// /// 物料dto /// /// 捕获异常 [HttpPost] public async Task ExitMate(MaterialsDto matedto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //更新人 matedto.UpdateUser = uid; //编辑 int i = await _mate.ExitMate(matedto); //判断是否编辑成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "修改失败" }); } else if (i == 2) { return Ok(new { data = i, code = 2, msg = "临期天数不可大于365及小于30" }); } //else if (i == 4) //{ // return Ok(new { data = i, code = 4, msg = "低库存不可高于1000" }); //} else { await _operation.InsertOperation("基础信息", "物料管理", matedto.SkuNo, "修改", "编辑物料信息 物料号:" + matedto.SkuNo, uid); return Ok(new { data = i, code = 0, msg = "修改成功" }); } } catch (Exception ex) { //抛出异 return Ok(new { code = 1, msg = "编辑物料异常"+ex.Message }); } } #region 包装 单位 /// /// 获取计量单位信息列表 /// /// [HttpGet] public IActionResult GetUnitList() { List unitlist = _mate.GetUnitList(); return Ok(new { data = unitlist, code = 0, msg = "成功" }); } /// /// 获取包装信息列表 /// /// [HttpGet] public IActionResult GetPackagList() { List packlist = _mate.GetPackagList(); return Ok(new { data = packlist, code = 0, msg = "成功" }); } #endregion #endregion #region erp /// /// 获取erp数据 /// /// [HttpGet] public IActionResult GetERPList() { List list = _mate.GetERPList(); return Ok(new { data = list, msg = "成功", code = 0 }); } /// /// 根据id获取erp数据 /// /// [HttpGet] public IActionResult GetERPListById(int id) { SysERPTest erp = _mate.GetERPListById(id); return Ok(new { data = erp, msg = "成功", code = 0 }); } /// /// 新增erp数据 /// /// erp测试dto /// /// 捕获异常 [HttpPost] public async Task AddERP(ERPTestDto erpdto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //创建人 erpdto.CreateUser = uid; //新增 int i = await _mate.AddERP(erpdto); //判断是否新增成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "失败" }); } else if (i == 3) { return Ok(new { data = i, code = 3, msg = "物料号必须唯一" }); } else { return Ok(new { data = i, code = 0, msg = "成功" }); } } catch (Exception ex) { //抛出异常 throw new Exception("新增erp异常", ex); } } /// /// 删除erp信息 /// /// erp测试dto /// /// 捕获异常 [HttpPost] public async Task DelERP(ERPTestDto erpdto) { //捕获异常 try { //根据id获取数据 SysERPTest erp = _mate.GetERPListById(erpdto.Id); // 获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); erp.UpdateUser = uid; //删除 int i = await _mate.DelERP(erp); return i; } catch (Exception ex) { //抛出异常 throw new Exception("删除erp异常", ex); } } /// /// 编辑erp数据 /// /// erp测试dto /// /// 捕获异常 [HttpPost] public async Task EditERP(ERPTestDto erpdto) { //捕获异常 try { //获取当前操作用户id var claimsIdentity = this.User.Identity as ClaimsIdentity; var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; int uid = Convert.ToInt32(userId); //创建人 erpdto.UpdateUser = uid; //新增 int i = await _mate.EditERP(erpdto); //判断是否编辑成功 if (i == 0) { return Ok(new { data = i, code = 1, msg = "失败" }); } else { return Ok(new { data = i, code = 0, msg = "成功" }); } } catch (Exception ex) { //抛出异常 throw new Exception("编辑erp异常", ex); } } #endregion #endregion #endregion #region 客户管理 /// /// 查询客户信息 /// /// /// [HttpPost] public IActionResult GetCustomerList(GetCustomerVm model) { try { var bolls = _customerSvc.GetCustomerList(model.CustomerNo,model.CustomerName, model.Type, model.LinkMan, model.Phone, model.Page, model.Limit, out int count); return Ok(new { code = 0, count, msg = "客户信息", data = bolls }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 查询单条客户信息 /// /// /// [HttpPost] public IActionResult GetCustomer(IdVm model) { try { var bolls = _customerSvc.GetCustomer(model.Id); return Ok(new { code = 0, count = 0, msg = "客户信息", data = bolls }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 查询全部客户信息 /// /// [HttpGet] public IActionResult GetCustomerSelect() { try { var bolls = _customerSvc.GetCustomerSelect(); return Ok(new { code = 0, count = 0, msg = "客户信息", data = bolls }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 添加客户信息 /// /// /// [HttpPost] public IActionResult AddCustomer(AddCustomerVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _customerSvc.AddCustomer(model.CustomerNo, model.CustomerName, model.Type, model.Address, model.LinkMan, model.Phone, model.BankAccount, model.CreditRating, model.Demo, int.Parse(userId)); if (bolls) { _operation.InsertOperation("基础信息", "客户管理", model.CustomerNo, "添加", "添加客户信息 客户号:" + model.CustomerNo, Convert.ToInt32(userId)); return Ok(new { code = 0, msg = "添加成功" }); } else { return Ok(new { code = 1, msg = "添加失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 编辑客户信息 /// /// /// [HttpPost] public IActionResult EditCustomer(EditCustomerVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _customerSvc.EditCustomer(model.Id, model.CustomerNo, model.CustomerName, model.Type, model.Address, model.LinkMan, model.Phone, model.BankAccount, model.CreditRating, model.Demo, int.Parse(userId)); if (bolls) { _operation.InsertOperation("基础信息", "客户管理", model.CustomerNo, "编辑", "编辑客户信息 客户号:" + model.CustomerNo, Convert.ToInt32(userId)); return Ok(new { code = 0, msg = "编辑成功" }); } else { return Ok(new { code = 1, msg = "编辑失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 删除客户信息 /// /// /// [HttpPost] public IActionResult DelCustomer(IdVm model) { try { SysCustomer customer = _customerSvc.GetCustomer(model.Id); //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _customerSvc.DelCustomer(model.Id, int.Parse(userId)); if (bolls) { _operation.InsertOperation("基础信息", "客户管理", customer.CustomerNo, "删除", "删除客户信息 客户号:" + customer.CustomerNo, Convert.ToInt32(userId)); return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = "删除失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 删除客户信息(多删除) /// /// /// [HttpPost] public IActionResult DelsCustomer(IdVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _customerSvc.DelsCustomer(model.Ids, int.Parse(userId)); if (bolls) { return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = "删除失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } #endregion #region 物流信息管理 /// /// 查询物流信息 /// /// /// [HttpPost] public IActionResult GetLogisticsInfoList(GetLogisticsInfoVm model) { try { var bolls = _logisticsSvc.GetLogisticsInfoList(model.CarrierName, model.LinkMan, model.Phone, model.LicensePlate, model.Type, model.Page, model.Limit, out int count); return Ok(new { code = 0, count, msg = "物流信息", data = bolls }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 查询单条物流信息 /// /// /// [HttpPost] public IActionResult GetLogisticsInfo(IdVm model) { try { var bolls = _logisticsSvc.GetLogisticsInfo(model.Id); return Ok(new { code = 0, data = bolls }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 查询全部物流信息 /// /// [HttpGet] public IActionResult GetLogisticsInfoSelect() { try { var bolls = _logisticsSvc.GetLogisticsInfoSelect(); return Ok(new { code = 0, data = bolls }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 添加物流信息 /// /// /// [HttpPost] public IActionResult AddLogisticsInfo(AddLogisticsInfoVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _logisticsSvc.AddLogisticsInfo(model, int.Parse(userId)); if (bolls) { _operation.InsertOperation("基础信息", "物流管理", model.CarrierName, "添加", "添加物流信息 公司名称:" + model.CarrierName, Convert.ToInt32(userId)); return Ok(new { code = 0, msg = "添加成功" }); } else { return Ok(new { code = 1, msg = "添加失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 编辑物流信息 /// /// /// [HttpPost] public IActionResult EditLogisticsInfo(EditLogisticsInfoVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _logisticsSvc.EditLogisticsInfo(model, int.Parse(userId)); if (bolls) { _operation.InsertOperation("基础信息", "物流管理", model.CarrierName, "编辑", "编辑物流信息 公司名称:" + model.CarrierName, Convert.ToInt32(userId)); return Ok(new { code = 0, msg = "编辑成功" }); } else { return Ok(new { code = 1, msg = "编辑失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 删除物流信息 /// /// /// [HttpPost] public IActionResult DelLogisticsInfo(IdVm model) { try { SysLogisticsInfo logisit = _logisticsSvc.GetLogisticsInfo(model.Id); //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _logisticsSvc.DelLogisticsInfo(model.Id, int.Parse(userId)); if (bolls) { _operation.InsertOperation("基础信息", "物流管理", logisit.CarrierName, "删除", "删除物流信息 公司名称:" + logisit.CarrierName, Convert.ToInt32(userId)); return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = "删除失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 删除物流信息(多条信息) /// /// /// [HttpPost] public IActionResult DelsLogisticsInfo(IdVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _logisticsSvc.DelsLogisticsInfo(model.Ids, int.Parse(userId)); if (bolls) { return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = "删除失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } #endregion #region 计量单位管理 /// /// 查询计量单位信息 /// /// /// [HttpPost] public IActionResult GetUnitList(GetUnitVm model) { try { var list = _unitSvc.GetUnitList(model.UnitNo, model.UnitName, model.Page, model.Limit, out int count); return Ok(new { code = 0, count, msg = "物流信息", data = list }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 查询单条单位信息 /// /// /// [HttpPost] public IActionResult GetUnit(IdVm model) { try { var data = _unitSvc.GetUnit(model.Id); if (data != null) { return Ok(new { code = 0, data }); } else { return Ok(new { code = 1, data = "未查询到物流信息" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 添加计量信息 /// /// /// [HttpPost] public IActionResult AddUnit(AddEditUnitVm model) { if (ModelState.IsValid) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _unitSvc.AddUnit(model.UnitName, model.Abbrev, int.Parse(userId)); if (bolls) { return Ok(new { code = 0, msg = "添加成功" }); } else { return Ok(new { code = 1, msg = "添加失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } else { return Ok(new { code = 1, msg = "数据格式错误" }); } } /// /// 编辑计量单位信息 /// /// /// [HttpPost] public IActionResult EditUnit(AddEditUnitVm model) { if (ModelState.IsValid) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _unitSvc.EditUnit(model.Id, model.UnitName, model.Abbrev, int.Parse(userId)); if (bolls) { SysUnit unit = _unitSvc.GetUnit(model.Id); _operation.InsertOperation("基础信息", "计量单位", unit.UnitNo, "编辑", "编辑计量单位 单位名称:" + unit.UnitNo, Convert.ToInt32(userId)); return Ok(new { code = 0, msg = "编辑成功" }); } else { return Ok(new { code = 1, msg = "编辑失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } else { return Ok(new { code = 1, msg = "数据格式错误" }); } } /// /// 删除计量单位信息 /// /// /// [HttpPost] public IActionResult DelUnit(IdVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _unitSvc.DelUnit(model.Id, int.Parse(userId)); if (bolls) { return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = "删除失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 删除计量单位信息(多删除) /// /// /// [HttpPost] public IActionResult DelsUnit(IdVm model) { try { //获取当前登录的用户ID var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(userId)) { return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); } var bolls = _unitSvc.DelsUnit(model.Ids, int.Parse(userId)); if (bolls) { return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = "删除失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } #endregion #region 包装管理 private string UserId; //public BasisController() //{ // var claimsIdentity = this.User.Identity as ClaimsIdentity; // if (claimsIdentity == null) // { // throw new Exception("未获取到用户信息"); // } // UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; // if (string.IsNullOrWhiteSpace(UserId)) // { // throw new Exception("未获取到用户信息"); // } //} /// /// 查询包装信息 /// /// /// [HttpPost] public IActionResult GetPackagList(GetPackagVm model) { try { var list = _packagSvc.GetPackagList(model.PackagNo, model.PackagName, model.Level, model.Page, model.Limit, out int count); return Ok(new { code = 0, count, msg = "物流信息", data = list }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 根据id获取包装信息 /// /// 包装id /// [HttpGet] public IActionResult GetPackagById(int id) { SysPackag packag = _packagSvc.GetPackagById(id); return Ok(new { data = packag, code = 0, msg = "成功" }); } /// /// 添加包装信息 /// /// 包装信息 /// [HttpPost] public IActionResult AddPackag(AddEditPackagVm model) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } model.CreateUser = int.Parse(UserId); int i = _packagSvc.AddPackag(model); if (i == 1) { _operation.InsertOperation("基础信息", "包装管理", model.PackagNo, "添加", "添加包装信息 包装编号:" + model.PackagNo, Convert.ToInt32(UserId)); return Ok(new { code = 0, msg = "添加成功" }); } else if (i > 1) { return Ok(new { code = i, msg = "包装等级不可越级添加" }); } else { return Ok(new { code = 1, msg = "添加失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 编辑包装信息 /// /// 包装信息 /// [HttpPost] public IActionResult EditPackag(AddEditPackagVm model) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } model.CreateUser = int.Parse(UserId); int i = _packagSvc.EditPackag(model); if (i == 1) { _operation.InsertOperation("基础信息", "包装管理", model.PackagNo, "编辑", "编辑包装信息 包装编号:" + model.PackagNo, Convert.ToInt32(UserId)); return Ok(new { code = 0, msg = "编辑成功" }); } if (i == 2) { return Ok(new { code = i, msg = "包装等级不可越级修改 请重新输入" }); } else { return Ok(new { code = 1, msg = "编辑失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 逻辑删除包装信息 /// /// /// [HttpPost] public IActionResult DelPackag(AddEditPackagVm model) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } var bolls = _packagSvc.DelPackag(model.Id, int.Parse(UserId)); if (bolls) { _operation.InsertOperation("基础信息", "包装管理", model.PackagNo, "删除", "删除包装信息 包装编号:" + model.PackagNo, Convert.ToInt32(UserId)); return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = "删除失败" }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } #endregion #region 系统操作日志 /// /// 获取操作日志信息列表 /// /// 菜单名称 /// 操作类型 /// 操作内容 /// 菜单号 /// 模块号 /// [HttpGet] public IActionResult GetSysOperationList(string menuName, string type, string msg, string menuNo, string parentNo) { List operation = _operation.GetSysOperationList(menuName, type, msg, menuNo, parentNo); return Ok(new { data = operation, code = 0, msg = "成功" }); } /// /// 获取类型菜单 /// /// 字典名称 /// [HttpGet] public IActionResult GetDicTypeList(string dicName) { List diclist = _operation.GetDicTypeList(dicName); return Ok(new { data = diclist, code = 0, msg = "成功" }); } #endregion #region 接口管理 /// /// 获取接口列表 /// /// /// [HttpPost] public IActionResult GetInterfaceList(InterfaceVm model) { try { var models = _interface.GetInterfaceList(model, out int count); return Ok(new { code = 0, count, msg = "接口列表", data = models }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 获取接口明细列表 /// /// /// [HttpPost] public IActionResult GetInterfaceDetailList(InterfaceDetailVm model) { try { var models = _interface.GetInterfaceDetailList(model, out int count); return Ok(new { code = 0, count, msg = "接口明细列表", data = models }); } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 添加接口信息 /// /// /// [HttpPost] public IActionResult AddInterface(InterfaceVm model) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } model.CreateUser = int.Parse(UserId); string strMesage = _interface.AddInterface(model); if (strMesage == "") { return Ok(new { code = 0, msg = "添加成功" }); } if (strMesage.Contains("-1")) { return Ok(new { code = 1, msg = strMesage }); } else { return Ok(new { code = 0, msg = strMesage }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 编辑接口信息 /// /// /// [HttpPost] public IActionResult EditInterface(InterfaceVm model) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } model.CreateUser = int.Parse(UserId); string strMesage = _interface.EditInterface(model); if (strMesage == "") { return Ok(new { code = 0, msg = "编辑成功" }); } if (strMesage.Contains("-1")) { return Ok(new { code = 0, msg = "部分成功" }); } else { return Ok(new { code = 1, msg = strMesage }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 删除接口信息 /// /// /// [HttpPost] public IActionResult DelInterface(InterfaceVm model) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } model.CreateUser = int.Parse(UserId); string strMesage = _interface.DelInterface(model); if (strMesage == "") { return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = strMesage }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } /// /// 删除接口明细信息 /// /// /// [HttpPost] public IActionResult DelInterfaceDetail(InterfaceDetailVm model) { try { var claimsIdentity = this.User.Identity as ClaimsIdentity; if (claimsIdentity == null) { throw new Exception("未获取到用户信息"); } string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; if (string.IsNullOrWhiteSpace(UserId)) { throw new Exception("未获取到用户信息"); } model.CreateUser = int.Parse(UserId); string strMesage = _interface.DelInterfaceDetail(model); if (strMesage == "") { return Ok(new { code = 0, msg = "删除成功" }); } else { return Ok(new { code = 1, msg = strMesage }); } } catch (Exception e) { return Ok(new { code = 1, msg = e.Message }); } } #endregion } }