| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package plat
- import (
- "context"
- "dashoo.cn/micro/app/dao/plat"
- model "dashoo.cn/micro/app/model/plat"
- "dashoo.cn/micro/app/service"
- )
- type UserConfigService struct {
- *service.ContextService
- Dao *plat.PlatUserConfigDao
- }
- func NewUserConfigService(ctx context.Context) (svc *UserConfigService, err error) {
- svc = new(UserConfigService)
- if svc.ContextService, err = svc.Init(ctx); err != nil {
- return nil, err
- }
- svc.Dao = plat.NewPlatUserConfigDao(svc.Tenant)
- return svc, nil
- }
- // QueryByUserIdAndModelCode 根据用户ID和模块编码查询
- func (s *UserConfigService) QueryByUserIdAndModelCode(userId int, moduleCode string) (config *model.PlatUserConfig, err error) {
- return s.Dao.Where("user_id = ? and module_code = ?", s.GetCxtUserId(), moduleCode).One()
- }
- // Create 添加用户配置信息
- func (s *UserConfigService) Create(param *model.PlatUserConfig) (lastInsertId int64, err error) {
- return s.Dao.InsertAndGetId(param)
- }
- // Edit 修改配置信息
- func (s *UserConfigService) Edit(param *model.PlatUserConfig) (err error) {
- _, err = s.Dao.Fields(s.Dao.C.ConfigInfo).WherePri(param.Id).Data(param).Update()
- return err
- }
- // Delete 删除配置信息
- func (s *UserConfigService) Delete(param *model.PlatUserConfig) (err error) {
- _, err = s.Dao.WherePri(param.Id).Delete()
- return err
- }
|