作者 唐旭辉

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev

# Conflicts:
#	Dockerfile
... ... @@ -15,4 +15,4 @@ ADD . $APP_DIR
RUN cd $APP_DIR && CGO_ENABLED=0 go build -mod=vendor -ldflags '-d -w -s' -o oppmg
WORKDIR $APP_DIR
EXPOSE 8080
CMD [ "./oppmg" ]
CMD ["./oppmg"]
... ...
... ... @@ -69,7 +69,7 @@ func (this *BulletinController) BulletinList() {
return
}
rsp, err := bulletin.BulletinList(uid, companyId, request)
msg = protocol.NewReturnResponse(rsp, err)
msg = protocol.NewPageDataResponse(rsp, err)
}
//GetBulletin
... ... @@ -149,3 +149,29 @@ func (this *BulletinController) OperateBulletin() {
rsp, err := bulletin.OperateBulletin(companyId, request)
msg = protocol.NewReturnResponse(rsp, err)
}
//BulletinFeedbacks 反馈详情
//@router /bulletinFeedbacks [post]
func (this *BulletinController) BulletinFeedbacks() {
var msg *protocol.ResponseMessage
defer func() {
this.ResposeJson(msg)
}()
var request *protocol.BulletinFeedbacksRequest
if err := json.Unmarshal(this.Ctx.Input.RequestBody, &request); err != nil {
log.Error("json 解析失败", err)
msg = protocol.BadRequestParam("1")
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
companyId := this.GetCompanyId()
if companyId <= 0 {
msg = protocol.BadRequestParam("1")
return
}
rsp, err := bulletin.BulletinFeedbacks(companyId, request)
msg = protocol.NewPageDataResponse(rsp, err)
}
... ...
... ... @@ -2,7 +2,7 @@
export PATH=/root/local/bin:$PATH
kubectl -n mmm-suplus-dev get pods | grep -q oppmg
if [ "$?" == "1" ];then
kubectl create -f /tmp/dev/oppmgmg/oppmg.yaml --record
kubectl create -f /tmp/dev/mmm-go-oppmg/oppmg.yaml --record
kubectl -n mmm-suplus-dev get svc | grep -q oppmg
if [ "$?" == "0" ];then
echo "oppmg service install success!"
... ... @@ -16,7 +16,7 @@ if [ "$?" == "1" ];then
echo "oppmg deployment install fail!"
fi
else
kubectl delete -f /tmp/dev/oppmg/oppmg.yaml
kubectl delete -f /tmp/dev/mmm-go-oppmg/oppmg.yaml
kubectl -n mmm-suplus-dev get svc | grep -q oppmg
while [ "$?" == "0" ]
do
... ... @@ -27,7 +27,7 @@ else
do
kubectl -n mmm-suplus-dev get pods | grep -q oppmg
done
kubectl create -f /tmp/dev/oppmg/oppmg.yaml --record
kubectl create -f /tmp/dev/mmm-go-oppmg/oppmg.yaml --record
kubectl -n mmm-suplus-dev get svc | grep -q oppmg
if [ "$?" == "0" ];then
echo "oppmg service update success!"
... ...
... ... @@ -46,17 +46,14 @@ spec:
- name: oppmg
image: 192.168.0.243:5000/mmm/oppmg:dev
imagePullPolicy: Always
ports:
- containerPort: 8080
volumeMounts:
- mountPath: /opt/logs
- mountPath: /opt/logs
name: accesslogs
- mountPath: /var/www/oppmg/file
name: mmmjihuitest-pvc1
ports:
- containerPort: 8080
env:
- name: ENTERPRISE_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: service.enterprise
- name: MYSQL_HOST
valueFrom:
configMapKeyRef:
... ... @@ -67,6 +64,16 @@ spec:
configMapKeyRef:
name: suplus-config
key: mysql.port
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: MYSQL_USER
valueFrom:
configMapKeyRef:
... ... @@ -79,16 +86,17 @@ spec:
key: mysql.password
- name: MYSQL_DB_NAME
value: "opportunity_dev"
- name: LOG_LEVEL
value: "debug"
- name: RUN_MODE
value: "test"
- name: aliyun_logs_suplus
- name: LOG_LEVEL
value: "debug"
- name: aliyun_logs_suplusfile
value: "stdout"
- name: aliyun_logs_access
value: "/opt/logs/oppmg.log"
- name: aliyun_logs_access
value: "/var/www/opp/file"
value: " /opt/logs/app.log"
volumes:
- name: accesslogs
emptyDir: {}
- name: mmmjihuitest-pvc1
persistentVolumeClaim:
claimName: mmmjihuitest-pvc
\ No newline at end of file
... ...
... ... @@ -14,6 +14,7 @@ type AuditTemplate struct {
Name string `orm:"column(name);size(20)" description:"子分类名称"`
Doc string `orm:"column(doc);size(255)" description:"说明"`
Icon string `orm:"column(icon);size(255)" description:"图标"`
Code string `orm:"column(code);size(50)" description:"编码"`
NoticeType int8 `orm:"column(notice_type)" description:"通知方式"`
NoApprover int8 `orm:"column(no_approver)" description:"审核人空时:【1:自动通过】【2:转交给管理员】"`
SortNum int `orm:"column(sort_num)" description:"自定义排序编号"`
... ...
... ... @@ -2,6 +2,7 @@ package models
import (
"fmt"
"oppmg/utils"
"time"
"github.com/astaxie/beego/orm"
... ... @@ -73,3 +74,29 @@ func DeleteBulletinQuestionAnswer(id int) (err error) {
}
return
}
func GetBulletinQuestionAnswers(page, pageSize int, id int, v interface{}) (total int, err error) {
sql := `select b.*,a.nick_name `
where := ` from user a INNER JOIN (
select b.*,a.user_id from user_company a INNER JOIN (
select answer,update_at,uid from bulletin_question_answer where bulletin_id =? order by update_at desc
)b on a.id = b.uid
) b on a.id = b.user_id `
sqlCount := `select count(0) `
sqlCount += where
sql += where
sql += ` limit ?,?`
if v != nil {
if err = utils.ExecuteQueryOne(&total, sqlCount, id); err != nil {
return
}
}
if page == 0 {
page = 1
}
if err = utils.ExecuteQueryAll(v, sql, id, (page-1)*pageSize, pageSize); err != nil {
return
}
return
}
... ...
... ... @@ -11,6 +11,7 @@ type ChanceType struct {
Id int `orm:"column(id);auto"`
Name string `orm:"column(name);size(50)" description:"机会类型名称"`
Icon string `orm:"column(icon);size(500);null" description:"图标地址"`
Code string `orm:"column(code);size(50)" description:"编码"`
CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号"`
SortNum int `orm:"column(sort_num);null" description:"序号 公司下的序号"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间 "`
... ...
... ... @@ -34,7 +34,7 @@ const (
)
const (
DeleteUserMsgSql = "delete from user_msg where company_id=? and msg_type=? and source_id=?"
SqlDeleteUserMsg = "delete from user_msg where company_id=? and msg_type=? and source_id=?"
)
func (t *UserMsg) TableName() string {
... ...
... ... @@ -86,12 +86,13 @@ type TemplateAddResponse struct {
}
type Template struct {
Id int64 `json:"id"` //创建时 0
ChanceTypeId int `json:"chanceTypeId"` //机会类型编号
Name string `json:"name"`
Doc string `json:"doc"`
Icon string `json:"icon"`
InputList []*InputElement `json:"inputList"`
Id int64 `json:"id"` //创建时 0
Code string `json:"code" valid:"Required; MaxSize(6)"`
ChanceTypeId int `json:"chanceTypeId" valid:"Required;"` //机会类型编号
Name string `json:"name" valid:"Required;"`
Doc string `json:"doc" valid:"Required;"`
Icon string `json:"icon" valid:"Required;"`
InputList []*InputElement `json:"inputList" valid:"Required;"`
}
/*TemplateUpdate */
... ... @@ -107,6 +108,7 @@ type TemplateListRequest struct {
}
type TemplateListResponse struct {
List []*TemplateList `json:"list"`
//ResponsePageInfo
}
type TemplateList struct {
... ... @@ -145,6 +147,7 @@ type TemplateEditVisibleResponse struct {
type TemplateOperateCategoryRequest struct {
Id int `json:"id"`
Name string `json:"name"`
Code string `json:"code"`
Icon string `json:"icon"`
}
type TemplateOperateCategoryResponse struct {
... ...
... ... @@ -44,22 +44,22 @@ type BulletinReleaseResponse struct {
/*BulletinList */
type BulletinListRequest struct {
Status int8 `json:"status"` //1:待上架 2:上架
Page int `json:"page"`
PageSize int `json:"pageSize"`
Status int8 `json:"status"` //1:待上架 2:上架
RequestPageInfo
}
type BulletinListResponse struct {
List []*BulletinItem `json:"list"`
Total int
List []*BulletinItem `json:"list"`
//Total int
ResponsePageInfo
}
type BulletinItem struct {
Id int `json:"id"`
Type int8 `json:"type"`
Title string `json:"title"`
Status int8 `json:"status"`
Receiver []Receiver `json:"receiver" valid:"Required"`
CreateAt string `json:"time"`
Id int `json:"id"`
Type int8 `json:"type"`
Title string `json:"title"`
Status int8 `json:"status"`
Receiver []VisibleObject `json:"receiver" valid:"Required"`
CreateAt string `json:"time"`
}
/*GetBulletin */
... ... @@ -107,3 +107,24 @@ type OperateBulletinRequest struct {
}
type OperateBulletinResponse struct {
}
/*BulletinFeedbacks 反馈详情*/
type BulletinFeedbacksRequest struct {
RequestPageInfo
Id int `json:"id" valid:"Required"` //公告编号
}
type BulletinFeedbacksResponse struct {
ResponsePageInfo
List []FeedBackItem `json:"list"`
}
type FeedBackItem struct {
Time int64 `json:"time"`
Name string `json:"name"`
Content string `json:"content"`
}
type Answer struct {
VoteResults []int `json:"voteResults"`
EditContent string `json:"editContent"`
}
... ...
... ... @@ -52,6 +52,7 @@ func init() {
beego.NSRouter("/get", &controllers.BulletinController{}, "post:GetBulletin"),
beego.NSRouter("/update", &controllers.BulletinController{}, "post:UpdateBulletin"),
beego.NSRouter("/operate", &controllers.BulletinController{}, "post:OperateBulletin"),
beego.NSRouter("/feedbacks", &controllers.BulletinController{}, "post:BulletinFeedbacks"),
),
beego.NSNamespace("/common",
beego.NSRouter("/department", &controllers.CommonController{}, "post:SelectorDepartment"),
... ...
... ... @@ -35,6 +35,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
Name: request.Template.Name,
Doc: request.Template.Doc,
Icon: request.Template.Icon,
Code: request.Template.Code,
NoApprover: 1, //TODO:配置
SortNum: 0,
VisibleType: int8(0),
... ... @@ -285,6 +286,7 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe
chanceType = &models.ChanceType{
Name: request.Name,
Icon: request.Icon,
Code: request.Code,
CompanyId: int(companyId),
CreateAt: time.Now(),
UpdateAt: time.Now(),
... ...
... ... @@ -162,21 +162,22 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) (
list []*models.Bulletin
total int
)
if request.Page == 0 {
request.Page = 1
if request.PageIndex == 0 {
request.PageIndex += 1
}
if request.PageSize == 0 {
request.PageSize = 20
}
rsp = &protocol.BulletinListResponse{}
if list, total, err = models.GetBulletins(companyId, request.Status, request.Page, request.PageSize); err != nil {
if list, total, err = models.GetBulletins(companyId, request.Status, request.PageIndex, request.PageSize); err != nil {
log.Error(err.Error())
return
}
if len(list) == 0 {
return
}
rsp.Total = total
rsp.TotalPage = total
rsp.CurrentPage = request.PageIndex
for i := range list {
bulletin := list[i]
item := &protocol.BulletinItem{
... ... @@ -186,8 +187,8 @@ func BulletinList(uid, companyId int64, request *protocol.BulletinListRequest) (
Status: int8(bulletin.Status),
CreateAt: bulletin.CreateAt.Format("2006-01-02 15:04:05"),
}
if item.Receiver, err = getUsersName(bulletin.Receiver); err != nil {
log.Error(err.Error())
if item.Receiver, err = agg.GetVisibleObject(bulletin.Receiver); err != nil {
log.Error(bulletin.Receiver, err.Error())
continue
}
rsp.List = append(rsp.List, item)
... ... @@ -374,7 +375,7 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest)
orm.Begin()
if request.CmdType == protocol.BulletinUnRelease { //下架
status = protocol.BulletinUnRelease
if err = utils.ExecuteSQLWithOrmer(orm, models.DeleteUserMsgSql, companyId, models.MsgTypeBulletin, bulletin.Id); err != nil {
if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteUserMsg, companyId, models.MsgTypeBulletin, bulletin.Id); err != nil {
log.Error(err.Error())
orm.Rollback()
return
... ... @@ -397,3 +398,57 @@ func OperateBulletin(companyId int64, request *protocol.OperateBulletinRequest)
rsp = &protocol.OperateBulletinResponse{}
return
}
//反馈详情
func BulletinFeedbacks(companyId int64, request *protocol.BulletinFeedbacksRequest) (rsp *protocol.BulletinFeedbacksResponse, err error) {
type Feedback struct {
Answer string `orm:"column(answer);null" description:"答案"`
Uid int64 `orm:"column(uid);null" description:"用户id"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"更新时间"`
NickName string `orm:"column(nick_name);size(100)" description:"昵称"`
}
var (
feedbacks []Feedback
total int
answer protocol.Answer
)
rsp = &protocol.BulletinFeedbacksResponse{}
if total, err = models.GetBulletinQuestionAnswers(request.PageIndex, request.PageSize, request.Id, &feedbacks); err != nil {
if err == orm2.ErrNoRows {
err = nil
}
return
}
rsp.CurrentPage = request.PageIndex
rsp.TotalPage = total
for i := range feedbacks {
tmp := feedbacks[i]
var content string
var other string
if err = json.Unmarshal([]byte(tmp.Answer), &answer); err != nil {
log.Error(err.Error())
continue
}
for i := range answer.VoteResults {
value := answer.VoteResults[i]
if value == -1 {
other = " 其他"
} else if value < 10 {
content += string(byte('A') + byte(value) - 1)
if i+1 < len(answer.VoteResults) {
content += ","
}
}
}
content = content + other
if len(answer.EditContent) != 0 {
content = fmt.Sprintf("%v (%v)", content, answer.EditContent)
}
rsp.List = append(rsp.List, protocol.FeedBackItem{
Time: tmp.UpdateAt.Unix(),
Name: tmp.NickName,
Content: content,
})
}
return
}
... ...