<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeeplus.modules.workappshow.dao.WorkappshowDao">
    
	<sql id="workappshowColumns">
		a.id AS "id",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",
		a.notify_status AS "notifyStatus",
		a.company_rule_status AS "companyRuleStatus",
		a.report_status AS "reportStatus",
		a.calendar_status AS "calendarStatus",
		a.audit_status AS "auditStatus",
		a.signin_status AS "signInStatus",
		a.manage_calendar_status AS "manageCalendarStatus",
		a.user_id AS "userId",
		a.meeting_status AS "meetingStatus",
		a.business_status AS "businessStatus",
		a.company_id AS "companyId"
	</sql>
	
	<sql id="workappshowJoins">
	</sql>
	
    
	<select id="get" resultType="Workappshow" >
		SELECT 
			<include refid="workappshowColumns"/>
		FROM work_app_show a
		<include refid="workappshowJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="Workappshow" >
		SELECT 
			<include refid="workappshowColumns"/>
		FROM work_app_show a
		<include refid="workappshowJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
            <if test="userId != null and userId != ''">
                AND a.user_id = #{userId}
            </if>
            <if test="companyId != null and companyId != ''">
                AND a.company_id = #{companyId}
            </if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<select id="findAllList" resultType="Workappshow" >
		SELECT 
			<include refid="workappshowColumns"/>
		FROM work_app_show a
		<include refid="workappshowJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
		</where>		
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.update_date DESC
			</otherwise>
		</choose>
	</select>
	
	<insert id="insert">
		INSERT INTO work_app_show(
			id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			notify_status,
			company_rule_status,
			report_status,
			calendar_status,
			audit_status,
			signin_status,
			manage_calendar_status,
			company_id,
			meeting_status,
			business_status,
			user_id
		) VALUES (
			#{id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{notifyStatus},
			#{companyRuleStatus},
			#{reportStatus},
			#{calendarStatus},
			#{auditStatus},
			#{signInStatus},
			#{manageCalendarStatus},
			#{companyId},
			#{meetingStatus},
			#{businessStatus},
			#{userId}
		)
	</insert>
	
	<update id="update">
		UPDATE work_app_show SET 	
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			notify_status = #{notifyStatus},
			company_rule_status = #{companyRuleStatus},
			report_status = #{reportStatus},
			calendar_status = #{calendarStatus},
			audit_status = #{auditStatus},
			signin_status = #{signInStatus},
			company_id = #{companyId},
			meeting_status = #{meetingStatus},
			manage_calendar_status = #{manageCalendarStatus},
			business_status = #{businessStatus},
			user_id = #{userId}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM work_app_show
		WHERE id = #{id}
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE work_app_show SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE id = #{id}
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="Workappshow" statementType="STATEMENT">
		select * FROM work_app_show  where ${propertyName} = '${value}'
	</select>
	
</mapper>