aa
This commit is contained in:
@@ -3770,3 +3770,51 @@ func GetDiffJxStoreAndMTWMStoreInfo(ctx *jxcontext.Context, storeIDs []int) (err
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetBrands(ctx *jxcontext.Context, name string) (brands []*model.Brand, err error) {
|
||||||
|
return dao.GetBrands(dao.GetDB(), name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddBrand(ctx *jxcontext.Context, brand *model.Brand) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
if brand.Name == "" {
|
||||||
|
return fmt.Errorf("请输入品牌名!")
|
||||||
|
}
|
||||||
|
brand.Name = utils.TrimBlankChar(brand.Name)
|
||||||
|
dao.WrapAddIDCULDEntity(brand, ctx.GetUserName())
|
||||||
|
err = dao.CreateEntity(db, brand)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateBrand(ctx *jxcontext.Context, payload map[string]interface{}, isDel bool) (err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
brand = &model.Brand{}
|
||||||
|
)
|
||||||
|
brand.ID = int(utils.MustInterface2Int64(payload["id"]))
|
||||||
|
dao.GetEntity(db, brand)
|
||||||
|
if isDel {
|
||||||
|
brand.DeletedAt = time.Now()
|
||||||
|
brand.LastOperator = ctx.GetUserName()
|
||||||
|
dao.UpdateEntity(db, brand, "DeletedAt", "LastOperator")
|
||||||
|
} else {
|
||||||
|
valid := dao.StrictMakeMapByStructObject(payload, brand, ctx.GetUserName())
|
||||||
|
if len(valid) > 0 {
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
if _, err = dao.UpdateEntityLogically(db, brand, valid, ctx.GetUserName(), nil); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -925,3 +925,20 @@ func GetStoreAuditPage(db *DaoDB, statuss []int, keyword string, applyTimeStart,
|
|||||||
}
|
}
|
||||||
return pagedInfo, err
|
return pagedInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetBrands(db *DaoDB, name string) (brands []*model.Brand, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM brand
|
||||||
|
WHERE deleted_at = ?
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if name != "" {
|
||||||
|
sql += " AND name LIKE ?"
|
||||||
|
sqlParams = append(sqlParams, "%"+name+"%")
|
||||||
|
}
|
||||||
|
err = GetRows(db, &brands, sql, sqlParams)
|
||||||
|
return brands, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -938,3 +938,52 @@ func (c *StoreController) GetJddjStoreInfo() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 查询品牌
|
||||||
|
// @Description 查询品牌
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param name query string false "品牌名"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetBrands [get]
|
||||||
|
func (c *StoreController) GetBrands() {
|
||||||
|
c.callGetBrands(func(params *tStoreGetBrandsParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, err = cms.GetBrands(params.Ctx, params.Name)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 新增品牌
|
||||||
|
// @Description 新增品牌
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param payload formData string true "brand payload"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /AddBrand [post]
|
||||||
|
func (c *StoreController) AddBrand() {
|
||||||
|
c.callAddBrand(func(params *tStoreAddBrandParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
var brand = &model.Brand{}
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), brand); err == nil {
|
||||||
|
err = cms.AddBrand(params.Ctx, brand)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title 修改品牌
|
||||||
|
// @Description 修改品牌
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param payload formData string true "brand payload"
|
||||||
|
// @Param isDel formData bool false "是否是删除"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /UpdateBrand [post]
|
||||||
|
func (c *StoreController) UpdateBrand() {
|
||||||
|
c.callUpdateBrand(func(params *tStoreUpdateBrandParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
payload := make(map[string]interface{})
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
||||||
|
err = cms.UpdateBrand(params.Ctx, payload, params.IsDel)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1854,6 +1854,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "AddBrand",
|
||||||
|
Router: `/AddBrand`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AddStoreCategoryMap",
|
Method: "AddStoreCategoryMap",
|
||||||
@@ -1971,6 +1980,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetBrands",
|
||||||
|
Router: `/GetBrands`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetCorporationInfo",
|
Method: "GetCorporationInfo",
|
||||||
@@ -2214,6 +2232,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "UpdateBrand",
|
||||||
|
Router: `/UpdateBrand`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "UpdateOrCreateCourierStores",
|
Method: "UpdateOrCreateCourierStores",
|
||||||
|
|||||||
Reference in New Issue
Block a user