Browse Source

feature: 项目管理相关接口开发

ZZH-wl 3 năm trước cách đây
mục cha
commit
6bc160af64

+ 3 - 0
opms_parent/app/dao/proj/internal/proj_business_dynamics.go

@@ -27,6 +27,7 @@ type ProjBusinessDynamicsDao struct {
 // ProjBusinessDynamicsColumns defines and stores column names for table proj_business_dynamics.
 type projBusinessDynamicsColumns struct {
 	Id          string // 主键
+	BusId       string // 关联项目
 	OpnPeopleId string // 操作人ID
 	OpnPeople   string // 操作人
 	OpnDate     string // 操作日期
@@ -50,6 +51,7 @@ var (
 		Table: "proj_business_dynamics",
 		Columns: projBusinessDynamicsColumns{
 			Id:          "id",
+			BusId:       "bus_id",
 			OpnPeopleId: "opn_people_id",
 			OpnPeople:   "opn_people",
 			OpnDate:     "opn_date",
@@ -75,6 +77,7 @@ func NewProjBusinessDynamicsDao(tenant string) ProjBusinessDynamicsDao {
 		Table: "proj_business_dynamics",
 		Columns: projBusinessDynamicsColumns{
 			Id:          "id",
+			BusId:       "bus_id",
 			OpnPeopleId: "opn_people_id",
 			OpnPeople:   "opn_people",
 			OpnDate:     "opn_date",

+ 3 - 0
opms_parent/app/dao/proj/internal/proj_business_file.go

@@ -31,6 +31,7 @@ type projBusinessFileColumns struct {
 	FileName    string // 附件名称
 	FileSize    string // 附件大小
 	FileSource  string // 来源
+	FileUrl     string // 附件链接
 	Remark      string // 备注
 	CreatedBy   string // 创建者
 	CreatedName string // 创建人
@@ -53,6 +54,7 @@ var (
 			FileName:    "file_name",
 			FileSize:    "file_size",
 			FileSource:  "file_source",
+			FileUrl:     "file_url",
 			Remark:      "remark",
 			CreatedBy:   "created_by",
 			CreatedName: "created_name",
@@ -77,6 +79,7 @@ func NewProjBusinessFileDao(tenant string) ProjBusinessFileDao {
 			FileName:    "file_name",
 			FileSize:    "file_size",
 			FileSource:  "file_source",
+			FileUrl:     "file_url",
 			Remark:      "remark",
 			CreatedBy:   "created_by",
 			CreatedName: "created_name",

+ 435 - 0
opms_parent/app/dao/proj/internal/proj_business_team.go

@@ -0,0 +1,435 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+	"time"
+
+	model "dashoo.cn/micro/app/model/proj"
+)
+
+// ProjBusinessTeamDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type ProjBusinessTeamDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns projBusinessTeamColumns
+}
+
+// ProjBusinessTeamColumns defines and stores column names for table proj_business_team.
+type projBusinessTeamColumns struct {
+	Id           string // 主键
+	BusId        string // 关联项目
+	UserId       string // 关联用户
+	Role         string // 团队角色
+	Permission   string // 权限
+	DeadlineTime string // 截止时间
+	Remark       string // 备注
+	CreatedBy    string // 创建者
+	CreatedName  string // 创建人
+	CreatedTime  string // 创建时间
+	UpdatedBy    string // 更新者
+	UpdatedName  string // 更新人
+	UpdatedTime  string // 更新时间
+	DeletedTime  string // 删除时间
+}
+
+var (
+	// ProjBusinessTeam is globally public accessible object for table proj_business_team operations.
+	ProjBusinessTeam = ProjBusinessTeamDao{
+		M:     g.DB("default").Model("proj_business_team").Safe(),
+		DB:    g.DB("default"),
+		Table: "proj_business_team",
+		Columns: projBusinessTeamColumns{
+			Id:           "id",
+			BusId:        "bus_id",
+			UserId:       "user_id",
+			Role:         "role",
+			Permission:   "permission",
+			DeadlineTime: "deadline_time",
+			Remark:       "remark",
+			CreatedBy:    "created_by",
+			CreatedName:  "created_name",
+			CreatedTime:  "created_time",
+			UpdatedBy:    "updated_by",
+			UpdatedName:  "updated_name",
+			UpdatedTime:  "updated_time",
+			DeletedTime:  "deleted_time",
+		},
+	}
+)
+
+func NewProjBusinessTeamDao(tenant string) ProjBusinessTeamDao {
+	var dao ProjBusinessTeamDao
+	dao = ProjBusinessTeamDao{
+		M:     g.DB(tenant).Model("proj_business_team").Safe(),
+		DB:    g.DB(tenant),
+		Table: "proj_business_team",
+		Columns: projBusinessTeamColumns{
+			Id:           "id",
+			BusId:        "bus_id",
+			UserId:       "user_id",
+			Role:         "role",
+			Permission:   "permission",
+			DeadlineTime: "deadline_time",
+			Remark:       "remark",
+			CreatedBy:    "created_by",
+			CreatedName:  "created_name",
+			CreatedTime:  "created_time",
+			UpdatedBy:    "updated_by",
+			UpdatedName:  "updated_name",
+			UpdatedTime:  "updated_time",
+			DeletedTime:  "deleted_time",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *ProjBusinessTeamDao) Ctx(ctx context.Context) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *ProjBusinessTeamDao) As(as string) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *ProjBusinessTeamDao) TX(tx *gdb.TX) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *ProjBusinessTeamDao) Master() *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *ProjBusinessTeamDao) Slave() *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *ProjBusinessTeamDao) Args(args ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *ProjBusinessTeamDao) LeftJoin(table ...string) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *ProjBusinessTeamDao) RightJoin(table ...string) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *ProjBusinessTeamDao) InnerJoin(table ...string) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *ProjBusinessTeamDao) Fields(fieldNamesOrMapStruct ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *ProjBusinessTeamDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *ProjBusinessTeamDao) Option(option int) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *ProjBusinessTeamDao) OmitEmpty() *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *ProjBusinessTeamDao) Filter() *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *ProjBusinessTeamDao) Where(where interface{}, args ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *ProjBusinessTeamDao) WherePri(where interface{}, args ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *ProjBusinessTeamDao) And(where interface{}, args ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *ProjBusinessTeamDao) Or(where interface{}, args ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *ProjBusinessTeamDao) Group(groupBy string) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *ProjBusinessTeamDao) Order(orderBy ...string) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *ProjBusinessTeamDao) Limit(limit ...int) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *ProjBusinessTeamDao) Offset(offset int) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *ProjBusinessTeamDao) Page(page, limit int) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *ProjBusinessTeamDao) Batch(batch int) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *ProjBusinessTeamDao) Cache(duration time.Duration, name ...string) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *ProjBusinessTeamDao) Data(data ...interface{}) *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.ProjBusinessTeam.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *ProjBusinessTeamDao) All(where ...interface{}) ([]*model.ProjBusinessTeam, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.ProjBusinessTeam
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.ProjBusinessTeam.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *ProjBusinessTeamDao) One(where ...interface{}) (*model.ProjBusinessTeam, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.ProjBusinessTeam
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *ProjBusinessTeamDao) FindOne(where ...interface{}) (*model.ProjBusinessTeam, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.ProjBusinessTeam
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *ProjBusinessTeamDao) FindAll(where ...interface{}) ([]*model.ProjBusinessTeam, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.ProjBusinessTeam
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *ProjBusinessTeamDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *ProjBusinessTeamDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *ProjBusinessTeamDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *ProjBusinessTeamDao) Chunk(limit int, callback func(entities []*model.ProjBusinessTeam, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.ProjBusinessTeam
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *ProjBusinessTeamDao) LockUpdate() *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *ProjBusinessTeamDao) LockShared() *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *ProjBusinessTeamDao) Unscoped() *ProjBusinessTeamDao {
+	return &ProjBusinessTeamDao{M: d.M.Unscoped()}
+}

+ 36 - 0
opms_parent/app/dao/proj/proj_business_team.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package dao
+
+import (
+	"dashoo.cn/micro/app/dao/proj/internal"
+)
+
+// projBusinessTeamDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type projBusinessTeamDao struct {
+	internal.ProjBusinessTeamDao
+}
+
+var (
+	// ProjBusinessTeam is globally public accessible object for table proj_business_team operations.
+	ProjBusinessTeam = projBusinessTeamDao{
+		internal.ProjBusinessTeam,
+	}
+)
+
+type ProjBusinessTeamDao struct {
+	internal.ProjBusinessTeamDao
+}
+
+func NewProjBusinessTeamDao(tenant string) *ProjBusinessTeamDao {
+	dao := internal.NewProjBusinessTeamDao(tenant)
+	return &ProjBusinessTeamDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 36 - 0
opms_parent/app/handler/proj/business.go

@@ -112,3 +112,39 @@ func (p *BusinessHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq,
 	}
 	return nil
 }
+
+// BusinessGradation 业务调级
+func (p *BusinessHandler) BusinessGradation(ctx context.Context, req *projModel.BusinessGradationReq, rsp *comm_def.CommonMsg) error {
+	// 参数校验
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
+	}
+	businessService, err := projSrv.NewBusinessService(ctx)
+	if err != nil {
+		return gerror.New("系统异常,请重新尝试")
+	}
+	err = businessService.BusinessGradation(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+// BusinessTransfer 项目转移
+func (p *BusinessHandler) BusinessTransfer(ctx context.Context, req *projModel.BusinessTransferReq, rsp *comm_def.CommonMsg) error {
+	// 参数校验
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
+	}
+	businessService, err := projSrv.NewBusinessService(ctx)
+	if err != nil {
+		return gerror.New("系统异常,请重新尝试")
+	}
+	err = businessService.BusinessTransfer(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 62 - 0
opms_parent/app/handler/proj/business_contact.go

@@ -0,0 +1,62 @@
+package base
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/opms_libary/myerrors"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/util/gvalid"
+
+	projModel "dashoo.cn/micro/app/model/proj"
+	projSrv "dashoo.cn/micro/app/service/proj"
+)
+
+type BusinessContactHandler struct{}
+
+func (p *BusinessContactHandler) GetList(ctx context.Context, req *projModel.BusinessReq, rsp *comm_def.CommonMsg) error {
+	if req.BusId == 0 {
+		return gerror.New("参数为空,操作失败")
+	}
+	contactService, err := projSrv.NewBusinessContactService(ctx)
+	if err != nil {
+		return err
+	}
+	list, err := contactService.GetList(req.BusId)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Data = list
+	return nil
+}
+
+func (p *BusinessContactHandler) Create(ctx context.Context, req *projModel.BusinessContactReq, rsp *comm_def.CommonMsg) error {
+	// 参数校验
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
+	}
+	contactService, err := projSrv.NewBusinessContactService(ctx)
+	if err != nil {
+		return err
+	}
+	err = contactService.Create(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func (p *BusinessContactHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq, rsp *comm_def.CommonMsg) error {
+	// 参数校验
+	if len(req.Ids) == 0 {
+		return gerror.New("参数为空,操作失败")
+	}
+	contactService, err := projSrv.NewBusinessContactService(ctx)
+	if err != nil {
+		return gerror.New("系统异常,请重新尝试")
+	}
+	err = contactService.DeleteByIds(req.Ids)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	return err
+}

+ 7 - 6
opms_parent/app/handler/proj/business_dynamics.go

@@ -2,8 +2,7 @@ package base
 
 import (
 	"context"
-
-	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/errors/gerror"
 
 	"dashoo.cn/common_definition/comm_def"
 	"dashoo.cn/opms_libary/myerrors"
@@ -15,17 +14,19 @@ import (
 type BusinessDynamicsHandler struct{}
 
 // GetList 获取列表
-func (p *BusinessDynamicsHandler) GetList(ctx context.Context, req *projModel.ProjBusinessSearchReq, rsp *comm_def.CommonMsg) error {
+func (p *BusinessDynamicsHandler) GetList(ctx context.Context, req *projModel.BusinessReq, rsp *comm_def.CommonMsg) error {
+	if req.BusId == 0 {
+		return gerror.New("参数为空,操作失败")
+	}
 	businessService, err := projSrv.NewBusinessDynamicsService(ctx)
 	if err != nil {
 		return err
 	}
-	g.Log().Info("搜索值", req)
-	total, list, err := businessService.GetList(req)
+	list, err := businessService.GetList(req.BusId)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		return err
 	}
-	rsp.Data = g.Map{"list": list, "total": total}
+	rsp.Data = list
 	return nil
 }

+ 6 - 7
opms_parent/app/handler/proj/business_file.go

@@ -5,7 +5,6 @@ import (
 	"dashoo.cn/common_definition/comm_def"
 	"dashoo.cn/opms_libary/myerrors"
 	"github.com/gogf/gf/errors/gerror"
-	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/util/gvalid"
 
 	projModel "dashoo.cn/micro/app/model/proj"
@@ -15,18 +14,20 @@ import (
 type BusinessFileHandler struct{}
 
 // GetList 获取列表
-func (p *BusinessFileHandler) GetList(ctx context.Context, req *projModel.ProjBusinessSearchReq, rsp *comm_def.CommonMsg) error {
+func (p *BusinessFileHandler) GetList(ctx context.Context, req *projModel.BusinessReq, rsp *comm_def.CommonMsg) error {
+	if req.BusId == 0 {
+		return gerror.New("参数为空,操作失败")
+	}
 	businessService, err := projSrv.NewBusinessFileService(ctx)
 	if err != nil {
 		return err
 	}
-	g.Log().Info("搜索值", req)
-	total, list, err := businessService.GetList()
+	list, err := businessService.GetList(req.BusId)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		return err
 	}
-	rsp.Data = g.Map{"list": list, "total": total}
+	rsp.Data = list
 	return nil
 }
 
@@ -38,13 +39,11 @@ func (p *BusinessFileHandler) Create(ctx context.Context, req *projModel.ProjBus
 	}
 	businessService, err := projSrv.NewBusinessFileService(ctx)
 	if err != nil {
-		g.Log().Error(err)
 		return err
 	}
 	err = businessService.Create(req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
-		g.Log().Error(err)
 		return err
 	}
 	return nil

+ 63 - 0
opms_parent/app/handler/proj/business_team.go

@@ -0,0 +1,63 @@
+package base
+
+import (
+	"context"
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/opms_libary/myerrors"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/util/gvalid"
+
+	projModel "dashoo.cn/micro/app/model/proj"
+	projSrv "dashoo.cn/micro/app/service/proj"
+)
+
+type BusinessTeamHandler struct{}
+
+// GetList 获取列表
+func (p *BusinessTeamHandler) GetList(ctx context.Context, req *projModel.BusinessReq, rsp *comm_def.CommonMsg) error {
+	if req.BusId == 0 {
+		return gerror.New("参数为空,操作失败")
+	}
+	teamService, err := projSrv.NewBusinessTeamService(ctx)
+	if err != nil {
+		return err
+	}
+	list, err := teamService.GetList(req.BusId)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	rsp.Data = list
+	return nil
+}
+
+func (p *BusinessTeamHandler) Create(ctx context.Context, req *projModel.BusinessTeamReq, rsp *comm_def.CommonMsg) error {
+	// 参数校验
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
+	}
+	teamService, err := projSrv.NewBusinessTeamService(ctx)
+	if err != nil {
+		return err
+	}
+	err = teamService.Create(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func (p *BusinessTeamHandler) DeleteByIds(ctx context.Context, req *comm_def.IdsReq, rsp *comm_def.CommonMsg) error {
+	// 参数校验
+	if len(req.Ids) == 0 {
+		return gerror.New("参数为空,操作失败")
+	}
+	teamService, err := projSrv.NewBusinessTeamService(ctx)
+	if err != nil {
+		return gerror.New("系统异常,请重新尝试")
+	}
+	err = teamService.DeleteByIds(req.Ids)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	return err
+}

+ 1 - 0
opms_parent/app/model/proj/internal/proj_business_dynamics.go

@@ -11,6 +11,7 @@ import (
 // ProjBusinessDynamics is the golang structure for table proj_business_dynamics.
 type ProjBusinessDynamics struct {
 	Id          int         `orm:"id,primary"    json:"id"`          // 主键
+	BusId       int         `orm:"bus_id"        json:"busId"`       // 关联项目
 	OpnPeopleId int         `orm:"opn_people_id" json:"opnPeopleId"` // 操作人ID
 	OpnPeople   string      `orm:"opn_people"    json:"opnPeople"`   // 操作人
 	OpnDate     *gtime.Time `orm:"opn_date"      json:"opnDate"`     // 操作日期

+ 1 - 0
opms_parent/app/model/proj/internal/proj_business_file.go

@@ -15,6 +15,7 @@ type ProjBusinessFile struct {
 	FileName    string      `orm:"file_name"    json:"fileName"`    // 附件名称
 	FileSize    string      `orm:"file_size"    json:"fileSize"`    // 附件大小
 	FileSource  string      `orm:"file_source"  json:"fileSource"`  // 来源
+	FileUrl     string      `orm:"file_url"     json:"fileUrl"`     // 附件链接
 	Remark      string      `orm:"remark"       json:"remark"`      // 备注
 	CreatedBy   int         `orm:"created_by"   json:"createdBy"`   // 创建者
 	CreatedName string      `orm:"created_name" json:"createdName"` // 创建人

+ 27 - 0
opms_parent/app/model/proj/internal/proj_business_team.go

@@ -0,0 +1,27 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// ProjBusinessTeam is the golang structure for table proj_business_team.
+type ProjBusinessTeam struct {
+	Id           int         `orm:"id,primary"    json:"id"`           // 主键
+	BusId        int         `orm:"bus_id"        json:"busId"`        // 关联项目
+	UserId       int         `orm:"user_id"       json:"userId"`       // 关联用户
+	Role         string      `orm:"role"          json:"role"`         // 团队角色
+	Permission   string      `orm:"permission"    json:"permission"`   // 权限
+	DeadlineTime *gtime.Time `orm:"deadline_time" json:"deadlineTime"` // 截止时间
+	Remark       string      `orm:"remark"        json:"remark"`       // 备注
+	CreatedBy    int         `orm:"created_by"    json:"createdBy"`    // 创建者
+	CreatedName  string      `orm:"created_name"  json:"createdName"`  // 创建人
+	CreatedTime  *gtime.Time `orm:"created_time"  json:"createdTime"`  // 创建时间
+	UpdatedBy    int         `orm:"updated_by"    json:"updatedBy"`    // 更新者
+	UpdatedName  string      `orm:"updated_name"  json:"updatedName"`  // 更新人
+	UpdatedTime  *gtime.Time `orm:"updated_time"  json:"updatedTime"`  // 更新时间
+	DeletedTime  *gtime.Time `orm:"deleted_time"  json:"deletedTime"`  // 删除时间
+}

+ 20 - 0
opms_parent/app/model/proj/proj_business.go

@@ -77,6 +77,7 @@ type UpdateProjBusinessReq struct {
 	*AddProjBusinessReq
 }
 
+// 项目产品
 type BusinessProduct struct {
 	Id            int    `json:"id"`                                   // 主键
 	Name          string `json:"name"           v:"required#产品名称不能为空"` // 产品名称
@@ -89,3 +90,22 @@ type BusinessProduct struct {
 	TotalPrice    int    `json:"totalPrice"`                           // 总价
 	Remark        string `json:"remark"`                               // 备注
 }
+
+// 项目调级请求
+type BusinessGradationReq struct {
+	Id      int    `json:"id"        v:"required# id不能为空"`                             // 主键
+	NboType string `json:"nboType"        v:"required|in:A,B,C#项目类别不能为空|项目类别只能为A、B、C"` // 项目类别(A类B类C类)
+}
+
+// 项目转移请求
+type BusinessTransferReq struct {
+	Id       int    `json:"id"        v:"required# id不能为空"`        // 主键
+	UserId   int    `json:"userId"        v:"required# 负责人不能为空"`   // 负责人
+	UserName string `json:"userName"        v:"required# 负责人不能为空"` // 负责人
+	Remark   string `json:"remark"`                                // 备注
+}
+
+// 获取项目关联信息
+type BusinessReq struct {
+	BusId int64 `json:"busId"        v:"required# 关联项目不能为空"` // 主键
+}

+ 20 - 0
opms_parent/app/model/proj/proj_business_contact.go

@@ -12,3 +12,23 @@ import (
 type ProjBusinessContact internal.ProjBusinessContact
 
 // Fill with you ideas below.
+
+type BusinessContact struct {
+	Id         int    `json:"id"`         // 主键
+	BusId      int    `json:"busId"`      // 关联项目
+	ContactId  int    `json:"contactId"`  // 联系人主键
+	CustId     int    `json:"custId" `    // 关联客户
+	CuctName   string `json:"cuctName"  ` // 姓名
+	CuctGender string `json:"cuctGender"` // 性别(10男20女)
+	Postion    string `json:"postion"`    // 职位
+	Telephone  string `json:"telephone"`  // 电话
+	Wechat     string `json:"wechat"`     // 微信
+	Email      string `json:"email"`      // 邮箱
+	Policy     int    `json:"policy"`     //是否决策
+}
+
+type BusinessContactReq struct {
+	BusId      int    `json:"busId"        v:"required#关联项目不能为空"`     // 关联项目
+	ContactIds []int  `json:"contactIds"        v:"required#联系人不能为空"` // 联系人主键
+	Remark     string `json:"remark"`                                 // 备注
+}

+ 2 - 1
opms_parent/app/model/proj/proj_business_file.go

@@ -17,6 +17,7 @@ type ProjBusinessFileReq struct {
 	BusId      int    `json:"busId"        v:"required# 关联项目不能为空"`      // 关联项目
 	FileName   string `json:"fileName"        v:"required# 附件名称不能为空"`   // 附件名称
 	FileSize   string `json:"fileSize"        v:"required# 附件大小不能为空"`   // 附件大小
-	FileSource string `json:"fileSource"        v:"required# 附件来源不能为空"` // 来源
+	FileSource string `json:"fileSource"        v:"required# 附件来源不能为空"` // 附件来源
+	FileUrl    string `json:"fileUrl"        v:"required# 附件链接不能为空"`    // 附件链接
 	Remark     string `json:"remark"`                                   // 备注
 }

+ 36 - 0
opms_parent/app/model/proj/proj_business_team.go

@@ -0,0 +1,36 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package model
+
+import (
+	"dashoo.cn/micro/app/model/proj/internal"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// ProjBusinessTeam is the golang structure for table proj_business_team.
+type ProjBusinessTeam internal.ProjBusinessTeam
+
+// Fill with you ideas below.
+
+type BusinessTeam struct {
+	Id           int         `json:"id"`           //
+	BusId        int         `json:"busId"`        // 关联项目
+	UserId       int         `json:"userId"`       // 用户
+	UserName     string      `json:"userName"`     // 用户姓名
+	DeptName     string      `json:"deptName"`     // 部门名称
+	Role         string      `json:"role"`         // 团队角色
+	Permission   string      `json:"permission"`   // 权限
+	DeadlineTime *gtime.Time `json:"deadlineTime"` // 截止时间
+	Remark       string      `json:"remark"`       // 备注
+}
+
+type BusinessTeamReq struct {
+	BusId        int         `json:"busId"        v:"required#关联项目不能为空"`        // 关联项目
+	UserIds      []int       `json:"userIds"        v:"required#用户不能为空"`        // 用户
+	Role         string      `json:"role"`                                      // 团队角色
+	Permission   string      `json:"permission"        v:"required#用户权限不能为空"`   // 权限
+	DeadlineTime *gtime.Time `json:"deadlineTime"        v:"required#截止时间不能为空"` // 截止时间
+	Remark       string      `json:"remark"`                                    // 备注
+}

+ 113 - 3
opms_parent/app/service/proj/business.go

@@ -5,7 +5,9 @@ import (
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
+	"strings"
 
 	projDao "dashoo.cn/micro/app/dao/proj"
 	model "dashoo.cn/micro/app/model/proj"
@@ -74,18 +76,34 @@ func (p *businessService) Create(req *model.AddProjBusinessReq) (err error) {
 
 	service.SetCreatedInfo(businessData, p.GetCxtUserId(), p.GetCxtUserName())
 	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+		// 添加项目
 		res, err := p.Dao.TX(tx).Insert(businessData)
 		if err != nil {
 			return err
 		}
+		// 处理项目产品信息
 		lastId, _ := res.LastInsertId()
 		for _, v := range products {
 			v.BusId = int(lastId)
 			v.TotalPrice = v.SellingPrice * v.Quantity
 			service.SetCreatedInfo(v, p.GetCxtUserId(), p.GetCxtUserName())
 		}
-		productDao := projDao.NewProjBusinessProductDao(p.Tenant)
-		_, err = productDao.TX(tx).Insert(products)
+		// 添加项目产品
+		_, err = projDao.NewProjBusinessProductDao(p.Tenant).TX(tx).Insert(products)
+		if err != nil {
+			return err
+		}
+		// 添加项目动态
+		dynamics := model.ProjBusinessDynamics{
+			OpnPeopleId: p.GetCxtUserId(),
+			OpnPeople:   p.GetCxtUserName(),
+			OpnDate:     gtime.Now(),
+			OpnType:     "CREATED",
+			OpnContent:  "创建项目",
+			Remark:      gconv.String(businessData),
+		}
+		service.SetCreatedInfo(dynamics, p.GetCxtUserId(), p.GetCxtUserName())
+		_, err = projDao.NewProjBusinessDao(p.Tenant).TX(tx).Insert(&dynamics)
 		return err
 	})
 
@@ -103,7 +121,26 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) (err erro
 		return
 	}
 	service.SetUpdatedInfo(businessData, p.GetCxtUserId(), p.GetCxtUserName())
-	_, err = p.Dao.FieldsEx(service.UpdateFieldEx).WherePri(projDao.ProjBusiness.Columns.Id, req.Id).Update(businessData)
+
+	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+		// 更新项目
+		_, err = p.Dao.TX(tx).FieldsEx(service.UpdateFieldEx).WherePri(projDao.ProjBusiness.Columns.Id, req.Id).Update(businessData)
+		if err != nil {
+			return err
+		}
+		// 添加项目动态
+		dynamics := model.ProjBusinessDynamics{
+			OpnPeopleId: p.GetCxtUserId(),
+			OpnPeople:   p.GetCxtUserName(),
+			OpnDate:     gtime.Now(),
+			OpnType:     "UPDATED",
+			OpnContent:  "编辑项目",
+			Remark:      gconv.String(businessData),
+		}
+		service.SetCreatedInfo(dynamics, p.GetCxtUserId(), p.GetCxtUserName())
+		_, err = projDao.NewProjBusinessDao(p.Tenant).TX(tx).Insert(&dynamics)
+		return err
+	})
 	return
 }
 
@@ -111,3 +148,76 @@ func (p *businessService) DeleteByIds(ids []int64) (err error) {
 	_, err = p.Dao.WhereIn(projDao.ProjBusiness.Columns.Id, ids).Delete()
 	return
 }
+
+// 项目调级
+func (p *businessService) BusinessGradation(req *model.BusinessGradationReq) error {
+	var business model.ProjBusiness
+	err := p.Dao.Where(projDao.ProjBusiness.Columns.Id, req.Id).Scan(&business)
+	if err != nil {
+		return err
+	}
+	if business.NboType == req.NboType {
+		return gerror.New("同级无法进行调级。")
+	}
+	opnContent := "项目升级 " + business.NboType + " => " + req.NboType
+	// A < B return -1 项目降级
+	if strings.Compare(business.NboType, req.NboType) < 0 {
+		opnContent = "项目降级 " + business.NboType + " => " + req.NboType
+	}
+	business.NboType = req.NboType
+	service.SetUpdatedInfo(business, p.GetCxtUserId(), p.GetCxtUserName())
+
+	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+		// 更新项目调级
+		_, err = p.Dao.TX(tx).Fields(p.Dao.Columns.NboType).WherePri(projDao.ProjBusiness.Columns.Id, req.Id).Update(business)
+		if err != nil {
+			return err
+		}
+		// 添加项目动态
+		dynamics := model.ProjBusinessDynamics{
+			OpnPeopleId: p.GetCxtUserId(),
+			OpnPeople:   p.GetCxtUserName(),
+			OpnDate:     gtime.Now(),
+			OpnType:     "UPDATED",
+			OpnContent:  opnContent,
+		}
+		service.SetCreatedInfo(dynamics, p.GetCxtUserId(), p.GetCxtUserName())
+		_, err = projDao.NewProjBusinessDao(p.Tenant).TX(tx).Insert(&dynamics)
+		return err
+	})
+	return err
+}
+
+// 项目转移
+func (p *businessService) BusinessTransfer(req *model.BusinessTransferReq) error {
+	var business model.ProjBusiness
+	err := p.Dao.Where(projDao.ProjBusiness.Columns.Id, req.Id).Scan(&business)
+	if err != nil {
+		return err
+	}
+	business.SaleId = req.UserId
+	business.SaleName = req.UserName
+	business.Remark = req.Remark
+	service.SetUpdatedInfo(business, p.GetCxtUserId(), p.GetCxtUserName())
+
+	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+		// 更新项目调级
+		_, err = p.Dao.TX(tx).Fields(p.Dao.Columns.SaleId, p.Dao.Columns.SaleName).WherePri(projDao.ProjBusiness.Columns.Id, req.Id).Update(business)
+		if err != nil {
+			return err
+		}
+		// 添加项目动态
+		dynamics := model.ProjBusinessDynamics{
+			OpnPeopleId: p.GetCxtUserId(),
+			OpnPeople:   p.GetCxtUserName(),
+			OpnDate:     gtime.Now(),
+			OpnType:     "UPDATED",
+			OpnContent:  "项目转移",
+			Remark:      gconv.String(business),
+		}
+		service.SetCreatedInfo(dynamics, p.GetCxtUserId(), p.GetCxtUserName())
+		_, err = projDao.NewProjBusinessDao(p.Tenant).TX(tx).Insert(&dynamics)
+		return err
+	})
+	return err
+}

+ 48 - 0
opms_parent/app/service/proj/business_contact.go

@@ -0,0 +1,48 @@
+package proj
+
+import (
+	"context"
+	custDao "dashoo.cn/micro/app/dao/cust"
+	projDao "dashoo.cn/micro/app/dao/proj"
+	projModel "dashoo.cn/micro/app/model/proj"
+	"dashoo.cn/micro/app/service"
+)
+
+type businessContactService struct {
+	*service.ContextService
+	Dao *projDao.ProjBusinessContactDao
+}
+
+func NewBusinessContactService(ctx context.Context) (svc *businessContactService, err error) {
+	svc = new(businessContactService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = projDao.NewProjBusinessContactDao(svc.Tenant)
+	return svc, nil
+}
+
+func (p *businessContactService) GetList(busId int64) (contactList []*projModel.BusinessContact, err error) {
+	err = p.Dao.As("bus").LeftJoin(custDao.CustCustomerContact.Table, "contact", "bus.contact_id=contact.id").
+		Where(p.Dao.Columns.BusId, busId).Fields("bus.id AS id, bus.*, contact.*").Scan(&contactList)
+	return
+}
+
+func (p *businessContactService) Create(req *projModel.BusinessContactReq) (err error) {
+	contactList := make([]*projModel.ProjBusinessContact, 0)
+	for _, v := range req.ContactIds {
+		data := new(projModel.ProjBusinessContact)
+		data.BusId = req.BusId
+		data.ContactId = v
+		data.Remark = req.Remark
+		service.SetCreatedInfo(data, p.GetCxtUserId(), p.GetCxtUserName())
+		contactList = append(contactList, data)
+	}
+	_, err = p.Dao.Insert(&contactList)
+	return
+}
+
+func (p *businessContactService) DeleteByIds(ids []int64) (err error) {
+	_, err = p.Dao.WhereIn(projDao.ProjBusinessContact.Columns.Id, ids).Delete()
+	return
+}

+ 8 - 52
opms_parent/app/service/proj/business_dynamics.go

@@ -2,18 +2,15 @@ package proj
 
 import (
 	"context"
-	"github.com/gogf/gf/errors/gerror"
-	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/util/gconv"
-
 	projDao "dashoo.cn/micro/app/dao/proj"
 	model "dashoo.cn/micro/app/model/proj"
 	"dashoo.cn/micro/app/service"
+	"github.com/gogf/gf/database/gdb"
 )
 
 type businessDynamicsService struct {
 	*service.ContextService
-	Dao *projDao.ProjBusinessDao
+	Dao *projDao.ProjBusinessDynamicsDao
 }
 
 func NewBusinessDynamicsService(ctx context.Context) (svc *businessDynamicsService, err error) {
@@ -21,63 +18,22 @@ func NewBusinessDynamicsService(ctx context.Context) (svc *businessDynamicsServi
 	if svc.ContextService, err = svc.Init(ctx); err != nil {
 		return nil, err
 	}
-	svc.Dao = projDao.NewProjBusinessDao(svc.Tenant)
+	svc.Dao = projDao.NewProjBusinessDynamicsDao(svc.Tenant)
 	return svc, nil
 }
 
-func (p *businessDynamicsService) GetList(req *model.ProjBusinessSearchReq) (total int, businessList []*model.ProjBusiness, err error) {
-	db := p.Dao.M
-	if req.NboName != "" {
-		db = db.WhereLike(p.Dao.Columns.NboName, "%"+req.NboName+"%")
-	}
-	if req.CustName != "" {
-		db = db.WhereLike(p.Dao.Columns.CustName, "%"+req.CustName+"%")
-	}
-	if req.SaleName != "" {
-		db = db.WhereLike(p.Dao.Columns.SaleName, "%"+req.SaleName+"%")
-	}
-	if req.NboType != "" {
-		db = db.Where(p.Dao.Columns.NboType, req.NboType)
-	}
-	total, err = db.Count()
-	if err != nil {
-		g.Log().Error(err)
-		err = gerror.New("获取总行数失败")
-		return
-	}
-
-	err = db.Page(req.GetPage()).Order("id desc").Scan(&businessList)
+func (p *businessDynamicsService) GetList(busId int64) (businessList []*model.ProjBusinessDynamics, err error) {
+	err = p.Dao.Where(p.Dao.Columns.BusId, busId).Order("id desc").Scan(&businessList)
 	return
 }
 
-func (p *businessDynamicsService) GetEntityById(id int64) (business *model.ProjBusiness, err error) {
+func (p *businessDynamicsService) GetEntityById(id int64) (business *model.ProjBusinessDynamics, err error) {
 	err = p.Dao.Where(projDao.ProjBusinessDynamics.Columns.Id, id).Scan(&business)
 	return
 }
 
-func (p *businessDynamicsService) Create(req *model.AddProjBusinessReq) (err error) {
-	businessData := new(model.ProjBusiness)
-	if err = gconv.Struct(req, businessData); err != nil {
-		return
-	}
-	service.SetCreatedInfo(businessData, p.GetCxtUserId(), p.GetCxtUserName())
-	_, err = p.Dao.Insert(businessData)
-	return
-}
-
-func (p *businessDynamicsService) UpdateById(req *model.UpdateProjBusinessReq) (err error) {
-	db := p.Dao.M
-	record, err := db.Count("Id", req.Id)
-	if err != nil || record == 0 {
-		err = gerror.New("该数据不存在")
-		return err
-	}
-	businessData := new(model.ProjBusiness)
-	if err = gconv.Struct(req, businessData); err != nil {
-		return
-	}
-	service.SetUpdatedInfo(businessData, p.GetCxtUserId(), p.GetCxtUserName())
-	_, err = db.FieldsEx(service.UpdateFieldEx).WherePri(projDao.ProjBusinessDynamics.Columns.Id, req.Id).Update(businessData)
+func (p *businessDynamicsService) Create(businessData *model.ProjBusinessDynamics, tenant string, tx *gdb.TX) (err error) {
+	_, err = projDao.NewProjBusinessDao(tenant).TX(tx).Insert(businessData)
 	return
 }
 

+ 2 - 2
opms_parent/app/service/proj/business_file.go

@@ -23,8 +23,8 @@ func NewBusinessFileService(ctx context.Context) (svc *businessFileService, err
 	return svc, nil
 }
 
-func (p *businessFileService) GetList() (total int, fileList []*model.ProjBusinessFile, err error) {
-	err = p.Dao.Order("id desc").Scan(&fileList)
+func (p *businessFileService) GetList(busId int64) (fileList []*model.ProjBusinessFile, err error) {
+	err = p.Dao.Where(p.Dao.Columns.BusId, busId).Order("id desc").Scan(&fileList)
 	return
 }
 

+ 51 - 0
opms_parent/app/service/proj/business_team.go

@@ -0,0 +1,51 @@
+package proj
+
+import (
+	"context"
+	projDao "dashoo.cn/micro/app/dao/proj"
+	projModel "dashoo.cn/micro/app/model/proj"
+	"dashoo.cn/micro/app/service"
+)
+
+type businessTeamService struct {
+	*service.ContextService
+	Dao *projDao.ProjBusinessTeamDao
+}
+
+func NewBusinessTeamService(ctx context.Context) (svc *businessTeamService, err error) {
+	svc = new(businessTeamService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = projDao.NewProjBusinessTeamDao(svc.Tenant)
+	return svc, nil
+}
+
+func (p *businessTeamService) GetList(busId int64) (teamList []*projModel.BusinessTeam, err error) {
+	err = p.Dao.As("team").LeftJoin("sys_user", "user", "team.user_id=user.id").
+		LeftJoin("sys_dept", "dept", "user.dept_id=dept.id").
+		Where(p.Dao.Columns.BusId, busId).Fields("team.id AS id, team.*, user.user_name, dept.dept_name").Scan(&teamList)
+	return
+}
+
+func (p *businessTeamService) Create(req *projModel.BusinessTeamReq) (err error) {
+	teamList := make([]*projModel.ProjBusinessTeam, 0)
+	for _, v := range req.UserIds {
+		data := new(projModel.ProjBusinessTeam)
+		data.BusId = req.BusId
+		data.UserId = v
+		data.Role = req.Role
+		data.Permission = req.Permission
+		data.DeadlineTime = req.DeadlineTime
+		data.Remark = req.Remark
+		service.SetCreatedInfo(data, p.GetCxtUserId(), p.GetCxtUserName())
+		teamList = append(teamList, data)
+	}
+	_, err = p.Dao.Insert(&teamList)
+	return
+}
+
+func (p *businessTeamService) DeleteByIds(ids []int64) (err error) {
+	_, err = p.Dao.WhereIn(projDao.ProjBusinessTeam.Columns.Id, ids).Delete()
+	return
+}

+ 5 - 2
opms_parent/main.go

@@ -24,9 +24,7 @@ func main() {
 	s.RegisterName("Region", new(base.RegionHandler), "")
 	s.RegisterName("Customer", new(cust.CustomerHeader), "")
 	s.RegisterName("Contant", new(cust.CustomerContantHeader), "")
-
 	s.RegisterName("Belong", new(cust.CustBelongHeader), "")
-
 	s.RegisterName("FollowUp", new(plat.FollowUpHandler), "")
 	s.RegisterName("FollowUpComment", new(plat.FollowUpCommentHandler), "")
 	s.RegisterName("FollowUpFile", new(plat.FollowUpFileHandler), "")
@@ -34,7 +32,12 @@ func main() {
 	s.RegisterName("TaskComment", new(plat.TaskCommentHandler), "")
 	s.RegisterName("TaskLog", new(plat.TaskLogHandler), "")
 	s.RegisterName("TaskProgress", new(plat.TaskProgressHandler), "")
+
 	s.RegisterName("Business", new(projHandler.BusinessHandler), "")
+	s.RegisterName("BusinessContact", new(projHandler.BusinessContactHandler), "")
+	s.RegisterName("BusinessDynamics", new(projHandler.BusinessDynamicsHandler), "")
+	s.RegisterName("BusinessFile", new(projHandler.BusinessFileHandler), "")
+	s.RegisterName("BusinessTeam", new(projHandler.BusinessTeamHandler), "")
 
 	// 注册服务对象
 	//s.RegisterName("Auth", new(handler.Auth), "")