模块标准化

This commit is contained in:
骑着蜗牛追导弹 2023-01-18 17:21:12 +08:00
parent c44203b176
commit 7c2bdebd0b
16 changed files with 162 additions and 162 deletions

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/constant" "cutego/pkg/constant"
"cutego/pkg/page" "cutego/pkg/page"
@ -19,8 +19,8 @@ func (d ConfigDao) sql(session *xorm.Session) *xorm.Session {
} }
// SelectByConfigKey 根据键名查询参数配置信息 // SelectByConfigKey 根据键名查询参数配置信息
func (d ConfigDao) SelectByConfigKey(configKey string) *entity.SysConfig { func (d ConfigDao) SelectByConfigKey(configKey string) *dataobject.SysConfig {
config := entity.SysConfig{} config := dataobject.SysConfig{}
_, err := d.sql(refs.SqlDB.NewSession()).Where("config_key = ?", configKey).Get(&config) _, err := d.sql(refs.SqlDB.NewSession()).Where("config_key = ?", configKey).Get(&config)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -30,8 +30,8 @@ func (d ConfigDao) SelectByConfigKey(configKey string) *entity.SysConfig {
} }
// SelectPage 分页查询数据 // SelectPage 分页查询数据
func (d ConfigDao) SelectPage(query request.ConfigQuery) (*[]entity.SysConfig, int64) { func (d ConfigDao) SelectPage(query request.ConfigQuery) (*[]dataobject.SysConfig, int64) {
configs := make([]entity.SysConfig, 0) configs := make([]dataobject.SysConfig, 0)
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
if gotool.StrUtils.HasNotEmpty(query.ConfigName) { if gotool.StrUtils.HasNotEmpty(query.ConfigName) {
session.And("config_name like concat('%', ?, '%')", 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 校验是否存在 // CheckConfigKeyUnique 校验是否存在
func (d ConfigDao) CheckConfigKeyUnique(config entity.SysConfig) int64 { func (d ConfigDao) CheckConfigKeyUnique(config dataobject.SysConfig) int64 {
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
if config.ConfigId > 0 { if config.ConfigId > 0 {
session.Where("config_id != ?", config.ConfigId) session.Where("config_id != ?", config.ConfigId)
@ -72,7 +72,7 @@ func (d ConfigDao) CheckConfigKeyUnique(config entity.SysConfig) int64 {
} }
// Insert 添加数据 // Insert 添加数据
func (d ConfigDao) Insert(config entity.SysConfig) int64 { func (d ConfigDao) Insert(config dataobject.SysConfig) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&config) insert, err := session.Insert(&config)
@ -86,8 +86,8 @@ func (d ConfigDao) Insert(config entity.SysConfig) int64 {
} }
// SelectById 查询数据 // SelectById 查询数据
func (d ConfigDao) SelectById(id int64) *entity.SysConfig { func (d ConfigDao) SelectById(id int64) *dataobject.SysConfig {
config := entity.SysConfig{} config := dataobject.SysConfig{}
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
_, err := session.Where("config_id = ?", id).Get(&config) _, err := session.Where("config_id = ?", id).Get(&config)
if err != nil { if err != nil {
@ -98,7 +98,7 @@ func (d ConfigDao) SelectById(id int64) *entity.SysConfig {
} }
// Update 修改数据 // Update 修改数据
func (d ConfigDao) Update(config entity.SysConfig) int64 { func (d ConfigDao) Update(config dataobject.SysConfig) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
update, err := session.Where("config_id = ?", config.ConfigId).Update(&config) update, err := session.Where("config_id = ?", config.ConfigId).Update(&config)
@ -112,8 +112,8 @@ func (d ConfigDao) Update(config entity.SysConfig) int64 {
} }
// CheckConfigByIds 根据id集合查询 // CheckConfigByIds 根据id集合查询
func (d ConfigDao) CheckConfigByIds(list []int64) *[]entity.SysConfig { func (d ConfigDao) CheckConfigByIds(list []int64) *[]dataobject.SysConfig {
configs := make([]entity.SysConfig, 0) configs := make([]dataobject.SysConfig, 0)
err := d.sql(refs.SqlDB.NewSession()).In("config_id", list).Find(&configs) err := d.sql(refs.SqlDB.NewSession()).In("config_id", list).Find(&configs)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -126,7 +126,7 @@ func (d ConfigDao) CheckConfigByIds(list []int64) *[]entity.SysConfig {
func (d ConfigDao) Delete(list []int64) bool { func (d ConfigDao) Delete(list []int64) bool {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.In("config_id", list).Delete(&entity.SysConfig{}) _, err := session.In("config_id", list).Delete(&dataobject.SysConfig{})
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
session.Rollback() session.Rollback()
@ -137,8 +137,8 @@ func (d ConfigDao) Delete(list []int64) bool {
} }
// SelectAll 查询所有数据 // SelectAll 查询所有数据
func (d ConfigDao) SelectAll() *[]entity.SysConfig { func (d ConfigDao) SelectAll() *[]dataobject.SysConfig {
configs := make([]entity.SysConfig, 0) configs := make([]dataobject.SysConfig, 0)
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
err := session.Find(&configs) err := session.Find(&configs)
if err != nil { if err != nil {
@ -152,7 +152,7 @@ func init() {
// 查询配置数据存入到缓存中 // 查询配置数据存入到缓存中
configDao := new(ConfigDao) configDao := new(ConfigDao)
configSession := configDao.sql(refs.SqlDB.NewSession()) configSession := configDao.sql(refs.SqlDB.NewSession())
configs := make([]*entity.SysConfig, 0) configs := make([]*dataobject.SysConfig, 0)
err := configSession.Find(&configs) err := configSession.Find(&configs)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -18,8 +18,8 @@ func (d CronJobDao) sql(session *xorm.Session) *xorm.Session {
} }
// SelectPage 分页查询数据 // SelectPage 分页查询数据
func (d CronJobDao) SelectPage(query request.CronJobQuery) ([]entity.SysCronJob, int64) { func (d CronJobDao) SelectPage(query request.CronJobQuery) ([]dataobject.SysCronJob, int64) {
configs := make([]entity.SysCronJob, 0) configs := make([]dataobject.SysCronJob, 0)
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
if gotool.StrUtils.HasNotEmpty(query.JobName) { if gotool.StrUtils.HasNotEmpty(query.JobName) {
session.And("job_name like concat('%', ?, '%')", query.JobName) session.And("job_name like concat('%', ?, '%')", query.JobName)
@ -37,7 +37,7 @@ func (d CronJobDao) SelectPage(query request.CronJobQuery) ([]entity.SysCronJob,
} }
// Insert 添加数据 // Insert 添加数据
func (d CronJobDao) Insert(config entity.SysCronJob) int64 { func (d CronJobDao) Insert(config dataobject.SysCronJob) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&config) insert, err := session.Insert(&config)
@ -51,8 +51,8 @@ func (d CronJobDao) Insert(config entity.SysCronJob) int64 {
} }
// SelectById 查询数据 // SelectById 查询数据
func (d CronJobDao) SelectById(id int64) *entity.SysCronJob { func (d CronJobDao) SelectById(id int64) *dataobject.SysCronJob {
config := entity.SysCronJob{} config := dataobject.SysCronJob{}
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
_, err := session.Where("job_id = ?", id).Get(&config) _, err := session.Where("job_id = ?", id).Get(&config)
if err != nil { if err != nil {
@ -63,7 +63,7 @@ func (d CronJobDao) SelectById(id int64) *entity.SysCronJob {
} }
// Update 修改数据 // Update 修改数据
func (d CronJobDao) Update(config entity.SysCronJob) int64 { func (d CronJobDao) Update(config dataobject.SysCronJob) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
update, err := session.Where("job_id = ?", config.JobId).Update(&config) 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 { func (d CronJobDao) Delete(list []int64) bool {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.In("job_id", list).Delete(&entity.SysCronJob{}) _, err := session.In("job_id", list).Delete(&dataobject.SysCronJob{})
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
session.Rollback() session.Rollback()
@ -91,8 +91,8 @@ func (d CronJobDao) Delete(list []int64) bool {
} }
// SelectByFuncAlias 通过方法别名获取任务详情 // SelectByFuncAlias 通过方法别名获取任务详情
func (d CronJobDao) SelectByFuncAlias(funcAlias string) *entity.SysCronJob { func (d CronJobDao) SelectByFuncAlias(funcAlias string) *dataobject.SysCronJob {
config := entity.SysCronJob{} config := dataobject.SysCronJob{}
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
_, err := session.Where("func_alias = ?", funcAlias).Get(&config) _, err := session.Where("func_alias = ?", funcAlias).Get(&config)
if err != nil { if err != nil {
@ -103,8 +103,8 @@ func (d CronJobDao) SelectByFuncAlias(funcAlias string) *entity.SysCronJob {
} }
// SelectAll 查找所有启用状态的任务 // SelectAll 查找所有启用状态的任务
func (d CronJobDao) SelectAll() ([]entity.SysCronJob, int) { func (d CronJobDao) SelectAll() ([]dataobject.SysCronJob, int) {
configs := make([]entity.SysCronJob, 0) configs := make([]dataobject.SysCronJob, 0)
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
err := session.Where("status = ?", 1).Find(&configs) err := session.Where("status = ?", 1).Find(&configs)
if err != nil { if err != nil {

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/refs" "cutego/refs"
"github.com/druidcaesa/gotool" "github.com/druidcaesa/gotool"
@ -12,8 +12,8 @@ type DeptDao struct {
} }
// SelectTree 根据条件查询部门集合 // SelectTree 根据条件查询部门集合
func (d DeptDao) SelectTree(query request.DeptQuery) *[]entity.SysDept { func (d DeptDao) SelectTree(query request.DeptQuery) *[]dataobject.SysDept {
depts := make([]entity.SysDept, 0) depts := make([]dataobject.SysDept, 0)
session := refs.SqlDB.NewSession().Where("del_flag = '0'") session := refs.SqlDB.NewSession().Where("del_flag = '0'")
if query.ParentId > 0 { if query.ParentId > 0 {
session.And("parent_id = ?", query.ParentId) session.And("parent_id = ?", query.ParentId)
@ -50,8 +50,8 @@ func (d DeptDao) SelectDeptListByRoleId(id int64, strictly bool) *[]int64 {
} }
// GetList 查询部门列表 // GetList 查询部门列表
func (d DeptDao) GetList(query request.DeptQuery) *[]entity.SysDept { func (d DeptDao) GetList(query request.DeptQuery) *[]dataobject.SysDept {
list := make([]entity.SysDept, 0) list := make([]dataobject.SysDept, 0)
session := refs.SqlDB.NewSession().OrderBy("parent_id").OrderBy("order_num") session := refs.SqlDB.NewSession().OrderBy("parent_id").OrderBy("order_num")
session.Where("del_flag = '0'") session.Where("del_flag = '0'")
if query.ParentId > 0 { if query.ParentId > 0 {
@ -72,8 +72,8 @@ func (d DeptDao) GetList(query request.DeptQuery) *[]entity.SysDept {
} }
// SelectDeptById 根据部门编号获取详细信息 // SelectDeptById 根据部门编号获取详细信息
func (d DeptDao) SelectDeptById(id int) *entity.SysDept { func (d DeptDao) SelectDeptById(id int) *dataobject.SysDept {
dept := entity.SysDept{} dept := dataobject.SysDept{}
_, err := refs.SqlDB.NewSession().Where("dept_id = ?", id).Get(&dept) _, err := refs.SqlDB.NewSession().Where("dept_id = ?", id).Get(&dept)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -83,7 +83,7 @@ func (d DeptDao) SelectDeptById(id int) *entity.SysDept {
} }
// Insert 添加部门数据 // Insert 添加部门数据
func (d DeptDao) Insert(dept entity.SysDept) int64 { func (d DeptDao) Insert(dept dataobject.SysDept) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&dept) insert, err := session.Insert(&dept)
@ -97,7 +97,7 @@ func (d DeptDao) Insert(dept entity.SysDept) int64 {
} }
// CheckDeptNameUnique 校验部门名称是否唯一 // CheckDeptNameUnique 校验部门名称是否唯一
func (d DeptDao) CheckDeptNameUnique(dept entity.SysDept) int64 { func (d DeptDao) CheckDeptNameUnique(dept dataobject.SysDept) int64 {
session := refs.SqlDB.NewSession() 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() 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 { if err != nil {
@ -124,7 +124,7 @@ func (d DeptDao) CheckDeptExistUser(id int) int64 {
// Delete 删除部门 // Delete 删除部门
func (d DeptDao) Delete(id int) int64 { func (d DeptDao) Delete(id int) int64 {
dept := entity.SysDept{ dept := dataobject.SysDept{
DeptId: id, DeptId: id,
} }
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
@ -140,7 +140,7 @@ func (d DeptDao) Delete(id int) int64 {
} }
// Update 更新部门 // Update 更新部门
func (d DeptDao) Update(dept entity.SysDept) int64 { func (d DeptDao) Update(dept dataobject.SysDept) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
update, err := session.Where("dept_id = ?", dept.DeptId).Update(&dept) update, err := session.Where("dept_id = ?", dept.DeptId).Update(&dept)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/constant" "cutego/pkg/constant"
"cutego/pkg/page" "cutego/pkg/page"
@ -20,9 +20,9 @@ func (d *DictDataDao) sql(session *xorm.Session) *xorm.Session {
// SelectByDictType 根据字典类型查询字典数据 // SelectByDictType 根据字典类型查询字典数据
// @Param dictType string 字典类型 // @Param dictType string 字典类型
// @Return []entity.SysDictData // @Return []dataobject.SysDictData
func (d *DictDataDao) SelectByDictType(dictType string) []entity.SysDictData { func (d *DictDataDao) SelectByDictType(dictType string) []dataobject.SysDictData {
data := make([]entity.SysDictData, 0) data := make([]dataobject.SysDictData, 0)
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
err := session.Where("status = '0' ").And("dict_type = ?", dictType).OrderBy("dict_sort").Asc("dict_sort"). err := session.Where("status = '0' ").And("dict_type = ?", dictType).OrderBy("dict_sort").Asc("dict_sort").
Find(&data) Find(&data)
@ -34,10 +34,10 @@ func (d *DictDataDao) SelectByDictType(dictType string) []entity.SysDictData {
} }
// GetDiceDataAll 查询所有字典数据 // GetDiceDataAll 查询所有字典数据
// @Return *[]entity.SysDictData // @Return *[]dataobject.SysDictData
func (d DictDataDao) GetDiceDataAll() *[]entity.SysDictData { func (d DictDataDao) GetDiceDataAll() *[]dataobject.SysDictData {
session := d.sql(refs.SqlDB.NewSession()) 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"). err := session.Where("status = '0' ").OrderBy("dict_sort").Asc("dict_sort").
Find(&data) Find(&data)
if err != nil { if err != nil {
@ -49,10 +49,10 @@ func (d DictDataDao) GetDiceDataAll() *[]entity.SysDictData {
// SelectPage 查询集合数据 // SelectPage 查询集合数据
// @Param query request.DiceDataQuery // @Param query request.DiceDataQuery
// @Return *[]entity.SysDictData // @Return *[]dataobject.SysDictData
// @Return 总行数 // @Return 总行数
func (d *DictDataDao) SelectPage(query request.DiceDataQuery) (*[]entity.SysDictData, int64) { func (d *DictDataDao) SelectPage(query request.DiceDataQuery) (*[]dataobject.SysDictData, int64) {
list := make([]entity.SysDictData, 0) list := make([]dataobject.SysDictData, 0)
session := refs.SqlDB.NewSession().Table("sys_dict_data").OrderBy("dict_sort").Asc("dict_sort") session := refs.SqlDB.NewSession().Table("sys_dict_data").OrderBy("dict_sort").Asc("dict_sort")
if gotool.StrUtils.HasNotEmpty(query.DictType) { if gotool.StrUtils.HasNotEmpty(query.DictType) {
session.And("dict_type = ?", query.DictType) session.And("dict_type = ?", query.DictType)
@ -74,9 +74,9 @@ func (d *DictDataDao) SelectPage(query request.DiceDataQuery) (*[]entity.SysDict
// SelectByDictCode 根据dictCode查询字典数据 // SelectByDictCode 根据dictCode查询字典数据
// @Param dictCode int64 // @Param dictCode int64
// @Return *entity.SysDictData // @Return *dataobject.SysDictData
func (d *DictDataDao) SelectByDictCode(dictCode int64) *entity.SysDictData { func (d *DictDataDao) SelectByDictCode(dictCode int64) *dataobject.SysDictData {
data := entity.SysDictData{} data := dataobject.SysDictData{}
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
_, err := session.Where("dict_code = ?", dictCode).Get(&data) _, err := session.Where("dict_code = ?", dictCode).Get(&data)
if err != nil { if err != nil {
@ -87,9 +87,9 @@ func (d *DictDataDao) SelectByDictCode(dictCode int64) *entity.SysDictData {
} }
// Insert 添加字典数据 // Insert 添加字典数据
// @Param data entity.SysDictData // @Param data dataobject.SysDictData
// @Return 新增的行数 // @Return 新增的行数
func (d *DictDataDao) Insert(data entity.SysDictData) int64 { func (d *DictDataDao) Insert(data dataobject.SysDictData) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&data) insert, err := session.Insert(&data)
@ -106,7 +106,7 @@ func (d *DictDataDao) Insert(data entity.SysDictData) int64 {
func (d *DictDataDao) Delete(codes []int64) bool { func (d *DictDataDao) Delete(codes []int64) bool {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.In("dict_code", codes).Delete(&entity.SysDictData{}) _, err := session.In("dict_code", codes).Delete(&dataobject.SysDictData{})
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
session.Rollback() 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 := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.Where("dict_code = ?", data.DictCode).Update(&data) _, err := session.Where("dict_code = ?", data.DictCode).Update(&data)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -18,8 +18,8 @@ func (d DictTypeDao) sql(session *xorm.Session) *xorm.Session {
} }
// SelectAll 查询所有字典类型数据 // SelectAll 查询所有字典类型数据
func (d DictTypeDao) SelectAll() []*entity.SysDictType { func (d DictTypeDao) SelectAll() []*dataobject.SysDictType {
types := make([]*entity.SysDictType, 0) types := make([]*dataobject.SysDictType, 0)
err := d.sql(refs.SqlDB.NewSession()).Where("status = '0'").Find(&types) err := d.sql(refs.SqlDB.NewSession()).Where("status = '0'").Find(&types)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -29,8 +29,8 @@ func (d DictTypeDao) SelectAll() []*entity.SysDictType {
} }
// SelectPage 分页查询字典类型数据 // SelectPage 分页查询字典类型数据
func (d DictTypeDao) SelectPage(query request.DictTypeQuery) (*[]entity.SysDictType, int64) { func (d DictTypeDao) SelectPage(query request.DictTypeQuery) (*[]dataobject.SysDictType, int64) {
list := make([]entity.SysDictType, 0) list := make([]dataobject.SysDictType, 0)
session := refs.SqlDB.NewSession().Table("sys_dict_type") session := refs.SqlDB.NewSession().Table("sys_dict_type")
if gotool.StrUtils.HasNotEmpty(query.DictName) { if gotool.StrUtils.HasNotEmpty(query.DictName) {
session.And("dict_name like concat('%', ?, '%')", 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查询字典类型数据 // SelectById 根据id查询字典类型数据
func (d DictTypeDao) SelectById(id int64) *entity.SysDictType { func (d DictTypeDao) SelectById(id int64) *dataobject.SysDictType {
dictType := entity.SysDictType{} dictType := dataobject.SysDictType{}
_, err := refs.SqlDB.NewSession().Where("dict_id = ?", id).Get(&dictType) _, err := refs.SqlDB.NewSession().Where("dict_id = ?", id).Get(&dictType)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -68,7 +68,7 @@ func (d DictTypeDao) SelectById(id int64) *entity.SysDictType {
} }
// CheckDictTypeUnique 检验字典类型是否存在 // 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") session := refs.SqlDB.NewSession().Table("sys_dict_type")
if dictType.DictId > 0 { if dictType.DictId > 0 {
session.And("dict_id != ?", dictType.DictId) session.And("dict_id != ?", dictType.DictId)
@ -82,7 +82,7 @@ func (d DictTypeDao) CheckDictTypeUnique(dictType entity.SysDictType) int64 {
} }
// Update 修改字典 // Update 修改字典
func (d DictTypeDao) Update(dictType entity.SysDictType) bool { func (d DictTypeDao) Update(dictType dataobject.SysDictType) bool {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.Where("dict_id = ?", dictType.DictId).Update(&dictType) _, err := session.Where("dict_id = ?", dictType.DictId).Update(&dictType)
@ -96,7 +96,7 @@ func (d DictTypeDao) Update(dictType entity.SysDictType) bool {
} }
// Insert 新增字典类型 // Insert 新增字典类型
func (d DictTypeDao) Insert(dictType entity.SysDictType) int64 { func (d DictTypeDao) Insert(dictType dataobject.SysDictType) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&dictType) insert, err := session.Insert(&dictType)
@ -113,7 +113,7 @@ func (d DictTypeDao) Insert(dictType entity.SysDictType) int64 {
func (d DictTypeDao) Delete(ids []int64) bool { func (d DictTypeDao) Delete(ids []int64) bool {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.In("dict_id", ids).Delete(entity.SysDictType{}) _, err := session.In("dict_id", ids).Delete(dataobject.SysDictType{})
if err != nil { if err != nil {
session.Rollback() session.Rollback()
common.ErrorLog(err) common.ErrorLog(err)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -18,8 +18,8 @@ func (d LogDao) sql(session *xorm.Session) *xorm.Session {
} }
// SelectPage 分页查询数据 // SelectPage 分页查询数据
func (d LogDao) SelectPage(query request.LogQuery) ([]entity.SysLog, int64) { func (d LogDao) SelectPage(query request.LogQuery) ([]dataobject.SysLog, int64) {
configs := make([]entity.SysLog, 0) configs := make([]dataobject.SysLog, 0)
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
if gotool.StrUtils.HasNotEmpty(query.Content) { if gotool.StrUtils.HasNotEmpty(query.Content) {
session.And("content like concat('%', ?, '%')", query.Content) session.And("content like concat('%', ?, '%')", query.Content)
@ -37,7 +37,7 @@ func (d LogDao) SelectPage(query request.LogQuery) ([]entity.SysLog, int64) {
} }
// Insert 添加数据 // Insert 添加数据
func (d LogDao) Insert(config entity.SysLog) int64 { func (d LogDao) Insert(config dataobject.SysLog) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&config) insert, err := session.Insert(&config)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -18,8 +18,8 @@ func (d LoginInfoDao) sql(session *xorm.Session) *xorm.Session {
} }
// SelectPage 分页查询数据 // SelectPage 分页查询数据
func (d LoginInfoDao) SelectPage(query request.LoginInfoQuery) (*[]entity.SysLoginInfo, int64) { func (d LoginInfoDao) SelectPage(query request.LoginInfoQuery) (*[]dataobject.SysLoginInfo, int64) {
loginInfos := make([]entity.SysLoginInfo, 0) loginInfos := make([]dataobject.SysLoginInfo, 0)
session := d.sql(refs.SqlDB.NewSession()) session := d.sql(refs.SqlDB.NewSession())
session.And("user_name = ?", query.UserName) session.And("user_name = ?", query.UserName)
total, _ := page.GetTotal(session.Clone()) total, _ := page.GetTotal(session.Clone())
@ -32,7 +32,7 @@ func (d LoginInfoDao) SelectPage(query request.LoginInfoQuery) (*[]entity.SysLog
} }
// Insert 添加登录记录 // Insert 添加登录记录
func (d LoginInfoDao) Insert(body entity.SysLoginInfo) *entity.SysLoginInfo { func (d LoginInfoDao) Insert(body dataobject.SysLoginInfo) *dataobject.SysLoginInfo {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.Table("sys_login_info").Insert(&body) _, err := session.Table("sys_login_info").Insert(&body)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/refs" "cutego/refs"
"github.com/druidcaesa/gotool" "github.com/druidcaesa/gotool"
@ -28,9 +28,9 @@ func (d MenuDao) GetMenuPermission(id int64) *[]string {
} }
// GetMenuAll 查询所有菜单数据 // GetMenuAll 查询所有菜单数据
func (d MenuDao) GetMenuAll() *[]entity.SysMenu { func (d MenuDao) GetMenuAll() *[]dataobject.SysMenu {
menus := make([]entity.SysMenu, 0) menus := make([]dataobject.SysMenu, 0)
session := refs.SqlDB.Table([]string{entity.SysMenu{}.TableName(), "m"}) 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"). 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) Where("m.menu_type in ('M', 'C')").And("m.status = 0").OrderBy("m.parent_id").OrderBy("m.order_num").Find(&menus)
if err != nil { if err != nil {
@ -41,9 +41,9 @@ func (d MenuDao) GetMenuAll() *[]entity.SysMenu {
} }
// GetMenuByUserId 根据用户ID查询菜单 // GetMenuByUserId 根据用户ID查询菜单
func (d MenuDao) GetMenuByUserId(id int64) *[]entity.SysMenu { func (d MenuDao) GetMenuByUserId(id int64) *[]dataobject.SysMenu {
menus := make([]entity.SysMenu, 0) menus := make([]dataobject.SysMenu, 0)
session := refs.SqlDB.Table([]string{entity.SysMenu{}.TableName(), "m"}) 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"). 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_role_menu", "rm"}, "m.menu_id = rm.menu_id").
Join("LEFT", []string{"sys_user_role", "ur"}, "rm.role_id = ur.role_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 查询系统菜单列表 // SelectMenuList 查询系统菜单列表
func (d MenuDao) SelectMenuList(query request.MenuQuery) *[]entity.SysMenu { func (d MenuDao) SelectMenuList(query request.MenuQuery) *[]dataobject.SysMenu {
list := make([]entity.SysMenu, 0) list := make([]dataobject.SysMenu, 0)
session := refs.SqlDB.NewSession().OrderBy("parent_id").OrderBy("order_num") session := refs.SqlDB.NewSession().OrderBy("parent_id").OrderBy("order_num")
if gotool.StrUtils.HasNotEmpty(query.MenuName) { if gotool.StrUtils.HasNotEmpty(query.MenuName) {
session.And("menu_name like concat('%', ?, '%')", query.MenuName) session.And("menu_name like concat('%', ?, '%')", query.MenuName)
@ -96,9 +96,9 @@ func (d MenuDao) SelectMenuList(query request.MenuQuery) *[]entity.SysMenu {
} }
// SelectMenuListByUserId 根据用户查询系统菜单列表 // 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") 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.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"). 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"). 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查询信息 // SelectMenuByMenuId 根据菜单ID查询信息
func (d MenuDao) SelectMenuByMenuId(id int) *entity.SysMenu { func (d MenuDao) SelectMenuByMenuId(id int) *dataobject.SysMenu {
menu := entity.SysMenu{ menu := dataobject.SysMenu{
MenuId: id, MenuId: id,
} }
_, err := refs.SqlDB.NewSession().Where("menu_id = ?", menu.MenuId).Get(&menu) _, err := refs.SqlDB.NewSession().Where("menu_id = ?", menu.MenuId).Get(&menu)
@ -135,7 +135,7 @@ func (d MenuDao) SelectMenuByMenuId(id int) *entity.SysMenu {
} }
// Insert 添加菜单数据 // Insert 添加菜单数据
func (d MenuDao) Insert(menu entity.SysMenu) int64 { func (d MenuDao) Insert(menu dataobject.SysMenu) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&menu) insert, err := session.Insert(&menu)
@ -149,7 +149,7 @@ func (d MenuDao) Insert(menu entity.SysMenu) int64 {
} }
// Update 修改菜单数据 // Update 修改菜单数据
func (d MenuDao) Update(menu entity.SysMenu) int64 { func (d MenuDao) Update(menu dataobject.SysMenu) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
update, err := session.Where("menu_id = ?", menu.MenuId).Update(&menu) update, err := session.Where("menu_id = ?", menu.MenuId).Update(&menu)
@ -164,7 +164,7 @@ func (d MenuDao) Update(menu entity.SysMenu) int64 {
// Delete 删除菜单操作 // Delete 删除菜单操作
func (d MenuDao) Delete(id int) int64 { func (d MenuDao) Delete(id int) int64 {
menu := entity.SysMenu{ menu := dataobject.SysMenu{
MenuId: id, MenuId: id,
} }
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -13,9 +13,9 @@ type NoticeDao struct {
} }
// SelectPage 查询集合 // SelectPage 查询集合
func (d NoticeDao) SelectPage(query request.NoticeQuery) (*[]entity.SysNotice, int64) { func (d NoticeDao) SelectPage(query request.NoticeQuery) (*[]dataobject.SysNotice, int64) {
notices := make([]entity.SysNotice, 0) notices := make([]dataobject.SysNotice, 0)
session := refs.SqlDB.NewSession().Table(entity.SysNotice{}.TableName()) session := refs.SqlDB.NewSession().Table(dataobject.SysNotice{}.TableName())
if gotool.StrUtils.HasNotEmpty(query.NoticeTitle) { if gotool.StrUtils.HasNotEmpty(query.NoticeTitle) {
session.And("notice_title like concat('%', ?, '%')", 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 添加数据 // Insert 添加数据
func (d NoticeDao) Insert(notice entity.SysNotice) int64 { func (d NoticeDao) Insert(notice dataobject.SysNotice) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&notice) insert, err := session.Insert(&notice)
@ -52,7 +52,7 @@ func (d NoticeDao) Insert(notice entity.SysNotice) int64 {
func (d NoticeDao) Delete(list []int64) int64 { func (d NoticeDao) Delete(list []int64) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() 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 { if err != nil {
session.Rollback() session.Rollback()
common.ErrorLog(err) common.ErrorLog(err)
@ -63,8 +63,8 @@ func (d NoticeDao) Delete(list []int64) int64 {
} }
// SelectById 查询 // SelectById 查询
func (d NoticeDao) SelectById(id int64) *entity.SysNotice { func (d NoticeDao) SelectById(id int64) *dataobject.SysNotice {
notice := entity.SysNotice{} notice := dataobject.SysNotice{}
_, err := refs.SqlDB.NewSession().Where("notice_id = ?", id).Get(&notice) _, err := refs.SqlDB.NewSession().Where("notice_id = ?", id).Get(&notice)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -74,7 +74,7 @@ func (d NoticeDao) SelectById(id int64) *entity.SysNotice {
} }
// Update 修改数据 // Update 修改数据
func (d NoticeDao) Update(notice entity.SysNotice) int64 { func (d NoticeDao) Update(notice dataobject.SysNotice) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
update, err := session.Where("notice_id = ?", notice.NoticeId).Update(&notice) update, err := session.Where("notice_id = ?", notice.NoticeId).Update(&notice)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -20,9 +20,9 @@ func (d PostDao) sqlSelectJoin(session *xorm.Session) *xorm.Session {
} }
// SelectAll 查询所有岗位数据, 数据库操作 // SelectAll 查询所有岗位数据, 数据库操作
func (d PostDao) SelectAll() []*entity.SysPost { func (d PostDao) SelectAll() []*dataobject.SysPost {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
posts := make([]*entity.SysPost, 0) posts := make([]*dataobject.SysPost, 0)
err := session.Find(&posts) err := session.Find(&posts)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -44,9 +44,9 @@ func (d PostDao) SelectPostListByUserId(userId int64) *[]int64 {
} }
// SelectPage 查询岗位分页数据 // SelectPage 查询岗位分页数据
func (d PostDao) SelectPage(query request.PostQuery) (*[]entity.SysPost, int64) { func (d PostDao) SelectPage(query request.PostQuery) (*[]dataobject.SysPost, int64) {
posts := make([]entity.SysPost, 0) posts := make([]dataobject.SysPost, 0)
session := refs.SqlDB.NewSession().Table(entity.SysPost{}.TableName()) session := refs.SqlDB.NewSession().Table(dataobject.SysPost{}.TableName())
if gotool.StrUtils.HasNotEmpty(query.PostCode) { if gotool.StrUtils.HasNotEmpty(query.PostCode) {
session.And("post_code like concat('%', ?, '%')", 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 校验岗位名称是否存在 // 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"). session := refs.SqlDB.NewSession().Table("sys_post").Cols("post_id").
Where("post_name = ?", post.PostName) Where("post_name = ?", post.PostName)
if post.PostId > 0 { if post.PostId > 0 {
@ -77,7 +77,7 @@ func (d PostDao) CheckPostNameUnique(post entity.SysPost) int64 {
} }
// CheckPostCodeUnique 校验岗位编码是否存在 // 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"). session := refs.SqlDB.NewSession().Table("sys_post").Cols("post_id").
Where("post_code = ?", post.PostCode) Where("post_code = ?", post.PostCode)
if post.PostId > 0 { if post.PostId > 0 {
@ -88,7 +88,7 @@ func (d PostDao) CheckPostCodeUnique(post entity.SysPost) int64 {
} }
// Insert 添加岗位数据 // Insert 添加岗位数据
func (d PostDao) Insert(post entity.SysPost) int64 { func (d PostDao) Insert(post dataobject.SysPost) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&post) insert, err := session.Insert(&post)
@ -102,7 +102,7 @@ func (d PostDao) Insert(post entity.SysPost) int64 {
} }
// GetPostById 根据id查询岗位数据 // 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) _, err := refs.SqlDB.NewSession().Where("post_id = ?", post.PostId).Get(&post)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -116,7 +116,7 @@ func (d PostDao) Delete(posts []int64) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() 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 { if err != nil {
session.Rollback() session.Rollback()
common.ErrorLog(err) common.ErrorLog(err)
@ -127,7 +127,7 @@ func (d PostDao) Delete(posts []int64) int64 {
} }
// Update 修改岗位数据 // Update 修改岗位数据
func (d PostDao) Update(post entity.SysPost) bool { func (d PostDao) Update(post dataobject.SysPost) bool {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.Where("post_id = ?", post.PostId).Update(&post) _, err := session.Where("post_id = ?", post.PostId).Update(&post)
@ -140,9 +140,9 @@ func (d PostDao) Update(post entity.SysPost) bool {
return true return true
} }
func (d PostDao) SelectPostByUserName(name string) *[]entity.SysPost { func (d PostDao) SelectPostByUserName(name string) *[]dataobject.SysPost {
posts := make([]entity.SysPost, 0) posts := make([]dataobject.SysPost, 0)
session := refs.SqlDB.NewSession().Table([]string{entity.SysPost{}.TableName(), "p"}) session := refs.SqlDB.NewSession().Table([]string{dataobject.SysPost{}.TableName(), "p"})
err := session.Cols("p.post_id", "p.post_name", "p.post_code"). 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_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) Join("LEFT", []string{"sys_user", "u"}, "u.user_id = up.user_id").Where("u.user_name = ?", name).Find(&posts)

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -15,7 +15,7 @@ type RoleDao struct {
// 角色公用sql // 角色公用sql
func (d RoleDao) sqlSelectJoin() *xorm.Session { 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_role", "ur"}, "ur.role_id = r.role_id").
Join("LEFT", []string{"sys_user", "u"}, "u.user_id = ur.user_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") Join("LEFT", []string{"sys_dept", "d"}, "u.dept_id = d.dept_id")
@ -23,14 +23,14 @@ func (d RoleDao) sqlSelectJoin() *xorm.Session {
// 用户角色关系查询sql // 用户角色关系查询sql
func (d RoleDao) sqlSelectRoleAndUser() *xorm.Session { 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_role", "ur"}, "ur.role_id = r.role_id").
Join("LEFT", []string{"sys_user", "u"}, "u.user_id = ur.user_id") Join("LEFT", []string{"sys_user", "u"}, "u.user_id = ur.user_id")
} }
// SelectPage 根据条件查询角色数据 // SelectPage 根据条件查询角色数据
func (d RoleDao) SelectPage(q *request.RoleQuery) ([]*entity.SysRole, int64) { func (d RoleDao) SelectPage(q *request.RoleQuery) ([]*dataobject.SysRole, int64) {
roles := make([]*entity.SysRole, 0) roles := make([]*dataobject.SysRole, 0)
session := d.sqlSelectJoin() session := d.sqlSelectJoin()
if !gotool.StrUtils.HasEmpty(q.RoleName) { if !gotool.StrUtils.HasEmpty(q.RoleName) {
session.And("r.role_name like concat('%', ?, '%')", 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 查询所有角色 // SelectAll 查询所有角色
func (d RoleDao) SelectAll() []*entity.SysRole { func (d RoleDao) SelectAll() []*dataobject.SysRole {
sql := d.sqlSelectJoin() sql := d.sqlSelectJoin()
roles := make([]*entity.SysRole, 0) roles := make([]*dataobject.SysRole, 0)
err := sql.Find(&roles) err := sql.Find(&roles)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -91,8 +91,8 @@ func (d RoleDao) SelectRolePermissionByUserId(id int64) *[]string {
} }
// GetRoleListByUserId 根据用户ID查询角色 // GetRoleListByUserId 根据用户ID查询角色
func (d RoleDao) GetRoleListByUserId(id int64) *[]entity.SysRole { func (d RoleDao) GetRoleListByUserId(id int64) *[]dataobject.SysRole {
roles := make([]entity.SysRole, 0) roles := make([]dataobject.SysRole, 0)
err := d.sqlSelectJoin().Where("r.del_flag = '0'").And("ur.user_id = ?", id).Find(&roles) err := d.sqlSelectJoin().Where("r.del_flag = '0'").And("ur.user_id = ?", id).Find(&roles)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -102,8 +102,8 @@ func (d RoleDao) GetRoleListByUserId(id int64) *[]entity.SysRole {
} }
// SelectRoleByRoleId 根据角色id查询角色数据 // SelectRoleByRoleId 根据角色id查询角色数据
func (d RoleDao) SelectRoleByRoleId(id int64) *entity.SysRole { func (d RoleDao) SelectRoleByRoleId(id int64) *dataobject.SysRole {
role := entity.SysRole{} role := dataobject.SysRole{}
_, err := d.sqlSelectJoin().Where("r.role_id = ?", id).Get(&role) _, err := d.sqlSelectJoin().Where("r.role_id = ?", id).Get(&role)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -113,7 +113,7 @@ func (d RoleDao) SelectRoleByRoleId(id int64) *entity.SysRole {
} }
// CheckRoleNameUnique 校验角色名称是否唯一 // 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) session := refs.SqlDB.Table(role.TableName()).Where("role_name = ?", role.RoleName)
if role.RoleId > 0 { if role.RoleId > 0 {
session.And("role_id != ?", role.RoleId) session.And("role_id != ?", role.RoleId)
@ -126,7 +126,7 @@ func (d RoleDao) CheckRoleNameUnique(role entity.SysRole) int64 {
} }
// CheckRoleKeyUnique 校验角色权限是否唯一 // 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) session := refs.SqlDB.Table(role.TableName()).Where("role_key = ?", role.RoleKey)
if role.RoleId > 0 { if role.RoleId > 0 {
session.And("role_id != ?", role.RoleId) session.And("role_id != ?", role.RoleId)
@ -139,7 +139,7 @@ func (d RoleDao) CheckRoleKeyUnique(role entity.SysRole) int64 {
} }
// Add 添加角色进入数据库操作 // Add 添加角色进入数据库操作
func (d RoleDao) Insert(role entity.SysRole) entity.SysRole { func (d RoleDao) Insert(role dataobject.SysRole) dataobject.SysRole {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.Insert(&role) _, err := session.Insert(&role)
@ -152,7 +152,7 @@ func (d RoleDao) Insert(role entity.SysRole) entity.SysRole {
} }
// Update 修改数据 // Update 修改数据
func (d RoleDao) Update(role entity.SysRole) int64 { func (d RoleDao) Update(role dataobject.SysRole) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
update, err := session.Where("role_id = ?", role.RoleId).Update(&role) update, err := session.Where("role_id = ?", role.RoleId).Update(&role)
@ -166,7 +166,7 @@ func (d RoleDao) Update(role entity.SysRole) int64 {
} }
// Delete 删除角色 // Delete 删除角色
func (d RoleDao) Delete(role entity.SysRole) int64 { func (d RoleDao) Delete(role dataobject.SysRole) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
i, err := session.Delete(&role) i, err := session.Delete(&role)
@ -180,7 +180,7 @@ func (d RoleDao) Delete(role entity.SysRole) int64 {
} }
// UpdateRoleStatus 修改角色状态 // UpdateRoleStatus 修改角色状态
func (d RoleDao) UpdateRoleStatus(role *entity.SysRole) int64 { func (d RoleDao) UpdateRoleStatus(role *dataobject.SysRole) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
update, err := session.Where("role_id = ?", role.RoleId).Cols("status", "update_by", "update_time").Update(role) 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 查询角色组 // SelectRolesByUserName 查询角色组
func (d RoleDao) SelectRolesByUserName(name string) *[]entity.SysRole { func (d RoleDao) SelectRolesByUserName(name string) *[]dataobject.SysRole {
roles := make([]entity.SysRole, 0) roles := make([]dataobject.SysRole, 0)
session := d.sqlSelectJoin() session := d.sqlSelectJoin()
err := session.Where("r.del_flag = '0'").And("u.user_name = ?", name).Find(&roles) err := session.Where("r.del_flag = '0'").And("u.user_name = ?", name).Find(&roles)
if err != nil { if err != nil {

View File

@ -1,7 +1,7 @@
package dao package dao
import ( import (
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/refs" "cutego/refs"
) )
@ -10,7 +10,7 @@ type RoleMenuDao struct {
} }
// Insert 添加角色菜单关系 // Insert 添加角色菜单关系
func (d RoleMenuDao) Insert(list []entity.SysRoleMenu) int64 { func (d RoleMenuDao) Insert(list []dataobject.SysRoleMenu) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
insert, err := session.Insert(&list) insert, err := session.Insert(&list)
@ -23,8 +23,8 @@ func (d RoleMenuDao) Insert(list []entity.SysRoleMenu) int64 {
} }
// Delete 删除角色和菜单关系 // Delete 删除角色和菜单关系
func (d RoleMenuDao) Delete(role entity.SysRole) { func (d RoleMenuDao) Delete(role dataobject.SysRole) {
menu := entity.SysRoleMenu{ menu := dataobject.SysRoleMenu{
RoleId: role.RoleId, RoleId: role.RoleId,
} }
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()

View File

@ -3,7 +3,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/api/v1/response" "cutego/modules/core/api/v1/response"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/page" "cutego/pkg/page"
"cutego/refs" "cutego/refs"
@ -68,7 +68,7 @@ func (d UserDao) GetUserById(userId int64) *response.UserResponse {
} }
// GetUserByUserName 根据用户名查询用户数据 // 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) i, err := refs.SqlDB.Get(&user)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
@ -81,8 +81,8 @@ func (d UserDao) GetUserByUserName(user entity.SysUser) *entity.SysUser {
} }
// CheckEmailUnique 校验邮箱是否存在 // CheckEmailUnique 校验邮箱是否存在
func (d UserDao) CheckEmailUnique(user request.UserBody) *entity.SysUser { func (d UserDao) CheckEmailUnique(user request.UserBody) *dataobject.SysUser {
sysUser := entity.SysUser{} sysUser := dataobject.SysUser{}
session := refs.SqlDB.NewSession().Table("sys_user") session := refs.SqlDB.NewSession().Table("sys_user")
session.Cols("user_id", "email") session.Cols("user_id", "email")
session.Where("email = ?", user.Email) session.Where("email = ?", user.Email)
@ -97,8 +97,8 @@ func (d UserDao) CheckEmailUnique(user request.UserBody) *entity.SysUser {
} }
// CheckPhoneNumUnique 校验手机号是否存在 // CheckPhoneNumUnique 校验手机号是否存在
func (d UserDao) CheckPhoneNumUnique(body request.UserBody) *entity.SysUser { func (d UserDao) CheckPhoneNumUnique(body request.UserBody) *dataobject.SysUser {
sysUser := entity.SysUser{} sysUser := dataobject.SysUser{}
session := refs.SqlDB.NewSession().Table("sys_user") session := refs.SqlDB.NewSession().Table("sys_user")
session.Cols("user_id", "phone_num") session.Cols("user_id", "phone_num")
session.Where("phone_num = ?", body.PhoneNumber) session.Where("phone_num = ?", body.PhoneNumber)
@ -141,7 +141,7 @@ func (d UserDao) Update(body request.UserBody) int64 {
// Delete 根据id删除用户数据 // Delete 根据id删除用户数据
func (d UserDao) Delete(id int64) int64 { func (d UserDao) Delete(id int64) int64 {
user := entity.SysUser{ user := dataobject.SysUser{
UserId: id, UserId: id,
} }
session := refs.SqlDB.NewSession().Table("sys_user") session := refs.SqlDB.NewSession().Table("sys_user")
@ -157,7 +157,7 @@ func (d UserDao) Delete(id int64) int64 {
// ResetPwd 修改用户密码数据库操作 // ResetPwd 修改用户密码数据库操作
func (d UserDao) ResetPwd(body request.UserBody) int64 { func (d UserDao) ResetPwd(body request.UserBody) int64 {
user := entity.SysUser{ user := dataobject.SysUser{
UserId: body.UserId, UserId: body.UserId,
Password: body.Password, Password: body.Password,
} }
@ -222,7 +222,7 @@ func (d UserDao) GetUnallocatedList(query request.UserQuery) ([]*response.UserRe
// UpdatePwd 修改密码 // UpdatePwd 修改密码
func (d UserDao) UpdatePwd(id int64, hash string) int64 { func (d UserDao) UpdatePwd(id int64, hash string) int64 {
user := entity.SysUser{} user := dataobject.SysUser{}
user.UserId = id user.UserId = id
user.Password = hash user.Password = hash
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
@ -239,7 +239,7 @@ func (d UserDao) UpdatePwd(id int64, hash string) int64 {
// UpdateAvatar 修改头像 // UpdateAvatar 修改头像
func (d UserDao) UpdateAvatar(info *response.UserResponse) int64 { func (d UserDao) UpdateAvatar(info *response.UserResponse) int64 {
user := entity.SysUser{ user := dataobject.SysUser{
Avatar: info.Avatar, Avatar: info.Avatar,
UserId: info.UserId, UserId: info.UserId,
UpdateBy: info.UserName, UpdateBy: info.UserName,
@ -258,7 +258,7 @@ func (d UserDao) UpdateAvatar(info *response.UserResponse) int64 {
} }
func (d UserDao) UpdateStatus(info request.UserBody) int64 { func (d UserDao) UpdateStatus(info request.UserBody) int64 {
user := entity.SysUser{ user := dataobject.SysUser{
UserId: info.UserId, UserId: info.UserId,
Status: info.Status, Status: info.Status,
UpdateBy: info.UserName, UpdateBy: info.UserName,

View File

@ -1,7 +1,7 @@
package dao package dao
import ( import (
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/refs" "cutego/refs"
) )
@ -10,10 +10,10 @@ type UserPostDao struct {
} }
// BatchInsert 批量新增用户岗位信息 // BatchInsert 批量新增用户岗位信息
func (d UserPostDao) BatchInsert(posts []entity.SysUserPost) { func (d UserPostDao) BatchInsert(posts []dataobject.SysUserPost) {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.Table(entity.SysUserPost{}.TableName()).Insert(&posts) _, err := session.Table(dataobject.SysUserPost{}.TableName()).Insert(&posts)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
session.Rollback() session.Rollback()
@ -24,7 +24,7 @@ func (d UserPostDao) BatchInsert(posts []entity.SysUserPost) {
// Delete 删除用户和岗位关系 // Delete 删除用户和岗位关系
func (d UserPostDao) Delete(id int64) { func (d UserPostDao) Delete(id int64) {
post := entity.SysUserPost{ post := dataobject.SysUserPost{
UserId: id, UserId: id,
} }
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()

View File

@ -2,7 +2,7 @@ package dao
import ( import (
"cutego/modules/core/api/v1/request" "cutego/modules/core/api/v1/request"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/refs" "cutego/refs"
) )
@ -11,10 +11,10 @@ type UserRoleDao struct {
} }
// BatchInsert 批量新增用户角色信息 // BatchInsert 批量新增用户角色信息
func (d UserRoleDao) BatchInsert(roles []entity.SysUserRole) { func (d UserRoleDao) BatchInsert(roles []dataobject.SysUserRole) {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
_, err := session.Table(entity.SysUserRole{}.TableName()).Insert(&roles) _, err := session.Table(dataobject.SysUserRole{}.TableName()).Insert(&roles)
if err != nil { if err != nil {
common.ErrorLog(err) common.ErrorLog(err)
session.Rollback() session.Rollback()
@ -25,7 +25,7 @@ func (d UserRoleDao) BatchInsert(roles []entity.SysUserRole) {
// Delete 删除用户和角色关系 // Delete 删除用户和角色关系
func (d UserRoleDao) Delete(id int64) { func (d UserRoleDao) Delete(id int64) {
role := entity.SysUserRole{ role := dataobject.SysUserRole{
UserId: id, UserId: id,
} }
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
@ -40,7 +40,7 @@ func (d UserRoleDao) Delete(id int64) {
} }
// DeleteAuthUser 取消用户授权 // DeleteAuthUser 取消用户授权
func (d UserRoleDao) DeleteAuthUser(role entity.SysUserRole) int64 { func (d UserRoleDao) DeleteAuthUser(role dataobject.SysUserRole) int64 {
session := refs.SqlDB.NewSession() session := refs.SqlDB.NewSession()
session.Begin() session.Begin()
i, err := session.Delete(&role) i, err := session.Delete(&role)
@ -56,9 +56,9 @@ func (d UserRoleDao) DeleteAuthUser(role entity.SysUserRole) int64 {
// InsertAuthUsers 批量选择用户授权 // InsertAuthUsers 批量选择用户授权
func (d UserRoleDao) InsertAuthUsers(body request.UserRoleBody) int64 { func (d UserRoleDao) InsertAuthUsers(body request.UserRoleBody) int64 {
ids := body.UserIds ids := body.UserIds
roles := make([]entity.SysUserRole, 0) roles := make([]dataobject.SysUserRole, 0)
for i := 0; i < len(ids); i++ { for i := 0; i < len(ids); i++ {
role := entity.SysUserRole{ role := dataobject.SysUserRole{
RoleId: body.RoleId, RoleId: body.RoleId,
UserId: ids[i], UserId: ids[i],
} }

View File

@ -2,7 +2,7 @@ package util
import ( import (
"cutego/modules/core/api/v1/response" "cutego/modules/core/api/v1/response"
"cutego/modules/core/entity" "cutego/modules/core/dataobject"
"cutego/pkg/common" "cutego/pkg/common"
"cutego/pkg/config" "cutego/pkg/config"
"cutego/pkg/jwt" "cutego/pkg/jwt"
@ -49,7 +49,7 @@ func CheckLockToken(c *gin.Context) bool {
} }
// CheckIsAdmin 判断是否是超级管理员 // CheckIsAdmin 判断是否是超级管理员
func CheckIsAdmin(user *entity.SysUser) bool { func CheckIsAdmin(user *dataobject.SysUser) bool {
if user.UserId == 1 { if user.UserId == 1 {
return true return true
} else { } else {