zoukankan      html  css  js  c++  java
  • c# 返回一个对象的写法

    创建对象ViewModel:

     1 using System;
     2 
     3 namespace DevOps.Api.ViewModel
     4 {
     5     public class AppDocList
     6     {
     7         /// <summary>
     8         /// 应用ID
     9         /// </summary>
    10         public string app_id { get; set; }
    11         /// <summary>
    12         /// 文档类别(来源字典)
    13         /// </summary>
    14         public string doc_type { get; set; }
    15         /// <summary>
    16         /// 文档标题
    17         /// </summary>
    18         public string title { get; set; }
    19         /// <summary>
    20         /// 关键字
    21         /// </summary>
    22         public string keyword { get; set; }
    23         /// <summary>
    24         /// 文档内容
    25         /// </summary>
    26         public string doc_content { get; set; }
    27         /// <summary>
    28         /// 状态(1-草稿;2-已发布;3-撤回)
    29         /// </summary>
    30         public int status { get; set; }
    31         /// <summary>
    32         /// 发布人
    33         /// </summary>
    34         public string publish_by { get; set; }
    35         /// <summary>
    36         /// 发布时间
    37         /// </summary>
    38         public DateTime? publish_time { get; set; }
    39         /// <summary>
    40         /// 发布时间
    41         /// </summary>
    42         public string statusname { get; set; }
    43     }
    44 }

    api核心代码:

    var applist = new List<AppDocList>();
                foreach (var item in ids)
                {
                    applist.Add(new AppDocList
                    {
                        app_id = item.app_id,
                        doc_type = item.doc_type,
                        title = item.title,
                        keyword = item.keyword,
                        doc_content = item.doc_content,
                        statusname = (int)DocStatus.Draft == item.status ? GetEnumDesc(DocStatus.Draft) : (
                        (int)DocStatus.Published == item.status ? GetEnumDesc(DocStatus.Published) : (
                        (int)DocStatus.Withdraw == item.status ? GetEnumDesc(DocStatus.Withdraw) : "")
                        ),
                        publish_by = item.publish_by,
                        publish_time = item.publish_time
                    });
                }
                result.Data = applist;
  • 相关阅读:
    Perforce笔记
    Lumia 800 无法正常开机
    Windows service 中出现Set ServiceLogin 对话框
    华为要求七千员工先辞职再竞岗 补偿费超10亿
    BLOG新址:http://longware.spaces.live.com
    家装(2)
    解脱
    论持久战
    有感于软件项目测试
    THE POEM AS A GIFT FOR MY GF'S BIRTHDAY
  • 原文地址:https://www.cnblogs.com/chenpanpan/p/14506352.html
Copyright © 2011-2022 走看看