|
@@ -1,21 +1,22 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
+ qu "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
+ "app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jybase/mongodb"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "github.com/lauyoume/gopinyin"
|
|
|
+ "go.mongodb.org/mongo-driver/bson"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
"io/ioutil"
|
|
|
"log"
|
|
|
"net/http"
|
|
|
- mongoutil "qfw/mongodb"
|
|
|
- qu "qfw/util"
|
|
|
+ . "seplatform/util"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
- . "util"
|
|
|
-
|
|
|
- "github.com/go-xweb/xweb"
|
|
|
- "github.com/lauyoume/gopinyin"
|
|
|
- "gopkg.in/mgo.v2/bson"
|
|
|
)
|
|
|
|
|
|
type Customer struct {
|
|
@@ -69,9 +70,9 @@ type Customer struct {
|
|
|
func (c *Customer) CustomerList() {
|
|
|
defer qu.Catch()
|
|
|
if c.Method() == "POST" {
|
|
|
- start, _ := c.GetInteger("start")
|
|
|
- limit, _ := c.GetInteger("length")
|
|
|
- draw, _ := c.GetInteger("draw")
|
|
|
+ start, _ := c.GetInt("start")
|
|
|
+ limit, _ := c.GetInt("length")
|
|
|
+ draw, _ := c.GetInt("draw")
|
|
|
searchStr := c.GetString("search[value]")
|
|
|
search := strings.TrimSpace(searchStr)
|
|
|
query := bson.M{
|
|
@@ -83,7 +84,7 @@ func (c *Customer) CustomerList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- data, _ := Mgo.Find("cuser", query, `{"i_updatetime":-1}`, nil, false, start, limit)
|
|
|
+ data, _ := Mgo.Find("cuser", query, `{"i_updatetime":-1}`, nil, false, int(start), int(limit))
|
|
|
count := Mgo.Count("cuser", query)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"draw": draw,
|
|
@@ -109,10 +110,10 @@ func (c *Customer) CustomerEdit() {
|
|
|
defer qu.Catch()
|
|
|
id := c.GetString("id")
|
|
|
query := bson.M{}
|
|
|
- query["_id"] = mongoutil.StringTOBsonId(id)
|
|
|
+ query["_id"] = mongodb.StringTOBsonId(id)
|
|
|
data, _ := Mgo.FindOneByField("cuser", query, `{}`)
|
|
|
depart, _ := Mgo.Find("cuserdepart", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
|
|
|
- (*data)["_id"] = mongoutil.BsonIdToSId((*data)["_id"])
|
|
|
+ (*data)["_id"] = mongodb.BsonIdToSId((*data)["_id"])
|
|
|
if (*data)["i_state"] == 1 {
|
|
|
tagRule, _ := Mgo.Find("eusertagrule", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
|
|
|
c.T["tagrule"] = *tagRule
|
|
@@ -127,10 +128,10 @@ func (c *Customer) CustomerEuser() {
|
|
|
id := c.GetString("id")
|
|
|
query := bson.M{}
|
|
|
|
|
|
- query["_id"] = mongoutil.StringTOBsonId(id)
|
|
|
+ query["_id"] = mongodb.StringTOBsonId(id)
|
|
|
data, _ := Mgo.FindOneByField("euser", query, `{}`)
|
|
|
depart, _ := Mgo.Find("euserdepart", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
|
|
|
- (*data)["_id"] = mongoutil.BsonIdToSId((*data)["_id"])
|
|
|
+ (*data)["_id"] = mongodb.BsonIdToSId((*data)["_id"])
|
|
|
if (*data)["i_state"] == 1 {
|
|
|
tagRule, _ := Mgo.Find("eusertagrule", bson.M{"s_userid": id, "b_delete": false}, nil, nil, false, -1, -1)
|
|
|
c.T["tagrule"] = *tagRule
|
|
@@ -176,7 +177,7 @@ func (c *Customer) CustomerSave() {
|
|
|
}
|
|
|
} else {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(id),
|
|
|
+ "_id": mongodb.StringTOBsonId(id),
|
|
|
}
|
|
|
rep = Mgo.Update("cuser", query, bson.M{"$set": data}, false, false)
|
|
|
}
|
|
@@ -225,12 +226,12 @@ func (c *Customer) DepartEdit() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-//部门启用、停用
|
|
|
+// 部门启用、停用
|
|
|
func (c *Customer) SetupDepart() {
|
|
|
defer qu.Catch()
|
|
|
if c.Method() == "POST" {
|
|
|
_id := c.GetString("_id")
|
|
|
- i_isuse, _ := c.GetInteger("i_isuse")
|
|
|
+ i_isuse, _ := c.GetInt("i_isuse")
|
|
|
nowtime := time.Now().Unix()
|
|
|
set := bson.M{
|
|
|
"$set": bson.M{
|
|
@@ -276,12 +277,12 @@ func (c *Customer) DepartDel() {
|
|
|
return
|
|
|
} else {
|
|
|
idAndSet := []map[string]interface{}{}
|
|
|
- idAndSet = append(idAndSet, bson.M{"_id": mongoutil.StringTOBsonId(v)}) //查询条件
|
|
|
- idAndSet = append(idAndSet, bson.M{"$set": bson.M{"b_delete": true}}) //修改的数据
|
|
|
+ idAndSet = append(idAndSet, bson.M{"_id": mongodb.StringTOBsonId(v)}) //查询条件
|
|
|
+ idAndSet = append(idAndSet, bson.M{"$set": bson.M{"b_delete": true}}) //修改的数据
|
|
|
update = append(update, idAndSet)
|
|
|
/*update = append(update, []map[string]interface{}{
|
|
|
map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId(v),
|
|
|
+ "_id": mongodb.StringTOBsonId(v),
|
|
|
},
|
|
|
map[string]interface{}{
|
|
|
"$set": map[string]interface{}{
|
|
@@ -297,7 +298,7 @@ func (c *Customer) DepartDel() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-//转企
|
|
|
+// 转企
|
|
|
func (c *Customer) CuserToEuser() {
|
|
|
defer qu.Catch()
|
|
|
|
|
@@ -326,7 +327,7 @@ func (c *Customer) CuserToEuser() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- b := Mgo.Update("cuser", bson.M{"_id": mongoutil.StringTOBsonId(_id)}, set, false, false)
|
|
|
+ b := Mgo.Update("cuser", bson.M{"_id": mongodb.StringTOBsonId(_id)}, set, false, false)
|
|
|
|
|
|
if !b {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
@@ -335,7 +336,7 @@ func (c *Customer) CuserToEuser() {
|
|
|
return
|
|
|
}
|
|
|
//2、复制信息(部门、规则)
|
|
|
- b = Mgo.Update("euser", bson.M{"_id": mongoutil.StringTOBsonId(_id)}, cuser, true, false)
|
|
|
+ b = Mgo.Update("euser", bson.M{"_id": mongodb.StringTOBsonId(_id)}, cuser, true, false)
|
|
|
if !b {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": b,
|
|
@@ -364,10 +365,8 @@ func GetCustomerAppId(customer string) string {
|
|
|
req, err := http.NewRequest("POST", url, nil)
|
|
|
if err == nil {
|
|
|
resp, err := client.Do(req)
|
|
|
- qu.Debug("1", err)
|
|
|
defer resp.Body.Close()
|
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
|
- qu.Debug("2", err)
|
|
|
if err == nil {
|
|
|
resp := map[string]interface{}{}
|
|
|
json.Unmarshal(body, &resp)
|
|
@@ -379,7 +378,7 @@ func GetCustomerAppId(customer string) string {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- qu.Debug("调企业用户接口失败", err)
|
|
|
+ log.Println("调企业用户接口失败", err)
|
|
|
}
|
|
|
}
|
|
|
//if appid != "" { //保存
|
|
@@ -393,7 +392,7 @@ func GetCustomerAppId(customer string) string {
|
|
|
return appid
|
|
|
}
|
|
|
|
|
|
-//同步
|
|
|
+// 同步
|
|
|
func (c *Customer) SynEuser() {
|
|
|
defer qu.Catch()
|
|
|
_id := c.GetString("_id")
|
|
@@ -405,14 +404,14 @@ func (c *Customer) SynEuser() {
|
|
|
"i_lastsynctime": nowTime,
|
|
|
},
|
|
|
}
|
|
|
- b := Mgo.Update("cuser", bson.M{"_id": mongoutil.StringTOBsonId(_id)}, set, false, false)
|
|
|
+ b := Mgo.Update("cuser", bson.M{"_id": mongodb.StringTOBsonId(_id)}, set, false, false)
|
|
|
if !b {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": b,
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- b = Mgo.Update("euser", bson.M{"_id": mongoutil.StringTOBsonId(_id)}, cuser, true, false)
|
|
|
+ b = Mgo.Update("euser", bson.M{"_id": mongodb.StringTOBsonId(_id)}, cuser, true, false)
|
|
|
if !b {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": b,
|
|
@@ -447,9 +446,9 @@ func (c *Customer) SynEuser() {
|
|
|
func (c *Customer) EntEuserList() {
|
|
|
defer qu.Catch()
|
|
|
if c.Method() == "POST" {
|
|
|
- start, _ := c.GetInteger("start")
|
|
|
- limit, _ := c.GetInteger("length")
|
|
|
- draw, _ := c.GetInteger("draw")
|
|
|
+ start, _ := c.GetInt("start")
|
|
|
+ limit, _ := c.GetInt("length")
|
|
|
+ draw, _ := c.GetInt("draw")
|
|
|
searchStr := c.GetString("search[value]")
|
|
|
search := strings.TrimSpace(searchStr)
|
|
|
query := bson.M{
|
|
@@ -461,7 +460,7 @@ func (c *Customer) EntEuserList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- data, _ := Mgo.Find("euser", query, `{"i_createtime":-1}`, nil, false, start, limit)
|
|
|
+ data, _ := Mgo.Find("euser", query, `{"i_createtime":-1}`, nil, false, int(start), int(limit))
|
|
|
count := Mgo.Count("euser", query)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"draw": draw,
|
|
@@ -478,9 +477,9 @@ func (c *Customer) CuserRule() {
|
|
|
defer qu.Catch()
|
|
|
ids := strings.Split(c.GetString("ids"), ",")
|
|
|
if c.Method() == "POST" {
|
|
|
- start, _ := c.GetInteger("start")
|
|
|
- limit, _ := c.GetInteger("length")
|
|
|
- draw, _ := c.GetInteger("draw")
|
|
|
+ start, _ := c.GetInt("start")
|
|
|
+ limit, _ := c.GetInt("length")
|
|
|
+ draw, _ := c.GetInt("draw")
|
|
|
searchStr := c.GetString("search[value]")
|
|
|
search := strings.TrimSpace(searchStr)
|
|
|
query := bson.M{
|
|
@@ -494,7 +493,7 @@ func (c *Customer) CuserRule() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- data, _ := Mgo.Find("cuserdepartrule", query, `{"i_createtime":-1}`, nil, false, start, limit)
|
|
|
+ data, _ := Mgo.Find("cuserdepartrule", query, `{"i_createtime":-1}`, nil, false, int(start), int(limit))
|
|
|
count := Mgo.Count("cuserdepartrule", query)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"draw": draw,
|
|
@@ -514,9 +513,9 @@ func (c *Customer) EuserRule() {
|
|
|
defer qu.Catch()
|
|
|
ids := strings.Split(c.GetString("ids"), ",")
|
|
|
if c.Method() == "POST" {
|
|
|
- start, _ := c.GetInteger("start")
|
|
|
- limit, _ := c.GetInteger("length")
|
|
|
- draw, _ := c.GetInteger("draw")
|
|
|
+ start, _ := c.GetInt("start")
|
|
|
+ limit, _ := c.GetInt("length")
|
|
|
+ draw, _ := c.GetInt("draw")
|
|
|
searchStr := c.GetString("search[value]")
|
|
|
search := strings.TrimSpace(searchStr)
|
|
|
query := bson.M{
|
|
@@ -530,7 +529,7 @@ func (c *Customer) EuserRule() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- data, _ := Mgo.Find("euserdepartrule", query, `{"i_createtime":-1}`, nil, false, start, limit)
|
|
|
+ data, _ := Mgo.Find("euserdepartrule", query, `{"i_createtime":-1}`, nil, false, int(start), int(limit))
|
|
|
count := Mgo.Count("euserdepartrule", query)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"draw": draw,
|
|
@@ -574,7 +573,7 @@ func (c *Customer) CuserRuleCreate() {
|
|
|
s_namekey := gopinyin.Convert(qu.ObjToString(data["s_name"]), false)
|
|
|
data["s_namekey"] = s_namekey
|
|
|
data["b_delete"] = false
|
|
|
- data["s_dataid"] = qu.SE.EncodeString(fmt.Sprintf("%v", i_createtime) + s_namekey + ids[0])
|
|
|
+ data["s_dataid"] = encrypt.SE.EncodeString(fmt.Sprintf("%v", i_createtime) + s_namekey + ids[0])
|
|
|
id = Mgo.Save("cuserdepartrule", data)
|
|
|
if id != "" {
|
|
|
rep = true
|
|
@@ -583,7 +582,7 @@ func (c *Customer) CuserRuleCreate() {
|
|
|
}
|
|
|
} else {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(id),
|
|
|
+ "_id": mongodb.StringTOBsonId(id),
|
|
|
}
|
|
|
rep = Mgo.Update("cuserdepartrule", query, bson.M{"$set": data}, false, false)
|
|
|
}
|
|
@@ -616,9 +615,9 @@ func (c *Customer) CuserRuleCreate() {
|
|
|
func (c *Customer) CuserRuleEdit() {
|
|
|
defer qu.Catch()
|
|
|
id := c.GetString("id")
|
|
|
- query := bson.M{"_id": mongoutil.StringTOBsonId(id)}
|
|
|
+ query := bson.M{"_id": mongodb.StringTOBsonId(id)}
|
|
|
data, _ := Mgo.FindOneByField("cuserdepartrule", query, `{}`)
|
|
|
- (*data)["id"] = mongoutil.BsonIdToSId((*data)["_id"])
|
|
|
+ (*data)["id"] = mongodb.BsonIdToSId((*data)["_id"])
|
|
|
c.T["cid"] = (*data)["s_userid"]
|
|
|
c.T["ids"] = qu.ObjToString((*data)["s_departid"]) + "," + qu.ObjToString((*data)["s_userid"])
|
|
|
c.T["data"] = *data
|
|
@@ -639,9 +638,9 @@ func (c *Customer) CuserRuleEdit() {
|
|
|
func (c *Customer) EuserRule1() {
|
|
|
defer qu.Catch()
|
|
|
id := c.GetString("id")
|
|
|
- query := bson.M{"_id": mongoutil.StringTOBsonId(id)}
|
|
|
+ query := bson.M{"_id": mongodb.StringTOBsonId(id)}
|
|
|
data, _ := Mgo.FindOneByField("euserdepartrule", query, `{}`)
|
|
|
- (*data)["id"] = mongoutil.BsonIdToSId((*data)["_id"])
|
|
|
+ (*data)["id"] = mongodb.BsonIdToSId((*data)["_id"])
|
|
|
var existfields = []string{}
|
|
|
if _, ok := (*data)["s_existfields"]; ok {
|
|
|
s_existfields := (*data)["s_existfields"].(string)
|
|
@@ -688,7 +687,7 @@ func (c *Customer) CuserRuleSetup() {
|
|
|
defer qu.Catch()
|
|
|
if c.Method() == "POST" {
|
|
|
_id := c.GetString("_id")
|
|
|
- i_isuse, _ := c.GetInteger("i_isuse")
|
|
|
+ i_isuse, _ := c.GetInt("i_isuse")
|
|
|
set := bson.M{
|
|
|
"$set": bson.M{
|
|
|
"i_isuse": i_isuse,
|
|
@@ -806,7 +805,7 @@ func (c *Customer) EuserTagEdit() {
|
|
|
_id = Mgo.Save("eusertagrule", data)
|
|
|
} else {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(_id),
|
|
|
+ "_id": mongodb.StringTOBsonId(_id),
|
|
|
}
|
|
|
rep = Mgo.Update("eusertagrule", query, bson.M{"$set": data}, false, false)
|
|
|
}
|
|
@@ -820,7 +819,7 @@ func (c *Customer) EuserTagEdit() {
|
|
|
rep = AddHistoryLogTag(data, false, _id)
|
|
|
} else {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(_id),
|
|
|
+ "_id": mongodb.StringTOBsonId(_id),
|
|
|
}
|
|
|
reps := Mgo.Update("eusertagrule", query, bson.M{"$set": data}, false, false)
|
|
|
if reps {
|
|
@@ -863,7 +862,7 @@ func (c *Customer) EuserTag() {
|
|
|
_id = Mgo.Save("eusertagrule", data)
|
|
|
} else {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(_id),
|
|
|
+ "_id": mongodb.StringTOBsonId(_id),
|
|
|
}
|
|
|
rep = Mgo.Update("eusertagrule", query, bson.M{"$set": data}, false, false)
|
|
|
}
|
|
@@ -911,7 +910,7 @@ func (c *Customer) TagSetup() {
|
|
|
defer qu.Catch()
|
|
|
if c.Method() == "POST" {
|
|
|
_id := c.GetString("_id")
|
|
|
- i_isuse, _ := c.GetInteger("i_isuse")
|
|
|
+ i_isuse, _ := c.GetInt("i_isuse")
|
|
|
set := bson.M{
|
|
|
"$set": bson.M{
|
|
|
"i_isuse": i_isuse,
|
|
@@ -942,9 +941,9 @@ func (c *Customer) CuserRuleList() {
|
|
|
defer qu.Catch()
|
|
|
if c.Method() == "POST" {
|
|
|
eid := c.GetString("eid")
|
|
|
- start, _ := c.GetInteger("start")
|
|
|
- limit, _ := c.GetInteger("length")
|
|
|
- draw, _ := c.GetInteger("draw")
|
|
|
+ start, _ := c.GetInt("start")
|
|
|
+ limit, _ := c.GetInt("length")
|
|
|
+ draw, _ := c.GetInt("draw")
|
|
|
searchStr := c.GetString("search[value]")
|
|
|
search := strings.TrimSpace(searchStr)
|
|
|
query := bson.M{
|
|
@@ -957,7 +956,7 @@ func (c *Customer) CuserRuleList() {
|
|
|
bson.M{"s_name": bson.M{"$regex": search}},
|
|
|
}
|
|
|
}
|
|
|
- data, _ := Mgo.Find("euserdepartrule", query, `{"i_createtime":-1}`, nil, false, start, limit)
|
|
|
+ data, _ := Mgo.Find("euserdepartrule", query, `{"i_createtime":-1}`, nil, false, int(start), int(limit))
|
|
|
for _, v := range *data {
|
|
|
d, _ := Mgo.FindById("euserdepart", qu.ObjToString(v["s_departid"]), nil)
|
|
|
v["s_depart"] = qu.ObjToString((*d)["s_name"])
|
|
@@ -992,13 +991,13 @@ func (c *Customer) CustomerHistory() {
|
|
|
id := c.GetString("id")
|
|
|
user := c.GetSession("user").(map[string]interface{})
|
|
|
query := bson.M{}
|
|
|
- query["_id"] = mongoutil.StringTOBsonId(id)
|
|
|
+ query["_id"] = mongodb.StringTOBsonId(id)
|
|
|
|
|
|
hid := c.GetString("hid")
|
|
|
history_id := ""
|
|
|
if hid != "" {
|
|
|
history_id = hid
|
|
|
- hData, ok := Mgo.FindOne("historylog", bson.M{"_id": mongoutil.StringTOBsonId(history_id)})
|
|
|
+ hData, ok := Mgo.FindOne("historylog", bson.M{"_id": mongodb.StringTOBsonId(history_id)})
|
|
|
if ok && hData != nil && len(*hData) > 0 {
|
|
|
c.T["history_rule"] = (*hData)["dep_rules"]
|
|
|
c.T["tagrule"] = (*hData)["tag_rules"]
|
|
@@ -1040,7 +1039,7 @@ func (c *Customer) CustomerHistory() {
|
|
|
c.Render("private/customer_history.html", &c.T)
|
|
|
}
|
|
|
|
|
|
-//选择历史规则
|
|
|
+// 选择历史规则
|
|
|
func (c *Customer) CustomerAllRule() {
|
|
|
customerId := c.GetString("c_id")
|
|
|
history_id := c.GetString("hid")
|
|
@@ -1050,7 +1049,7 @@ func (c *Customer) CustomerAllRule() {
|
|
|
}
|
|
|
inc_query := bson.M{
|
|
|
"user_id": customerId,
|
|
|
- "_id": mongoutil.StringTOBsonId(history_id),
|
|
|
+ "_id": mongodb.StringTOBsonId(history_id),
|
|
|
}
|
|
|
//获取新增历史规则
|
|
|
inc_rules := []map[string]interface{}{}
|
|
@@ -1059,7 +1058,7 @@ func (c *Customer) CustomerAllRule() {
|
|
|
if inc_data != nil && *inc_data != nil {
|
|
|
for _, t := range (*inc_data)["dep_rules"].([]interface{}) {
|
|
|
if !t.(map[string]interface{})["is_new"].(bool) {
|
|
|
- inc_rule["id"] = t.(map[string]interface{})["_id"].(bson.ObjectId).Hex() //规则id
|
|
|
+ inc_rule["id"] = t.(map[string]interface{})["_id"].(primitive.ObjectID).Hex() //规则id
|
|
|
inc_rule["s_depart_name"] = t.(map[string]interface{})["s_depart_name"]
|
|
|
inc_rule["s_name"] = t.(map[string]interface{})["s_name"]
|
|
|
inc_rule["s_depart_status"] = t.(map[string]interface{})["s_depart_status"]
|
|
@@ -1076,7 +1075,7 @@ func (c *Customer) CustomerAllRule() {
|
|
|
for _, m := range *data {
|
|
|
history_rule_data := make(map[string]interface{})
|
|
|
q := bson.M{
|
|
|
- "s_departid": m["_id"].(bson.ObjectId).Hex(),
|
|
|
+ "s_departid": m["_id"].(primitive.ObjectID).Hex(),
|
|
|
"b_delete": false,
|
|
|
}
|
|
|
history_rule_data["department_isuse"] = m["i_isuse"]
|
|
@@ -1084,7 +1083,7 @@ func (c *Customer) CustomerAllRule() {
|
|
|
depart_rule_data, _ := Mgo.Find("euserdepartrule", q, `{"i_createtime":-1}`, `{"s_name":1,"i_updatetime":1,"i_isuse":1,"_id":1}`, false, 0, 0)
|
|
|
if depart_rule_data != nil && len(*depart_rule_data) != 0 {
|
|
|
for _, j := range *depart_rule_data {
|
|
|
- j["_id"] = j["_id"].(bson.ObjectId).Hex()
|
|
|
+ j["_id"] = j["_id"].(primitive.ObjectID).Hex()
|
|
|
}
|
|
|
history_rule_data["department_rule"] = depart_rule_data
|
|
|
history_rule_data["is_slected"] = true
|
|
@@ -1104,14 +1103,14 @@ func (c *Customer) CustomerAllRule() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//保存历史规则
|
|
|
+// 保存历史规则
|
|
|
func (c *Customer) SaveHistoryRule() {
|
|
|
rules_id := c.GetString("rulesid")
|
|
|
history_id := c.GetString("hid")
|
|
|
// userid := c.GetString("userid")
|
|
|
if history_id != "" {
|
|
|
user_history, _ := Mgo.FindOne("historylog", map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId(history_id),
|
|
|
+ "_id": mongodb.StringTOBsonId(history_id),
|
|
|
})
|
|
|
if *user_history != nil && user_history != nil {
|
|
|
//获取私有标签
|
|
@@ -1123,21 +1122,21 @@ func (c *Customer) SaveHistoryRule() {
|
|
|
if len(dep_rules) > 0 {
|
|
|
for _, r := range dep_rules {
|
|
|
dep_new_rules = append(dep_new_rules, r)
|
|
|
- ruleMap[mongoutil.BsonIdToSId(r["_id"])] = true
|
|
|
+ ruleMap[mongodb.BsonIdToSId(r["_id"])] = true
|
|
|
}
|
|
|
}
|
|
|
rules_id_list := strings.Split(rules_id, ",")
|
|
|
for _, rule := range rules_id_list {
|
|
|
if !ruleMap[rule] {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(rule),
|
|
|
+ "_id": mongodb.StringTOBsonId(rule),
|
|
|
"b_delete": false,
|
|
|
}
|
|
|
res, _ := Mgo.FindOne("euserdepartrule", query)
|
|
|
if res != nil && len(*res) != 0 {
|
|
|
//获取规则所属部门信息
|
|
|
department_info, _ := Mgo.FindOne("euserdepart", map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId((*res)["s_departid"].(string)),
|
|
|
+ "_id": mongodb.StringTOBsonId((*res)["s_departid"].(string)),
|
|
|
"b_delete": false,
|
|
|
})
|
|
|
(*res)["is_new"] = false
|
|
@@ -1154,7 +1153,7 @@ func (c *Customer) SaveHistoryRule() {
|
|
|
},
|
|
|
}
|
|
|
ok := Mgo.Update("historylog", map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId(history_id),
|
|
|
+ "_id": mongodb.StringTOBsonId(history_id),
|
|
|
}, set, false, false)
|
|
|
//log.Println("ok", ok)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
@@ -1166,14 +1165,14 @@ func (c *Customer) SaveHistoryRule() {
|
|
|
dep_rules := []map[string]interface{}{}
|
|
|
for _, rule := range rules_id_list {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(rule),
|
|
|
+ "_id": mongodb.StringTOBsonId(rule),
|
|
|
"b_delete": false,
|
|
|
}
|
|
|
res, _ := Mgo.FindOne("euserdepartrule", query)
|
|
|
if res != nil && *res != nil {
|
|
|
//获取规则所属部门信息
|
|
|
department_info, _ := Mgo.FindOne("euserdepart", map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId((*res)["s_departid"].(string)),
|
|
|
+ "_id": mongodb.StringTOBsonId((*res)["s_departid"].(string)),
|
|
|
"b_delete": false,
|
|
|
})
|
|
|
(*res)["is_new"] = false
|
|
@@ -1189,7 +1188,7 @@ func (c *Customer) SaveHistoryRule() {
|
|
|
},
|
|
|
}
|
|
|
isupdata := Mgo.Update("historylog", map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId(history_id),
|
|
|
+ "_id": mongodb.StringTOBsonId(history_id),
|
|
|
}, set, false, false)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"status": isupdata,
|
|
@@ -1242,7 +1241,7 @@ func (c *Customer) HistoryRuleCreate() {
|
|
|
}
|
|
|
s_id = Mgo.Save("euserdepart", d_data)
|
|
|
} else {
|
|
|
- s_id = mongoutil.BsonIdToSId((*dData)["_id"])
|
|
|
+ s_id = mongodb.BsonIdToSId((*dData)["_id"])
|
|
|
}
|
|
|
data["s_userid"] = user_id
|
|
|
data["s_departid"] = s_id
|
|
@@ -1251,7 +1250,7 @@ func (c *Customer) HistoryRuleCreate() {
|
|
|
s_namekey := gopinyin.Convert(qu.ObjToString(data["s_name"]), false)
|
|
|
data["s_namekey"] = s_namekey
|
|
|
data["b_delete"] = true
|
|
|
- data["s_dataid"] = qu.SE.EncodeString(fmt.Sprintf("%v", i_createtime) + s_namekey + s_id)
|
|
|
+ data["s_dataid"] = encrypt.SE.EncodeString(fmt.Sprintf("%v", i_createtime) + s_namekey + s_id)
|
|
|
data["i_type"] = "historyData"
|
|
|
id = Mgo.Save("euserdepartrule", data)
|
|
|
if id != "" {
|
|
@@ -1261,7 +1260,7 @@ func (c *Customer) HistoryRuleCreate() {
|
|
|
}
|
|
|
} else {
|
|
|
query := bson.M{
|
|
|
- "_id": mongoutil.StringTOBsonId(id),
|
|
|
+ "_id": mongodb.StringTOBsonId(id),
|
|
|
}
|
|
|
reps := Mgo.Update("euserdepartrule", query, bson.M{"$set": data}, false, false)
|
|
|
if reps {
|
|
@@ -1296,7 +1295,7 @@ func (c *Customer) HistoryRuleCreate() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//私有标签关联数据
|
|
|
+// 私有标签关联数据
|
|
|
func (c *Customer) HistoryTagAssociated() {
|
|
|
defer qu.Catch()
|
|
|
userid := c.GetString("userid")
|
|
@@ -1306,14 +1305,14 @@ func (c *Customer) HistoryTagAssociated() {
|
|
|
|
|
|
if userid != "" {
|
|
|
user_info, _ := Mgo.FindOne("historylog", map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId(hid),
|
|
|
+ "_id": mongodb.StringTOBsonId(hid),
|
|
|
})
|
|
|
if user_info != nil && *user_info != nil {
|
|
|
tagrules := (*user_info)["tag_rules"]
|
|
|
if tagrules != nil {
|
|
|
tagrulesArr := qu.ObjArrToMapArr(tagrules.([]interface{}))
|
|
|
for _, m := range tagrulesArr {
|
|
|
- if rule_id == mongoutil.BsonIdToSId(m["_id"]) {
|
|
|
+ if rule_id == mongodb.BsonIdToSId(m["_id"]) {
|
|
|
m["o_departruleids"] = tags
|
|
|
}
|
|
|
}
|
|
@@ -1323,7 +1322,7 @@ func (c *Customer) HistoryTagAssociated() {
|
|
|
},
|
|
|
}
|
|
|
is_updata := Mgo.Update("historylog", map[string]interface{}{
|
|
|
- "_id": mongoutil.StringTOBsonId(hid),
|
|
|
+ "_id": mongodb.StringTOBsonId(hid),
|
|
|
}, set, false, false)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": is_updata,
|
|
@@ -1339,7 +1338,7 @@ func getTserTag(userid string) *[]map[string]interface{} {
|
|
|
}
|
|
|
|
|
|
func AddHistoryLogDep(ruleData map[string]interface{}, isUpdate bool, id string) bool {
|
|
|
- history_id := mongoutil.StringTOBsonId(ruleData["history_id"].(string))
|
|
|
+ history_id := mongodb.StringTOBsonId(ruleData["history_id"].(string))
|
|
|
hData, ok := Mgo.FindOne("historylog", bson.M{"_id": history_id})
|
|
|
if ok && hData != nil && *hData != nil && len(*hData) > 0 {
|
|
|
dep_rules := []map[string]interface{}{}
|
|
@@ -1349,7 +1348,7 @@ func AddHistoryLogDep(ruleData map[string]interface{}, isUpdate bool, id string)
|
|
|
ruleData["is_new"] = true
|
|
|
if isUpdate {
|
|
|
for k, v := range dep_rules {
|
|
|
- if mongoutil.BsonIdToSId(v["_id"]) == id {
|
|
|
+ if mongodb.BsonIdToSId(v["_id"]) == id {
|
|
|
dep_rules[k] = ruleData
|
|
|
}
|
|
|
}
|
|
@@ -1364,7 +1363,7 @@ func AddHistoryLogDep(ruleData map[string]interface{}, isUpdate bool, id string)
|
|
|
}
|
|
|
|
|
|
func AddHistoryLogTag(ruleData map[string]interface{}, isUpdate bool, id string) bool {
|
|
|
- history_id := mongoutil.StringTOBsonId(qu.ObjToString(ruleData["hid"]))
|
|
|
+ history_id := mongodb.StringTOBsonId(qu.ObjToString(ruleData["hid"]))
|
|
|
hData, ok := Mgo.FindOne("historylog", bson.M{"_id": history_id})
|
|
|
if ok && hData != nil && *hData != nil && len(*hData) > 0 {
|
|
|
tag_rules := []map[string]interface{}{}
|
|
@@ -1374,7 +1373,7 @@ func AddHistoryLogTag(ruleData map[string]interface{}, isUpdate bool, id string)
|
|
|
ruleData["is_new"] = true
|
|
|
if isUpdate {
|
|
|
for k, v := range tag_rules {
|
|
|
- if mongoutil.BsonIdToSId(v["_id"]) == id {
|
|
|
+ if mongodb.BsonIdToSId(v["_id"]) == id {
|
|
|
tag_rules[k] = ruleData
|
|
|
}
|
|
|
}
|
|
@@ -1388,24 +1387,24 @@ func AddHistoryLogTag(ruleData map[string]interface{}, isUpdate bool, id string)
|
|
|
|
|
|
}
|
|
|
|
|
|
-//历史任务删除私有标签
|
|
|
+// 历史任务删除私有标签
|
|
|
func (c *Customer) HistoryTagDel() {
|
|
|
defer qu.Catch()
|
|
|
// userid := c.GetString("userid")
|
|
|
tagid := c.GetString("tagid")
|
|
|
hid := c.GetString("hid")
|
|
|
- user_info, _ := Mgo.FindOne("historylog", bson.M{"_id": mongoutil.StringTOBsonId(hid)})
|
|
|
+ user_info, _ := Mgo.FindOne("historylog", bson.M{"_id": mongodb.StringTOBsonId(hid)})
|
|
|
if user_info != nil && *user_info != nil {
|
|
|
if (*user_info)["tag_rules"] != nil {
|
|
|
user_tag_rules := qu.ObjArrToMapArr((*user_info)["tag_rules"].([]interface{}))
|
|
|
ruleMap := map[string]bool{tagid: true}
|
|
|
ruleArr := []map[string]interface{}{}
|
|
|
for _, m := range user_tag_rules {
|
|
|
- if !ruleMap[mongoutil.BsonIdToSId(m["_id"])] {
|
|
|
+ if !ruleMap[mongodb.BsonIdToSId(m["_id"])] {
|
|
|
ruleArr = append(ruleArr, m)
|
|
|
}
|
|
|
}
|
|
|
- is_updata := Mgo.Update("historylog", bson.M{"_id": mongoutil.StringTOBsonId(hid)}, bson.M{"$set": bson.M{"tag_rules": ruleArr}}, false, false)
|
|
|
+ is_updata := Mgo.Update("historylog", bson.M{"_id": mongodb.StringTOBsonId(hid)}, bson.M{"$set": bson.M{"tag_rules": ruleArr}}, false, false)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": is_updata,
|
|
|
})
|
|
@@ -1452,18 +1451,18 @@ func (c *Customer) DelHistoryRule() {
|
|
|
hid := c.GetString("hid")
|
|
|
log.Println(id, hid)
|
|
|
if hid != "" {
|
|
|
- data, ok := Mgo.FindOne("historylog", bson.M{"_id": mongoutil.StringTOBsonId(hid)})
|
|
|
+ data, ok := Mgo.FindOne("historylog", bson.M{"_id": mongodb.StringTOBsonId(hid)})
|
|
|
if ok && data != nil && *data != nil {
|
|
|
if (*data)["dep_rules"] != nil {
|
|
|
dep_rules := qu.ObjArrToMapArr((*data)["dep_rules"].([]interface{}))
|
|
|
ruleMap := map[string]bool{id: true}
|
|
|
ruleArr := []map[string]interface{}{}
|
|
|
for _, m := range dep_rules {
|
|
|
- if !ruleMap[mongoutil.BsonIdToSId(m["_id"])] {
|
|
|
+ if !ruleMap[mongodb.BsonIdToSId(m["_id"])] {
|
|
|
ruleArr = append(ruleArr, m)
|
|
|
}
|
|
|
}
|
|
|
- ok := Mgo.Update("historylog", bson.M{"_id": mongoutil.StringTOBsonId(hid)}, bson.M{"$set": bson.M{"dep_rules": ruleArr}}, false, false)
|
|
|
+ ok := Mgo.Update("historylog", bson.M{"_id": mongodb.StringTOBsonId(hid)}, bson.M{"$set": bson.M{"dep_rules": ruleArr}}, false, false)
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"success": ok,
|
|
|
})
|
|
@@ -1481,9 +1480,9 @@ func (c *Customer) Addhistoryrule() {
|
|
|
//newHistory["tag_rules"] = usertags
|
|
|
push_model, _ := strconv.Atoi(c.GetString("send_mode"))
|
|
|
push_type, _ := strconv.Atoi(c.GetString("push_type"))
|
|
|
- isDup, _ := c.GetInteger("isDup")
|
|
|
- i_projectdup, _ := c.GetInteger("i_projectdup")
|
|
|
- i_datatable, _ := c.GetInteger("i_datatable")
|
|
|
+ isDup, _ := c.GetInt("isDup")
|
|
|
+ i_projectdup, _ := c.GetInt("i_projectdup")
|
|
|
+ i_datatable, _ := c.GetInt("i_datatable")
|
|
|
log.Println(isDup, i_projectdup, i_datatable)
|
|
|
i_updatetime, _ := strconv.ParseInt(c.GetString("i_updatetime"), 10, 64)
|
|
|
i_extfieldstype, _ := strconv.Atoi(c.GetString("i_extfieldstype"))
|
|
@@ -1503,7 +1502,7 @@ func (c *Customer) Addhistoryrule() {
|
|
|
"i_datatable": i_datatable,
|
|
|
},
|
|
|
}
|
|
|
- isupdata := Mgo.UpdateById("historylog", mongoutil.StringTOBsonId(his_id), set)
|
|
|
+ isupdata := Mgo.UpdateById("historylog", mongodb.StringTOBsonId(his_id), set)
|
|
|
if isupdata {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"history_id": his_id,
|