public async Task <ActionResult <ApiResult> > GetPageByParm([FromQuery] ActionQueryParm parm)
        {
            ApiResult resp = new ApiResult();
            var       ret  = await _ActionService.GetPageByParm(parm);

            if (ret.code == (int)ErrType.OK)
            {
                var data = new { rows = ret.data, total = ret.relatedData };
                //var resp = new { code = ret.code, data = data };
                resp.code = Code.Success;
                resp.data = data;
                return(resp);
            }
            else
            {
                resp.code = Code.Failure;
                resp.msg  = ret.msg;
                return(resp);
            }
        }
Exemple #2
0
        public async Task <MSSResult <ActionView> > GetPageByParm(ActionQueryParm parm)
        {
            MSSResult <ActionView> mRet = new MSSResult <ActionView>();

            try
            {
                parm.page  = parm.page == 0 ? 1 : parm.page;
                parm.rows  = parm.rows == 0 ? Common.Const.PAGESIZE : parm.rows;
                parm.sort  = string.IsNullOrWhiteSpace(parm.sort) ? "id" : parm.sort;
                parm.order = parm.order.ToLower() == "desc" ? "desc" : "asc";
                mRet       = await _ActionRepo.GetPageByParm(parm);

                mRet.code = (int)ErrType.OK;
                return(mRet);
            }
            catch (Exception ex)
            {
                mRet.code = (int)ErrType.SystemErr;
                mRet.msg  = ex.Message;
                return(mRet);
            }
        }
Exemple #3
0
 public async Task <MSSResult <ActionView> > GetPageByParm(ActionQueryParm parm)
 {
     return(await WithConnection(async c =>
     {
         MSSResult <ActionView> mRet = new MSSResult <ActionView>();
         StringBuilder sql = new StringBuilder();
         sql.Append("SELECT a.*,u1.user_name as created_name,u2.user_name as updated_name,ag.group_name, ")
         .Append(" ai.action_name as parent_name FROM Action_Info a ")
         .Append(" left join user u1 on a.created_by=u1.id left join user u2 on a.updated_by=u2.id ")
         .Append(" left join Action_Group ag on ag.id=a.group_id ")
         .Append(" left join Action_Info ai on ai.id=a.parent_menu ")
         .Append(" where 1=1 ");
         StringBuilder whereSql = new StringBuilder();
         if (!string.IsNullOrWhiteSpace(parm.searchName))
         {
             whereSql.Append(" and a.action_name like '%" + parm.searchName + "%' ");
         }
         if (parm.searchParent != null)
         {
             whereSql.Append(" and a.parent_menu=" + parm.searchParent);
         }
         if (parm.searchGroup != null)
         {
             whereSql.Append(" and a.group_id=" + parm.searchGroup);
         }
         sql.Append(whereSql)
         .Append(" order by a." + parm.sort + " " + parm.order)
         .Append(" limit " + (parm.page - 1) * parm.rows + "," + parm.rows);
         var tmp = await c.QueryAsync <ActionView>(sql.ToString());
         if (tmp != null)
         {
             mRet.data = tmp.ToList();
         }
         mRet.relatedData = await c.QueryFirstOrDefaultAsync <int>(
             "select count(*) from Action_Info a where 1=1 " + whereSql.ToString());
         return mRet;
     }));
 }