diff --git a/modules/core/dao/config_dao.go b/modules/core/dao/config_dao.go index fa50d23..6ca1d77 100644 --- a/modules/core/dao/config_dao.go +++ b/modules/core/dao/config_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/constant" "cutego/pkg/page" @@ -19,8 +19,8 @@ func (d ConfigDao) sql(session *xorm.Session) *xorm.Session { } // SelectByConfigKey 根据键名查询参数配置信息 -func (d ConfigDao) SelectByConfigKey(configKey string) *entity.SysConfig { - config := entity.SysConfig{} +func (d ConfigDao) SelectByConfigKey(configKey string) *dataobject.SysConfig { + config := dataobject.SysConfig{} _, err := d.sql(refs.SqlDB.NewSession()).Where("config_key = ?", configKey).Get(&config) if err != nil { common.ErrorLog(err) @@ -30,8 +30,8 @@ func (d ConfigDao) SelectByConfigKey(configKey string) *entity.SysConfig { } // SelectPage 分页查询数据 -func (d ConfigDao) SelectPage(query request.ConfigQuery) (*[]entity.SysConfig, int64) { - configs := make([]entity.SysConfig, 0) +func (d ConfigDao) SelectPage(query request.ConfigQuery) (*[]dataobject.SysConfig, int64) { + configs := make([]dataobject.SysConfig, 0) session := d.sql(refs.SqlDB.NewSession()) if gotool.StrUtils.HasNotEmpty(query.ConfigName) { session.And("config_name like concat('%', ?, '%')", query.ConfigName) @@ -58,7 +58,7 @@ func (d ConfigDao) SelectPage(query request.ConfigQuery) (*[]entity.SysConfig, i } // CheckConfigKeyUnique 校验是否存在 -func (d ConfigDao) CheckConfigKeyUnique(config entity.SysConfig) int64 { +func (d ConfigDao) CheckConfigKeyUnique(config dataobject.SysConfig) int64 { session := d.sql(refs.SqlDB.NewSession()) if config.ConfigId > 0 { session.Where("config_id != ?", config.ConfigId) @@ -72,7 +72,7 @@ func (d ConfigDao) CheckConfigKeyUnique(config entity.SysConfig) int64 { } // Insert 添加数据 -func (d ConfigDao) Insert(config entity.SysConfig) int64 { +func (d ConfigDao) Insert(config dataobject.SysConfig) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&config) @@ -86,8 +86,8 @@ func (d ConfigDao) Insert(config entity.SysConfig) int64 { } // SelectById 查询数据 -func (d ConfigDao) SelectById(id int64) *entity.SysConfig { - config := entity.SysConfig{} +func (d ConfigDao) SelectById(id int64) *dataobject.SysConfig { + config := dataobject.SysConfig{} session := d.sql(refs.SqlDB.NewSession()) _, err := session.Where("config_id = ?", id).Get(&config) if err != nil { @@ -98,7 +98,7 @@ func (d ConfigDao) SelectById(id int64) *entity.SysConfig { } // Update 修改数据 -func (d ConfigDao) Update(config entity.SysConfig) int64 { +func (d ConfigDao) Update(config dataobject.SysConfig) int64 { session := refs.SqlDB.NewSession() session.Begin() update, err := session.Where("config_id = ?", config.ConfigId).Update(&config) @@ -112,8 +112,8 @@ func (d ConfigDao) Update(config entity.SysConfig) int64 { } // CheckConfigByIds 根据id集合查询 -func (d ConfigDao) CheckConfigByIds(list []int64) *[]entity.SysConfig { - configs := make([]entity.SysConfig, 0) +func (d ConfigDao) CheckConfigByIds(list []int64) *[]dataobject.SysConfig { + configs := make([]dataobject.SysConfig, 0) err := d.sql(refs.SqlDB.NewSession()).In("config_id", list).Find(&configs) if err != nil { common.ErrorLog(err) @@ -126,7 +126,7 @@ func (d ConfigDao) CheckConfigByIds(list []int64) *[]entity.SysConfig { func (d ConfigDao) Delete(list []int64) bool { session := refs.SqlDB.NewSession() session.Begin() - _, err := session.In("config_id", list).Delete(&entity.SysConfig{}) + _, err := session.In("config_id", list).Delete(&dataobject.SysConfig{}) if err != nil { common.ErrorLog(err) session.Rollback() @@ -137,8 +137,8 @@ func (d ConfigDao) Delete(list []int64) bool { } // SelectAll 查询所有数据 -func (d ConfigDao) SelectAll() *[]entity.SysConfig { - configs := make([]entity.SysConfig, 0) +func (d ConfigDao) SelectAll() *[]dataobject.SysConfig { + configs := make([]dataobject.SysConfig, 0) session := refs.SqlDB.NewSession() err := session.Find(&configs) if err != nil { @@ -152,7 +152,7 @@ func init() { // 查询配置数据存入到缓存中 configDao := new(ConfigDao) configSession := configDao.sql(refs.SqlDB.NewSession()) - configs := make([]*entity.SysConfig, 0) + configs := make([]*dataobject.SysConfig, 0) err := configSession.Find(&configs) if err != nil { common.ErrorLog(err) diff --git a/modules/core/dao/cron_job_dao.go b/modules/core/dao/cron_job_dao.go index 93028eb..afdf510 100644 --- a/modules/core/dao/cron_job_dao.go +++ b/modules/core/dao/cron_job_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -18,8 +18,8 @@ func (d CronJobDao) sql(session *xorm.Session) *xorm.Session { } // SelectPage 分页查询数据 -func (d CronJobDao) SelectPage(query request.CronJobQuery) ([]entity.SysCronJob, int64) { - configs := make([]entity.SysCronJob, 0) +func (d CronJobDao) SelectPage(query request.CronJobQuery) ([]dataobject.SysCronJob, int64) { + configs := make([]dataobject.SysCronJob, 0) session := d.sql(refs.SqlDB.NewSession()) if gotool.StrUtils.HasNotEmpty(query.JobName) { session.And("job_name like concat('%', ?, '%')", query.JobName) @@ -37,7 +37,7 @@ func (d CronJobDao) SelectPage(query request.CronJobQuery) ([]entity.SysCronJob, } // Insert 添加数据 -func (d CronJobDao) Insert(config entity.SysCronJob) int64 { +func (d CronJobDao) Insert(config dataobject.SysCronJob) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&config) @@ -51,8 +51,8 @@ func (d CronJobDao) Insert(config entity.SysCronJob) int64 { } // SelectById 查询数据 -func (d CronJobDao) SelectById(id int64) *entity.SysCronJob { - config := entity.SysCronJob{} +func (d CronJobDao) SelectById(id int64) *dataobject.SysCronJob { + config := dataobject.SysCronJob{} session := d.sql(refs.SqlDB.NewSession()) _, err := session.Where("job_id = ?", id).Get(&config) if err != nil { @@ -63,7 +63,7 @@ func (d CronJobDao) SelectById(id int64) *entity.SysCronJob { } // Update 修改数据 -func (d CronJobDao) Update(config entity.SysCronJob) int64 { +func (d CronJobDao) Update(config dataobject.SysCronJob) int64 { session := refs.SqlDB.NewSession() session.Begin() update, err := session.Where("job_id = ?", config.JobId).Update(&config) @@ -80,7 +80,7 @@ func (d CronJobDao) Update(config entity.SysCronJob) int64 { func (d CronJobDao) Delete(list []int64) bool { session := refs.SqlDB.NewSession() session.Begin() - _, err := session.In("job_id", list).Delete(&entity.SysCronJob{}) + _, err := session.In("job_id", list).Delete(&dataobject.SysCronJob{}) if err != nil { common.ErrorLog(err) session.Rollback() @@ -91,8 +91,8 @@ func (d CronJobDao) Delete(list []int64) bool { } // SelectByFuncAlias 通过方法别名获取任务详情 -func (d CronJobDao) SelectByFuncAlias(funcAlias string) *entity.SysCronJob { - config := entity.SysCronJob{} +func (d CronJobDao) SelectByFuncAlias(funcAlias string) *dataobject.SysCronJob { + config := dataobject.SysCronJob{} session := d.sql(refs.SqlDB.NewSession()) _, err := session.Where("func_alias = ?", funcAlias).Get(&config) if err != nil { @@ -103,8 +103,8 @@ func (d CronJobDao) SelectByFuncAlias(funcAlias string) *entity.SysCronJob { } // SelectAll 查找所有启用状态的任务 -func (d CronJobDao) SelectAll() ([]entity.SysCronJob, int) { - configs := make([]entity.SysCronJob, 0) +func (d CronJobDao) SelectAll() ([]dataobject.SysCronJob, int) { + configs := make([]dataobject.SysCronJob, 0) session := d.sql(refs.SqlDB.NewSession()) err := session.Where("status = ?", 1).Find(&configs) if err != nil { diff --git a/modules/core/dao/dept_dao.go b/modules/core/dao/dept_dao.go index 0999a78..5882ead 100644 --- a/modules/core/dao/dept_dao.go +++ b/modules/core/dao/dept_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/refs" "github.com/druidcaesa/gotool" @@ -12,8 +12,8 @@ type DeptDao struct { } // SelectTree 根据条件查询部门集合 -func (d DeptDao) SelectTree(query request.DeptQuery) *[]entity.SysDept { - depts := make([]entity.SysDept, 0) +func (d DeptDao) SelectTree(query request.DeptQuery) *[]dataobject.SysDept { + depts := make([]dataobject.SysDept, 0) session := refs.SqlDB.NewSession().Where("del_flag = '0'") if query.ParentId > 0 { session.And("parent_id = ?", query.ParentId) @@ -50,8 +50,8 @@ func (d DeptDao) SelectDeptListByRoleId(id int64, strictly bool) *[]int64 { } // GetList 查询部门列表 -func (d DeptDao) GetList(query request.DeptQuery) *[]entity.SysDept { - list := make([]entity.SysDept, 0) +func (d DeptDao) GetList(query request.DeptQuery) *[]dataobject.SysDept { + list := make([]dataobject.SysDept, 0) session := refs.SqlDB.NewSession().OrderBy("parent_id").OrderBy("order_num") session.Where("del_flag = '0'") if query.ParentId > 0 { @@ -72,8 +72,8 @@ func (d DeptDao) GetList(query request.DeptQuery) *[]entity.SysDept { } // SelectDeptById 根据部门编号获取详细信息 -func (d DeptDao) SelectDeptById(id int) *entity.SysDept { - dept := entity.SysDept{} +func (d DeptDao) SelectDeptById(id int) *dataobject.SysDept { + dept := dataobject.SysDept{} _, err := refs.SqlDB.NewSession().Where("dept_id = ?", id).Get(&dept) if err != nil { common.ErrorLog(err) @@ -83,7 +83,7 @@ func (d DeptDao) SelectDeptById(id int) *entity.SysDept { } // Insert 添加部门数据 -func (d DeptDao) Insert(dept entity.SysDept) int64 { +func (d DeptDao) Insert(dept dataobject.SysDept) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&dept) @@ -97,7 +97,7 @@ func (d DeptDao) Insert(dept entity.SysDept) int64 { } // CheckDeptNameUnique 校验部门名称是否唯一 -func (d DeptDao) CheckDeptNameUnique(dept entity.SysDept) int64 { +func (d DeptDao) CheckDeptNameUnique(dept dataobject.SysDept) int64 { session := refs.SqlDB.NewSession() count, err := session.Table("sys_dept").Cols("dept_id").Where("dept_name=?", dept.DeptName).And("parent_id = ?", dept.ParentId).Limit(1).Count() if err != nil { @@ -124,7 +124,7 @@ func (d DeptDao) CheckDeptExistUser(id int) int64 { // Delete 删除部门 func (d DeptDao) Delete(id int) int64 { - dept := entity.SysDept{ + dept := dataobject.SysDept{ DeptId: id, } session := refs.SqlDB.NewSession() @@ -140,7 +140,7 @@ func (d DeptDao) Delete(id int) int64 { } // Update 更新部门 -func (d DeptDao) Update(dept entity.SysDept) int64 { +func (d DeptDao) Update(dept dataobject.SysDept) int64 { session := refs.SqlDB.NewSession() session.Begin() update, err := session.Where("dept_id = ?", dept.DeptId).Update(&dept) diff --git a/modules/core/dao/dict_data_dao.go b/modules/core/dao/dict_data_dao.go index 3136ad4..e2f6c10 100644 --- a/modules/core/dao/dict_data_dao.go +++ b/modules/core/dao/dict_data_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/constant" "cutego/pkg/page" @@ -20,9 +20,9 @@ func (d *DictDataDao) sql(session *xorm.Session) *xorm.Session { // SelectByDictType 根据字典类型查询字典数据 // @Param dictType string 字典类型 -// @Return []entity.SysDictData -func (d *DictDataDao) SelectByDictType(dictType string) []entity.SysDictData { - data := make([]entity.SysDictData, 0) +// @Return []dataobject.SysDictData +func (d *DictDataDao) SelectByDictType(dictType string) []dataobject.SysDictData { + data := make([]dataobject.SysDictData, 0) session := d.sql(refs.SqlDB.NewSession()) err := session.Where("status = '0' ").And("dict_type = ?", dictType).OrderBy("dict_sort").Asc("dict_sort"). Find(&data) @@ -34,10 +34,10 @@ func (d *DictDataDao) SelectByDictType(dictType string) []entity.SysDictData { } // GetDiceDataAll 查询所有字典数据 -// @Return *[]entity.SysDictData -func (d DictDataDao) GetDiceDataAll() *[]entity.SysDictData { +// @Return *[]dataobject.SysDictData +func (d DictDataDao) GetDiceDataAll() *[]dataobject.SysDictData { session := d.sql(refs.SqlDB.NewSession()) - data := make([]entity.SysDictData, 0) + data := make([]dataobject.SysDictData, 0) err := session.Where("status = '0' ").OrderBy("dict_sort").Asc("dict_sort"). Find(&data) if err != nil { @@ -49,10 +49,10 @@ func (d DictDataDao) GetDiceDataAll() *[]entity.SysDictData { // SelectPage 查询集合数据 // @Param query request.DiceDataQuery -// @Return *[]entity.SysDictData +// @Return *[]dataobject.SysDictData // @Return 总行数 -func (d *DictDataDao) SelectPage(query request.DiceDataQuery) (*[]entity.SysDictData, int64) { - list := make([]entity.SysDictData, 0) +func (d *DictDataDao) SelectPage(query request.DiceDataQuery) (*[]dataobject.SysDictData, int64) { + list := make([]dataobject.SysDictData, 0) session := refs.SqlDB.NewSession().Table("sys_dict_data").OrderBy("dict_sort").Asc("dict_sort") if gotool.StrUtils.HasNotEmpty(query.DictType) { session.And("dict_type = ?", query.DictType) @@ -74,9 +74,9 @@ func (d *DictDataDao) SelectPage(query request.DiceDataQuery) (*[]entity.SysDict // SelectByDictCode 根据dictCode查询字典数据 // @Param dictCode int64 -// @Return *entity.SysDictData -func (d *DictDataDao) SelectByDictCode(dictCode int64) *entity.SysDictData { - data := entity.SysDictData{} +// @Return *dataobject.SysDictData +func (d *DictDataDao) SelectByDictCode(dictCode int64) *dataobject.SysDictData { + data := dataobject.SysDictData{} session := refs.SqlDB.NewSession() _, err := session.Where("dict_code = ?", dictCode).Get(&data) if err != nil { @@ -87,9 +87,9 @@ func (d *DictDataDao) SelectByDictCode(dictCode int64) *entity.SysDictData { } // Insert 添加字典数据 -// @Param data entity.SysDictData +// @Param data dataobject.SysDictData // @Return 新增的行数 -func (d *DictDataDao) Insert(data entity.SysDictData) int64 { +func (d *DictDataDao) Insert(data dataobject.SysDictData) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&data) @@ -106,7 +106,7 @@ func (d *DictDataDao) Insert(data entity.SysDictData) int64 { func (d *DictDataDao) Delete(codes []int64) bool { session := refs.SqlDB.NewSession() session.Begin() - _, err := session.In("dict_code", codes).Delete(&entity.SysDictData{}) + _, err := session.In("dict_code", codes).Delete(&dataobject.SysDictData{}) if err != nil { common.ErrorLog(err) session.Rollback() @@ -117,7 +117,7 @@ func (d *DictDataDao) Delete(codes []int64) bool { } // 修改字典数据 -func (d *DictDataDao) Update(data entity.SysDictData) bool { +func (d *DictDataDao) Update(data dataobject.SysDictData) bool { session := refs.SqlDB.NewSession() session.Begin() _, err := session.Where("dict_code = ?", data.DictCode).Update(&data) diff --git a/modules/core/dao/dict_type_dao.go b/modules/core/dao/dict_type_dao.go index 5480062..b25145d 100644 --- a/modules/core/dao/dict_type_dao.go +++ b/modules/core/dao/dict_type_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -18,8 +18,8 @@ func (d DictTypeDao) sql(session *xorm.Session) *xorm.Session { } // SelectAll 查询所有字典类型数据 -func (d DictTypeDao) SelectAll() []*entity.SysDictType { - types := make([]*entity.SysDictType, 0) +func (d DictTypeDao) SelectAll() []*dataobject.SysDictType { + types := make([]*dataobject.SysDictType, 0) err := d.sql(refs.SqlDB.NewSession()).Where("status = '0'").Find(&types) if err != nil { common.ErrorLog(err) @@ -29,8 +29,8 @@ func (d DictTypeDao) SelectAll() []*entity.SysDictType { } // SelectPage 分页查询字典类型数据 -func (d DictTypeDao) SelectPage(query request.DictTypeQuery) (*[]entity.SysDictType, int64) { - list := make([]entity.SysDictType, 0) +func (d DictTypeDao) SelectPage(query request.DictTypeQuery) (*[]dataobject.SysDictType, int64) { + list := make([]dataobject.SysDictType, 0) session := refs.SqlDB.NewSession().Table("sys_dict_type") if gotool.StrUtils.HasNotEmpty(query.DictName) { session.And("dict_name like concat('%', ?, '%')", query.DictName) @@ -57,8 +57,8 @@ func (d DictTypeDao) SelectPage(query request.DictTypeQuery) (*[]entity.SysDictT } // SelectById 根据id查询字典类型数据 -func (d DictTypeDao) SelectById(id int64) *entity.SysDictType { - dictType := entity.SysDictType{} +func (d DictTypeDao) SelectById(id int64) *dataobject.SysDictType { + dictType := dataobject.SysDictType{} _, err := refs.SqlDB.NewSession().Where("dict_id = ?", id).Get(&dictType) if err != nil { common.ErrorLog(err) @@ -68,7 +68,7 @@ func (d DictTypeDao) SelectById(id int64) *entity.SysDictType { } // CheckDictTypeUnique 检验字典类型是否存在 -func (d DictTypeDao) CheckDictTypeUnique(dictType entity.SysDictType) int64 { +func (d DictTypeDao) CheckDictTypeUnique(dictType dataobject.SysDictType) int64 { session := refs.SqlDB.NewSession().Table("sys_dict_type") if dictType.DictId > 0 { session.And("dict_id != ?", dictType.DictId) @@ -82,7 +82,7 @@ func (d DictTypeDao) CheckDictTypeUnique(dictType entity.SysDictType) int64 { } // Update 修改字典 -func (d DictTypeDao) Update(dictType entity.SysDictType) bool { +func (d DictTypeDao) Update(dictType dataobject.SysDictType) bool { session := refs.SqlDB.NewSession() session.Begin() _, err := session.Where("dict_id = ?", dictType.DictId).Update(&dictType) @@ -96,7 +96,7 @@ func (d DictTypeDao) Update(dictType entity.SysDictType) bool { } // Insert 新增字典类型 -func (d DictTypeDao) Insert(dictType entity.SysDictType) int64 { +func (d DictTypeDao) Insert(dictType dataobject.SysDictType) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&dictType) @@ -113,7 +113,7 @@ func (d DictTypeDao) Insert(dictType entity.SysDictType) int64 { func (d DictTypeDao) Delete(ids []int64) bool { session := refs.SqlDB.NewSession() session.Begin() - _, err := session.In("dict_id", ids).Delete(entity.SysDictType{}) + _, err := session.In("dict_id", ids).Delete(dataobject.SysDictType{}) if err != nil { session.Rollback() common.ErrorLog(err) diff --git a/modules/core/dao/log_dao.go b/modules/core/dao/log_dao.go index 1dd36aa..dede4a3 100644 --- a/modules/core/dao/log_dao.go +++ b/modules/core/dao/log_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -18,8 +18,8 @@ func (d LogDao) sql(session *xorm.Session) *xorm.Session { } // SelectPage 分页查询数据 -func (d LogDao) SelectPage(query request.LogQuery) ([]entity.SysLog, int64) { - configs := make([]entity.SysLog, 0) +func (d LogDao) SelectPage(query request.LogQuery) ([]dataobject.SysLog, int64) { + configs := make([]dataobject.SysLog, 0) session := d.sql(refs.SqlDB.NewSession()) if gotool.StrUtils.HasNotEmpty(query.Content) { session.And("content like concat('%', ?, '%')", query.Content) @@ -37,7 +37,7 @@ func (d LogDao) SelectPage(query request.LogQuery) ([]entity.SysLog, int64) { } // Insert 添加数据 -func (d LogDao) Insert(config entity.SysLog) int64 { +func (d LogDao) Insert(config dataobject.SysLog) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&config) diff --git a/modules/core/dao/login_info_dao.go b/modules/core/dao/login_info_dao.go index dd89525..3b99d3b 100644 --- a/modules/core/dao/login_info_dao.go +++ b/modules/core/dao/login_info_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -18,8 +18,8 @@ func (d LoginInfoDao) sql(session *xorm.Session) *xorm.Session { } // SelectPage 分页查询数据 -func (d LoginInfoDao) SelectPage(query request.LoginInfoQuery) (*[]entity.SysLoginInfo, int64) { - loginInfos := make([]entity.SysLoginInfo, 0) +func (d LoginInfoDao) SelectPage(query request.LoginInfoQuery) (*[]dataobject.SysLoginInfo, int64) { + loginInfos := make([]dataobject.SysLoginInfo, 0) session := d.sql(refs.SqlDB.NewSession()) session.And("user_name = ?", query.UserName) total, _ := page.GetTotal(session.Clone()) @@ -32,7 +32,7 @@ func (d LoginInfoDao) SelectPage(query request.LoginInfoQuery) (*[]entity.SysLog } // Insert 添加登录记录 -func (d LoginInfoDao) Insert(body entity.SysLoginInfo) *entity.SysLoginInfo { +func (d LoginInfoDao) Insert(body dataobject.SysLoginInfo) *dataobject.SysLoginInfo { session := refs.SqlDB.NewSession() session.Begin() _, err := session.Table("sys_login_info").Insert(&body) diff --git a/modules/core/dao/menu_dao.go b/modules/core/dao/menu_dao.go index b0e8b95..cf42c53 100644 --- a/modules/core/dao/menu_dao.go +++ b/modules/core/dao/menu_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/refs" "github.com/druidcaesa/gotool" @@ -28,9 +28,9 @@ func (d MenuDao) GetMenuPermission(id int64) *[]string { } // GetMenuAll 查询所有菜单数据 -func (d MenuDao) GetMenuAll() *[]entity.SysMenu { - menus := make([]entity.SysMenu, 0) - session := refs.SqlDB.Table([]string{entity.SysMenu{}.TableName(), "m"}) +func (d MenuDao) GetMenuAll() *[]dataobject.SysMenu { + menus := make([]dataobject.SysMenu, 0) + session := refs.SqlDB.Table([]string{dataobject.SysMenu{}.TableName(), "m"}) err := session.Distinct("m.menu_id").Cols("m.parent_id", "m.menu_name", "m.path", "m.component", "m.visible", "m.status", "m.perms", "m.is_frame", "m.is_cache", "m.menu_type", "m.icon", "m.order_num", "m.create_time"). Where("m.menu_type in ('M', 'C')").And("m.status = 0").OrderBy("m.parent_id").OrderBy("m.order_num").Find(&menus) if err != nil { @@ -41,9 +41,9 @@ func (d MenuDao) GetMenuAll() *[]entity.SysMenu { } // GetMenuByUserId 根据用户ID查询菜单 -func (d MenuDao) GetMenuByUserId(id int64) *[]entity.SysMenu { - menus := make([]entity.SysMenu, 0) - session := refs.SqlDB.Table([]string{entity.SysMenu{}.TableName(), "m"}) +func (d MenuDao) GetMenuByUserId(id int64) *[]dataobject.SysMenu { + menus := make([]dataobject.SysMenu, 0) + session := refs.SqlDB.Table([]string{dataobject.SysMenu{}.TableName(), "m"}) err := session.Distinct("m.menu_id").Cols("m.parent_id", "m.menu_name", "m.path", "m.component", "m.visible", "m.status", "m.perms", "m.is_frame", "m.is_cache", "m.menu_type", "m.icon", "m.order_num", "m.create_time"). Join("LEFT", []string{"sys_role_menu", "rm"}, "m.menu_id = rm.menu_id"). Join("LEFT", []string{"sys_user_role", "ur"}, "rm.role_id = ur.role_id"). @@ -75,8 +75,8 @@ func (d MenuDao) SelectMenuByRoleId(id int64, strictly bool) *[]int64 { } // SelectMenuList 查询系统菜单列表 -func (d MenuDao) SelectMenuList(query request.MenuQuery) *[]entity.SysMenu { - list := make([]entity.SysMenu, 0) +func (d MenuDao) SelectMenuList(query request.MenuQuery) *[]dataobject.SysMenu { + list := make([]dataobject.SysMenu, 0) session := refs.SqlDB.NewSession().OrderBy("parent_id").OrderBy("order_num") if gotool.StrUtils.HasNotEmpty(query.MenuName) { session.And("menu_name like concat('%', ?, '%')", query.MenuName) @@ -96,9 +96,9 @@ func (d MenuDao) SelectMenuList(query request.MenuQuery) *[]entity.SysMenu { } // SelectMenuListByUserId 根据用户查询系统菜单列表 -func (d MenuDao) SelectMenuListByUserId(query request.MenuQuery) *[]entity.SysMenu { +func (d MenuDao) SelectMenuListByUserId(query request.MenuQuery) *[]dataobject.SysMenu { session := refs.SqlDB.NewSession().OrderBy("parent_id").OrderBy("order_num") - list := make([]entity.SysMenu, 0) + list := make([]dataobject.SysMenu, 0) session.Distinct("m.menu_id", "m.parent_id", "m.menu_name", "m.path", "m.component", "m.visible", "m.status", "ifnull(m.perms,'') as perms", "m.is_frame", "m.is_cache", "m.menu_type", "m.icon", "m.order_num", "m.create_time") session.Join("LEFT", []string{"sys_role_menu", "rm"}, "m.menu_id = rm.menu_id"). Join("LEFT", []string{"sys_user_role", "ur"}, "rm.role_id = ur.role_id"). @@ -122,8 +122,8 @@ func (d MenuDao) SelectMenuListByUserId(query request.MenuQuery) *[]entity.SysMe } // SelectMenuByMenuId 根据菜单ID查询信息 -func (d MenuDao) SelectMenuByMenuId(id int) *entity.SysMenu { - menu := entity.SysMenu{ +func (d MenuDao) SelectMenuByMenuId(id int) *dataobject.SysMenu { + menu := dataobject.SysMenu{ MenuId: id, } _, err := refs.SqlDB.NewSession().Where("menu_id = ?", menu.MenuId).Get(&menu) @@ -135,7 +135,7 @@ func (d MenuDao) SelectMenuByMenuId(id int) *entity.SysMenu { } // Insert 添加菜单数据 -func (d MenuDao) Insert(menu entity.SysMenu) int64 { +func (d MenuDao) Insert(menu dataobject.SysMenu) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&menu) @@ -149,7 +149,7 @@ func (d MenuDao) Insert(menu entity.SysMenu) int64 { } // Update 修改菜单数据 -func (d MenuDao) Update(menu entity.SysMenu) int64 { +func (d MenuDao) Update(menu dataobject.SysMenu) int64 { session := refs.SqlDB.NewSession() session.Begin() update, err := session.Where("menu_id = ?", menu.MenuId).Update(&menu) @@ -164,7 +164,7 @@ func (d MenuDao) Update(menu entity.SysMenu) int64 { // Delete 删除菜单操作 func (d MenuDao) Delete(id int) int64 { - menu := entity.SysMenu{ + menu := dataobject.SysMenu{ MenuId: id, } session := refs.SqlDB.NewSession() diff --git a/modules/core/dao/notice_dao.go b/modules/core/dao/notice_dao.go index 1e12e47..cf12080 100644 --- a/modules/core/dao/notice_dao.go +++ b/modules/core/dao/notice_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -13,9 +13,9 @@ type NoticeDao struct { } // SelectPage 查询集合 -func (d NoticeDao) SelectPage(query request.NoticeQuery) (*[]entity.SysNotice, int64) { - notices := make([]entity.SysNotice, 0) - session := refs.SqlDB.NewSession().Table(entity.SysNotice{}.TableName()) +func (d NoticeDao) SelectPage(query request.NoticeQuery) (*[]dataobject.SysNotice, int64) { + notices := make([]dataobject.SysNotice, 0) + session := refs.SqlDB.NewSession().Table(dataobject.SysNotice{}.TableName()) if gotool.StrUtils.HasNotEmpty(query.NoticeTitle) { session.And("notice_title like concat('%', ?, '%')", query.NoticeTitle) } @@ -35,7 +35,7 @@ func (d NoticeDao) SelectPage(query request.NoticeQuery) (*[]entity.SysNotice, i } // Insert 添加数据 -func (d NoticeDao) Insert(notice entity.SysNotice) int64 { +func (d NoticeDao) Insert(notice dataobject.SysNotice) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(¬ice) @@ -52,7 +52,7 @@ func (d NoticeDao) Insert(notice entity.SysNotice) int64 { func (d NoticeDao) Delete(list []int64) int64 { session := refs.SqlDB.NewSession() session.Begin() - i, err := session.In("notice_id", list).Delete(&entity.SysNotice{}) + i, err := session.In("notice_id", list).Delete(&dataobject.SysNotice{}) if err != nil { session.Rollback() common.ErrorLog(err) @@ -63,8 +63,8 @@ func (d NoticeDao) Delete(list []int64) int64 { } // SelectById 查询 -func (d NoticeDao) SelectById(id int64) *entity.SysNotice { - notice := entity.SysNotice{} +func (d NoticeDao) SelectById(id int64) *dataobject.SysNotice { + notice := dataobject.SysNotice{} _, err := refs.SqlDB.NewSession().Where("notice_id = ?", id).Get(¬ice) if err != nil { common.ErrorLog(err) @@ -74,7 +74,7 @@ func (d NoticeDao) SelectById(id int64) *entity.SysNotice { } // Update 修改数据 -func (d NoticeDao) Update(notice entity.SysNotice) int64 { +func (d NoticeDao) Update(notice dataobject.SysNotice) int64 { session := refs.SqlDB.NewSession() session.Begin() update, err := session.Where("notice_id = ?", notice.NoticeId).Update(¬ice) diff --git a/modules/core/dao/post_dao.go b/modules/core/dao/post_dao.go index 7d3e4dc..716d29e 100644 --- a/modules/core/dao/post_dao.go +++ b/modules/core/dao/post_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -20,9 +20,9 @@ func (d PostDao) sqlSelectJoin(session *xorm.Session) *xorm.Session { } // SelectAll 查询所有岗位数据, 数据库操作 -func (d PostDao) SelectAll() []*entity.SysPost { +func (d PostDao) SelectAll() []*dataobject.SysPost { session := refs.SqlDB.NewSession() - posts := make([]*entity.SysPost, 0) + posts := make([]*dataobject.SysPost, 0) err := session.Find(&posts) if err != nil { common.ErrorLog(err) @@ -44,9 +44,9 @@ func (d PostDao) SelectPostListByUserId(userId int64) *[]int64 { } // SelectPage 查询岗位分页数据 -func (d PostDao) SelectPage(query request.PostQuery) (*[]entity.SysPost, int64) { - posts := make([]entity.SysPost, 0) - session := refs.SqlDB.NewSession().Table(entity.SysPost{}.TableName()) +func (d PostDao) SelectPage(query request.PostQuery) (*[]dataobject.SysPost, int64) { + posts := make([]dataobject.SysPost, 0) + session := refs.SqlDB.NewSession().Table(dataobject.SysPost{}.TableName()) if gotool.StrUtils.HasNotEmpty(query.PostCode) { session.And("post_code like concat('%', ?, '%')", query.PostCode) } @@ -66,7 +66,7 @@ func (d PostDao) SelectPage(query request.PostQuery) (*[]entity.SysPost, int64) } // CheckPostNameUnique 校验岗位名称是否存在 -func (d PostDao) CheckPostNameUnique(post entity.SysPost) int64 { +func (d PostDao) CheckPostNameUnique(post dataobject.SysPost) int64 { session := refs.SqlDB.NewSession().Table("sys_post").Cols("post_id"). Where("post_name = ?", post.PostName) if post.PostId > 0 { @@ -77,7 +77,7 @@ func (d PostDao) CheckPostNameUnique(post entity.SysPost) int64 { } // CheckPostCodeUnique 校验岗位编码是否存在 -func (d PostDao) CheckPostCodeUnique(post entity.SysPost) int64 { +func (d PostDao) CheckPostCodeUnique(post dataobject.SysPost) int64 { session := refs.SqlDB.NewSession().Table("sys_post").Cols("post_id"). Where("post_code = ?", post.PostCode) if post.PostId > 0 { @@ -88,7 +88,7 @@ func (d PostDao) CheckPostCodeUnique(post entity.SysPost) int64 { } // Insert 添加岗位数据 -func (d PostDao) Insert(post entity.SysPost) int64 { +func (d PostDao) Insert(post dataobject.SysPost) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&post) @@ -102,7 +102,7 @@ func (d PostDao) Insert(post entity.SysPost) int64 { } // GetPostById 根据id查询岗位数据 -func (d PostDao) GetPostById(post entity.SysPost) *entity.SysPost { +func (d PostDao) GetPostById(post dataobject.SysPost) *dataobject.SysPost { _, err := refs.SqlDB.NewSession().Where("post_id = ?", post.PostId).Get(&post) if err != nil { common.ErrorLog(err) @@ -116,7 +116,7 @@ func (d PostDao) Delete(posts []int64) int64 { session := refs.SqlDB.NewSession() session.Begin() - i, err := session.In("post_id", posts).Delete(&entity.SysPost{}) + i, err := session.In("post_id", posts).Delete(&dataobject.SysPost{}) if err != nil { session.Rollback() common.ErrorLog(err) @@ -127,7 +127,7 @@ func (d PostDao) Delete(posts []int64) int64 { } // Update 修改岗位数据 -func (d PostDao) Update(post entity.SysPost) bool { +func (d PostDao) Update(post dataobject.SysPost) bool { session := refs.SqlDB.NewSession() session.Begin() _, err := session.Where("post_id = ?", post.PostId).Update(&post) @@ -140,9 +140,9 @@ func (d PostDao) Update(post entity.SysPost) bool { return true } -func (d PostDao) SelectPostByUserName(name string) *[]entity.SysPost { - posts := make([]entity.SysPost, 0) - session := refs.SqlDB.NewSession().Table([]string{entity.SysPost{}.TableName(), "p"}) +func (d PostDao) SelectPostByUserName(name string) *[]dataobject.SysPost { + posts := make([]dataobject.SysPost, 0) + session := refs.SqlDB.NewSession().Table([]string{dataobject.SysPost{}.TableName(), "p"}) err := session.Cols("p.post_id", "p.post_name", "p.post_code"). Join("LEFT", []string{"sys_user_post", "up"}, "up.post_id = p.post_id"). Join("LEFT", []string{"sys_user", "u"}, "u.user_id = up.user_id").Where("u.user_name = ?", name).Find(&posts) diff --git a/modules/core/dao/role_dao.go b/modules/core/dao/role_dao.go index 1c81f25..17e4eaf 100644 --- a/modules/core/dao/role_dao.go +++ b/modules/core/dao/role_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -15,7 +15,7 @@ type RoleDao struct { // 角色公用sql func (d RoleDao) sqlSelectJoin() *xorm.Session { - return refs.SqlDB.Table([]string{entity.SysRole{}.TableName(), "r"}). + return refs.SqlDB.Table([]string{dataobject.SysRole{}.TableName(), "r"}). Join("LEFT", []string{"sys_user_role", "ur"}, "ur.role_id = r.role_id"). Join("LEFT", []string{"sys_user", "u"}, "u.user_id = ur.user_id"). Join("LEFT", []string{"sys_dept", "d"}, "u.dept_id = d.dept_id") @@ -23,14 +23,14 @@ func (d RoleDao) sqlSelectJoin() *xorm.Session { // 用户角色关系查询sql func (d RoleDao) sqlSelectRoleAndUser() *xorm.Session { - return refs.SqlDB.Table([]string{entity.SysRole{}.TableName(), "r"}). + return refs.SqlDB.Table([]string{dataobject.SysRole{}.TableName(), "r"}). Join("LEFT", []string{"sys_user_role", "ur"}, "ur.role_id = r.role_id"). Join("LEFT", []string{"sys_user", "u"}, "u.user_id = ur.user_id") } // SelectPage 根据条件查询角色数据 -func (d RoleDao) SelectPage(q *request.RoleQuery) ([]*entity.SysRole, int64) { - roles := make([]*entity.SysRole, 0) +func (d RoleDao) SelectPage(q *request.RoleQuery) ([]*dataobject.SysRole, int64) { + roles := make([]*dataobject.SysRole, 0) session := d.sqlSelectJoin() if !gotool.StrUtils.HasEmpty(q.RoleName) { session.And("r.role_name like concat('%', ?, '%')", q.RoleName) @@ -56,9 +56,9 @@ func (d RoleDao) SelectPage(q *request.RoleQuery) ([]*entity.SysRole, int64) { } // SelectAll 查询所有角色 -func (d RoleDao) SelectAll() []*entity.SysRole { +func (d RoleDao) SelectAll() []*dataobject.SysRole { sql := d.sqlSelectJoin() - roles := make([]*entity.SysRole, 0) + roles := make([]*dataobject.SysRole, 0) err := sql.Find(&roles) if err != nil { common.ErrorLog(err) @@ -91,8 +91,8 @@ func (d RoleDao) SelectRolePermissionByUserId(id int64) *[]string { } // GetRoleListByUserId 根据用户ID查询角色 -func (d RoleDao) GetRoleListByUserId(id int64) *[]entity.SysRole { - roles := make([]entity.SysRole, 0) +func (d RoleDao) GetRoleListByUserId(id int64) *[]dataobject.SysRole { + roles := make([]dataobject.SysRole, 0) err := d.sqlSelectJoin().Where("r.del_flag = '0'").And("ur.user_id = ?", id).Find(&roles) if err != nil { common.ErrorLog(err) @@ -102,8 +102,8 @@ func (d RoleDao) GetRoleListByUserId(id int64) *[]entity.SysRole { } // SelectRoleByRoleId 根据角色id查询角色数据 -func (d RoleDao) SelectRoleByRoleId(id int64) *entity.SysRole { - role := entity.SysRole{} +func (d RoleDao) SelectRoleByRoleId(id int64) *dataobject.SysRole { + role := dataobject.SysRole{} _, err := d.sqlSelectJoin().Where("r.role_id = ?", id).Get(&role) if err != nil { common.ErrorLog(err) @@ -113,7 +113,7 @@ func (d RoleDao) SelectRoleByRoleId(id int64) *entity.SysRole { } // CheckRoleNameUnique 校验角色名称是否唯一 -func (d RoleDao) CheckRoleNameUnique(role entity.SysRole) int64 { +func (d RoleDao) CheckRoleNameUnique(role dataobject.SysRole) int64 { session := refs.SqlDB.Table(role.TableName()).Where("role_name = ?", role.RoleName) if role.RoleId > 0 { session.And("role_id != ?", role.RoleId) @@ -126,7 +126,7 @@ func (d RoleDao) CheckRoleNameUnique(role entity.SysRole) int64 { } // CheckRoleKeyUnique 校验角色权限是否唯一 -func (d RoleDao) CheckRoleKeyUnique(role entity.SysRole) int64 { +func (d RoleDao) CheckRoleKeyUnique(role dataobject.SysRole) int64 { session := refs.SqlDB.Table(role.TableName()).Where("role_key = ?", role.RoleKey) if role.RoleId > 0 { session.And("role_id != ?", role.RoleId) @@ -139,7 +139,7 @@ func (d RoleDao) CheckRoleKeyUnique(role entity.SysRole) int64 { } // Add 添加角色进入数据库操作 -func (d RoleDao) Insert(role entity.SysRole) entity.SysRole { +func (d RoleDao) Insert(role dataobject.SysRole) dataobject.SysRole { session := refs.SqlDB.NewSession() session.Begin() _, err := session.Insert(&role) @@ -152,7 +152,7 @@ func (d RoleDao) Insert(role entity.SysRole) entity.SysRole { } // Update 修改数据 -func (d RoleDao) Update(role entity.SysRole) int64 { +func (d RoleDao) Update(role dataobject.SysRole) int64 { session := refs.SqlDB.NewSession() session.Begin() update, err := session.Where("role_id = ?", role.RoleId).Update(&role) @@ -166,7 +166,7 @@ func (d RoleDao) Update(role entity.SysRole) int64 { } // Delete 删除角色 -func (d RoleDao) Delete(role entity.SysRole) int64 { +func (d RoleDao) Delete(role dataobject.SysRole) int64 { session := refs.SqlDB.NewSession() session.Begin() i, err := session.Delete(&role) @@ -180,7 +180,7 @@ func (d RoleDao) Delete(role entity.SysRole) int64 { } // UpdateRoleStatus 修改角色状态 -func (d RoleDao) UpdateRoleStatus(role *entity.SysRole) int64 { +func (d RoleDao) UpdateRoleStatus(role *dataobject.SysRole) int64 { session := refs.SqlDB.NewSession() session.Begin() update, err := session.Where("role_id = ?", role.RoleId).Cols("status", "update_by", "update_time").Update(role) @@ -194,8 +194,8 @@ func (d RoleDao) UpdateRoleStatus(role *entity.SysRole) int64 { } // SelectRolesByUserName 查询角色组 -func (d RoleDao) SelectRolesByUserName(name string) *[]entity.SysRole { - roles := make([]entity.SysRole, 0) +func (d RoleDao) SelectRolesByUserName(name string) *[]dataobject.SysRole { + roles := make([]dataobject.SysRole, 0) session := d.sqlSelectJoin() err := session.Where("r.del_flag = '0'").And("u.user_name = ?", name).Find(&roles) if err != nil { diff --git a/modules/core/dao/role_menu_dao.go b/modules/core/dao/role_menu_dao.go index ea8e826..f9978db 100644 --- a/modules/core/dao/role_menu_dao.go +++ b/modules/core/dao/role_menu_dao.go @@ -1,7 +1,7 @@ package dao import ( - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/refs" ) @@ -10,7 +10,7 @@ type RoleMenuDao struct { } // Insert 添加角色菜单关系 -func (d RoleMenuDao) Insert(list []entity.SysRoleMenu) int64 { +func (d RoleMenuDao) Insert(list []dataobject.SysRoleMenu) int64 { session := refs.SqlDB.NewSession() session.Begin() insert, err := session.Insert(&list) @@ -23,8 +23,8 @@ func (d RoleMenuDao) Insert(list []entity.SysRoleMenu) int64 { } // Delete 删除角色和菜单关系 -func (d RoleMenuDao) Delete(role entity.SysRole) { - menu := entity.SysRoleMenu{ +func (d RoleMenuDao) Delete(role dataobject.SysRole) { + menu := dataobject.SysRoleMenu{ RoleId: role.RoleId, } session := refs.SqlDB.NewSession() diff --git a/modules/core/dao/user_dao.go b/modules/core/dao/user_dao.go index 9e32f61..3c0b654 100644 --- a/modules/core/dao/user_dao.go +++ b/modules/core/dao/user_dao.go @@ -3,7 +3,7 @@ package dao import ( "cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/response" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/page" "cutego/refs" @@ -68,7 +68,7 @@ func (d UserDao) GetUserById(userId int64) *response.UserResponse { } // GetUserByUserName 根据用户名查询用户数据 -func (d UserDao) GetUserByUserName(user entity.SysUser) *entity.SysUser { +func (d UserDao) GetUserByUserName(user dataobject.SysUser) *dataobject.SysUser { i, err := refs.SqlDB.Get(&user) if err != nil { common.ErrorLog(err) @@ -81,8 +81,8 @@ func (d UserDao) GetUserByUserName(user entity.SysUser) *entity.SysUser { } // CheckEmailUnique 校验邮箱是否存在 -func (d UserDao) CheckEmailUnique(user request.UserBody) *entity.SysUser { - sysUser := entity.SysUser{} +func (d UserDao) CheckEmailUnique(user request.UserBody) *dataobject.SysUser { + sysUser := dataobject.SysUser{} session := refs.SqlDB.NewSession().Table("sys_user") session.Cols("user_id", "email") session.Where("email = ?", user.Email) @@ -97,8 +97,8 @@ func (d UserDao) CheckEmailUnique(user request.UserBody) *entity.SysUser { } // CheckPhoneNumUnique 校验手机号是否存在 -func (d UserDao) CheckPhoneNumUnique(body request.UserBody) *entity.SysUser { - sysUser := entity.SysUser{} +func (d UserDao) CheckPhoneNumUnique(body request.UserBody) *dataobject.SysUser { + sysUser := dataobject.SysUser{} session := refs.SqlDB.NewSession().Table("sys_user") session.Cols("user_id", "phone_num") session.Where("phone_num = ?", body.PhoneNumber) @@ -141,7 +141,7 @@ func (d UserDao) Update(body request.UserBody) int64 { // Delete 根据id删除用户数据 func (d UserDao) Delete(id int64) int64 { - user := entity.SysUser{ + user := dataobject.SysUser{ UserId: id, } session := refs.SqlDB.NewSession().Table("sys_user") @@ -157,7 +157,7 @@ func (d UserDao) Delete(id int64) int64 { // ResetPwd 修改用户密码数据库操作 func (d UserDao) ResetPwd(body request.UserBody) int64 { - user := entity.SysUser{ + user := dataobject.SysUser{ UserId: body.UserId, Password: body.Password, } @@ -222,7 +222,7 @@ func (d UserDao) GetUnallocatedList(query request.UserQuery) ([]*response.UserRe // UpdatePwd 修改密码 func (d UserDao) UpdatePwd(id int64, hash string) int64 { - user := entity.SysUser{} + user := dataobject.SysUser{} user.UserId = id user.Password = hash session := refs.SqlDB.NewSession() @@ -239,7 +239,7 @@ func (d UserDao) UpdatePwd(id int64, hash string) int64 { // UpdateAvatar 修改头像 func (d UserDao) UpdateAvatar(info *response.UserResponse) int64 { - user := entity.SysUser{ + user := dataobject.SysUser{ Avatar: info.Avatar, UserId: info.UserId, UpdateBy: info.UserName, @@ -258,7 +258,7 @@ func (d UserDao) UpdateAvatar(info *response.UserResponse) int64 { } func (d UserDao) UpdateStatus(info request.UserBody) int64 { - user := entity.SysUser{ + user := dataobject.SysUser{ UserId: info.UserId, Status: info.Status, UpdateBy: info.UserName, diff --git a/modules/core/dao/user_post_dao.go b/modules/core/dao/user_post_dao.go index a4c7698..680b96b 100644 --- a/modules/core/dao/user_post_dao.go +++ b/modules/core/dao/user_post_dao.go @@ -1,7 +1,7 @@ package dao import ( - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/refs" ) @@ -10,10 +10,10 @@ type UserPostDao struct { } // BatchInsert 批量新增用户岗位信息 -func (d UserPostDao) BatchInsert(posts []entity.SysUserPost) { +func (d UserPostDao) BatchInsert(posts []dataobject.SysUserPost) { session := refs.SqlDB.NewSession() session.Begin() - _, err := session.Table(entity.SysUserPost{}.TableName()).Insert(&posts) + _, err := session.Table(dataobject.SysUserPost{}.TableName()).Insert(&posts) if err != nil { common.ErrorLog(err) session.Rollback() @@ -24,7 +24,7 @@ func (d UserPostDao) BatchInsert(posts []entity.SysUserPost) { // Delete 删除用户和岗位关系 func (d UserPostDao) Delete(id int64) { - post := entity.SysUserPost{ + post := dataobject.SysUserPost{ UserId: id, } session := refs.SqlDB.NewSession() diff --git a/modules/core/dao/user_role_dao.go b/modules/core/dao/user_role_dao.go index e34e608..b8231fa 100644 --- a/modules/core/dao/user_role_dao.go +++ b/modules/core/dao/user_role_dao.go @@ -2,7 +2,7 @@ package dao import ( "cutego/modules/core/api/v1/request" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/refs" ) @@ -11,10 +11,10 @@ type UserRoleDao struct { } // BatchInsert 批量新增用户角色信息 -func (d UserRoleDao) BatchInsert(roles []entity.SysUserRole) { +func (d UserRoleDao) BatchInsert(roles []dataobject.SysUserRole) { session := refs.SqlDB.NewSession() session.Begin() - _, err := session.Table(entity.SysUserRole{}.TableName()).Insert(&roles) + _, err := session.Table(dataobject.SysUserRole{}.TableName()).Insert(&roles) if err != nil { common.ErrorLog(err) session.Rollback() @@ -25,7 +25,7 @@ func (d UserRoleDao) BatchInsert(roles []entity.SysUserRole) { // Delete 删除用户和角色关系 func (d UserRoleDao) Delete(id int64) { - role := entity.SysUserRole{ + role := dataobject.SysUserRole{ UserId: id, } session := refs.SqlDB.NewSession() @@ -40,7 +40,7 @@ func (d UserRoleDao) Delete(id int64) { } // DeleteAuthUser 取消用户授权 -func (d UserRoleDao) DeleteAuthUser(role entity.SysUserRole) int64 { +func (d UserRoleDao) DeleteAuthUser(role dataobject.SysUserRole) int64 { session := refs.SqlDB.NewSession() session.Begin() i, err := session.Delete(&role) @@ -56,9 +56,9 @@ func (d UserRoleDao) DeleteAuthUser(role entity.SysUserRole) int64 { // InsertAuthUsers 批量选择用户授权 func (d UserRoleDao) InsertAuthUsers(body request.UserRoleBody) int64 { ids := body.UserIds - roles := make([]entity.SysUserRole, 0) + roles := make([]dataobject.SysUserRole, 0) for i := 0; i < len(ids); i++ { - role := entity.SysUserRole{ + role := dataobject.SysUserRole{ RoleId: body.RoleId, UserId: ids[i], } diff --git a/pkg/util/token_util.go b/pkg/util/token_util.go index 47d1b28..8a01346 100644 --- a/pkg/util/token_util.go +++ b/pkg/util/token_util.go @@ -2,7 +2,7 @@ package util import ( "cutego/modules/core/api/v1/response" - "cutego/modules/core/entity" + "cutego/modules/core/dataobject" "cutego/pkg/common" "cutego/pkg/config" "cutego/pkg/jwt" @@ -49,7 +49,7 @@ func CheckLockToken(c *gin.Context) bool { } // CheckIsAdmin 判断是否是超级管理员 -func CheckIsAdmin(user *entity.SysUser) bool { +func CheckIsAdmin(user *dataobject.SysUser) bool { if user.UserId == 1 { return true } else {