作者 yangfu

共创详情附件查询

... ... @@ -3,3 +3,6 @@
.idea
/lastupdate.tmp
static/*
cmd/pdftopng.exe
tmp/*
... ...
... ... @@ -4,6 +4,7 @@ RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
COPY ./config config
COPY ./cmd/pdftopng cmd
COPY ./go.mod go.mod
COPY ./go.sum go.sum
COPY ./main.go main.go
... ...
不能预览此文件类型
... ... @@ -107,6 +107,10 @@ spec:
value: "false"
- name: HTTP_PORT
value: "8082"
- name: SUPLUS_ADMIN_BASE_HOST
value: "http://suplus-admin-base-prd.fjmaimaimai.com"
- name: ALLIED_CREATION_GATEWAY_HOST
value: "https://allied-creation-gateway-prd.fjmaimaimai.com"
- name: ALLIED_CREATION_USER_HOST
value: "https://allied-creation-user-prd.fjmaimaimai.com"
- name: ALLIED_CREATION_COOPERATION_HOST
... ...
... ... @@ -6,11 +6,13 @@ require (
github.com/GeeTeam/gt3-golang-sdk v0.0.0-20200116043922-446ca8a507d2
github.com/beego/beego/v2 v2.0.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/disintegration/imaging v1.6.2
github.com/forgoer/openssl v0.0.0-20210828150411-6c5378b5b719
github.com/go-pg/pg/v10 v10.10.1
github.com/go-redis/redis v6.15.7+incompatible
github.com/google/uuid v1.1.1
github.com/linmadan/egglib-go v0.0.0-20210827085852-177fa745932d
github.com/pdfcpu/pdfcpu v0.3.13
github.com/stretchr/testify v1.7.0
github.com/tal-tech/go-queue v1.0.5
golang.org/x/text v0.3.6
... ...
... ... @@ -58,6 +58,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
... ... @@ -163,6 +165,11 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hhrutter/lzw v0.0.0-20190827003112-58b82c5a41cc/go.mod h1:yJBvOcu1wLQ9q9XZmfiPfur+3dQJuIhYQsMGLYcItZk=
github.com/hhrutter/lzw v0.0.0-20190829144645-6f07a24e8650 h1:1yY/RQWNSBjJe2GDCIYoLmpWVidrooriUr4QS/zaATQ=
github.com/hhrutter/lzw v0.0.0-20190829144645-6f07a24e8650/go.mod h1:yJBvOcu1wLQ9q9XZmfiPfur+3dQJuIhYQsMGLYcItZk=
github.com/hhrutter/tiff v0.0.0-20190829141212-736cae8d0bc7 h1:o1wMw7uTNyA58IlEdDpxIrtFHTgnvYzA8sCQz8luv94=
github.com/hhrutter/tiff v0.0.0-20190829141212-736cae8d0bc7/go.mod h1:WkUxfS2JUu3qPo6tRld7ISb8HiC0gVSU91kooBMDVok=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
... ... @@ -248,6 +255,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA=
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/pdfcpu/pdfcpu v0.3.13 h1:VFon2Yo1PJt+sA57vPAeXWGLSZ7Ux3Jl4h02M0+s3dg=
github.com/pdfcpu/pdfcpu v0.3.13/go.mod h1:UJc5xsXg0fpmjp1zOPdyYcAQArc/Zf3V0nv5URe+9fg=
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
... ... @@ -385,6 +394,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.0.0-20190823064033-3a9bac650e44/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb h1:fqpd0EBDzlHRCjiphRR5Zo/RSWWQlWv34418dnEixWk=
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
... ... @@ -552,8 +563,9 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/cache"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/blur"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego"
)
... ... @@ -24,6 +25,6 @@ func main() {
}
broker.RegisterDefaultPusherClient(constant.KAFKA_HOST, constant.TOPIC_UP_BLOCK_CHAIN)
blur.InitDefaultConfig()
web.Run()
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type PersonCooperationProjectSharedInfoAttachmentQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户
UserId int64 `json:"userId" valid:"Required"`
// 项目ID
ProjectId int64 `json:"cooperationProjectId" valid:"Required"`
// 合约ID
ContractId int64 `json:"cooperationContractId" valid:"Required"`
// 附件类型 1:合约附件 2:支付凭证
AttachmentType int `json:"attachmentType" valid:"Required"`
}
func (updateCooperationProjectCommand *PersonCooperationProjectSharedInfoAttachmentQuery) Valid(validation *validation.Validation) {
}
func (updateCooperationProjectCommand *PersonCooperationProjectSharedInfoAttachmentQuery) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateCooperationProjectCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package service
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/blur"
"strconv"
"strings"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
... ... @@ -221,6 +225,42 @@ func (srv CooperationProjectService) PersonSearchCooperationProjectShareInfo(pro
return result, nil
}
func (srv CooperationProjectService) PersonSearchCooperationProjectShareInfoAttachment(projectQuery *command.PersonCooperationProjectSharedInfoAttachmentQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
response := struct {
Attachment *domain.Attachment `json:"attachment"`
UserBaseId int64 `json:"userBaseId"`
}{}
err := creationCooperationGateway.CooperationStatisticsWithObject(
allied_creation_cooperation.PersonCooperationProjectSharedInfoAttachment,
map[string]interface{}{
"userId": projectQuery.UserId,
"cooperationContractId": projectQuery.ContractId,
"cooperationProjectId": projectQuery.ProjectId,
"attachmentType": projectQuery.AttachmentType,
}, &response,
)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 不是本人查看需要做模糊处理
if response.UserBaseId != projectQuery.Operator.UserBaseId {
file, err := blur.FileBlur(response.Attachment.Url, true)
if err != nil { // || len(file)==0
log.Logger.Error(err.Error())
return nil, application.ThrowError(application.BUSINESS_ERROR, "文件加载错误,请重试")
}
if !(strings.HasPrefix(file, "http") || strings.HasPrefix(file, "https")) {
file = constant.ALLIED_CREATION_GATEWAY_HOST + "/" + file
}
response.Attachment.Url = file
}
return map[string]interface{}{
"attachment": response.Attachment,
}, nil
}
// PersonSearchCooperationProject 共创用户获取共创项目列表
func (srv CooperationProjectService) PersonSearchCooperationProjectStarred(projectQuery *command.PersonSearchCooperationProjectQuery) (int, interface{}, error) {
//extQueries := extQuires(projectQuery.Operator)
... ...
... ... @@ -183,7 +183,7 @@ func (srv PersonStatisticsService) CooperationProjectRecommend(projectQuery *com
PageNumber: projectQuery.PageNumber + 1,
PageSize: projectQuery.PageSize,
CooperationProjectUndertakerType: 3,
Status: 1,
//Status: 1,
IsSkipFetchProjectModel: true,
// Status: 1,
SortByStatus: 1,
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UpdateFavoriteCommand struct {
Operator domain.Operator `json:"-"`
//UserBaseId int64 `json:"userBaseId" `
// 菜单编码列表
Item string `json:"item" valid:"Required"`
// 项唯一标识
ItemId int64 `cname:"项唯一标识" json:"itemId" valid:"Required"`
// 用户Id 用户唯一标识
Action int64 `cname:"操作类型 1:关注 2:取消关注 " json:"action" valid:"Required"`
}
func (UpdateFavoriteCommand *UpdateFavoriteCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (UpdateFavoriteCommand *UpdateFavoriteCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(UpdateFavoriteCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(UpdateFavoriteCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
... ... @@ -284,3 +284,26 @@ func (srv UserService) CooperationOrg(operator domain.Operator) (interface{}, er
"orgs": ret,
}, nil
}
// 设置收藏菜单
func (srv UserService) UpdateFavorite(menuFavoriteCommand *command.UpdateFavoriteCommand) (interface{}, error) {
if err := menuFavoriteCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
if menuFavoriteCommand.Operator.UserBaseId == 0 {
return nil, application.ThrowError(application.ARG_ERROR, "用户未登录")
}
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
menuFavoriteCommand.Operator,
)
result, err := creationUserGateway.FavoriteUpadate(allied_creation_user.ReqFavoriteUpdate{
UserBaseId: menuFavoriteCommand.Operator.UserBaseId,
Item: menuFavoriteCommand.Item,
Action: menuFavoriteCommand.Action,
ItemId: menuFavoriteCommand.ItemId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return result, nil
}
... ...
... ... @@ -13,8 +13,10 @@ var LOG_FRAMEWORK = "beego" // beego logrus
var LOG_FILE = "app.log"
var LOG_PREFIX = "[allied-creation-gateway]"
var FileStatic = "./static"
var HTTP_PORT int = 8083
var ALLIED_CREATION_GATEWAY_HOST = "https://allied-creation-gateway-dev.fjmaimaimai.com"
var ALLIED_CREATION_GATEWAY_HOST = "http://localhost:8080"
//天联共创基础模块
var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com"
... ...
... ... @@ -41,6 +41,8 @@ const (
PersonCompanyPaymentHistoryStatistics = "PersonCompanyPaymentHistoryStatistics"
// 个人 - 共创项目共享信息数据
PersonCooperationProjectSharedInfo = "PersonCooperationProjectSharedInfo"
// 个人 - 共创项目共享信息数据 - 附件
PersonCooperationProjectSharedInfoAttachment = "PersonCooperationProjectSharedInfoAttachment"
// 账期结算单统计
CreditAccountStatistics = "CreditAccountStatistics"
... ... @@ -154,3 +156,37 @@ func (gateway HttplibAlliedCreationCooperation) RelevantCooperationContractNumbe
err = gateway.GetResponseData(result, &data)
return data, err
}
// CooperationStatistics 共创统计
func (gateway HttplibAlliedCreationCooperation) CooperationStatisticsWithObject(action string, queryOptions interface{}, object interface{}) error {
url := gateway.baseUrL + "/cooperation-statistics"
method := "post"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向业务模块请求数据:共创统计。", map[string]interface{}{
"api": method + ":" + url,
"param": queryOptions,
})
param := map[string]interface{}{
"action": action,
"queryOptions": queryOptions,
}
req, err := req.JSONBody(param)
if err != nil {
return fmt.Errorf("请求共创统计失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return fmt.Errorf("获取共创统计失败:%w", err)
}
log.Logger.Debug("获取业务模块请求数据:共创统计。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return fmt.Errorf("解析共创统计:%w", err)
}
err = gateway.GetResponseData(result, &object)
return err
}
... ...
... ... @@ -101,3 +101,33 @@ func (gateway HttplibAlliedCreationUser) FavoriteMenusGet(param ReqFavoriteMenus
err = gateway.GetResponseData(result, &data)
return &data, err
}
func (gateway HttplibAlliedCreationUser) FavoriteUpadate(param ReqFavoriteUpdate) (*DataFavoriteUpdate, error) {
url := gateway.baseUrL + "/user-base/favorite"
method := "post"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向用户模块请求数据:更新我喜欢。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求更新我喜欢失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取更新我喜欢失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:更新我喜欢。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析更新我喜欢:%w", err)
}
var data DataFavoriteUpdate
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -34,3 +34,18 @@ type (
FavoriteMenus []string `json:"favoriteMenus"`
}
)
type (
ReqFavoriteUpdate struct {
UserBaseId int64 `json:"userBaseId" valid:"Required"`
// 菜单编码列表
Item string `json:"item" valid:"Required"`
// 项唯一标识
ItemId int64 `cname:"项唯一标识" json:"itemId" valid:"Required"`
// 用户Id 用户唯一标识
Action int64 `cname:"操作类型 1:关注 2:取消关注 " json:"action" valid:"Required"`
}
DataFavoriteUpdate struct {
}
)
... ...
... ... @@ -255,15 +255,28 @@ func (controller *CooperationController) PersonSearchCooperationProjectStarred()
func (controller *CooperationController) PersonCooperationProjectSharedInfo() {
svr := service.CooperationProjectService{}
cmd := &command.PersonSearchCooperationProjectQuery{}
cmd := &command.GetCooperationProjectQuery{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
total, data, err := svr.PersonSearchCooperationProject(cmd)
controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
data, err := svr.PersonSearchCooperationProjectShareInfo(cmd)
controller.Response(data, err)
}
func (controller *CooperationController) PersonCooperationProjectSharedInfoAttachment() {
svr := service.CooperationProjectService{}
cmd := &command.PersonCooperationProjectSharedInfoAttachmentQuery{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.PersonSearchCooperationProjectShareInfoAttachment(cmd)
controller.Response(data, err)
}
//func (controller *CooperationController) PersonRecommendCooperationProject() {
... ...
... ... @@ -148,13 +148,13 @@ func (controller *UserController) CooperationOrg() {
func (controller *UserController) UpdateOrgFavorite() {
svr := service.UserService{}
cmd := &command.MenuFavoriteCommand{}
cmd := &command.UpdateFavoriteCommand{}
err := controller.Unmarshal(cmd)
if err != nil {
controller.Response(nil, err)
return
}
cmd.Operator = controller.GetOperator()
data, err := svr.UpdateMenuFavorite(cmd)
data, err := svr.UpdateFavorite(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -2,9 +2,11 @@ package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers"
)
func init() {
web.Router("/log", &controllers.LoggerController{}, "Get:Index")
web.SetStaticPath("/static", constant.FileStatic)
}
... ...
... ... @@ -39,6 +39,7 @@ func init() {
web.Router("/v1/app/cooperation-projects/person/search", &mobile_client.CooperationController{}, "Post:PersonSearchCooperationProject")
web.Router("/v1/app/cooperation-projects/person/search-starred", &mobile_client.CooperationController{}, "Post:PersonSearchCooperationProjectStarred")
web.Router("/v1/app/cooperation-projects/person/shared-info", &mobile_client.CooperationController{}, "Post:PersonCooperationProjectSharedInfo")
web.Router("/v1/app/cooperation-projects/person/shared-info/attachment", &mobile_client.CooperationController{}, "Post:PersonCooperationProjectSharedInfoAttachment")
/***** CompanyDividends 账期结算 *****/
web.Router("/v1/app/company/credit-accounts/search", &mobile_client.CooperationController{}, "Post:CreditAccountSearch")
... ...
... ... @@ -15,7 +15,7 @@ func init() {
web.Router("/v1/user/user-menu", &controllers.AuthController{}, "Post:GetUserMenus")
web.Router("/v1/user/favorite-menus", &controllers.AuthController{}, "Get:GetFavoriteMenus")
web.Router("/v1/user/favorite-menus", &mobile_client.UserController{}, "Post:UpdateMenuFavorite")
web.Router("/v1/user/favorite-org", &mobile_client.UserController{}, "Post:UpdateOrgFavorite")
web.Router("/v1/user/favorite", &mobile_client.UserController{}, "Post:UpdateOrgFavorite")
web.Router("/v1/user/change-password", &mobile_client.UserController{}, "Post:ChangePassword")
web.Router("/v1/user/change-phone", &mobile_client.UserController{}, "Post:ChangePhone")
... ...
package blur
import (
"errors"
"fmt"
"github.com/disintegration/imaging"
"github.com/pdfcpu/pdfcpu/pkg/api"
"io/fs"
"io/ioutil"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strings"
)
const (
SIGMA = 5
BlurPrefix = "blur-"
)
var (
outPath = "./static/"
cmdPath = "./cmd/pdftopng.exe" //xpdf https://www.xpdfreader.com/download.html
tmpPath = "./tmp/"
)
// InitConfig 初始化配置
// cp 执行文件目录
// op 输出目录
// tp 临时文件目录
func InitConfig(cp, op, tp string) {
cmdPath = cp
outPath = op
tmpPath = tp
initConfig()
}
func InitDefaultConfig() {
initConfig()
}
func initConfig() {
if _, err := os.Stat(tmpPath); err != nil {
if errors.Is(err, os.ErrNotExist) {
os.MkdirAll(tmpPath, os.ModePerm)
}
}
if _, err := os.Stat(outPath); err != nil {
if errors.Is(err, os.ErrNotExist) {
os.MkdirAll(outPath, os.ModePerm)
}
}
if runtime.GOOS == "linux" {
cmdPath = strings.TrimLeft(cmdPath, ".exe")
}
}
// CheckFileExist 检查文件是否存在
func CheckFileExist(p string) (string, error) {
filename := filepath.Base(p)
f, err := os.Stat(filepath.Join(outPath, filename))
if f != nil && err == nil {
return p, nil
}
return "", fmt.Errorf("file not exisit %v", p)
}
// FileBlur 文件模糊处理
// blurFlag true:执行模糊 false:不需要模糊
func FileBlur(filePath string, blurFlag bool) (string, error) {
filename := filepath.Base(filePath)
// 判断文件是否存在
if !blurFlag {
return filePath, nil
}
if fs, e := CheckFileExist(filepath.Join(outPath, BlurPrefix+filename)); e == nil && len(fs) > 0 {
return fs, nil
}
var err error
filePath, err = ResolveFilePath(filePath)
if err != nil {
return "", err
}
ext := filepath.Ext(filePath)
ext = strings.TrimSpace(ext)
if ext == ".pdf" {
return PDFBlur(filePath)
}
if strings.Contains(".png|.jpg|.jpeg", ext) {
return ImageBlur(filePath)
}
return filePath, nil
}
// ImageBlur 图片模糊处理
func ImageBlur(filePath string) (string, error) {
filename := filepath.Base(filePath)
blurFilename := filepath.Join(outPath, BlurPrefix+filename)
img, err := imaging.Open(filePath)
if err != nil {
return "", err
}
dst := imaging.Blur(img, SIGMA)
err = imaging.Save(dst, blurFilename)
// clear
os.Remove(filePath)
return blurFilename, err
}
// PDFBlur PDF 模糊处理
func PDFBlur(pdfPath string) (string, error) {
filename := filepath.Base(pdfPath)
blurFilename := filepath.Join(outPath, BlurPrefix+filename)
tmpImagePath, err := ioutil.TempDir("", "image-")
tmpImagePathBlur, err := ioutil.TempDir("", "image-"+BlurPrefix)
cmd := exec.Command(cmdPath, pdfPath, tmpImagePath+"/")
err = cmd.Run()
if err != nil {
panic(err)
}
var blurFiles = make([]string, 0)
files, _ := ioutil.ReadDir(tmpImagePath)
for _, f := range files {
img, _ := imaging.Open(filepath.Join(tmpImagePath, f.Name()))
dst := imaging.Blur(img, SIGMA)
blurFiles = append(blurFiles, filepath.Join(tmpImagePathBlur, f.Name()))
_ = imaging.Save(dst, filepath.Join(tmpImagePathBlur, f.Name()))
}
sort.Strings(blurFiles)
err = api.ImportImagesFile(blurFiles, blurFilename, nil, nil)
if err != nil {
return "", err
}
//clear
os.RemoveAll(tmpImagePath)
os.RemoveAll(tmpImagePathBlur)
os.Remove(pdfPath)
return blurFilename, nil
}
// ResolveFilePath 解析文件
func ResolveFilePath(filePath string) (string, error) {
if strings.HasPrefix(filePath, "http") || strings.HasPrefix(filePath, "https") {
return download(filePath)
}
return filePath, nil
}
func download(url string) (string, error) {
resp, err := http.Get(url)
if err != nil {
return "", err
}
fileName := filepath.Base(url)
data, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
tmpFilePath := filepath.Join(tmpPath, fileName)
err = ioutil.WriteFile(tmpFilePath, data, fs.ModePerm)
if err != nil {
return "", nil
}
return tmpFilePath, err
}
... ...