Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
9e9d161137
|
@ -61,7 +61,6 @@ func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCant
|
|||
now := time.Now().UTC().Unix()
|
||||
//开启事务
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
canteenProductModel = gmodel.NewFsCanteenProductModel(tx)
|
||||
sort := int64(0)
|
||||
//新的变更记录
|
||||
mapUpdateCanteenPid := make(map[int64]struct{})
|
||||
|
@ -73,12 +72,12 @@ func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCant
|
|||
}
|
||||
if v.Id > 0 { //更新
|
||||
mapUpdateCanteenPid[v.Id] = struct{}{}
|
||||
err = canteenProductModel.UpdateById(l.ctx, v.Id, &gmodel.FsCanteenProduct{
|
||||
err = tx.WithContext(l.ctx).Model(&gmodel.FsCanteenProduct{}).Where("id = ?", v.Id).Updates(&gmodel.FsCanteenProduct{
|
||||
SizeId: &v.SizeId,
|
||||
Sid: &v.SId,
|
||||
Sort: &sort,
|
||||
ProductId: sizeInfo.ProductId,
|
||||
})
|
||||
}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -86,7 +85,7 @@ func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCant
|
|||
}
|
||||
//新增
|
||||
addStatus := int64(1)
|
||||
err = canteenProductModel.Create(l.ctx, &gmodel.FsCanteenProduct{
|
||||
err = tx.WithContext(l.ctx).Model(&gmodel.FsCanteenProduct{}).Create(&gmodel.FsCanteenProduct{
|
||||
SizeId: &v.SizeId,
|
||||
Sid: &v.SId,
|
||||
Sort: &sort,
|
||||
|
@ -94,7 +93,7 @@ func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCant
|
|||
Ctime: &now,
|
||||
CanteenType: &req.Id,
|
||||
ProductId: sizeInfo.ProductId,
|
||||
})
|
||||
}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -110,9 +109,9 @@ func (l *SaveCanteenTypeProductLogic) SaveCanteenTypeProduct(req *types.SaveCant
|
|||
return nil
|
||||
}
|
||||
delStatus := int64(0)
|
||||
if err = canteenProductModel.UpdateByIdArr(l.ctx, diffCanteenProductId, &gmodel.FsCanteenProduct{
|
||||
if err = tx.WithContext(l.ctx).Model(&gmodel.FsCanteenProduct{}).Where("id in (?)", diffCanteenProductId).Updates(&gmodel.FsCanteenProduct{
|
||||
Status: &delStatus,
|
||||
}); err != nil {
|
||||
}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/chinese_to_pinyin"
|
||||
"fusenapi/utils/email"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -63,38 +62,38 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
|||
userDN := fmt.Sprintf("cn=%s,%s", req.Email, l.svcCtx.Config.Ldap.PeopleGroupDN)
|
||||
//新增一条记录获取递增用户id
|
||||
now := time.Now().UTC()
|
||||
err := l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
userData := &gmodel.LdapUser{
|
||||
UserDn: &userDN,
|
||||
Ctime: &now,
|
||||
Utime: &now,
|
||||
}
|
||||
if err := tx.WithContext(l.ctx).Model(&gmodel.LdapUser{}).Create(userData).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return l.svcCtx.Ldap.Create(userDN, map[string][]string{
|
||||
"objectClass": {"person", "organizationalPerson", "inetOrgPerson", "posixAccount", "top", "shadowAccount"}, //固有属性
|
||||
"shadowLastChange": {"19676"}, //固有属性
|
||||
"shadowMin": {"0"}, //固有属性
|
||||
"shadowMax": {"99999"}, //固有属性
|
||||
"shadowWarning": {"7"}, //固有属性
|
||||
"loginShell": {"/usr/sbin/nologin"}, //固有属性
|
||||
"homeDirectory": {"/home/users/" + userNamePinyin},
|
||||
"employeeType": {fmt.Sprintf("%d", req.EmployeeType)}, //员工类型:1正式 2实习 3外包
|
||||
"uidNumber": {fmt.Sprintf("%d", userData.Id)}, //用户id
|
||||
"gidNumber": {fmt.Sprintf("%d", userData.Id)}, //用户id
|
||||
"uid": {userNamePinyin}, //用户名(拼音)
|
||||
"cn": {req.Email}, //邮箱
|
||||
"sn": {req.UserName}, //用户名
|
||||
"mail": {req.Email}, //邮箱
|
||||
"postalCode": {fmt.Sprintf("%d", req.Status)}, //状态
|
||||
"departmentNumber": {fmt.Sprintf("%d", req.GroupId)}, //权限分组id
|
||||
"postalAddress": {req.Avatar}, //头像
|
||||
"mobile": {req.Mobile}, //手机号
|
||||
"userPassword": {req.Password}, //密码
|
||||
})
|
||||
userData := &gmodel.LdapUser{
|
||||
UserDn: &userDN,
|
||||
Ctime: &now,
|
||||
Utime: &now,
|
||||
}
|
||||
if err := l.svcCtx.AllModels.LdapUser.Create(l.ctx, userData); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "新增用户失败!")
|
||||
}
|
||||
err := l.svcCtx.Ldap.Create(userDN, map[string][]string{
|
||||
"objectClass": {"person", "organizationalPerson", "inetOrgPerson", "posixAccount", "top", "shadowAccount"}, //固有属性
|
||||
"shadowLastChange": {"19676"}, //固有属性
|
||||
"shadowMin": {"0"}, //固有属性
|
||||
"shadowMax": {"99999"}, //固有属性
|
||||
"shadowWarning": {"7"}, //固有属性
|
||||
"loginShell": {"/usr/sbin/nologin"}, //固有属性
|
||||
"homeDirectory": {"/home/users/" + userNamePinyin},
|
||||
"employeeType": {fmt.Sprintf("%d", req.EmployeeType)}, //员工类型:1正式 2实习 3外包
|
||||
"uidNumber": {fmt.Sprintf("%d", userData.Id)}, //用户id
|
||||
"gidNumber": {fmt.Sprintf("%d", userData.Id)}, //用户id
|
||||
"uid": {userNamePinyin}, //用户名(拼音)
|
||||
"cn": {req.Email}, //邮箱
|
||||
"sn": {req.UserName}, //用户名
|
||||
"mail": {req.Email}, //邮箱
|
||||
"postalCode": {fmt.Sprintf("%d", req.Status)}, //状态
|
||||
"departmentNumber": {fmt.Sprintf("%d", req.GroupId)}, //权限分组id
|
||||
"postalAddress": {req.Avatar}, //头像
|
||||
"mobile": {req.Mobile}, //手机号
|
||||
"userPassword": {req.Password}, //密码
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "添加用户失败,"+err.Error())
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "添加用户成功")
|
||||
|
|
|
@ -6,8 +6,6 @@ import (
|
|||
"fusenapi/utils/basic"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/ldap-admin/internal/svc"
|
||||
|
@ -38,18 +36,11 @@ func (l *DeleteMenuLogic) DeleteMenu(req *types.DeleteMenuReq, userinfo *auth.Us
|
|||
if req.Id <= 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数id无效")
|
||||
}
|
||||
err := l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
menusModel := gmodel.NewLdapMenusModel(tx)
|
||||
status := int64(0)
|
||||
now := time.Now().UTC()
|
||||
err := menusModel.Update(l.ctx, req.Id, &gmodel.LdapMenus{
|
||||
Status: &status,
|
||||
Utime: &now,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
status := int64(0)
|
||||
now := time.Now().UTC()
|
||||
err := l.svcCtx.AllModels.LdapMenus.Update(l.ctx, req.Id, &gmodel.LdapMenus{
|
||||
Status: &status,
|
||||
Utime: &now,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
|
|
|
@ -57,7 +57,7 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, r *ht
|
|||
}
|
||||
//把用户名转pinyin
|
||||
userNamePinyin := chinese_to_pinyin.ChineseToPinyin(req.UserName)
|
||||
now := time.Now()
|
||||
now := time.Now().UTC()
|
||||
//更新的属性
|
||||
attr := map[string][]string{
|
||||
"homeDirectory": {"/home/users/" + userNamePinyin},
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/email"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -66,6 +68,13 @@ func (l *UpdateLdapUserPwdLogic) UpdateLdapUserPwd(req *types.UpdateLdapUserPwdR
|
|||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "修改密码失败")
|
||||
}
|
||||
now := time.Now().UTC()
|
||||
err = l.svcCtx.AllModels.LdapUser.Update(l.ctx, req.UserDN, &gmodel.LdapUser{
|
||||
Utime: &now,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "修改密码成功")
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
subTotalPrice := int64(0)
|
||||
//开启事物
|
||||
err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error {
|
||||
shoppingCartModel := gmodel.NewFsShoppingCartModel(tx)
|
||||
for _, cart := range carts {
|
||||
modelInfo, ok := mapModel[*cart.ModelId]
|
||||
if !ok {
|
||||
|
@ -138,7 +137,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
subTotalPrice += totalPrice
|
||||
}
|
||||
//更新购物车购买数量
|
||||
if err = shoppingCartModel.Update(l.ctx, cart.Id, userinfo.UserId, updData); err != nil {
|
||||
if err = tx.WithContext(l.ctx).Model(&gmodel.FsShoppingCart{}).Where("id = ? and user_id = ?", cart.Id, userinfo.UserId).Updates(updData).Error; err != nil {
|
||||
logx.Error(err)
|
||||
return errors.New(fmt.Sprintf("failed to update cart`s purchase quantity:%d", cart.Id))
|
||||
}
|
||||
|
|
|
@ -140,9 +140,6 @@ func (w *wsConnectItem) consumeRenderImageData() {
|
|||
|
||||
// 执行渲染任务
|
||||
func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageReqMsg) {
|
||||
//用户id赋值
|
||||
renderImageData.RenderData.UserId = w.userId
|
||||
renderImageData.RenderData.GuestId = w.guestId
|
||||
if renderImageData.RenderData.Logo == "" {
|
||||
w.renderErrResponse(renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
|
@ -211,8 +208,8 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
|
|||
defer decreaseCombineRequestCount(w.userId, w.guestId)
|
||||
//获取刀版图
|
||||
combineReq := repositories.LogoCombineReq{
|
||||
UserId: renderImageData.RenderData.UserId,
|
||||
GuestId: renderImageData.RenderData.GuestId,
|
||||
UserId: w.userId,
|
||||
GuestId: w.guestId,
|
||||
ProductTemplateV2Info: productTemplate,
|
||||
ProductTemplateTagGroups: renderImageData.RenderData.TemplateTagGroups,
|
||||
TemplateTag: renderImageData.RenderData.TemplateTag,
|
||||
|
@ -225,13 +222,13 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
|
|||
Debug: w.debug,
|
||||
}
|
||||
//qrcode不需要依赖合图组开关
|
||||
if switchInfo.SwitchInfo.QRcode.IfShow {
|
||||
if switchInfo.SwitchInfo.QRcode.IfShow && switchInfo.SwitchInfo.QRcode.UserDisabled {
|
||||
combineReq.Qrcode = &switchInfo.SwitchInfo.QRcode.DefaultValue
|
||||
}
|
||||
//合图组开关开启
|
||||
if switchInfo.CombineIsVisible {
|
||||
//开启slogan
|
||||
if switchInfo.SwitchInfo.Slogan.IfShow {
|
||||
if switchInfo.SwitchInfo.Slogan.IfShow && switchInfo.SwitchInfo.Slogan.UserDisabled {
|
||||
if renderImageData.RenderData.Slogan == "" {
|
||||
combineReq.Slogan = &switchInfo.SwitchInfo.Slogan.DefaultValue
|
||||
} else {
|
||||
|
@ -239,7 +236,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
|
|||
}
|
||||
}
|
||||
//开启website
|
||||
if switchInfo.SwitchInfo.Website.IfShow {
|
||||
if switchInfo.SwitchInfo.Website.IfShow && switchInfo.SwitchInfo.Website.UserDisabled {
|
||||
if renderImageData.RenderData.Website == "" {
|
||||
combineReq.Website = &switchInfo.SwitchInfo.Website.DefaultValue
|
||||
} else {
|
||||
|
@ -247,7 +244,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
|
|||
}
|
||||
}
|
||||
//开启address
|
||||
if switchInfo.SwitchInfo.Address.IfShow {
|
||||
if switchInfo.SwitchInfo.Address.IfShow && switchInfo.SwitchInfo.Address.UserDisabled {
|
||||
if renderImageData.RenderData.Address == "" {
|
||||
combineReq.Address = &switchInfo.SwitchInfo.Address.DefaultValue
|
||||
} else {
|
||||
|
@ -255,7 +252,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
|
|||
}
|
||||
}
|
||||
//开启Phone
|
||||
if switchInfo.SwitchInfo.Phone.IfShow {
|
||||
if switchInfo.SwitchInfo.Phone.IfShow && switchInfo.SwitchInfo.Phone.UserDisabled {
|
||||
if renderImageData.RenderData.Phone == "" {
|
||||
combineReq.Phone = &switchInfo.SwitchInfo.Phone.DefaultValue
|
||||
} else {
|
||||
|
@ -384,7 +381,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, resolution int,
|
|||
return err
|
||||
}
|
||||
}
|
||||
//组装data数据(参照以前PHP,不要随便动)
|
||||
//组装data数据
|
||||
var mode map[string]interface{}
|
||||
if element.Mode != nil && *element.Mode != "" {
|
||||
if err = json.Unmarshal([]byte(*element.Mode), &mode); err != nil {
|
||||
|
@ -451,8 +448,8 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, resolution int,
|
|||
sendData := map[string]interface{}{
|
||||
"id": string(temIdBytes),
|
||||
"order_id": 0,
|
||||
"user_id": info.RenderData.UserId,
|
||||
"guest_id": info.RenderData.GuestId,
|
||||
"user_id": w.userId,
|
||||
"guest_id": w.guestId,
|
||||
"sku_ids": []int64{info.RenderData.ProductId},
|
||||
"tids": []string{*element.Title},
|
||||
"data": result,
|
||||
|
@ -488,11 +485,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, resolution int,
|
|||
|
||||
// 组装渲染任务id
|
||||
func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData websocket_data.RenderImageReqMsg, model3dInfo *gmodel.FsProductModel3d, productTemplate *gmodel.FsProductTemplateV2, element *gmodel.FsProductTemplateElement) string {
|
||||
//生成任务id(需要把user_id,guest_id设为0)
|
||||
incomeHashParam := renderImageData.RenderData
|
||||
incomeHashParam.UserId = 0 //设为0(渲染跟用户id无关)
|
||||
incomeHashParam.GuestId = 0 //设为0(渲染跟用户id无关)
|
||||
incomeHashBytes, _ := json.Marshal(incomeHashParam)
|
||||
incomeHashBytes, _ := json.Marshal(renderImageData.RenderData)
|
||||
modelHashStr := ""
|
||||
templateHashStr := ""
|
||||
if model3dInfo.ModelInfo != nil {
|
||||
|
|
|
@ -70,19 +70,32 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa
|
|||
Id: templateId,
|
||||
Material: templateMaterialImg,
|
||||
SwitchInfo: SwitchInfo{
|
||||
QRcode: QRcode{
|
||||
UserDisabled: true,
|
||||
DefaultValue: "your qrcode",
|
||||
},
|
||||
Website: Website{
|
||||
UserDisabled: true,
|
||||
DefaultValue: "your website",
|
||||
},
|
||||
Address: Address{
|
||||
UserDisabled: true,
|
||||
DefaultValue: "your address",
|
||||
},
|
||||
Phone: Phone{
|
||||
UserDisabled: true,
|
||||
DefaultValue: "your phone",
|
||||
},
|
||||
Slogan: Slogan{
|
||||
UserDisabled: true,
|
||||
DefaultValue: "your slogan",
|
||||
},
|
||||
Logo: Logo{
|
||||
Material: "/image/logo/aHnT1_rzubdwax_scale.png",
|
||||
},
|
||||
},
|
||||
CombineIsVisible: false,
|
||||
}
|
||||
defer func() {
|
||||
returnData.SwitchInfo.QRcode.UserDisabled = true
|
||||
returnData.SwitchInfo.Website.UserDisabled = true
|
||||
returnData.SwitchInfo.Address.UserDisabled = true
|
||||
returnData.SwitchInfo.Phone.UserDisabled = true
|
||||
returnData.SwitchInfo.Slogan.UserDisabled = true
|
||||
}()
|
||||
if templateJsonStr == nil || *templateJsonStr == "" {
|
||||
return returnData
|
||||
}
|
||||
|
@ -98,35 +111,20 @@ func GetTemplateSwitchInfo(templateId int64, templateJsonStr *string, templateMa
|
|||
}
|
||||
switch v.Tag {
|
||||
case "Phone": //电话
|
||||
returnData.SwitchInfo.Phone = Phone{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "your phone",
|
||||
}
|
||||
returnData.SwitchInfo.Phone.IfShow = v.Visible
|
||||
returnData.SwitchInfo.Phone.Text = v.Text
|
||||
case "Address": //地址
|
||||
returnData.SwitchInfo.Address = Address{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "your address",
|
||||
}
|
||||
returnData.SwitchInfo.Address.IfShow = v.Visible
|
||||
returnData.SwitchInfo.Address.Text = v.Text
|
||||
case "Website":
|
||||
returnData.SwitchInfo.Website = Website{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "your website",
|
||||
}
|
||||
returnData.SwitchInfo.Website.IfShow = v.Visible
|
||||
returnData.SwitchInfo.Website.Text = v.Text
|
||||
case "QRcode":
|
||||
returnData.SwitchInfo.QRcode = QRcode{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "your qrcode content",
|
||||
}
|
||||
returnData.SwitchInfo.QRcode.IfShow = v.Visible
|
||||
returnData.SwitchInfo.QRcode.Text = v.Text
|
||||
case "Slogan":
|
||||
returnData.SwitchInfo.Slogan = Slogan{
|
||||
IfShow: v.Visible,
|
||||
Text: v.Text,
|
||||
DefaultValue: "your slogan",
|
||||
}
|
||||
returnData.SwitchInfo.Slogan.IfShow = v.Visible
|
||||
returnData.SwitchInfo.Slogan.Text = v.Text
|
||||
}
|
||||
}
|
||||
return returnData
|
||||
|
|
|
@ -18,8 +18,8 @@ type RenderData struct {
|
|||
Address string `json:"address"` //地址(可选)
|
||||
Phone string `json:"phone"` //电话(可选)
|
||||
Qrcode string `json:"qrcode"` //二维码(可选)
|
||||
UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
//UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值)
|
||||
//GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值)
|
||||
}
|
||||
type TemplateTagColor struct {
|
||||
Colors [][]string `json:"colors"` //颜色组合
|
||||
|
|
Loading…
Reference in New Issue
Block a user