|
@@ -10,6 +10,7 @@ import (
|
|
|
"fmt"
|
|
|
"io/ioutil"
|
|
|
"net/http"
|
|
|
+ "net/url"
|
|
|
"os"
|
|
|
"time"
|
|
|
)
|
|
@@ -33,6 +34,7 @@ type WordTask struct {
|
|
|
Position int `json:"position"`
|
|
|
Score int `json:"score"`
|
|
|
Creator_id int `json:"creator_id"`
|
|
|
+ Swimlane_id int `json:"swimlane_Id"`
|
|
|
}
|
|
|
|
|
|
// GetFilePath 获取文件路径、名称
|
|
@@ -46,22 +48,18 @@ func GetFilePath(fm, types string) (s string) {
|
|
|
// SendWechatWorkMessage 发送企业微信消息
|
|
|
func SendWechatWorkMessage() error {
|
|
|
// 构造请求URL
|
|
|
- fullURL := SysConfig.WechatWorkUrl
|
|
|
- //params := url.Values{}
|
|
|
- //params.Add("key", webhookKey)
|
|
|
- //fullURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())
|
|
|
- message := &WechatWorkMessage{
|
|
|
- MsgType: "text",
|
|
|
- Text: TextContent{
|
|
|
- Content: "今日天气:31度,大部分晴,降雨概率:0%",
|
|
|
- },
|
|
|
- }
|
|
|
- /*messages := map[string]interface{}{
|
|
|
+ baseURL := SysConfig.WechatWorkUrl
|
|
|
+ params := url.Values{}
|
|
|
+ params.Add("key", SysConfig.WechatWorkKey)
|
|
|
+ fullURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())
|
|
|
+ //log.Println(fullURL)
|
|
|
+ message := map[string]interface{}{
|
|
|
"msgtype": "text",
|
|
|
"text": map[string]interface{}{
|
|
|
- "content": "今日天气:31度,大部分晴,降雨概率:0%",
|
|
|
+ "content": "您有一个新工单,请及时处理",
|
|
|
+ "mentioned_mobile_list": SysConfig.WechatRemind,
|
|
|
},
|
|
|
- }*/
|
|
|
+ }
|
|
|
payload, err := json.Marshal(message)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("JSON序列化失败: %v", err)
|
|
@@ -101,14 +99,17 @@ func SendWechatWorkMessage() error {
|
|
|
}
|
|
|
|
|
|
func CheckCreateUserAccount(name string) (accountId int, err error) {
|
|
|
- res := KbDb.FindOne("users", map[string]interface{}{"name": name}, `"id"`, "id DESC")
|
|
|
+ if name == "" {
|
|
|
+ return 0, errors.New("名字不能为空")
|
|
|
+ }
|
|
|
+ res := KbDb.FindOne("users", map[string]interface{}{"name": name}, "id", "id DESC")
|
|
|
if res != nil && len(*res) > 0 {
|
|
|
accountId = common.IntAll((*res)["id"])
|
|
|
} else {
|
|
|
fullNamePy, username := public.ConvertToPinyin(name)
|
|
|
in := KbDb.Insert("users", map[string]interface{}{
|
|
|
"username": username,
|
|
|
- "password": "$2y$10$HiZaBYTxhppdxmm259JcoO1NW4dWDkEZnPNC74ExRtj0sPFE7FB7m",
|
|
|
+ "password": "$10$pZhH7qLlW2bh1Qk.UjOkgekVPkpCjG1KfRhv3H0FXidx51a1ZntB2",
|
|
|
"is_ldap_user": 0,
|
|
|
"name": name,
|
|
|
"email": fmt.Sprintf("%s@topnet.net.cn", fullNamePy),
|
|
@@ -124,14 +125,16 @@ func CheckCreateUserAccount(name string) (accountId int, err error) {
|
|
|
|
|
|
func (t *WordTask) WordTaskSave() error {
|
|
|
in := KbDb.Insert("tasks", map[string]interface{}{
|
|
|
- "title": t.Title,
|
|
|
- "description": t.Description,
|
|
|
- "color_id": t.Color_id,
|
|
|
- "project_id": t.Project_id,
|
|
|
- "column_Id": t.Column_id,
|
|
|
- "position": t.Position,
|
|
|
- "score": t.Score,
|
|
|
- "creator_id": t.Creator_id,
|
|
|
+ "title": t.Title,
|
|
|
+ "description": t.Description,
|
|
|
+ "color_id": t.Color_id,
|
|
|
+ "project_id": t.Project_id,
|
|
|
+ "column_Id": t.Column_id,
|
|
|
+ "position": t.Position,
|
|
|
+ "score": t.Score,
|
|
|
+ "creator_id": t.Creator_id,
|
|
|
+ "swimlane_id": t.Swimlane_id,
|
|
|
+ "date_creation": time.Now().Unix(),
|
|
|
})
|
|
|
if in < 0 {
|
|
|
return errors.New("创建任务失败")
|