| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- using CallCenterApi.Common;
- using CallCenterApi.Interface.Controllers.Base;
- using CallCenterApi.Interface.Models.Common;
- using CallCenterApi.Interface.Models.Input;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers
- {
- [Authority]
- public class FunctionController : BaseController
- {
- private BLL.T_Sys_Function functionBLL = new BLL.T_Sys_Function();
- /// <summary>
- /// 获取菜单列表
- /// </summary>
- /// <param name="filter"></param>
- /// <returns></returns>
- public ActionResult GetAllList()
- {
- DataTable dt = new DataTable();
- StringBuilder sql = new StringBuilder();
- dt = functionBLL.GetList(0, "1=1", "F_Sort asc").Tables[0];
- return Success("加载成功", dt);
- }
- /// <summary>
- /// 获取菜单列表
- /// </summary>
- /// <param name="filter"></param>
- /// <returns></returns>
- public ActionResult GetList()
- {
- DataTable dt = new DataTable();
- StringBuilder sql = new StringBuilder();
- int pid = RequestString.GetInt("pid", 0);
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (pid != 0)
- { sql.Append(" and f_parentid=" + pid); }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- var recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_Function",
- "F_FunctionId",
- "*",
- sql.ToString(),
- "ORDER BY F_Sort ",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取菜单信息
- /// </summary>
- /// <returns></returns>
- public ActionResult GetFunction()
- {
- DataTable dt = new DataTable();
- StringBuilder sql = new StringBuilder();
- int id = RequestString.GetInt("id", 0);
- var model = functionBLL.GetModel(id);
- return Success("加载成功", model);
- }
- /// <summary>
- /// 添加/编辑菜单
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult AddFunction()
- {
- int id = RequestString.GetInt("id", 0);
- int pid = RequestString.GetInt("pid", 0);
- string name = RequestString.GetFormString("name");
- string code = RequestString.GetFormString("code");
- int state = RequestString.GetInt("state", 0);
- int sort = RequestString.GetInt("sort", 0);
- string url = RequestString.GetFormString("url");
- string img = RequestString.GetFormString("img");
- string remark = RequestString.GetFormString("remark");
- Model.T_Sys_Function orderModel = new Model.T_Sys_Function();
- if (pid == 0) return Error("参数错误");
- if (pid != -1)
- {
- var model = functionBLL.GetModel(pid);
- if (model == null) return Error("父菜单不存在");
- }
- if (id == 0)
- {
- orderModel.F_ParentId = pid;
- orderModel.F_FunctionCode = code;
- orderModel.F_FunctionName = name;
- orderModel.F_OptUrl = url;
- orderModel.F_ImgUrl = img;
- orderModel.F_Sort = sort;
- orderModel.F_Remark = remark;
- orderModel.F_State = state;
- orderModel.F_Layer = 2;
- orderModel.F_flag = 0;
- if (pid < 0)
- {
- orderModel.F_Layer = 1;
- orderModel.F_flag = 1;
- }
- if (functionBLL.Add(orderModel) > 0)
- return Success("菜单添加成功");
- else
- return Error("菜单添加失败");
- }
- else
- {
- orderModel = functionBLL.GetModel(id);
- if (orderModel != null)
- {
- orderModel.F_ParentId = pid;
- orderModel.F_FunctionCode = code;
- orderModel.F_FunctionName = name;
- orderModel.F_OptUrl = url;
- orderModel.F_ImgUrl = img;
- orderModel.F_Sort = sort;
- orderModel.F_Remark = remark;
- orderModel.F_State = state;
- orderModel.F_Layer = 2;
- orderModel.F_flag = 0;
- if (pid < 0)
- {
- orderModel.F_Layer = 1;
- orderModel.F_flag = 1;
- }
- if (functionBLL.Update(orderModel))
- return Success("菜单修改成功");
- else
- return Error("菜单修改失败");
- }
- else
- {
- return Error("菜单修改失败");
- }
- }
- }
- /// <summary>
- /// 删除菜单
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelFunction(string[] ids)
- {
- if (ids != null && ids.Length > 0)
- {
- string idd = " ";
- foreach (string str in ids)
- {
- idd += str + ",";
- }
- if (new BLL.T_Sys_Function().DeleteList(idd.TrimEnd(',')))
- {
- return Success("删除成功");
- }
- else
- {
- return Error("删除失败");
- }
- }
- else
- {
- return Error("获取参数失败");
- }
- }
- }
- }
|