renjiaojiao 3 лет назад
Родитель
Сommit
6af249bef3
2 измененных файлов с 12 добавлено и 3 удалено
  1. 2 1
      src/customerService/newsController.go
  2. 10 2
      src/customerService/newsService.go

+ 2 - 1
src/customerService/newsController.go

@@ -91,6 +91,7 @@ func MessageList(context *admin.Context) (interface{}, error) {
 	isLookAll := 0
 	lookAllMsgUser := config.SysConfigs.LookAllMsg
 	loginUserId := context.User.Id
+	loginUserName := context.User.Username
 	if ok := lookAllMsgUser[strconv.Itoa(loginUserId)]; ok {
 		isLookAll = 1
 	} else {
@@ -103,7 +104,7 @@ func MessageList(context *admin.Context) (interface{}, error) {
 		}
 	}
 	log.Println(isLookAll)
-	data, count := MsgList(param, isLookAll, loginUserId)
+	data, count := MsgList(param, isLookAll, loginUserId, loginUserName)
 	return map[string]interface{}{
 		"lists": data,
 		"total": count,

+ 10 - 2
src/customerService/newsService.go

@@ -76,12 +76,16 @@ func MsgDetail(id int) (*map[string]interface{}, error) {
 var Str = "a.id,a.send_usergroup_name,a.msg_type,a.title,a.content,a.send_mode,a.send_time,a.send_status,a.update_time,a.createtime,a.link,a.isdel,a.send_name,a.send_usergroup_id,a.sign,a.user_add_way,a.template_name"
 
 //消息列表查询
-func MsgList(param *MsgListParam, isLookAllMsg, loginUserId int) (*[]map[string]interface{}, int) {
+func MsgList(param *MsgListParam, isLookAllMsg, loginUserId int, loginUserName string) (*[]map[string]interface{}, int) {
 	sql := "SELECT " + Str + "  FROM message_send_log as a LEFT JOIN sendmsg_customer_info as b on a.id = b.msg_id "
 	str := ""
 	sqlc := "SELECT COUNt(*) FROM message_send_log as a  LEFT JOIN sendmsg_customer_info as b on a.id = b.msg_id "
 	if param.UserGroupName != "" {
-		str += " a.send_usergroup_name = '" + param.UserGroupName + "' and"
+		if param.UserGroupName == "自定义" {
+			str += " a.sign = 1 and"
+		} else {
+			str += " a.send_usergroup_name = '" + param.UserGroupName + "' and"
+		}
 	}
 	if param.MsgType != 0 {
 		str += " a.msg_type = " + strconv.Itoa(param.MsgType) + " and"
@@ -106,6 +110,10 @@ func MsgList(param *MsgListParam, isLookAllMsg, loginUserId int) (*[]map[string]
 	}
 	if isLookAllMsg == 0 {
 		str += " a.send_userid = " + strconv.Itoa(loginUserId) + " and"
+	} else {
+		if param.Creator != "" {
+			str += " a.send_name = " + loginUserName + " and"
+		}
 	}
 	if param.Phone != "" {
 		str += " b.register_phone like '%" + param.Phone + "%' and"