feat:完善信息

This commit is contained in:
henry
2021-10-27 13:27:01 +08:00
parent d4ab041711
commit 70ba3078b3
20 changed files with 717 additions and 68 deletions

View File

@ -60,7 +60,7 @@ func (a *Account) Register(c *gin.Context) {
api.APIResponse(err, data)(c)
}
func (a *Account) BindMobile() {
func (a *Account) BindMobile(c *gin.Context) {
//account.NewOther()().BindMobile()
}
@ -72,6 +72,6 @@ func (a *Account) Logout(c *gin.Context) {
if handle != nil {
session = handle.(*service.SessionEnterprise)
}
err := account2.NewLogout()(session, api.GetLocal()(c).(uint64)).Launch()
err := account2.NewLogout()(session).Launch()
api.APIResponse(err)(c)
}

View File

@ -0,0 +1,25 @@
package api
import (
"SciencesServer/app/api/enterprise/controller/identity"
"SciencesServer/app/basic/api"
"SciencesServer/app/service"
"github.com/gin-gonic/gin"
)
type Identity struct{}
func (*Identity) Expert(c *gin.Context) {
form := &struct {
Name string `json:"name" form:"name"`
Mobile string `json:"mobile" form:"mobile"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := identity.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Expert(form.Name, form.Mobile, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}

View File

@ -1,3 +0,0 @@
package api
type Tenant struct{}

View File

@ -42,7 +42,7 @@ func (a *User) Detail(c *gin.Context) {
api.APIResponse(err, data)(c)
}
func (a *Tenant) SettledCompany(c *gin.Context) {
func (a *User) SettledCompany(c *gin.Context) {
form := &struct {
userSettledForm
}{}
@ -57,7 +57,7 @@ func (a *Tenant) SettledCompany(c *gin.Context) {
api.APIResponse(err)(c)
}
func (a *Tenant) SettledExpert(c *gin.Context) {
func (a *User) SettledExpert(c *gin.Context) {
form := &struct {
userSettledForm
config.IdentityForExpert
@ -67,12 +67,13 @@ func (a *Tenant) SettledExpert(c *gin.Context) {
return
}
err := user2.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Expert(&user2.SettledParams{
ID: form.Convert(), Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
ID: form.Convert(), Area: form.Area, Introduce: form.Introduce, Industry: form.Industry,
Keywords: form.Keywords,
}, &form.IdentityForExpert)
api.APIResponse(err)(c)
}
func (a *Tenant) SettledResearch(c *gin.Context) {
func (a *User) SettledResearch(c *gin.Context) {
form := &struct {
userSettledForm
config.IdentityForResearch
@ -88,7 +89,7 @@ func (a *Tenant) SettledResearch(c *gin.Context) {
api.APIResponse(err)(c)
}
func (a *Tenant) SettledLaboratory(c *gin.Context) {
func (a *User) SettledLaboratory(c *gin.Context) {
form := &struct {
userSettledForm
config.IdentityForLaboratory
@ -117,7 +118,7 @@ func (a *User) SwitchIdentity(c *gin.Context) {
}
func (a *User) Back(c *gin.Context) {
data, err := user2.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).List()
data, err := user2.NewBank()(api.GetSession()(c).(*service.SessionEnterprise)).List()
api.APIResponse(err, data)
}
@ -128,11 +129,11 @@ func (a *User) BackBind(c *gin.Context) {
api.APIFailure(err.(error))(c)
return
}
err := user2.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).Bind(&user2.BackParams{
err := user2.NewBank()(api.GetSession()(c).(*service.SessionEnterprise)).Bind(&user2.BankParams{
Name: form.Name,
IDCard: form.IDCard,
BackCard: form.BackCard,
BackName: form.BackName,
BankCard: form.BackCard,
BankName: form.BackName,
}, form.Captcha)
api.APIResponse(err)
}
@ -144,6 +145,6 @@ func (a *User) BackUnbind(c *gin.Context) {
api.APIFailure(err.(error))(c)
return
}
err := user2.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).Unbind(form.Convert())
err := user2.NewBank()(api.GetSession()(c).(*service.SessionEnterprise)).Unbind(form.Convert())
api.APIResponse(err)
}

View File

@ -8,18 +8,19 @@ import (
type Logout struct {
*service.SessionEnterprise
local uint64
}
type LogoutHandle func(enterprise *service.SessionEnterprise, local uint64) *Logout
type LogoutHandle func(enterprise *service.SessionEnterprise) *Logout
func (c *Logout) Launch() error {
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
if c.UID > 0 {
service.Publish(config.EventForRedisHashDestroy, config.RedisKeyForAccount, utils.UintToString(c.UID))
}
return nil
}
func NewLogout() LogoutHandle {
return func(enterprise *service.SessionEnterprise, local uint64) *Logout {
return &Logout{enterprise, local}
return func(enterprise *service.SessionEnterprise) *Logout {
return &Logout{enterprise}
}
}

View File

@ -13,8 +13,8 @@ func (c *Config) Basic() {
}
// Config 配置信息
func (c *Config) Config() {
func (c *Config) Config() map[string]interface{} {
return config2.SystemConfig
}
// Identity 身份信息

View File

@ -1,7 +1,9 @@
package identity
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/api/manage/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
)
@ -12,12 +14,46 @@ type Instance struct {
type InstanceHandle func(enterprise *service.SessionEnterprise, local string) *Instance
type (
// InstanceForExpert 专家信息
InstanceForExpert struct {
*model.UserManageForExpert
ID string `json:"id"`
}
)
// Expert 专家列表
func (c *Instance) Expert(name, mobile string, page, pageSize int) (*controller.ReturnPages, error) {
return nil, nil
mUserManage := model.NewUserManage()
where := make([]*model2.ModelWhere, 0)
if name != "" {
where = append(where, model2.NewWhereLike("m.name", name))
}
if mobile != "" {
where = append(where, model2.NewWhereLike("u.mobile", mobile))
}
var count int64
out, err := mUserManage.Expert(page, pageSize, &count, where...)
if err != nil {
return nil, err
}
list := make([]*InstanceForExpert, 0)
for _, v := range out {
mUserManage.ID = v.ID
list = append(list, &InstanceForExpert{
UserManageForExpert: v, ID: mUserManage.GetEncodeID(),
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
}
func NewIdentity() InstanceHandle {
func NewInstance() InstanceHandle {
return func(enterprise *service.SessionEnterprise, local string) *Instance {
return &Instance{
SessionEnterprise: enterprise,

View File

@ -9,37 +9,37 @@ import (
"errors"
)
type Back struct {
type Bank struct {
*service.SessionEnterprise
}
type BackHandle func(enterprise *service.SessionEnterprise) *Back
type BankHandle func(enterprise *service.SessionEnterprise) *Bank
type (
// BackInfo 银行卡信息
BackInfo struct {
// BankInfo 银行卡信息
BankInfo struct {
ID string `json:"id"`
*model2.UserManageBank
}
// BackParams 银行卡参数信息
BackParams struct {
Name, IDCard, BackCard, BackName string
// BankParams 银行卡参数信息
BankParams struct {
Name, IDCard, BankCard, BankName string
}
)
// checkIDCard 验证身份证号
func (c *BackParams) checkIDCard() bool {
func (c *BankParams) checkIDCard() bool {
return utils.ValidateIDCard(c.IDCard)
}
// checkBankCard 验证银行卡号
func (c *BackParams) checkBankCard() bool {
func (c *BankParams) checkBankCard() bool {
return true
}
// List 列表信息
func (c *Back) List() ([]*BackInfo, error) {
mUserManageBack := model.NewUserManageBank()
func (c *Bank) List() ([]*BankInfo, error) {
mUserManageBank := model.NewUserManageBank()
out := make([]*model2.UserManageBank, 0)
@ -47,19 +47,19 @@ func (c *Back) List() ([]*BackInfo, error) {
Where: model2.NewWhere("uid", c.ManageUID),
Order: model2.NewOrder("is_default", model2.OrderModeToDesc),
}}
if err := model2.Find(mUserManageBack.UserManageBank, &out, where...); err != nil {
if err := model2.Find(mUserManageBank.UserManageBank, &out, where...); err != nil {
return nil, err
}
list := make([]*BackInfo, 0)
list := make([]*BankInfo, 0)
for _, v := range out {
list = append(list, &BackInfo{ID: v.GetEncodeID(), UserManageBank: v})
list = append(list, &BankInfo{ID: v.GetEncodeID(), UserManageBank: v})
}
return list, nil
}
// Bind 绑定
func (c *Back) Bind(params *BackParams, captcha string) error {
func (c *Bank) Bind(params *BankParams, captcha string) error {
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
Mobile: c.Mobile, Captcha: captcha,
})
@ -75,48 +75,48 @@ func (c *Back) Bind(params *BackParams, captcha string) error {
if !params.checkBankCard() {
return errors.New("银行卡信息错误")
}
mUserManageBack := model.NewUserManageBank()
mUserManageBank := model.NewUserManageBank()
var count int64
if err = model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("back_card", params.BackCard)); err != nil {
if err = model2.Count(mUserManageBank.UserManageBank, &count, model2.NewWhere("bank_card", params.BankCard)); err != nil {
return err
} else if count > 0 {
return errors.New("当前银行卡已被注册")
}
mUserManageBack.UID = c.ManageUID
mUserManageBack.Name = params.Name
mUserManageBack.IDCard = params.IDCard
mUserManageBack.BankCard = params.BackCard
mUserManageBack.BackName = params.BackName
mUserManageBank.UID = c.ManageUID
mUserManageBank.Name = params.Name
mUserManageBank.IDCard = params.IDCard
mUserManageBank.BankCard = params.BankCard
mUserManageBank.BankName = params.BankName
if err = model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("uid", c.ManageUID)); err != nil {
if err = model2.Count(mUserManageBank.UserManageBank, &count, model2.NewWhere("uid", c.ManageUID)); err != nil {
return err
} else if count <= 0 {
mUserManageBack.IsDefault = model2.UserManageBankDefaultForYes
mUserManageBank.IsDefault = model2.UserManageBankDefaultForYes
}
return model2.Create(mUserManageBack.UserManageBank)
return model2.Create(mUserManageBank.UserManageBank)
}
// Unbind 解绑,直接删除
func (c *Back) Unbind(id uint64) error {
mUserManageBack := model.NewUserManageBank()
mUserManageBack.ID = id
func (c *Bank) Unbind(id uint64) error {
mUserManageBank := model.NewUserManageBank()
mUserManageBank.ID = id
isExist, err := model2.FirstField(mUserManageBack.UserManageBank, []string{"id", "uid"})
isExist, err := model2.FirstField(mUserManageBank.UserManageBank, []string{"id", "uid"})
if err != nil {
return err
} else if !isExist {
return errors.New("操作错误,绑定信息不存在")
} else if mUserManageBack.UID != c.ManageUID {
} else if mUserManageBank.UID != c.ManageUID {
return errors.New("无权限操作")
}
return model2.Delete(mUserManageBack)
return model2.Delete(mUserManageBank)
}
func NewBack() BackHandle {
return func(enterprise *service.SessionEnterprise) *Back {
return &Back{enterprise}
func NewBank() BankHandle {
return func(enterprise *service.SessionEnterprise) *Bank {
return &Bank{enterprise}
}
}

View File

@ -1,13 +1,50 @@
package model
import (
"SciencesServer/app/basic/config"
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
"strings"
)
type UserManage struct {
*model.UserManage
}
type (
// UserManageForExpert 专家信息
UserManageForExpert struct {
ID uint64 `json:"id"`
Name string `json:"name"`
Mobile string `json:"mobile"`
}
)
// Expert 专家数据
func (m *UserManage) Expert(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*UserManageForExpert, error) {
query := orm.GetDB().Table(m.TableName()+" AS m").
Select(strings.Join([]string{"m.id", "m.name", "u.mobile"}, ",")).
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON m.uid = u.uuid", model.NewUserInstance().TableName())).
Where("m.is_deleted = ?", model.DeleteStatusForNot).
Where("m.identity = ?", config.TenantUserIdentityForExpert)
out := make([]*UserManageForExpert, 0)
if len(where) > 0 {
for _, v := range where {
query = query.Where(v.Condition, v.Value)
}
}
if err := query.Count(count).Error; err != nil {
return nil, err
}
if err := query.Order("m.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
// LastChooseInfo 最后一次选中的信息
func (m *UserManage) LastChooseInfo(uid uint64) error {
_, err := model.FirstField(m.UserManage, []string{"id", "tenant_id", "uuid", "identity"},

View File

@ -0,0 +1,13 @@
package controller
import "SciencesServer/app/service"
type Config struct{ *service.Session }
type ConfigHandle func(session *service.Session) *Config
func NewConfig() ConfigHandle {
return func(session *service.Session) *Config {
return &Config{Session: session}
}
}

View File

@ -0,0 +1,19 @@
package controller
import "SciencesServer/app/service"
type Index struct {
*service.Session
local string
}
type IndexHandle func(session *service.Session, local string) *Index
func NewIndex() IndexHandle {
return func(session *service.Session, local string) *Index {
return &Index{
Session: session,
local: local,
}
}
}

View File

@ -3,6 +3,7 @@ package api
import (
"SciencesServer/config"
"SciencesServer/lib"
"strings"
"github.com/gin-gonic/gin"
)
@ -51,8 +52,9 @@ func (a *Upload) Upload(c *gin.Context) {
}
resp := new(lib.UploadHandle)
if resp, err = lib.Upload(config.SettingInfo.Upload.Path, config.SettingInfo.Upload.Exts, config.SettingInfo.Upload.Size,
config.SettingInfo.Upload.Rename).Handle()(file, config.SettingInfo.Domain); err != nil {
if resp, err = lib.Upload(config.SystemConfig[config.UploadPath].(string),
strings.Split(config.SystemConfig[config.UploadExt].(string), ","), config.SystemConfig[config.UploadSize].(int64),
config.SystemConfig[config.UploadRename].(int) > 0).Handle()(file, config.SettingInfo.Domain); err != nil {
APIFailure(err)(c)
return
}

View File

@ -28,13 +28,13 @@ type (
IdentityForResearch struct {
Longitude float64 `json:"longitude" form:"longitude"` // 经度
Latitude float64 `json:"latitude" form:"latitude"` // 纬度
Research string `json:"research" form:"research"` // 研究方向
Research string `json:"research" form:"research"` // 研究领域方向
}
// IdentityForLaboratory 实验室
IdentityForLaboratory struct {
TenantID uint64 `json:"tenant_id" form:"tenant_id"`
Longitude float64 `json:"longitude" form:"longitude"` // 经度
Latitude float64 `json:"latitude" form:"latitude"` // 纬度
Research map[int]string `json:"research" form:"research"` // 研究方向
Research map[int]string `json:"research" form:"research"` // 研究领域方向
}
)

View File

@ -45,8 +45,12 @@ func initModel() {
&synchronized{iModel: model.NewSysUserTenant()},
&synchronized{iModel: model.NewSysDepartment()},
&synchronized{iModel: model.NewSysRole()}, &synchronized{iModel: model.NewSysRoleMenu()}, &synchronized{iModel: model.NewSysRoleAuth()},
&synchronized{iModel: model.NewSysUserRole()},
// 配置管理
&synchronized{iModel: model.NewSysConfig(), iValues: func() interface{} {
return nil
}},
// 日志管理
&synchronized{iModel: model.NewSysUserRole()},
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
)
}

View File

@ -13,7 +13,7 @@ type ManageExpert struct {
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Area
Position string `gorm:"column:position;type:varchar(50);default:null;comment:坐标" json:"-"`
School string `gorm:"column:school;type:varchar(50);default:null;comment:坐标" json:"school"`
School string `gorm:"column:school;type:varchar(50);default:null;comment:院校" json:"school"`
Major string `gorm:"column:major;type:varchar(50);default:null;comment:专业" json:"major"`
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
Title string `gorm:"column:title;type:varchar(50);default:null;comment:职称" json:"title"`

View File

@ -8,7 +8,7 @@ type UserManageBank struct {
Name string `gorm:"column:name;type:varchar(30);default:null;comment:姓名" json:"name"`
IDCard string `gorm:"column:id_card;type:varchar(18);default:null;comment:身份证号" json:"id_card"`
BankCard string `gorm:"column:bank_card;type:varchar(18);default:null;comment:银行卡号" json:"bank_card"`
BackName string `gorm:"column:back_name;type:varchar(15);default:null;comment:银行名称" json:"back_name"`
BankName string `gorm:"column:bank_name;type:varchar(15);default:null;comment:银行名称" json:"bank_name"`
IsDefault UserManageBankDefault `gorm:"column:is_default;type:tinyint(1);default:0;comment:默认使用0不默认1默认" json:"-"`
ModelDeleted
ModelAt

View File

@ -4,7 +4,6 @@ import "SciencesServer/app/common/model"
type SysLogProduce struct{}
// Handle
func (this *SysLogProduce) Handle(arg ...interface{}) {
tenantID := arg[0].(uint64)
uid := arg[1].(uint64)