|
@@ -24,6 +24,8 @@ type Client struct {
|
|
|
departEdit xweb.Mapper `xweb:"/client/depart/edit"` //保存和修改部门
|
|
|
setupDepart xweb.Mapper `xweb:"/client/customer/setup"` //部门列表中启用、禁用
|
|
|
cuserRuleEdit xweb.Mapper `xweb:"/client/cuser/rule/Edit"`
|
|
|
+ //同步
|
|
|
+ synEuser xweb.Mapper `xweb:"/client/cuser/synchronous"`
|
|
|
}
|
|
|
|
|
|
func (this *Client) Index() {
|
|
@@ -226,3 +228,54 @@ func (c *Client) CuserRuleEdit() {
|
|
|
c.T["scopeClass"] = ScopeClassMap
|
|
|
c.Render("client/cuser_rule_edit.html", &c.T)
|
|
|
}
|
|
|
+
|
|
|
+//同步
|
|
|
+func (c *Client) SynEuser() {
|
|
|
+ defer qu.Catch()
|
|
|
+ _id := c.GetString("_id")
|
|
|
+ cuser, _ := Mgo.FindById("cuser", _id, nil)
|
|
|
+ nowTime := time.Now().Unix()
|
|
|
+ (*cuser)["i_lastsynctime"] = nowTime //同步时间
|
|
|
+ set := bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ "i_lastsynctime": nowTime,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ b := Mgo.Update("cuser", bson.M{"_id": mongoutil.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)
|
|
|
+ if !b {
|
|
|
+ c.ServeJson(map[string]interface{}{
|
|
|
+ "rep": b,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ departMap, _ := Mgo.Find("cuserdepart", bson.M{"s_userid": _id, "b_delete": false}, nil, nil, false, -1, -1)
|
|
|
+ //Mgo.SaveBulk("euserdepart", *departMap...)
|
|
|
+ update := [][]map[string]interface{}{}
|
|
|
+ for _, v := range *departMap {
|
|
|
+ idAndSet := []map[string]interface{}{}
|
|
|
+ idAndSet = append(idAndSet, bson.M{"_id": v["_id"]}) //查询条件
|
|
|
+ idAndSet = append(idAndSet, v) //修改的数据
|
|
|
+ update = append(update, idAndSet)
|
|
|
+ }
|
|
|
+ Mgo.UpSertBulk("euserdepart", update...)
|
|
|
+ ruleMap, _ := Mgo.Find("cuserdepartrule", bson.M{"s_userid": _id, "b_delete": false}, nil, nil, false, -1, -1)
|
|
|
+ //b = Mgo.SaveBulk("euserdepartrule", *ruleMap...)
|
|
|
+ update2 := [][]map[string]interface{}{}
|
|
|
+ for _, v := range *ruleMap {
|
|
|
+ idAndSet := []map[string]interface{}{}
|
|
|
+ idAndSet = append(idAndSet, bson.M{"_id": v["_id"]}) //查询条件
|
|
|
+ idAndSet = append(idAndSet, v) //修改的数据
|
|
|
+ update2 = append(update2, idAndSet)
|
|
|
+ }
|
|
|
+ b = Mgo.UpSertBulk("euserdepartrule", update2...)
|
|
|
+ c.ServeJson(map[string]interface{}{
|
|
|
+ "rep": b,
|
|
|
+ })
|
|
|
+}
|