<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, hnqz All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the pig4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: hnqz
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.qunzhixinxi.hnqz.daemon.quartz.mapper.WmWkArticleMapper">

	<resultMap id="wmWkArticleMap" type="com.qunzhixinxi.hnqz.daemon.quartz.entity.WmWkArticle">
		<id property="id" column="id"/>
		<result property="title" column="title"/>
		<result property="author" column="author"/>
		<result property="fm" column="fm"/>
		<result property="content" column="content"/>
		<result property="source" column="source"/>
		<result property="description" column="description"/>
		<result property="deptId" column="dept_id"/>
		<result property="delFlag" column="del_flag"/>
		<result property="enableFlag" column="enable_flag"/>
		<result property="tenantId" column="tenant_id"/>
		<result property="createTime" column="create_time"/>
		<result property="createUser" column="create_user"/>
		<result property="updateTime" column="update_time"/>
		<result property="updateUser" column="update_user"/>
		<result property="forwardNum" column="forward_num"/>
		<result property="channelId" column="channel_id"/>
		<result property="articleId" column="article_id"/>
	</resultMap>

	<update id="updateNewFlag">
		UPDATE wm_wk_article SET new_flag = 0 where new_flag = 1 ;
		UPDATE wm_wk_article
		SET new_flag = 1
		WHERE
			create_time = (
				SELECT
					*
				FROM
					(
						SELECT
							max(create_time)
						FROM
							wm_wk_article
					) tmp
			);

	</update>

	<update id="setHotArtileTask">
		UPDATE wm_wk_article SET hot_flag = 0 where hot_flag = 1 ;
		UPDATE wm_wk_article SET hot_flag = 1
		WHERE
			id IN (
				SELECT
					*
				FROM
					(
						SELECT
							id
						FROM
							wm_wk_article
						ORDER BY
							forward_num DESC
						LIMIT 3
					) temp
			);
	</update>
</mapper>
