LargeModelProject/LargeScreenServer(1)/large-system/target/classes/mapper/system/QuestionAnswerMapper.xml

134 lines
5.2 KiB
XML
Raw Normal View History

2024-07-03 09:28:21 +08:00
<?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.bonus.system.mapper.QuestionAnswerMapper">
<insert id="insert">
INSERT INTO bm_question_answer (id, windows_id, question, answer, user_id, knowledge)
VALUES (#{id}, #{windowId}, #{question}, #{answer}, #{userId}, #{knowledge});
</insert>
<select id="getQuestionAnswersByWinId" resultType="com.bonus.system.domain.QuestionAnswerEntity">
SELECT id AS id,
windows_id AS windowId,
question AS question,
answer AS answer,
create_time AS createTime,
update_time AS updateTime,
response_time AS responseTime,
user_id AS userId,
knowledge as knowledge,
collect as collect,
like_type AS likeType
FROM bm_question_answer
WHERE windows_id = #{windowId}
AND user_id = #{userId}
</select>
<select id="getknowCollect" resultType="com.bonus.system.domain.QuestionAnswerEntity">
SELECT id AS id,
question AS question,
answer AS answer,
response_time AS responseTime,
knowledge as knowledge,
collect_time as collectTime
FROM bm_question_answer
where user_id = #{userId}
and collect = '1'
</select>
<select id="questionNum" resultType="java.util.Map">
SELECT any_value(question) AS question,
COUNT(*) AS num
FROM bm_question_answer
where 1=1
<if test="startTime != null and startTime != ''">
and create_time BETWEEN #{startTime} AND #{endTime}
</if>
GROUP BY question
ORDER BY num DESC
LIMIT 10
</select>
<select id="question" resultType="java.util.Map">
select 'questionNum' AS name, COUNT(*) AS num
from bm_question_answer WHERE 1=1
<if test="startTime != null and startTime != ''">
and create_time BETWEEN #{startTime} AND #{endTime}
</if>
UNION ALL
select 'questionPeople' AS name, COUNT(DISTINCT user_id) AS num
from bm_question_answer WHERE 1=1
<if test="startTime != null and startTime != ''">
and create_time BETWEEN #{startTime} AND #{endTime}
</if>
UNION ALL
select 'systemPeople' AS name, COUNT(DISTINCT user_name) AS num
from sys_logininfor where msg ='登录成功'
<if test="startTime != null and startTime != ''">
and login_time BETWEEN #{startTime} AND #{endTime}
</if>
</select>
<select id="barChartQuestionNum" resultType="java.util.Map">
select 'questionNum' AS name, COUNT(*) AS num,DATE(create_time) AS time
from bm_question_answer WHERE 1=1
<if test="startTime != null and startTime != ''">
and create_time BETWEEN #{startTime} AND #{endTime}
</if>
GROUP BY time
</select>
<select id="barChartQuestionPeople" resultType="java.util.Map">
select 'questionPeople' AS name, COUNT(DISTINCT user_id) AS num,DATE(create_time) AS time
from bm_question_answer WHERE 1=1
<if test="startTime != null and startTime != ''">
and create_time BETWEEN #{startTime} AND #{endTime}
</if>
GROUP BY time
</select>
<select id="barChartSystemPeople" resultType="java.util.Map">
select 'systemPeople' AS name, COUNT(DISTINCT user_name) AS num,DATE(login_time) AS time
from sys_logininfor where msg ='登录成功'
<if test="startTime != null and startTime != ''">
and login_time BETWEEN #{startTime} AND #{endTime}
</if>
GROUP BY time
</select>
<select id="barChart" resultType="java.util.Map">
select 'questionNum' AS name, COUNT(*) AS num
from bm_question_answer WHERE 1=1
<if test="startTime != null and startTime != ''">
and create_time BETWEEN #{startTime} AND #{endTime}
</if>
UNION ALL
select 'questionPeople' AS name, COUNT(DISTINCT user_id) AS num
from bm_question_answer WHERE 1=1
<if test="startTime != null and startTime != ''">
and create_time BETWEEN #{startTime} AND #{endTime}
</if>
UNION ALL
select 'systemPeople' AS name, COUNT(DISTINCT user_name) AS num
from sys_logininfor where msg ='登录成功'
<if test="startTime != null and startTime != ''">
and login_time BETWEEN #{startTime} AND #{endTime}
</if>
</select>
<update id="insertSearch">
update bm_question_answer
set like_type=#{likeType}
WHERE id = #{id}
</update>
<update id="documentInsertSearch">
update bm_document_like
set like_type=#{likeType}
WHERE id = #{id}
</update>
<update id="collectChange">
update bm_question_answer
set collect=#{collect},collect_time=#{collectTime}
WHERE id = #{id}
</update>
</mapper>