| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using CallCenterApi.Common;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Input;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers
- {
- [Authority]
- public class RoleInfoController : BaseController
- {
- private BLL.T_Sys_RoleInfo roleInfoBLL = new BLL.T_Sys_RoleInfo();
- // 获取角色列表
- public ActionResult GetRoleList(int pageIndex = 1, int pageSize = 10, string code = "", string name = "", int isall = 0)
- {
- if (isall == 0)
- {
- DataTable dt = new DataTable();
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_RoleInfo",
- "F_RoleId",
- "*",
- " and F_RoleName like '%" + name + "%' and F_RoleCode like '%" + code + "%' ",
- "",
- pageSize,
- pageIndex,
- true,
- out recordCount);
- var obj = new
- {
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- else
- {
- return Success("获取角色信息成功", new BLL.T_Sys_RoleInfo().GetAllList().Tables[0]);
- }
- }
- //获取角色
- public ActionResult GetRole(int roleid = 0)
- {
- Model.T_Sys_RoleInfo dModel = roleInfoBLL.GetModel(roleid);
- if (dModel != null)
- return Success("获取角色信息成功", dModel);
- else
- return Error("获取角色信息失败");
- }
- //添加角色
- public ActionResult AddRole(RoleInput input)
- {
- Model.T_Sys_RoleInfo rModel = new Model.T_Sys_RoleInfo();
- rModel.F_RoleName = input.RoleName;
- rModel.F_Remark = input.RoleRemark;
- rModel.F_RoleCode = input.Code;
- if (roleInfoBLL.Add(rModel) > 0)
- return Success("添加成功");
- else
- return Success("添加失败");
- }
- //编辑角色
- public ActionResult EditRole(RoleInput input)
- {
- if (input.RoleId <= 0)
- return Error("请选择要编辑的角色");
- Model.T_Sys_RoleInfo rModel = roleInfoBLL.GetModel(input.RoleId);
- rModel.F_Remark = input.RoleRemark;
- rModel.F_RoleCode = input.Code;
- rModel.F_RoleName = input.RoleName;
- if (rModel == null)
- return Error("获取信息失败");
- if (roleInfoBLL.Update(rModel))
- return Success("编辑成功");
- else
- return Success("编辑失败");
- }
- //删除角色
- public ActionResult DelRole(int id = 0)
- {
- if (id <= 0)
- return Error("请选择角色");
- if (roleInfoBLL.Delete(id))
- return Success("删除成功");
- else
- return Error("删除失败");
- }
- }
- }
|