This commit is contained in:
裴浩宇 2020-04-17 17:24:06 +08:00
parent 2ee3b9f173
commit 8ef01a9293
12 changed files with 219 additions and 52 deletions

View File

@ -178,4 +178,12 @@ public class HSController {
Map<String,Object> result = hsService.deleteLetter(param); Map<String,Object> result = hsService.deleteLetter(param);
return result; return result;
} }
/**定时任务*/
@RequestMapping(value = "/timingTask", method = {RequestMethod.POST,RequestMethod.GET})
@ResponseBody
public Map<String,Object> timingTask(@RequestBody Map<String,Object> param) {
Map<String,Object> result = hsService.timingTask(param);
return result;
}
} }

View File

@ -115,10 +115,15 @@ public interface HSLinkMapper {
Map<String,Object> getPersonalInfo(Map<String,Object> param); Map<String,Object> getPersonalInfo(Map<String,Object> param);
/** /**
* 获取班级成员 * 获取个人私信
*/ */
List<Map<String,Object>> getPersonalPrivateLetter(Map<String,Object> param); List<Map<String,Object>> getPersonalPrivateLetter(Map<String,Object> param);
/**
* 获取已发送私信
*/
List<Map<String,Object>> getSentPrivateLetter(Map<String,Object> param);
/** /**
* 将未读私信置位已读 * 将未读私信置位已读
*/ */
@ -134,4 +139,14 @@ public interface HSLinkMapper {
*/ */
int deleteLetter(Map<String,Object> param); int deleteLetter(Map<String,Object> param);
/**
* 删除一条已读私信
*/
int deleteSentLetter(Map<String,Object> param);
/**
* 更新个人积分
*/
int updateIntegral(Map<String,Object> param);
} }

View File

@ -243,16 +243,17 @@
<!--获取个人信息--> <!--获取个人信息-->
<select id="getPersonalInfo" parameterType="map" resultType="map"> <select id="getPersonalInfo" parameterType="map" resultType="map">
select * , (select count(*) from hs_private_letter where receive_id = #{releaseId} and already_read = "0" and status = "1") letter_number select * , (select count(*) from hs_private_letter where receive_id = #{releaseId} and already_read = "0" and receive_status = "1") letter_number
from hs_user where user_id = #{releaseId} from hs_user where user_id = #{releaseId}
</select> </select>
<!--获取个人私信--> <!--获取个人私信-->
<select id="getPersonalPrivateLetter" resultType="map" parameterType="map"> <select id="getPersonalPrivateLetter" resultType="map" parameterType="map">
select * from hs_private_letter left join hs_user on send_id = user_id where receive_id = #{userId} and status = "1" select * from hs_private_letter left join hs_user on send_id = user_id where receive_id = #{userId} and receive_status = "1"
<if test="id != '' and id != null"> <if test="id != '' and id != null">
and id = #{id} and id = #{id}
</if> </if>
ORDER BY letter_create_time desc
</select> </select>
<!--将未读私信置位已读--> <!--将未读私信置位已读-->
@ -262,12 +263,38 @@
<!--发送私信--> <!--发送私信-->
<insert id="sendLetter" parameterType="map"> <insert id="sendLetter" parameterType="map">
insert into hs_private_letter (id,send_id,receive_id,content,letter_create_time,status,already_read) values insert into hs_private_letter (id,send_id,receive_id,content,letter_create_time) values
(uuid(),#{sendId},#{receiveId},#{content},#{time},"1","0") (uuid(),#{sendId},#{receiveId},#{content},#{time})
</insert> </insert>
<!--删除一条私信--> <!--删除一条私信-->
<update id="deleteLetter" parameterType="map"> <update id="deleteLetter" parameterType="map">
update hs_private_letter set status = "0" where id = #{id} update hs_private_letter set receive_status = "0" where id = #{id}
</update> </update>
<!--删除一条已读私信-->
<delete id="deleteSentLetter" parameterType="map">
update hs_private_letter set send_status = "0" where id = #{id}
</delete>
<!--更新个人积分-->
<delete id="updateIntegral" parameterType="map">
UPDATE hs_user
SET integral = (
( ( SELECT count( * ) FROM hs_notice WHERE release_id = #{userId} ) * 100 ) +
( ( SELECT count( * ) FROM hs_leave_message WHERE messager_id = #{userId} ) * 10 )
)
WHERE
user_id = #{userId}
</delete>
<!--获取已发送私信-->
<select id="getSentPrivateLetter" resultType="map" parameterType="map">
select * from hs_private_letter left join hs_user on send_id = user_id where send_id = #{userId} and send_status = "1"
<if test="id != '' and id != null">
and id = #{id}
</if>
ORDER BY letter_create_time desc
</select>
</mapper> </mapper>

View File

@ -110,4 +110,9 @@ public interface HSService {
* 删除一条私信 * 删除一条私信
*/ */
Map<String,Object> deleteLetter(Map<String,Object> param); Map<String,Object> deleteLetter(Map<String,Object> param);
/**
* 定时任务
*/
Map<String,Object> timingTask(Map<String,Object> param);
} }

View File

@ -5,6 +5,8 @@ import com.qinxx.hslink.service.HSService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -241,7 +243,11 @@ public class HSServiceImpl implements HSService {
@Override @Override
public Map<String, Object> getPersonalPrivateLetter(Map<String, Object> param) { public Map<String, Object> getPersonalPrivateLetter(Map<String, Object> param) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> res = hsLinkMapper.getPersonalPrivateLetter(param); Map<String, Object> res = new HashMap<>();
List<Map<String, Object>> res1 = hsLinkMapper.getPersonalPrivateLetter(param);
List<Map<String, Object>> res2 = hsLinkMapper.getSentPrivateLetter(param);
res.put("privateLetter",res1);
res.put("sentLetter",res2);
result.put("data",res); result.put("data",res);
result.put("success",true); result.put("success",true);
return result; return result;
@ -277,16 +283,45 @@ public class HSServiceImpl implements HSService {
@Override @Override
public Map<String, Object> deleteLetter(Map<String, Object> param) { public Map<String, Object> deleteLetter(Map<String, Object> param) {
Integer type = (Integer) param.get("type");
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
int res = 0; int res = 0;
try { if (type == 0) {
res = hsLinkMapper.deleteLetter(param); try {
} catch (Exception e) { res = hsLinkMapper.deleteLetter(param);
e.printStackTrace(); } catch (Exception e) {
res = 0; e.printStackTrace();
res = 0;
}
} else {
try {
res = hsLinkMapper.deleteSentLetter(param);
} catch (Exception e) {
e.printStackTrace();
res = 0;
}
} }
result.put("data",res); result.put("data",res);
result.put("success",true); result.put("success",true);
return result; return result;
} }
@Override
public Map<String, Object> timingTask(Map<String, Object> param) {
/**定时刷新*/
Map<String, Object> result = new HashMap<>();
Map<String, Object> res = new HashMap<>();
/**更新个人积分*/
int res1 = hsLinkMapper.updateIntegral(param);
if (res1 == 1) {
res.put("taskIntegral","更新个人积分成功");
} else {
res.put("taskIntegral","更新个人积分失败");
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
res.put("time",df.format(new Date()));
result.put("data",res);
result.put("success",true);
return result;
}
} }

View File

@ -0,0 +1,16 @@
package com.qinxx.hslink.util;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author 帅气的布里茨
*/
public class TestClass {
public static void main(String[] args) {
//设置日期格式
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// new Date()为获取当前系统时间
System.out.println(df.format(new Date()));
}
}

View File

@ -1,8 +1,8 @@
// 配置API接口地址 // 配置API接口地址
import de from "element-ui/src/locale/lang/de"; import de from "element-ui/src/locale/lang/de";
// let root = 'http://192.168.10.29:8048' let root = 'http://192.168.10.29:8048'
let root = 'http://123.57.22.91:8048' // let root = 'http://123.57.22.91:8048'
// let root = 'http://127.0.0.1:8048' // let root = 'http://127.0.0.1:8048'
// 引用axios // 引用axios
let axios = require('axios') let axios = require('axios')

View File

@ -110,6 +110,9 @@
label:this.label,title:this.title,content:this.msg.mdValue,releaseId:userInfo.user_id, label:this.label,title:this.title,content:this.msg.mdValue,releaseId:userInfo.user_id,
release_time:getDate(),type:this.type},r=> { release_time:getDate(),type:this.type},r=> {
if (r === 1) { if (r === 1) {
this.$ajax.post("/hs/timingTask",{userId:userInfo.user_id},r=>{
console.log(r)
});
this.$message({ this.$message({
message: "发布成功", message: "发布成功",
type: "success" type: "success"
@ -117,7 +120,7 @@
this.$emit("goInfo"); this.$emit("goInfo");
this.$emit("refresh"); this.$emit("refresh");
} }
}) });
sessionStorage.setItem("releaseType","") sessionStorage.setItem("releaseType","")
} else { } else {
let userInfo = JSON.parse(sessionStorage.getItem("userInfo")); let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));

View File

@ -206,7 +206,7 @@
}).then(({ value }) => { }).then(({ value }) => {
this.$ajax.post("/hs/addMessage",{noticeId:sessionStorage.getItem("noticeId"),content:value, this.$ajax.post("/hs/addMessage",{noticeId:sessionStorage.getItem("noticeId"),content:value,
createTime:getDate(),userId:JSON.parse(sessionStorage.getItem("userInfo")).user_id},r=>{ createTime:getDate(),userId:JSON.parse(sessionStorage.getItem("userInfo")).user_id},r=>{
if (r == "1") { if (r === 1) {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '留言成功' message: '留言成功'
@ -220,7 +220,10 @@
} }
}) })
} }
}) });
this.$ajax.post("/hs/timingTask",{userId:JSON.parse(sessionStorage.getItem("userInfo")).user_id},r=>{
console.log(r)
});
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
type: 'info', type: 'info',

View File

@ -56,6 +56,9 @@
}, },
mounted() { mounted() {
let userInfo = JSON.parse(sessionStorage.getItem("userInfo")); let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
/*setInterval(()=>{
this.timingTask(userInfo.user_id)
},60000);*/
if (userInfo == '' || userInfo === null) { if (userInfo == '' || userInfo === null) {
} else { } else {
@ -71,11 +74,15 @@
+day2.getMinutes():day2.getMinutes())+"分"+(day2.getSeconds()<10?"0"+day2.getSeconds():day2.getSeconds())+"";},1000) +day2.getMinutes():day2.getMinutes())+"分"+(day2.getSeconds()<10?"0"+day2.getSeconds():day2.getSeconds())+"";},1000)
}, },
methods:{ methods:{
timingTask(userId) {
this.$ajax.post("/hs/timingTask",{userId:userId},r=>{
console.log(r)
})
},
goPersonalInfo(userId) { goPersonalInfo(userId) {
this.$router.push({name: 'personalinfo'}); this.$router.push({name: 'personalinfo'});
sessionStorage.setItem("userId",userId); sessionStorage.setItem("userId",userId);
setTimeout(()=>{location.reload()},100) setTimeout(()=>{location.reload()},1)
}, },
goMore() { goMore() {
this.$message({ this.$message({
@ -84,11 +91,15 @@
}, },
goMyClass() { goMyClass() {
if (this.isLogin == true) { if (JSON.parse(sessionStorage.getItem("userInfo")).class_name === undefined) {
this.$router.push({name: "myclass"}) this.$message.warning("您没有加入任何班级")
} else { } else {
this.$message.warning("请先登录") if (this.isLogin === true) {
this.$router.push({name: "login"}) this.$router.push({name: "myclass"})
} else {
this.$message.warning("请先登录")
this.$router.push({name: "login"})
}
} }
}, },
goStudentThought() { goStudentThought() {

View File

@ -48,8 +48,7 @@
<el-dialog <el-dialog
title="编辑公告" title="编辑公告"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="30%" width="30%">
:before-close="handleClose">
<el-form> <el-form>
<el-form-item label="标题"> <el-form-item label="标题">
<el-input v-model="editors.title" clearable size="small"></el-input> <el-input v-model="editors.title" clearable size="small"></el-input>
@ -183,13 +182,6 @@
} }
this.dialogVisible = false this.dialogVisible = false
}, },
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
.catch(_ => {});
},
editor() { editor() {
let userInfo = JSON.parse(sessionStorage.getItem("userInfo")) let userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
if (userInfo.user_type === "教师") { if (userInfo.user_type === "教师") {

View File

@ -108,7 +108,7 @@
<div class="name">{{item.real_name}}</div> <div class="name">{{item.real_name}}</div>
<div class="time">{{item.letter_create_time}}</div> <div class="time">{{item.letter_create_time}}</div>
</div> </div>
<div class="delete" @click="deleteLetter(item.id)">删除</div> <div class="delete" @click="deleteLetter(item.id,0)">删除</div>
</div> </div>
</div> </div>
<div class="already-read"> <div class="already-read">
@ -120,9 +120,21 @@
<div class="name">{{item.real_name}}</div> <div class="name">{{item.real_name}}</div>
<div class="time">{{item.letter_create_time}}</div> <div class="time">{{item.letter_create_time}}</div>
</div> </div>
<div class="delete" @click="deleteLetter(item.id)">删除</div> <div class="delete" @click="deleteLetter(item.id,0)">删除</div>
</div> </div>
</div> </div>
<div class="sent">
<p>已发送</p>
<p v-if="sentIsNull">暂无发送</p>
<div class="privateLetterOne" v-for="item in sentList">
<div class="box" @click="read(item.id)">
<div class="content">{{item.content}}</div>
<div class="name">{{item.real_name}}</div>
<div class="time">{{item.letter_create_time}}</div>
</div>
<div class="delete" @click="deleteLetter(item.id,1)">删除</div>
</div>
</div>
</div> </div>
</el-drawer> </el-drawer>
@ -146,6 +158,7 @@
} }
} }
return{ return{
sentIsNull: true,
unreadIsNull: true, unreadIsNull: true,
alreadyReadIsNull: true, alreadyReadIsNull: true,
privateLetterList: '', privateLetterList: '',
@ -178,6 +191,7 @@
dialogVisible: false, dialogVisible: false,
drawer: false, drawer: false,
direction: 'rtl', direction: 'rtl',
sentList: [],
} }
}, },
mounted() { mounted() {
@ -202,29 +216,34 @@
// },1000) // },1000)
}, },
methods: { methods: {
deleteLetter(id) { deleteLetter(id,type) {
this.$confirm('删除该私信?, 是否继续?', '删除', { this.$confirm('删除该私信?, 是否继续?', '删除', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$ajax.post("/hs/deleteLetter",{id:id},r=>{ this.$ajax.post("/hs/deleteLetter",{id:id,type:type},r=>{
if (r === 1) { if (r === 1) {
let userInfo = JSON.parse(sessionStorage.getItem("userInfo")); let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
this.$ajax.post("/hs/getPersonalPrivateLetter",{userId:userInfo.user_id},res=>{ this.$ajax.post("/hs/getPersonalPrivateLetter",{userId:userInfo.user_id},res=>{
this.privateLetterList = res this.privateLetterList = res.privateLetter;
if (res.length === 0) { this.sentList = res.sentLetter;
if (res.sentLetter.length === 0) {
this.sentIsNull = true
} else {
this.sentIsNull = false
}
if (res.privateLetter.length === 0) {
this.unreadIsNull = true; this.unreadIsNull = true;
this.alreadyReadIsNull = true; this.alreadyReadIsNull = true;
} }
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.privateLetter.length; i++) {
debugger if (res.privateLetter[i].already_read === "0") {
if (res[i].already_read === "0") {
this.unreadIsNull = false this.unreadIsNull = false
} else { } else {
this.unreadIsNull = true this.unreadIsNull = true
} }
if (res[i].already_read === "1") { if (res.privateLetter[i].already_read === "1") {
this.alreadyReadIsNull = false this.alreadyReadIsNull = false
} else { } else {
this.unreadIsNull = true this.unreadIsNull = true
@ -260,6 +279,15 @@
type: 'success', type: 'success',
message: '发送成功' message: '发送成功'
}); });
let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
this.$ajax.post("/hs/getPersonalPrivateLetter",{userId:userInfo.user_id},res=>{
this.sentList = res.sentLetter;
if (res.sentLetter.length === 0) {
this.sentIsNull = true
} else {
this.sentIsNull = false
}
})
} else { } else {
this.$message.error("发送失败") this.$message.error("发送失败")
} }
@ -278,20 +306,24 @@
<p style="font-size: 0.9rem">内容${r.onePrivateLetter[0].content}</p> <p style="font-size: 0.9rem">内容${r.onePrivateLetter[0].content}</p>
<p style="font-size: 0.9rem">发送时间${r.onePrivateLetter[0].letter_create_time}</p> <p style="font-size: 0.9rem">发送时间${r.onePrivateLetter[0].letter_create_time}</p>
`, '私信', { `, '私信', {
distinguishCancelAndClose: true,
cancelButtonText: '回复', cancelButtonText: '回复',
dangerouslyUseHTMLString: true dangerouslyUseHTMLString: true
}).catch(() => { }).catch(action => {
this.sendLetter(r.onePrivateLetter[0].user_id,r.onePrivateLetter[0].real_name) console.log("action",action)
if (action === 'cancel') {
this.sendLetter(r.onePrivateLetter[0].user_id,r.onePrivateLetter[0].real_name)
}
}); });
this.$ajax.post("/hs/getPersonalPrivateLetter",{userId:userInfo.user_id},r=>{ this.$ajax.post("/hs/getPersonalPrivateLetter",{userId:userInfo.user_id},r=>{
this.privateLetterList = r this.privateLetterList = r.privateLetter
for (let i = 0; i < r.length; i++) { for (let i = 0; i < r.privateLetter.length; i++) {
if (r[i].already_read === "0") { if (r.privateLetter[i].already_read === "0") {
this.unreadIsNull = false this.unreadIsNull = false
} else { } else {
this.unreadIsNull = true this.unreadIsNull = true
} }
if (r[i].already_read === "1") { if (r[i].privateLetter.already_read === "1") {
this.alreadyReadIsNull = false this.alreadyReadIsNull = false
} else { } else {
this.unreadIsNull = true this.unreadIsNull = true
@ -315,12 +347,18 @@
let userInfo = JSON.parse(sessionStorage.getItem("userInfo")); let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
this.drawer = true; this.drawer = true;
this.$ajax.post("/hs/getPersonalPrivateLetter",{userId:userInfo.user_id},r=>{ this.$ajax.post("/hs/getPersonalPrivateLetter",{userId:userInfo.user_id},r=>{
this.privateLetterList = r this.privateLetterList = r.privateLetter;
for (let i = 0; i < r.length; i++) { this.sentList = r.sentLetter;
if (r[i].already_read === "0") { if (r.sentLetter.length === 0) {
this.sentIsNull = true
} else {
this.sentIsNull = false
}
for (let i = 0; i < r.privateLetter.length; i++) {
if (r.privateLetter[i].already_read === "0") {
this.unreadIsNull = false this.unreadIsNull = false
} }
if (r[i].already_read === "1") { if (r.privateLetter[i].already_read === "1") {
this.alreadyReadIsNull = false this.alreadyReadIsNull = false
} }
} }
@ -458,6 +496,20 @@
padding: 1rem; padding: 1rem;
margin-top: -1rem; margin-top: -1rem;
} }
.sent{
margin-top: 1rem;
padding: 0 1rem;
}
.sent p:nth-child(1){
font-size: 1.2rem;
font-weight: bold;
color: #52C5C0;
margin: 0.5rem 0 0 0;
}
.sent p:nth-child(2), .unread p:nth-child(2){
color: #419EFF;
text-align: center;
}
.already-read{ .already-read{
margin-top: 1rem; margin-top: 1rem;
padding: 0 1rem; padding: 0 1rem;