getList.md 5.09 KB

资讯列表查询

接口名: '/guang/article/getList'

方法

POST JSONRAW

入参


属性名称 类型 例子 说明 是否必填 长度限制
articleTitle String 尖货盘点 资讯标题 0-85
articleGender String 1 性别 0-1
authorId int 2890 作者ID 0-11
maxSortId int 12 分类ID 0-11
status int 1 资讯状态 0-1
orderBy String 1 时间方式 0-13
startTime String 2016-01-01 开始时间 0-10
endTime String 2016-02-01 结束时间 0-10

对应SQL的操作库表

  <select id="selectArticleList" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from article where 1 = 1
    <if test="article.articleTitle != null and article.articleTitle != ''" >
        and article_title like CONCAT('%',#{article.articleTitle},'%')
    </if>
    <if test="article.articleGender != null and article.articleGender != ''" >
        and article_gender = #{article.articleGender}
    </if>
    <if test="article.authorId != null and article.authorId != ''" >
        and author_id = #{article.authorId}
    </if>
    <if test="article.tag != null and article.tag != ''" >
        and tag = #{article.tag}
    </if>
    <if test="article.maxSortId != null and article.maxSortId != ''" >
        and max_sort_id = #{article.maxSortId}
    </if>
    <if test="article.status != null and article.status == 0" >
        and (publish_time > unix_timestamp(curdate())  or publish_time = 0)
    </if>
    <if test="article.status != null and article.status == 1" >
        and unix_timestamp(curdate()) > publish_time and publish_time > 0
    </if>
    <if test="article.status != null and article.status == -1" >
        and status = #{article.status}
    </if>
    <if test="article.createTime == 1 and startTime != null" >
        and create_time > #{startTime}
    </if>
    <if test="article.createTime == 1 and endTime != null" >
        and #{endTime} > create_time
    </if>
    <if test="article.publishTime == 1 and startTime != null" >
        and publish_time > #{startTime}
    </if>
    <if test="article.publishTime == 1 and endTime != null" >
        and #{endTime} > publish_time
    </if>
    <if test="orderBy != null and orderBy == 'create_time'" >
        order by create_time desc
    </if>
    <if test="orderBy != null and orderBy == 'publish_time'" >
        order by publish_time desc
    </if>
    limit #{offset}, #{limit}
  </select>
  <select id="selectArticleListCount" resultType="java.lang.Integer">
    select ifnull(count(1),0)
    from article where 1 = 1
    <if test="article.articleTitle != null and article.articleTitle != ''" >
        and article_title like CONCAT('%',#{article.articleTitle},'%')
    </if>
    <if test="article.articleGender != null and article.articleGender != ''" >
        and article_gender = #{article.articleGender}
    </if>
    <if test="article.authorId != null and article.authorId != ''" >
        and author_id = #{article.authorId}
    </if>
    <if test="article.tag != null and article.tag != ''" >
        and tag = #{article.tag}
    </if>
    <if test="article.maxSortId != null and article.maxSortId != ''" >
        and max_sort_id = #{article.maxSortId}
    </if>
    <if test="article.status != null and article.status == 0" >
        and (publish_time > unix_timestamp(curdate())  or publish_time = 0)
    </if>
    <if test="article.status != null and article.status == 1" >
        and unix_timestamp(curdate()) > publish_time and publish_time > 0
    </if>
    <if test="article.status != null and article.status == -1" >
        and status = #{article.status}
    </if>
    <if test="article.createTime == 1 and startTime != null" >
        and create_time > #{startTime}
    </if>
    <if test="article.createTime == 1 and endTime != null" >
        and #{endTime} > create_time
    </if>
    <if test="article.publishTime == 1 and startTime != null" >
        and publish_time > #{startTime}
    </if>
    <if test="article.publishTime == 1 and endTime != null" >
        and #{endTime} > publish_time
    </if>
  </select>

错误编码


错误码code 消息 说明
400 请求参数为空!
200 操作成功

返回

{
    "code":200,
    "message":"操作成功",
    "data": {
        "list": [
            {
                "id": "",            //资讯ID
                "coverImage": "",    //封面图
                "articleTitle": "",  //资讯标题
                "maxSortId": "",     //分类
                "articleGender": "", //性别
                "authorId": "",      //作者
                "status": "",        //状态,-1已关闭,0 未发布,1 已发布
                "createTime": "",    //创建时间
                "publishTime": "",   //发布时间
            }
        ],
        "page": 0,
        "size": 50,
        "total": 1000,
        "totalPage":20
    }
}