|
@@ -2,8 +2,8 @@ package service
|
|
|
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
- . "bindresume/config"
|
|
|
- "bindresume/public"
|
|
|
+ . "biBackService/config"
|
|
|
+ "biBackService/public"
|
|
|
"bytes"
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
@@ -37,7 +37,50 @@ type WordTask struct {
|
|
|
Swimlane_id int `json:"swimlane_Id"`
|
|
|
}
|
|
|
|
|
|
-// GetFilePath 获取文件路径、名称
|
|
|
+func CheckCreateUserAccount(name string) (accountId int, err error) {
|
|
|
+ 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": "$10$pZhH7qLlW2bh1Qk.UjOkgekVPkpCjG1KfRhv3H0FXidx51a1ZntB2",
|
|
|
+ "is_ldap_user": 0,
|
|
|
+ "name": name,
|
|
|
+ "email": fmt.Sprintf("%s@topnet.net.cn", fullNamePy),
|
|
|
+ })
|
|
|
+ if in < 0 {
|
|
|
+ return 0, errors.New("创建用户信息出错")
|
|
|
+ }
|
|
|
+ accountId = int(in)
|
|
|
+ }
|
|
|
+
|
|
|
+ return accountId, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (wt *WordTask) WordTaskSave() (err error) {
|
|
|
+ in := KbDb.Insert("tasks", map[string]interface{}{
|
|
|
+ "title": wt.Title,
|
|
|
+ "description": wt.Description,
|
|
|
+ "color_id": wt.Color_id,
|
|
|
+ "project_id": wt.Project_id,
|
|
|
+ "column_Id": wt.Column_id,
|
|
|
+ "position": wt.Position,
|
|
|
+ "score": wt.Score,
|
|
|
+ "creator_id": wt.Creator_id,
|
|
|
+ "swimlane_id": wt.Swimlane_id,
|
|
|
+ "date_creation": time.Now().Unix(),
|
|
|
+ })
|
|
|
+ if in < 0 {
|
|
|
+ return errors.New("创建任务失败")
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
func GetFilePath(fm, types string) (s string) {
|
|
|
var tm = time.Now().Format("20060102")
|
|
|
var path = SysConfig.FilePath + types + "/" + tm[:4] + "/" + tm[4:6] + "/"
|
|
@@ -45,14 +88,12 @@ func GetFilePath(fm, types string) (s string) {
|
|
|
return path + fm
|
|
|
}
|
|
|
|
|
|
-// SendWechatWorkMessage 发送企业微信消息
|
|
|
func SendWechatWorkMessage() error {
|
|
|
// 构造请求URL
|
|
|
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{}{
|
|
@@ -97,47 +138,3 @@ func SendWechatWorkMessage() error {
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
-
|
|
|
-func CheckCreateUserAccount(name string) (accountId int, err error) {
|
|
|
- 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": "$10$pZhH7qLlW2bh1Qk.UjOkgekVPkpCjG1KfRhv3H0FXidx51a1ZntB2",
|
|
|
- "is_ldap_user": 0,
|
|
|
- "name": name,
|
|
|
- "email": fmt.Sprintf("%s@topnet.net.cn", fullNamePy),
|
|
|
- })
|
|
|
- if in < 0 {
|
|
|
- return 0, errors.New("创建用户信息出错")
|
|
|
- }
|
|
|
- accountId = int(in)
|
|
|
- }
|
|
|
-
|
|
|
- return accountId, nil
|
|
|
-}
|
|
|
-
|
|
|
-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,
|
|
|
- "swimlane_id": t.Swimlane_id,
|
|
|
- "date_creation": time.Now().Unix(),
|
|
|
- })
|
|
|
- if in < 0 {
|
|
|
- return errors.New("创建任务失败")
|
|
|
- }
|
|
|
- return nil
|
|
|
-}
|