初始
This commit is contained in:
923
internal/app/wxApplet/controller/appPort.go
Normal file
923
internal/app/wxApplet/controller/appPort.go
Normal file
@ -0,0 +1,923 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/samber/lo"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/system"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/tiger1103/gfast/v3/library/liberr"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/common/coryCommon"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
wxSystem "github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
controllerDao "github.com/tiger1103/gfast/v3/internal/app/system/dao"
|
||||
|
||||
ct "github.com/tiger1103/gfast/v3/internal/app/system/logic/context"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/model"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/model/entity"
|
||||
serviceController "github.com/tiger1103/gfast/v3/internal/app/system/service"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/dao"
|
||||
wxAppletModel "github.com/tiger1103/gfast/v3/internal/app/wxApplet/model"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type appPortController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var AppPortController = new(appPortController)
|
||||
|
||||
// ===========================================APP首页===========================================
|
||||
// ===========================================APP首页===========================================
|
||||
// ===========================================APP首页===========================================
|
||||
|
||||
// GetsTheAttendanceOfASpecifiedShiftGroupFunc 班组长人员打卡统计
|
||||
func (c *appPortController) GetsTheAttendanceOfASpecifiedShiftGroupFunc(ctx context.Context, req *wxApplet.GetsTheAttendanceOfASpecifiedShiftGroupReq) (res *wxApplet.GetsTheAttendanceOfASpecifiedShiftGroupRes, err error) {
|
||||
res, err = service.SysProjectTeam().GetsTheAttendanceOfASpecifiedShiftGroupFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ListOfAttendancePersonnelFunc 获取用户对应出勤状态的人员列表
|
||||
func (c *appPortController) ListOfAttendancePersonnelFunc(ctx context.Context, req *wxApplet.ListOfAttendancePersonnelReq) (res *wxApplet.ListOfAttendancePersonnelRes, err error) {
|
||||
res, err = service.SysProjectTeam().ListOfAttendancePersonnelFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppUserMenuFunc 获取用户菜单
|
||||
func (c *appPortController) AppUserMenuFunc(ctx context.Context, req *wxApplet.AppUserMenusReq) (*wxApplet.AppUserMenusRes, error) {
|
||||
// 获取用户信息
|
||||
userInfo := ct.New().GetLoginUser(ctx)
|
||||
|
||||
// 获取用户角色
|
||||
roleIds, err := getUserRoles(ctx, userInfo, req.UserType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var userMenuList []wxApplet.AppUserMenu
|
||||
// 获取用户菜单
|
||||
if err := controllerDao.AppMenus.Ctx(ctx).As("menu").
|
||||
InnerJoin("app_role_menus roleMenu", "menu.menu_id = roleMenu.menu_id").
|
||||
Where("roleMenu.role_id IN (?)", roleIds).
|
||||
Fields("menu.menu_id, menu.menu_name").Scan(&userMenuList); err != nil {
|
||||
return nil, fmt.Errorf("获取用户菜单失败:%w", err)
|
||||
}
|
||||
|
||||
userMenuList = lo.UniqBy(userMenuList, func(item wxApplet.AppUserMenu) uint {
|
||||
return item.MenuID
|
||||
})
|
||||
|
||||
return &wxApplet.AppUserMenusRes{MenuList: userMenuList}, nil
|
||||
}
|
||||
|
||||
// getUserRoles 获取用户角色
|
||||
func getUserRoles(ctx context.Context, user *model.ContextUser, role int) ([]int, error) {
|
||||
rules := []model.Ruler{}
|
||||
|
||||
query := controllerDao.AppUserRoles.Ctx(ctx).As("aur").
|
||||
InnerJoin("app_roles ar", "aur.role_id = ar.role_id").
|
||||
Fields("ar.role_id,ar.role_name,aur.user_id").
|
||||
Where("aur.user_id", user.Id).
|
||||
Where("aur.major_role", role)
|
||||
if err := query.Scan(&rules); err != nil {
|
||||
return nil, fmt.Errorf("获取用户角色失败:%w", err)
|
||||
}
|
||||
|
||||
roleID := lo.FilterMap(rules, func(item model.Ruler, _ int) (int, bool) {
|
||||
return item.RoleId, true
|
||||
})
|
||||
|
||||
return roleID, nil
|
||||
}
|
||||
|
||||
// AppMyAttendanceFunc 我的考勤
|
||||
func (c *appPortController) AppMyAttendanceFunc(ctx context.Context, req *wxApplet.AppMyAttendanceReq) (res *wxApplet.AppMyAttendanceRes, err error) {
|
||||
res = new(wxApplet.AppMyAttendanceRes)
|
||||
res, err = service.BusAttendance().AppMyAttendanceFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppMyAttendanceDetailsFunc 我的考勤详情数据
|
||||
func (c *appPortController) AppMyAttendanceDetailsFunc(ctx context.Context, req *wxApplet.AppMyAttendanceDetailsReq) (res *wxApplet.AppMyAttendanceDetailsRes, err error) {
|
||||
res = new(wxApplet.AppMyAttendanceDetailsRes)
|
||||
res, err = service.BusAttendance().AppMyAttendanceDetailsFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppProjectOverviewFunc 项目概况
|
||||
func (c *appPortController) AppProjectOverviewFunc(ctx context.Context, req *wxApplet.AppProjectOverviewReq) (res *wxApplet.AppProjectOverviewRes, err error) {
|
||||
res = new(wxApplet.AppProjectOverviewRes)
|
||||
res, err = service.BusAttendance().AppProjectOverviewFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppSafetyHazardTodayFunc 项目概况>今日AI安全隐患
|
||||
func (c *appPortController) AppSafetyHazardTodayFunc(ctx context.Context, req *wxApplet.AppSafetyHazardTodayReq) (res *wxApplet.AppSafetyHazardTodayRes, err error) {
|
||||
res, err = serviceController.BusViolationRecord().AppSafetyHazardTodayFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppWeatherFunc 【小程序】获取施工人员天气
|
||||
func (c *appPortController) AppWeatherFunc(ctx context.Context, req *wxApplet.AppWeatherReq) (res *wxApplet.AppWeatherRes, err error) {
|
||||
res = new(wxApplet.AppWeatherRes)
|
||||
we := coryCommon.Weather(req.Location)
|
||||
bodyData := []byte(we)
|
||||
err = json.Unmarshal(bodyData, &res)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to parse JSON data:", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AppProjectNoticeListFunc 首页获取滚动的项目公告列表
|
||||
func (c *appPortController) AppProjectNoticeListFunc(ctx context.Context, req *wxApplet.AppProjectNoticeReq) (*wxApplet.AppProjectNoticeRes, error) {
|
||||
userId := ct.New().GetLoginUser(ctx).Id
|
||||
|
||||
noticeList := []*wxApplet.ProjectNoticeList{}
|
||||
if err := controllerDao.Notifications.Ctx(ctx).
|
||||
Fields(controllerDao.Notifications.Columns().Title).
|
||||
LeftJoin("notification_recipients nf", "notifications.id = nf.notification_id").
|
||||
Where(controllerDao.Notifications.Columns().ProjectId, req.ProjectId).
|
||||
Where(controllerDao.Notifications.Columns().IsApp, 1).
|
||||
Where("nf.recipient_id", userId).
|
||||
Limit(20).OrderDesc("notifications.id").Scan(¬iceList); err != nil {
|
||||
return nil, fmt.Errorf("获取项目公告失败:%w", err)
|
||||
}
|
||||
return &wxApplet.AppProjectNoticeRes{
|
||||
List: noticeList,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AppRegisteredButNotVerifiedWithRealName 获取所有已注册未实名的用户
|
||||
func (c *appPortController) AppRegisteredButNotVerifiedWithRealName(ctx context.Context, req *wxApplet.AppRegisteredButNotVerifiedWithRealNameReq) (res *wxApplet.AppRegisteredButNotVerifiedWithRealNameRes, err error) {
|
||||
res, err = serviceController.BusConstructionUser().AppRegisteredButNotVerifiedWithRealNameFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================定位考勤===========================================
|
||||
// ===========================================定位考勤===========================================
|
||||
// ===========================================定位考勤===========================================
|
||||
|
||||
// AppCodedBackwardsByLatitudeAndLongitudeFunc 根据经度纬度逆编码为省市区信息
|
||||
func (c *appPortController) AppCodedBackwardsByLatitudeAndLongitudeFunc(ctx context.Context, req *wxApplet.AppCodedBackwardsByLatitudeAndLongitudeReq) (res *wxApplet.AppCodedBackwardsByLatitudeAndLongitudeRes, err error) {
|
||||
res = new(wxApplet.AppCodedBackwardsByLatitudeAndLongitudeRes)
|
||||
we := coryCommon.InverseGeocoding(req.Location)
|
||||
bodyData := []byte(we)
|
||||
err = json.Unmarshal(bodyData, &res)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AppOpenidByFounderFunc 返回当前用户所在项目的打卡范围
|
||||
func (c *appPortController) AppOpenidByFounderFunc(ctx context.Context, req *wxApplet.AppOpenidByFounderReq) (res *wxApplet.AppOpenidByFounderRes, err error) {
|
||||
res = new(wxApplet.AppOpenidByFounderRes)
|
||||
founderFunc, err := OpenidByFounderFunc(ctx, req.Openid)
|
||||
err = copier.Copy(&res, founderFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// AppWhetherToEnterTheClockRangeFunc 判断当前用户是否进入打卡范围
|
||||
func (c *appPortController) AppWhetherToEnterTheClockRangeFunc(ctx context.Context, req *wxApplet.AppWhetherToEnterTheClockRangeReq) (res *wxApplet.AppWhetherToEnterTheClockRangeRes, err error) {
|
||||
res = new(wxApplet.AppWhetherToEnterTheClockRangeRes)
|
||||
res, err = service.BusAttendance().AppWhetherToEnterTheClockRangeFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppClockingStatusOfTheDayFunc 判断当前用户当天的打卡状态(1未打卡、2已打上班卡、3已打下班卡)
|
||||
func (c *appPortController) AppClockingStatusOfTheDayFunc(ctx context.Context, req *wxApplet.AppClockingStatusOfTheDayReq) (res *wxApplet.AppClockingStatusOfTheDayRes, err error) {
|
||||
res = new(wxApplet.AppClockingStatusOfTheDayRes)
|
||||
res, err = service.BusAttendance().AppClockingStatusOfTheDayFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppFaceDetectionFunc 人脸检测
|
||||
func (c *appPortController) AppFaceDetectionFunc(ctx context.Context, req *wxApplet.AppFaceDetectionReq) (res *wxApplet.AppFaceDetectionRes, err error) {
|
||||
res = new(wxApplet.AppFaceDetectionRes)
|
||||
res.Path, err = FaceDetectionFunc(ctx, req.File)
|
||||
return
|
||||
}
|
||||
|
||||
// AppAttendanceCardFunc 考勤打卡
|
||||
func (c *appPortController) AppAttendanceCardFunc(ctx context.Context, req *wxApplet.AppAttendanceCardReq) (res *wxApplet.AppAttendanceCardRes, err error) {
|
||||
res = new(wxApplet.AppAttendanceCardRes)
|
||||
addReq := wxApplet.BusAttendanceAddReq{}
|
||||
copier.Copy(&addReq, &req)
|
||||
err = service.BusAttendance().Add(ctx, &addReq)
|
||||
return
|
||||
}
|
||||
|
||||
// AppAllMembersOfTheCurrentGroupFunc 获取当前组的所有成员(除自己)
|
||||
func (c *appPortController) AppAllMembersOfTheCurrentGroupFunc(ctx context.Context, req *wxApplet.AppAllMembersOfTheCurrentGroupReq) (res *wxApplet.AppAllMembersOfTheCurrentGroupRes, err error) {
|
||||
res, err = service.BusConstructionUser().AppAllMembersOfTheCurrentGroupFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppSelectThisUserByCardRecordFunc 为指定用户查询打卡记录
|
||||
func (c *appPortController) AppSelectThisUserByCardRecordFunc(ctx context.Context, req *wxApplet.AppSelectThisUserByCardRecordReq) (res *wxApplet.AppSelectThisUserByCardRecordRes, err error) {
|
||||
res, err = service.BusAttendance().AppSelectThisUserByCardRecordFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppLocationAttendanceStatisticsFunc 定位考勤统计
|
||||
func (c *appPortController) AppLocationAttendanceStatisticsFunc(ctx context.Context, req *wxApplet.AppLocationAttendanceStatisticsReq) (res *wxApplet.AppLocationAttendanceStatisticsRes, err error) {
|
||||
res, err = service.BusAttendance().AppLocationAttendanceStatisticsFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppSelectBySiteDateAndTimeFunc 根据openid获取到项目的逆编码地址及项目的上下班打卡时间
|
||||
func (c *appPortController) AppSelectBySiteDateAndTimeFunc(ctx context.Context, req *wxApplet.AppSelectBySiteDateAndTimeReq) (res *wxApplet.AppSelectBySiteDateAndTimeRes, err error) {
|
||||
res = new(wxApplet.AppSelectBySiteDateAndTimeRes)
|
||||
data, err := serviceController.SysProject().GetById(ctx, req.ProjectId)
|
||||
res.PunchRange = data.PunchRange
|
||||
res.Lng = data.Lng
|
||||
res.Lat = data.Lat
|
||||
// 逆编码
|
||||
var entity *coryCommon.InverseGeocodingRep
|
||||
we := coryCommon.InverseGeocoding(data.Lng + "," + data.Lat)
|
||||
bodyData := []byte(we)
|
||||
err = json.Unmarshal(bodyData, &entity)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res.Site = entity.Regeocode.FormattedAddress
|
||||
return
|
||||
}
|
||||
|
||||
// AppMyProjectListFunc 获取项目列表
|
||||
func (c *appPortController) AppMyProjectListFunc(ctx context.Context, req *wxApplet.AppMyProjectListReq) (*wxApplet.SysUserProjectRelevancySearchRes, error) {
|
||||
// 获取当前登录用户ID
|
||||
userInfo := ct.New().GetLoginUser(ctx)
|
||||
|
||||
// 当前登录用户ID
|
||||
userID := userInfo.Id
|
||||
|
||||
// 用户手机号
|
||||
phone := userInfo.Mobile
|
||||
|
||||
var query *gdb.Model
|
||||
|
||||
fields := `a.*,
|
||||
CASE WHEN (b.short_name IS NULL OR b.project_name = '') THEN b.project_name ELSE b.short_name END AS project_name,
|
||||
b.lng, b.lat, b.type, b.project_site`
|
||||
|
||||
if req.ProjectType == 0 {
|
||||
// 管理员获取项目时,将获取后台所拥有的项目
|
||||
query = dao.SysUserProjectRelevancy.Ctx(ctx).As("a").
|
||||
InnerJoin("sys_project as b on a.project_id = b.id").
|
||||
Fields(fields).Where("a.user_id", userID)
|
||||
} else {
|
||||
// 当请求者为施工人员时,从 bus_construction_user 表中获取其绑定的项目信息
|
||||
query = dao.BusConstructionUser.Ctx(ctx).As("a").
|
||||
InnerJoin("sys_project as b on a.project_id = b.id").
|
||||
Fields(fields).Where("a.phone", phone)
|
||||
}
|
||||
|
||||
var projectList []*wxAppletModel.SysUserProjectRelevancyListRes
|
||||
if err := query.Scan(&projectList); err != nil {
|
||||
return nil, fmt.Errorf("获取项目列表失败:%w", err)
|
||||
}
|
||||
|
||||
return &wxApplet.SysUserProjectRelevancySearchRes{
|
||||
List: projectList,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AppReissueACardListFunc 补卡申请列表(目前只会展示缺卡的数据)
|
||||
func (c *appPortController) AppReissueACardListFunc(ctx context.Context, req *wxApplet.AppReissueACardListReq) (res *wxApplet.AppReissueACardListRes, err error) {
|
||||
res, err = service.BusAttendance().AppReissueACardListFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppReissueACardIdFunc 补卡申请ID查询
|
||||
func (c *appPortController) AppReissueACardIdFunc(ctx context.Context, req *wxApplet.AppReissueACardIdReq) (res *wxApplet.AppReissueACardIdRes, err error) {
|
||||
res, err = service.BusAttendance().AppReissueACardIdFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppCardReplacementApplicationAddFunc 新增补卡申请
|
||||
func (c *appPortController) AppCardReplacementApplicationAddFunc(ctx context.Context, req *wxApplet.AppCardReplacementApplicationAddReq) (res *wxApplet.AppCardReplacementApplicationAddRes, err error) {
|
||||
r := wxApplet.ReissueACardWxAddReq{}
|
||||
copier.Copy(&r, &req)
|
||||
err = serviceController.BusReissueACard().ReissueACardWxAdd(ctx, &r)
|
||||
return
|
||||
}
|
||||
|
||||
// AppReplacementCardApplicationRecordFunc 申请人补卡记录(分页)
|
||||
func (c *appPortController) AppReplacementCardApplicationRecordFunc(ctx context.Context, req *wxApplet.AppReplacementCardApplicationRecordReq) (res *wxApplet.AppReplacementCardApplicationRecordRes, err error) {
|
||||
res = new(wxApplet.AppReplacementCardApplicationRecordRes)
|
||||
// 请求
|
||||
r := wxApplet.ReissueACardWxGetByIdReq{}
|
||||
copier.Copy(&r, &req)
|
||||
// 返回
|
||||
idFunc, err := serviceController.BusReissueACard().ReissueACardWxGetByIdFunc(ctx, &r)
|
||||
copier.Copy(&res, &idFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// AppTheTeamLeaderSupplementCardApprovalListFun 班组长补卡审批列表(分页)
|
||||
func (c *appPortController) AppTheTeamLeaderSupplementCardApprovalListFun(ctx context.Context, req *wxApplet.AppTheTeamLeaderSupplementCardApprovalListReq) (res *wxApplet.AppTheTeamLeaderSupplementCardApprovalListRes, err error) {
|
||||
entity := model.AppTheTeamLeaderSupplementCardApprovalRes{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Type = "1"
|
||||
res, err = serviceController.BusReissueACard().AppTheTeamLeaderSupplementCardApprovalListFun(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// AppTheTeamLeaderSupplementCardApprovalRecordListFunc 班组长补卡审批记录列表(分页)
|
||||
func (c *appPortController) AppTheTeamLeaderSupplementCardApprovalRecordListFunc(ctx context.Context, req *wxApplet.AppTheTeamLeaderSupplementCardApprovalRecordListReq) (res *wxApplet.AppTheTeamLeaderSupplementCardApprovalListRes, err error) {
|
||||
entity := model.AppTheTeamLeaderSupplementCardApprovalRes{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Type = "2"
|
||||
res, err = serviceController.BusReissueACard().AppTheTeamLeaderSupplementCardApprovalListFun(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// AppApprovalRecordDetailsFunc 审批记录详情
|
||||
func (c *appPortController) AppApprovalRecordDetailsFunc(ctx context.Context, req *wxApplet.AppApprovalRecordDetailsReq) (res *wxApplet.AppApprovalRecordDetailsRes, err error) {
|
||||
res, err = serviceController.BusReissueACard().AppApprovalRecordDetailsFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppForemanApprovalFunc 班组长审批
|
||||
func (c *appPortController) AppForemanApprovalFunc(ctx context.Context, req *wxApplet.AppForemanApprovalReq) (res *wxApplet.AppForemanApprovalRes, err error) {
|
||||
entity := wxApplet.ReissueACardWxEditTeamReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
err = serviceController.BusReissueACard().ReissueACardWxEditTeam(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// @Title AdministratorApprovalFunc 2024/7/26 15:20:00
|
||||
// @Description 管理员审批(仅限于管理员操作)
|
||||
// @Auth Cory
|
||||
func (c *appPortController) AdministratorApprovalFunc(ctx context.Context, req *wxApplet.AdministratorApprovalReq) (res *wxApplet.AdministratorApprovalRes, err error) {
|
||||
editReq := system.BusReissueACardEditReq{}
|
||||
copier.Copy(&editReq, &req)
|
||||
err = serviceController.BusReissueACard().Edit(ctx, &editReq)
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================安全(HSE)巡检工单===========================================
|
||||
// ===========================================安全(HSE)巡检工单===========================================
|
||||
// ===========================================安全(HSE)巡检工单===========================================
|
||||
|
||||
// AppManagementAppletListInformFunc 安全巡检工单列表-全部(分页)
|
||||
func (c *appPortController) AppManagementAppletListInformFunc(ctx context.Context, req *wxApplet.AppManagementAppletListInformReq) (res *wxApplet.AppManagementAppletListRes, err error) {
|
||||
res = new(wxApplet.AppManagementAppletListRes)
|
||||
entity := wxApplet.HseManagementAppletListReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Status = "0"
|
||||
listFunc, err := serviceController.BusHseManagement().HseManagementAppletListFunc(ctx, &entity)
|
||||
copier.Copy(&res, listFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// AppManagementAppletListAbarbeitungFunc 安全巡检工单列表-整改(分页)
|
||||
func (c *appPortController) AppManagementAppletListAbarbeitungFunc(ctx context.Context, req *wxApplet.AppManagementAppletListAbarbeitungReq) (res *wxApplet.AppManagementAppletListRes, err error) {
|
||||
res = new(wxApplet.AppManagementAppletListRes)
|
||||
entity := wxApplet.HseManagementAppletListReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Status = "1"
|
||||
listFunc, err := serviceController.BusHseManagement().HseManagementAppletListFunc(ctx, &entity)
|
||||
copier.Copy(&res, listFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// AppManagementAppletListReviewFunc 安全巡检工单列表-复查(分页)
|
||||
func (c *appPortController) AppManagementAppletListReviewFunc(ctx context.Context, req *wxApplet.AppManagementAppletListReviewReq) (res *wxApplet.AppManagementAppletListRes, err error) {
|
||||
res = new(wxApplet.AppManagementAppletListRes)
|
||||
entity := wxApplet.HseManagementAppletListReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Status = "2"
|
||||
listFunc, err := serviceController.BusHseManagement().HseManagementAppletListFunc(ctx, &entity)
|
||||
copier.Copy(&res, listFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// APPAddedDataSecurityForBackgroundUsersFunc APP的后台用户新增安全数据
|
||||
func (c *appPortController) APPAddedDataSecurityForBackgroundUsersFunc(ctx context.Context, req *wxApplet.APPAddedDataSecurityForBackgroundUsersReq) (res *wxApplet.APPAddedDataSecurityForBackgroundUsersRes, err error) {
|
||||
entity := system.BusHseManagementAddReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.HseManagementAdd = 1
|
||||
entity.FileTwo = req.File
|
||||
err = serviceController.BusHseManagement().Add(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// APPReviewDataSecurityForBackgroundUsersFunc APP的后台用户复查安全数据
|
||||
func (c *appPortController) APPReviewDataSecurityForBackgroundUsersFunc(ctx context.Context, req *wxApplet.APPReviewDataSecurityForBackgroundUsersReq) (res *wxApplet.APPReviewDataSecurityForBackgroundUsersRes, err error) {
|
||||
entity := system.EditReviewReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
err = serviceController.BusHseManagement().EditReview(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================质量管理===========================================
|
||||
// ===========================================质量管理===========================================
|
||||
// ===========================================质量管理===========================================
|
||||
|
||||
// AppInspectionTicketAppletListInformFunc 质量管理列表-全部(分页)
|
||||
func (c *appPortController) AppInspectionTicketAppletListInformFunc(ctx context.Context, req *wxApplet.AppInspectionTicketAppletListInformReq) (res *wxApplet.AppInspectionTicketAppletListRes, err error) {
|
||||
res = new(wxApplet.AppInspectionTicketAppletListRes)
|
||||
entity := wxApplet.InspectionTicketAppletListReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Status = "0"
|
||||
listFunc, err := serviceController.BusInspectionTicket().InspectionTicketAppletListFunc(ctx, &entity)
|
||||
copier.Copy(&res, listFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// AppInspectionTicketAppletListAbarbeitungFunc 质量管理列表-整改(分页)
|
||||
func (c *appPortController) AppInspectionTicketAppletListAbarbeitungFunc(ctx context.Context, req *wxApplet.AppInspectionTicketAppletListAbarbeitungReq) (res *wxApplet.AppInspectionTicketAppletListRes, err error) {
|
||||
res = new(wxApplet.AppInspectionTicketAppletListRes)
|
||||
entity := wxApplet.InspectionTicketAppletListReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Status = "1"
|
||||
listFunc, err := serviceController.BusInspectionTicket().InspectionTicketAppletListFunc(ctx, &entity)
|
||||
copier.Copy(&res, listFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// AppInspectionTicketAppletListReviewFunc 质量管理列表-复查(分页)
|
||||
func (c *appPortController) AppInspectionTicketAppletListReviewFunc(ctx context.Context, req *wxApplet.AppInspectionTicketAppletListReviewReq) (res *wxApplet.AppInspectionTicketAppletListRes, err error) {
|
||||
res = new(wxApplet.AppInspectionTicketAppletListRes)
|
||||
entity := wxApplet.InspectionTicketAppletListReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.Status = "2"
|
||||
listFunc, err := serviceController.BusInspectionTicket().InspectionTicketAppletListFunc(ctx, &entity)
|
||||
copier.Copy(&res, listFunc)
|
||||
return
|
||||
}
|
||||
|
||||
// AppQualityDataIsAddedForBackgroundUsersFunc APP的后台用户新增质量数据
|
||||
func (c *appPortController) AppQualityDataIsAddedForBackgroundUsersFunc(ctx context.Context, req *wxApplet.AppQualityDataIsAddedForBackgroundUsersReq) (res *wxApplet.AppQualityDataIsAddedForBackgroundUsersRes, err error) {
|
||||
entity := system.BusInspectionTicketAddReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
entity.HseManagementAdd = 1
|
||||
entity.FileTwo = req.File
|
||||
err = serviceController.BusInspectionTicket().Add(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// AppBackgroundUsersReviewQualityDataFunc APP的后台用户复查质量数据
|
||||
func (c *appPortController) AppBackgroundUsersReviewQualityDataFunc(ctx context.Context, req *wxApplet.AppBackgroundUsersReviewQualityDataReq) (res *wxApplet.AppBackgroundUsersReviewQualityDataRes, err error) {
|
||||
entity := system.BusInspectionTicketVerificationReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
err = serviceController.BusInspectionTicket().EditVerification(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================AI===========================================
|
||||
// ===========================================AI===========================================
|
||||
// ===========================================AI===========================================
|
||||
|
||||
// AppAiInformFunc 选择处理人
|
||||
func (c *appPortController) AppAiInformFunc(ctx context.Context, req *wxApplet.AppAiInformReq) (res *wxApplet.AppAiInformRes, err error) {
|
||||
err = serviceController.BusViolationRecord().AppAiInformFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppGetsAllThePeopleUnderTheCurrentPersonsProjectFunc 取当前人所在项目下的所有人
|
||||
func (c *appPortController) AppGetsAllThePeopleUnderTheCurrentPersonsProjectFunc(ctx context.Context, req *wxApplet.AppGetsAllThePeopleUnderTheCurrentPersonsProjectReq) (res *wxApplet.AppGetsAllThePeopleUnderTheCurrentPersonsProjectRes, err error) {
|
||||
res = new(wxApplet.AppGetsAllThePeopleUnderTheCurrentPersonsProjectRes)
|
||||
projectFunc, err := serviceController.BusViolationRecord().AppGetsAllThePeopleUnderTheCurrentPersonsProjectFunc(ctx, req)
|
||||
res = projectFunc
|
||||
return
|
||||
}
|
||||
|
||||
// AppWorkOrderPcListFunc AI工单列表(根据pc用户主键ID进行分页获取)
|
||||
func (c *appPortController) AppWorkOrderPcListFunc(ctx context.Context, req *wxApplet.AppWorkOrderPcListReq) (res *wxApplet.AppWorkOrderPcListRes, err error) {
|
||||
res = new(wxApplet.AppWorkOrderPcListRes)
|
||||
projectFunc, err := serviceController.BusViolationRecord().AppWorkOrderPcListFunc(ctx, req)
|
||||
res = projectFunc
|
||||
return
|
||||
}
|
||||
|
||||
// AppWorkOrderAppListFunc AI工单列表(根据App用户主键ID进行分页获取)
|
||||
func (c *appPortController) AppWorkOrderAppListFunc(ctx context.Context, req *wxApplet.AppWorkOrderAppListReq) (res *wxApplet.AppWorkOrderPcListRes, err error) {
|
||||
res = new(wxApplet.AppWorkOrderPcListRes)
|
||||
projectFunc, err := serviceController.BusViolationRecord().AppWorkOrderAppListFunc(ctx, req)
|
||||
res = projectFunc
|
||||
return
|
||||
}
|
||||
|
||||
// AppRectificationReplyFunc AI整改回复
|
||||
func (c *appPortController) AppRectificationReplyFunc(ctx context.Context, req *wxApplet.AppRectificationReplyReq) (res *wxApplet.AppRectificationReplyRes, err error) {
|
||||
res = new(wxApplet.AppRectificationReplyRes)
|
||||
err = serviceController.BusViolationRecord().AppRectificationReplyFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppReviewFuncFunc AI复查
|
||||
func (c *appPortController) AppReviewFuncFunc(ctx context.Context, req *wxApplet.AppReviewReq) (res *wxApplet.AppReviewRes, err error) {
|
||||
res = new(wxApplet.AppReviewRes)
|
||||
req.Operator = ct.New().GetLoginUser(ctx).OpenId
|
||||
err = serviceController.BusViolationRecord().AppReviewFuncFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppWorkOrderParticularsFunc AI工单详情
|
||||
func (c *appPortController) AppWorkOrderParticularsFunc(ctx context.Context, req *wxApplet.AppWorkOrderParticularsReq) (res *wxApplet.AppWorkOrderParticularsRes, err error) {
|
||||
res = new(wxApplet.AppWorkOrderParticularsRes)
|
||||
particularsFunc, err := serviceController.BusViolationRecord().AppWorkOrderParticularsFunc(ctx, req)
|
||||
res = particularsFunc
|
||||
return
|
||||
}
|
||||
|
||||
// =========================================== 消息 ===========================================
|
||||
// =========================================== 消息 ===========================================
|
||||
// =========================================== 消息 ===========================================
|
||||
|
||||
// AppMessageListFunc 消息列表
|
||||
func (c *appPortController) AppMessageListFunc(ctx context.Context, req *wxApplet.AppMessageListReq) (res *wxApplet.AppMessageListRes, err error) {
|
||||
// 获取用户信息
|
||||
user := ct.New().GetLoginUser(ctx)
|
||||
|
||||
res = new(wxApplet.AppMessageListRes)
|
||||
|
||||
fields := "title,created_at, (SELECT COUNT(*) FROM reminders WHERE is_read = 0 and user_id = '%s' and project_id = %s) AS unread_count"
|
||||
|
||||
userID := lo.If(req.OpenID != "", user.OpenId).Else(strconv.Itoa(int(user.Id)))
|
||||
|
||||
// 查询提醒
|
||||
controllerDao.Reminders.Ctx(ctx).Fields(fmt.Sprintf(fields, userID, req.ProjectId)).
|
||||
Where("is_read", 0).
|
||||
Where("project_id", req.ProjectId).
|
||||
OrderDesc("id").
|
||||
Where("user_id", userID).
|
||||
Limit(1).Scan(&res.Remind)
|
||||
|
||||
fields = "content as title,created_at, (SELECT COUNT(*) FROM comment_list WHERE is_read = 0 and receiver = %d and project_id = %s) AS unread_count"
|
||||
controllerDao.CommentList.Ctx(ctx).Fields(fmt.Sprintf(fields, user.Id, req.ProjectId)).
|
||||
Where("is_read", 0).
|
||||
Where("receiver", user.Id).
|
||||
Where("project_id", req.ProjectId).
|
||||
OrderDesc("id").
|
||||
Limit(1).Scan(&res.Comment)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================人员管理===========================================
|
||||
// ===========================================人员管理===========================================
|
||||
// ===========================================人员管理===========================================
|
||||
|
||||
// AppChangeThePunchStatusForTheSpecifiedPersonFunc 给指定人更改打卡状态
|
||||
func (c *appPortController) AppChangeThePunchStatusForTheSpecifiedPersonFunc(ctx context.Context, req *wxApplet.AppChangeThePunchStatusForTheSpecifiedPersonReq) (res *wxApplet.AppChangeThePunchStatusForTheSpecifiedPersonRes, err error) {
|
||||
entity := system.ClockingConditionReq{}
|
||||
copier.Copy(&entity, &req)
|
||||
err = serviceController.BusConstructionUser().ClockingConditionFunc(ctx, &entity)
|
||||
return
|
||||
}
|
||||
|
||||
// AppSelectAppointProjectAllTeamFunc 获取指定项目所有班组
|
||||
func (c *appPortController) AppSelectAppointProjectAllTeamFunc(ctx context.Context, req *wxApplet.AppSelectAppointProjectAllTeamReq) (res *wxApplet.AppSelectAppointProjectAllTeamRes, err error) {
|
||||
res = new(wxApplet.AppSelectAppointProjectAllTeamRes)
|
||||
var entity []*wxAppletModel.SysProjectTeamListRes
|
||||
err = dao.SysProjectTeam.Ctx(ctx).Where(dao.SysProjectTeam.Columns().ProjectId, req.ProjectId).Scan(&entity)
|
||||
res.List = entity
|
||||
return
|
||||
}
|
||||
|
||||
// AppListOfParticipatingUnitsFunc 参建单位列表
|
||||
func (c *appPortController) AppListOfParticipatingUnitsFunc(ctx context.Context, req *wxApplet.AppListOfParticipatingUnitsReq) (res *wxApplet.AppListOfParticipatingUnitsRes, err error) {
|
||||
res, err = service.BusLabourservice().AppListOfParticipatingUnitsFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppListOfConstructionPersonnelFunc 施工人员列表(分页)
|
||||
func (c *appPortController) AppListOfConstructionPersonnelFunc(ctx context.Context, req *wxApplet.AppListOfConstructionPersonnelReq) (res *wxApplet.AppListOfConstructionPersonnelRes, err error) {
|
||||
res, err = service.BusConstructionUser().AppListOfConstructionPersonnelFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppExitFunc 退场
|
||||
func (c *appPortController) AppExitFunc(ctx context.Context, req *wxApplet.AppExitReq) (res *wxApplet.AppExitRes, err error) {
|
||||
res = new(wxApplet.AppExitRes)
|
||||
err = serviceController.BusConstructionUser().AppExitFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppResubmitTheExitAttachmentFunc 补交退场附件
|
||||
func (c *appPortController) AppResubmitTheExitAttachmentFunc(ctx context.Context, req *wxApplet.AppResubmitTheExitAttachmentReq) (res *wxApplet.AppResubmitTheExitAttachmentRes, err error) {
|
||||
res = new(wxApplet.AppResubmitTheExitAttachmentRes)
|
||||
err = serviceController.BusConstructionUser().AppResubmitTheExitAttachmentFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppTeamAttendanceFunc 团队出勤
|
||||
func (c *appPortController) AppTeamAttendanceFunc(ctx context.Context, req *wxApplet.AppTeamAttendanceReq) (res *wxApplet.AppTeamAttendanceRes, err error) {
|
||||
res, err = service.BusAttendance().AppTeamAttendanceFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppGetsThePeopleUnderTheSpecifiedProjectFunc 获取指定项目下已实名认证或已退出班组的人
|
||||
func (c *appPortController) AppGetsThePeopleUnderTheSpecifiedProjectFunc(ctx context.Context, req *wxApplet.AppGetsThePeopleUnderTheSpecifiedProjectReq) (res *wxApplet.AppGetsThePeopleUnderTheSpecifiedProjectRes, err error) {
|
||||
res, err = service.BusConstructionUser().AppGetsThePeopleUnderTheSpecifiedProjectFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppJoinATeamFunc 加入指定项目下的指定班组
|
||||
func (c *appPortController) AppJoinATeamFunc(ctx context.Context, req *wxApplet.AppJoinATeamReq) (res *wxApplet.AppJoinATeamRes, err error) {
|
||||
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
for _, openid := range req.Openids {
|
||||
r := new(wxSystem.SysProjectTeamMemberAddReq)
|
||||
r.Openid = openid
|
||||
r.PostId = 4
|
||||
copier.Copy(r, req)
|
||||
err = service.SysProjectTeamMember().Add(ctx, r)
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
}
|
||||
})
|
||||
return err
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// AppGetPersonnelDetailsFunc 获取人员详情
|
||||
func (c *appPortController) AppGetPersonnelDetailsFunc(ctx context.Context, req *wxApplet.AppGetPersonnelDetailsReq) (res *wxApplet.AppGetPersonnelDetailsRes, err error) {
|
||||
res, err = service.BusConstructionUser().AppGetPersonnelDetailsFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================提醒===========================================
|
||||
// ===========================================提醒===========================================
|
||||
// ===========================================提醒===========================================
|
||||
|
||||
// AIWorkOrderDetailsFunc AI工单详情
|
||||
func (c *appPortController) AIWorkOrderDetailsFunc(ctx context.Context, req *wxApplet.AIWorkOrderDetailsReq) (res *wxApplet.AIWorkOrderDetailsRes, err error) {
|
||||
res = new(wxApplet.AIWorkOrderDetailsRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
// 1、获取主体信息
|
||||
err = g.DB().Model("reminders").As("e").
|
||||
LeftJoin("bus_violation_record", "a", "a.id = e.order_id").
|
||||
LeftJoin("sys_dict_data", "b", "b.dict_type = 'tour_type' and b.dict_value = a.tour_type").
|
||||
LeftJoin("sys_dict_data", "c", "c.dict_type = 'violation_record_data_source' and c.dict_value = a.data_source").
|
||||
LeftJoin("sys_project", "d", "d.id = a.project_id").
|
||||
Fields("a.*,b.dict_label as tt,c.dict_label as ds,d.project_name as projectName,e.status").
|
||||
Where("e.id", req.Id).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "获取当前AI数据失败")
|
||||
if res.Openid != "" { // 获取处理人名称
|
||||
value, _ := dao.BusConstructionUser.Ctx(ctx).Where("openid", res.Openid).Fields("user_name").Value()
|
||||
res.OpenidName = value.String()
|
||||
}
|
||||
if res.Status == "3" { // 复查人名称
|
||||
value, _ := g.DB().Model("sys_user").Ctx(ctx).Where("id", res.SelectPeople).Fields("user_nickname").Value()
|
||||
res.ReviewName = value.String()
|
||||
}
|
||||
i2, _ := g.DB().Model("bus_violation_record_correlation").Ctx(ctx).
|
||||
Where("a.record_id", res.Id).As("a").
|
||||
LeftJoin("sys_user", "b", "b.id = a.user_id").
|
||||
Fields("b.user_nickname").Array()
|
||||
for i3 := range i2 { // 哪些人可以复查(只需有一个复查就行了)
|
||||
res.SuperintendName = append(res.SuperintendName, i2[i3].String())
|
||||
}
|
||||
// 2、获取附件
|
||||
var pathEntity []*model.BusViolationRecordPathLogicRes
|
||||
err = g.DB().Model("bus_violation_record_path").Ctx(ctx).Where("ticket_id", req.Id).Scan(&pathEntity)
|
||||
liberr.ErrIsNil(ctx, err, "查询失败")
|
||||
// 3、分类附件
|
||||
var one []*model.BusViolationRecordPathLogicRes
|
||||
var two []*model.BusViolationRecordPathLogicRes
|
||||
for i := range pathEntity {
|
||||
if pathEntity[i].Type == "1" {
|
||||
one = append(one, pathEntity[i])
|
||||
} else {
|
||||
two = append(two, pathEntity[i])
|
||||
}
|
||||
}
|
||||
res.CheckAttachment = one
|
||||
res.AbarbeitungAttachment = two
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// QualityControlDetailsFunc 质量管理详情
|
||||
func (c *appPortController) QualityControlDetailsFunc(ctx context.Context, req *wxApplet.QualityControlDetailsReq) (res *wxApplet.QualityControlDetailsRes, err error) {
|
||||
res = new(wxApplet.QualityControlDetailsRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
m := g.DB().Model("reminders").As("e").
|
||||
LeftJoin("bus_inspection_ticket", "a", "a.id = e.order_id").
|
||||
LeftJoin("sys_project", "b", "b.id = a.project_id").
|
||||
LeftJoin("sys_dict_data", "c", "dict_type = 'inspection_type' and dict_value = a.Inspection_type").
|
||||
LeftJoin(dao.BusConstructionUser.Table(), "d", "d.openid = a.corrector").
|
||||
Fields(
|
||||
"a.id,b.project_name as projectName," + // 主键ID、项目名称
|
||||
"c.dict_label," + // 巡检类型
|
||||
"a.inspection_headline," + // 巡检主题
|
||||
"a.inspection_result," + // 巡检结果
|
||||
"d.user_name as abarbeitung," + // 整改人
|
||||
"a.is_reply,a.reply_date," + // 是否回复、回复时间
|
||||
"a.created_by as fill,a.created_at," + // 填报人、填报时间
|
||||
"a.feedback," + // 整改反馈
|
||||
"a.verification_result," + // 验证结果
|
||||
"e.status,a.verification_type," + // 工单状态、验证状态
|
||||
"a.updated_at as updatedAt," + // 更新时间
|
||||
"a.rectification_time as rectificationTime", // 整改时间
|
||||
)
|
||||
err = m.Where("e.id", req.Id).Scan(&res)
|
||||
liberr.ErrIsNil(ctx, err, "查询失败")
|
||||
// 2、获取附件
|
||||
var pathEntity []*wxApplet.SecurityManagementDetailsPath
|
||||
err = g.DB().Model("bus_inspection_ticket_path").Ctx(ctx).Where("ticket_id", res.Id).Scan(&pathEntity)
|
||||
liberr.ErrIsNil(ctx, err, "查询失败")
|
||||
// 3、分类附件
|
||||
var one []*wxApplet.SecurityManagementDetailsPath
|
||||
var two []*wxApplet.SecurityManagementDetailsPath
|
||||
for i := range pathEntity {
|
||||
if pathEntity[i].Type == "1" {
|
||||
one = append(one, pathEntity[i])
|
||||
} else {
|
||||
two = append(two, pathEntity[i])
|
||||
}
|
||||
}
|
||||
res.Inspectionccessories = one
|
||||
res.CorrectiveAttachment = two
|
||||
// 3、获取
|
||||
res.Fill = coryCommon.SelectByString(ctx, coryCommon.IsNumeric(res.Fill), res.Fill)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// SecurityManagementDetailsFunc 安全管理详情
|
||||
func (c *appPortController) SecurityManagementDetailsFunc(ctx context.Context, req *wxApplet.SecurityManagementDetailsReq) (res *wxApplet.SecurityManagementDetailsRes, err error) {
|
||||
res = new(wxApplet.SecurityManagementDetailsRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
m := g.DB().Model("reminders").As("f").
|
||||
LeftJoin("bus_hse_management", "a", "a.id = f.order_id").
|
||||
LeftJoin("sys_project", "b", "b.id = a.project_id").
|
||||
LeftJoin("sys_dict_data", "c", "c.dict_type = 'study_type' and c.dict_value = a.study_type").
|
||||
LeftJoin("sys_dict_data", "e", "e.dict_type = 'tour_type' and e.dict_value = a.tour_type").
|
||||
LeftJoin(dao.BusConstructionUser.Table(), "d", "d.openid = a.corrector").
|
||||
Fields(
|
||||
"a.id,b.project_name as projectName," + // 主键ID、项目名称
|
||||
"c.dict_label as studyTypeName," + // 检查类型
|
||||
"e.dict_label as tourTypeName," + // 违章类型
|
||||
"a.inspection_result," + // 巡检结果
|
||||
"a.check_time," + // 检查时间
|
||||
"a.reply_date," + // 要求整改期限
|
||||
"a.team_name as teamName," + // 班组
|
||||
"d.user_name as abarbeitung," + // 整改人
|
||||
"a.rectification_time," + // 整改时间
|
||||
"a.hidden_danger," + // 问题隐患
|
||||
"a.measure," + // 整改措施
|
||||
"a.review_time," + // 复查时间
|
||||
"a.review," + // 复查情况
|
||||
"f.status," + // 工单状态
|
||||
"a.review_type," + // 复查状态
|
||||
"a.created_by as fill," + // 复查状态
|
||||
"a.created_at") // 创建人(检查、复查)
|
||||
err = m.Where("f.id", req.Id).Scan(&res)
|
||||
|
||||
liberr.ErrIsNil(ctx, err, "查询失败")
|
||||
// 2、获取附件
|
||||
var pathEntity []*wxApplet.SecurityManagementDetailsPath
|
||||
err = g.DB().Model("bus_hse_management_path").Ctx(ctx).Where("ticket_id", req.Id).Scan(&pathEntity)
|
||||
liberr.ErrIsNil(ctx, err, "查询失败")
|
||||
// 3、分类附件
|
||||
var one []*wxApplet.SecurityManagementDetailsPath
|
||||
var two []*wxApplet.SecurityManagementDetailsPath
|
||||
for i := range pathEntity {
|
||||
if pathEntity[i].Type == "1" {
|
||||
one = append(one, pathEntity[i])
|
||||
} else {
|
||||
two = append(two, pathEntity[i])
|
||||
}
|
||||
}
|
||||
res.CheckAttachment = one
|
||||
res.AbarbeitungAttachment = two
|
||||
// 3、获取
|
||||
res.Fill = coryCommon.SelectByString(ctx, coryCommon.IsNumeric(res.Fill), res.Fill)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================请假===========================================
|
||||
// ===========================================请假===========================================
|
||||
// ===========================================请假===========================================
|
||||
|
||||
// AppAskForLeaveAdd 务工者-请假新增
|
||||
func (c *appPortController) AppAskForLeaveAdd(ctx context.Context, req *wxApplet.AppAskForLeaveAddReq) (res *wxApplet.AppBusAskforleaveAddRes, err error) {
|
||||
err = service.BusAskforleave().AppAskForLeaveAdd(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AppAskForLeaveListPage 务工者-请假记录列表-分页
|
||||
func (c *appPortController) AppAskForLeaveListPage(ctx context.Context, req *wxApplet.AppAskForLeaveListPageReq) (res *wxApplet.AppAskForLeaveListPageRes, err error) {
|
||||
return service.BusAskforleave().AppAskForLeaveListPage(ctx, req)
|
||||
}
|
||||
|
||||
// AppAskForLeaveInfo 务工者-请假详情
|
||||
func (c *appPortController) AppAskForLeaveInfo(ctx context.Context, req *wxApplet.AppAskForLeaveInfoReq) (res *wxApplet.AppAskForLeaveInfoRes, err error) {
|
||||
return service.BusAskforleave().AppAskForLeaveInfo(ctx, req)
|
||||
}
|
||||
|
||||
// AppBzzAskForLeaveListPage 班组长-审批
|
||||
func (c *appPortController) AppBzzAskForLeaveUpdate(ctx context.Context, req *wxApplet.AppBzzAskForLeaveUpdateReq) (res *wxApplet.AppBzzAskForLeaveUpdateRes, err error) {
|
||||
err = service.BusAskforleave().AppBzzAskForLeaveUpdate(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ===========================================其它===========================================
|
||||
// ===========================================其它===========================================
|
||||
// ===========================================其它===========================================
|
||||
|
||||
// AppBase64ToImgFuncFunc 将图片的base64转成png存储到本地,返回相对路径
|
||||
func (c *appPortController) AppBase64ToImgFuncFunc(ctx context.Context, req *wxApplet.AppBase64ToImgFuncReq) (res *wxApplet.AppBase64ToImgFuncRes, err error) {
|
||||
res = new(wxApplet.AppBase64ToImgFuncRes)
|
||||
path, err := coryCommon.Base64ToImgFunc(req.Base64Str, "1", coryCommon.Helmet)
|
||||
res.Path = "/" + path
|
||||
return
|
||||
}
|
||||
|
||||
// AppGetLatestAppVersionFunc 获取最新的App版本号
|
||||
func (c *appPortController) AppGetLatestAppVersionFunc(ctx context.Context, req *wxApplet.GetLatestAppVersionReq) (*wxApplet.GetLatestAppVersionRes, error) {
|
||||
var AppVersionInfo entity.AppVersions
|
||||
err := controllerDao.AppVersions.Ctx(ctx).Fields(entity.AppVersions{}).
|
||||
Where(controllerDao.AppVersions.Columns().Platform, req.Platform).
|
||||
OrderDesc(controllerDao.AppVersions.Columns().Id).Limit(1).Scan(&AppVersionInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &wxApplet.GetLatestAppVersionRes{
|
||||
Info: AppVersionInfo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AppReleaseAppVersionFunc 发布一个新的版本
|
||||
func (c *appPortController) AppReleaseAppVersionFunc(ctx context.Context, req *wxApplet.ReleaseAppVersionReq) (*wxApplet.ReleaseAppVersionRes, error) {
|
||||
var (
|
||||
path, _ = os.Getwd()
|
||||
Version = req.Version
|
||||
plantType = req.Platform
|
||||
)
|
||||
|
||||
// 根据平台类型拼接版本号
|
||||
var devicePlatform string
|
||||
switch plantType {
|
||||
case 0:
|
||||
devicePlatform = "Android"
|
||||
case 1:
|
||||
devicePlatform = "IOS"
|
||||
}
|
||||
|
||||
// 拼接文件保存路径: 当前路径 + resource + public + version + 版本号 + 平台类型
|
||||
filePath := filepath.Join(path, "resource", "public", "version", Version, devicePlatform)
|
||||
|
||||
// 保存到数据库的静态文件托管路径: file + version + 版本号 + 平台类型 + 文件名
|
||||
savePath := filepath.Join("file", "version", Version, devicePlatform, req.File.Filename)
|
||||
|
||||
// 检查版本号是否已存在,如果存在则用新版本替换旧版本
|
||||
var appVersion entity.AppVersions
|
||||
if err := controllerDao.AppVersions.Ctx(ctx).Where(controllerDao.AppVersions.Columns().Version, Version).Where(controllerDao.AppVersions.Columns().Platform, plantType).Scan(&appVersion); err == nil {
|
||||
// 删除旧版本文件
|
||||
if err := os.RemoveAll(filepath.Join(filePath, filepath.Base(appVersion.FilePath))); err != nil {
|
||||
return nil, fmt.Errorf("删除以往的版本文件失败:%w", err)
|
||||
}
|
||||
|
||||
// 保存新版本文件
|
||||
if _, err := req.File.Save(filePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 更新数据库中的文件路径
|
||||
if _, err := controllerDao.AppVersions.Ctx(ctx).Data(gdb.Map{controllerDao.AppVersions.Columns().FilePath: savePath}).Where(controllerDao.AppVersions.Columns().Id, appVersion.Id).Update(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &wxApplet.ReleaseAppVersionRes{}, nil
|
||||
}
|
||||
|
||||
if _, err := req.File.Save(filePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 构造数据库记录
|
||||
appVersionInfo := entity.AppVersions{
|
||||
Version: Version, // 版本号
|
||||
FilePath: savePath, // 文件路径
|
||||
Platform: plantType, // 平台类型
|
||||
}
|
||||
|
||||
// 保存到数据库
|
||||
_, err := controllerDao.AppVersions.Ctx(ctx).Data(appVersionInfo).Insert()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &wxApplet.ReleaseAppVersionRes{}, nil
|
||||
}
|
||||
22
internal/app/wxApplet/controller/base.go
Normal file
22
internal/app/wxApplet/controller/base.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* @desc:system base controller
|
||||
* @company:云南奇讯科技有限公司
|
||||
* @Author: yixiaohu
|
||||
* @Date: 2022/3/4 18:12
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
commonController "github.com/tiger1103/gfast/v3/internal/app/common/controller"
|
||||
)
|
||||
|
||||
type BaseController struct {
|
||||
commonController.BaseController
|
||||
}
|
||||
|
||||
// Init 自动执行的初始化方法
|
||||
func (c *BaseController) Init(r *ghttp.Request) {
|
||||
c.BaseController.Init(r)
|
||||
}
|
||||
145
internal/app/wxApplet/controller/bus_attendance.go
Normal file
145
internal/app/wxApplet/controller/bus_attendance.go
Normal file
@ -0,0 +1,145 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-07 16:29:52
|
||||
// 生成路径: internal/app/wxApplet/controller/bus_attendance.go
|
||||
// 生成人:gfast
|
||||
// desc:考勤
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/common/coryCommon/excelUtil"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type busAttendanceController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var BusAttendance = new(busAttendanceController)
|
||||
|
||||
// SalaryDetailsFunc 小程序工资详情
|
||||
func (c *busAttendanceController) SalaryDetailsFunc(ctx context.Context, req *wxApplet.SalaryDetailsReq) (res *wxApplet.SalaryDetailsRes, err error) {
|
||||
res = new(wxApplet.SalaryDetailsRes)
|
||||
res, err = service.BusAttendance().SalaryDetailsFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ProjectExport 导出(项目专用)
|
||||
func (c *busAttendanceController) ProjectExport(ctx context.Context, req *wxApplet.PunchingCardRecordProjectReq) (res *wxApplet.PunchingCardRecordTwoRes, err error) {
|
||||
recordReq := &wxApplet.PunchingCardRecordReq{
|
||||
ProjectId: req.ProjectId,
|
||||
SelectDate: req.SelectDate,
|
||||
Type: req.Type,
|
||||
}
|
||||
res = new(wxApplet.PunchingCardRecordTwoRes)
|
||||
res, err = PublicExport(ctx, recordReq)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Export 导出
|
||||
func (c *busAttendanceController) Export(ctx context.Context, req *wxApplet.PunchingCardRecordReq) (res *wxApplet.PunchingCardRecordTwoRes, err error) {
|
||||
res = new(wxApplet.PunchingCardRecordTwoRes)
|
||||
res, err = PublicExport(ctx, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
func PublicExport(ctx context.Context, req *wxApplet.PunchingCardRecordReq) (res *wxApplet.PunchingCardRecordTwoRes, err error) {
|
||||
var resList *wxApplet.PunchingCardRecordRes
|
||||
//1、生成数据
|
||||
resList, err = service.BusAttendance().Export(ctx, req)
|
||||
//2、生成excel数据表
|
||||
_, filePath, _ := excelUtil.ExcelThree(resList.List)
|
||||
if filePath == "" {
|
||||
err = errors.New("导出失败!")
|
||||
return nil, err
|
||||
}
|
||||
res = new(wxApplet.PunchingCardRecordTwoRes)
|
||||
getwd := strings.ReplaceAll(filePath, "\\", "/")
|
||||
all := strings.ReplaceAll(getwd, "/resource/public", "/file")
|
||||
res.Path = all
|
||||
return res, err
|
||||
}
|
||||
|
||||
//// delFile 删除文件
|
||||
//func delFile(file string) {
|
||||
// time.Sleep(10 * time.Second)
|
||||
// // 5. 删除本地临时文件
|
||||
// if err := os.Remove(file); err != nil {
|
||||
// fmt.Println("Failed to delete temporary file:", err)
|
||||
// }
|
||||
//10秒过后自动删除文件
|
||||
//go delFile(file)
|
||||
//}
|
||||
|
||||
// List 列表
|
||||
func (c *busAttendanceController) List(ctx context.Context, req *wxApplet.BusAttendanceSearchReq) (res *wxApplet.BusAttendanceSearchRes, err error) {
|
||||
res, err = service.BusAttendance().List(ctx, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Get 获取考勤
|
||||
func (c *busAttendanceController) Get(ctx context.Context, req *wxApplet.BusAttendanceGetReq) (res *wxApplet.BusAttendanceGetRes, err error) {
|
||||
res = new(wxApplet.BusAttendanceGetRes)
|
||||
res.BusAttendanceInfoRes, err = service.BusAttendance().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加考勤
|
||||
func (c *busAttendanceController) Add(ctx context.Context, req *wxApplet.BusAttendanceAddReq) (res *wxApplet.BusAttendanceAddRes, err error) {
|
||||
err = service.BusAttendance().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改考勤
|
||||
func (c *busAttendanceController) Edit(ctx context.Context, req *wxApplet.BusAttendanceEditReq) (res *wxApplet.BusAttendanceEditRes, err error) {
|
||||
err = service.BusAttendance().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除考勤
|
||||
func (c *busAttendanceController) Delete(ctx context.Context, req *wxApplet.BusAttendanceDeleteReq) (res *wxApplet.BusAttendanceDeleteRes, err error) {
|
||||
err = service.BusAttendance().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
// ByOpenidFunc 打卡日历
|
||||
func (c *busAttendanceController) ByOpenidFunc(ctx context.Context, req *wxApplet.ByOpenIdFuncReq) (res *wxApplet.ByOpenIdFuncRes, err error) {
|
||||
res, err = service.BusAttendance().ByOpenidFunc(ctx, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// PCListFunc 后端pc考勤打卡列表
|
||||
func (c *busAttendanceController) PCListFunc(ctx context.Context, req *wxApplet.PCListReq) (res *wxApplet.PCListRes, err error) {
|
||||
res, err = service.BusAttendance().PCListFunc(ctx, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// AttendanceByOpenIdFunc 根据openid去获取到当前用户当天的打卡信息
|
||||
func (c *busAttendanceController) AttendanceByOpenIdFunc(ctx context.Context, req *wxApplet.AttendanceByOpenIdGetReq) (res *wxApplet.AttendanceByOpenIdRes, err error) {
|
||||
res = new(wxApplet.AttendanceByOpenIdRes)
|
||||
idFunc, err := service.BusAttendance().AttendanceByOpenIdFunc(ctx, req.Openid)
|
||||
res = idFunc
|
||||
return
|
||||
}
|
||||
|
||||
// ListOfAttendanceMachines 建立考勤机列表
|
||||
func (c *busAttendanceController) ListOfAttendanceMachines(ctx context.Context, req *wxApplet.AttendanceByOpenIdGetReq) (res *wxApplet.AttendanceByOpenIdRes, err error) {
|
||||
res = new(wxApplet.AttendanceByOpenIdRes)
|
||||
idFunc, err := service.BusAttendance().AttendanceByOpenIdFunc(ctx, req.Openid)
|
||||
res = idFunc
|
||||
return
|
||||
}
|
||||
|
||||
// 修改考勤机的基本信息(如项目选择、班组)
|
||||
|
||||
// 修改考勤机的基本信息(如项)
|
||||
|
||||
// 获取当前设备所关联到的班组下的所有成员消息
|
||||
54
internal/app/wxApplet/controller/bus_construction_project.go
Normal file
54
internal/app/wxApplet/controller/bus_construction_project.go
Normal file
@ -0,0 +1,54 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-07 11:17:50
|
||||
// 生成路径: internal/app/wxApplet/controller/bus_construction_project.go
|
||||
// 生成人:gfast
|
||||
// desc:施工人员对应项目
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type busConstructionProjectController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var BusConstructionProject = new(busConstructionProjectController)
|
||||
|
||||
// List 列表
|
||||
func (c *busConstructionProjectController) List(ctx context.Context, req *wxApplet.BusConstructionProjectSearchReq) (res *wxApplet.BusConstructionProjectSearchRes, err error) {
|
||||
res, err = service.BusConstructionProject().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取施工人员对应项目
|
||||
func (c *busConstructionProjectController) Get(ctx context.Context, req *wxApplet.BusConstructionProjectGetReq) (res *wxApplet.BusConstructionProjectGetRes, err error) {
|
||||
res = new(wxApplet.BusConstructionProjectGetRes)
|
||||
res.BusConstructionProjectInfoRes, err = service.BusConstructionProject().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加施工人员对应项目
|
||||
func (c *busConstructionProjectController) Add(ctx context.Context, req *wxApplet.BusConstructionProjectAddReq) (res *wxApplet.BusConstructionProjectAddRes, err error) {
|
||||
err = service.BusConstructionProject().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改施工人员对应项目
|
||||
func (c *busConstructionProjectController) Edit(ctx context.Context, req *wxApplet.BusConstructionProjectEditReq) (res *wxApplet.BusConstructionProjectEditRes, err error) {
|
||||
err = service.BusConstructionProject().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除施工人员对应项目
|
||||
func (c *busConstructionProjectController) Delete(ctx context.Context, req *wxApplet.BusConstructionProjectDeleteReq) (res *wxApplet.BusConstructionProjectDeleteRes, err error) {
|
||||
err = service.BusConstructionProject().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
475
internal/app/wxApplet/controller/bus_construction_user.go
Normal file
475
internal/app/wxApplet/controller/bus_construction_user.go
Normal file
@ -0,0 +1,475 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-07 11:17:50
|
||||
// 生成路径: internal/app/wxApplet/controller/bus_construction_user.go
|
||||
// 生成人:gfast
|
||||
// desc:施工人员
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gfile"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/common/coryCommon"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/system"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/dao"
|
||||
controllerModel "github.com/tiger1103/gfast/v3/internal/app/system/model"
|
||||
systemService "github.com/tiger1103/gfast/v3/internal/app/system/service"
|
||||
daoTwo "github.com/tiger1103/gfast/v3/internal/app/wxApplet/dao"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/model"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
"github.com/tiger1103/gfast/v3/library/liberr"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type busConstructionUserController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var BusConstructionUser = new(busConstructionUserController)
|
||||
|
||||
// ImgUpload 图片(银行卡或身份证)上传并返回图片内容
|
||||
func (c *busConstructionUserController) ImgUpload(ctx context.Context, req *wxApplet.ImgUploadReq) (res *wxApplet.ImgUploadRes, err error) {
|
||||
m := make(map[string]interface{})
|
||||
//1、上传图片
|
||||
str, err := coryCommon.UploadFile(ctx, req.ImgUpload, coryCommon.LargeFilePrivacy)
|
||||
if len(str) > 0 && str[0] == '/' {
|
||||
str = str[1:]
|
||||
}
|
||||
//2、获取图片的二进制
|
||||
getwd, err := os.Getwd()
|
||||
join := gfile.Join(getwd, str)
|
||||
//3、解析图片内容
|
||||
var ocr coryCommon.OcrReq
|
||||
strType := req.StrType
|
||||
switch strType {
|
||||
case "1":
|
||||
err, urlBase64 := coryCommon.ImgDataBase64(join)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ocr = coryCommon.OcrReq{
|
||||
Image: urlBase64,
|
||||
IdCardSide: "front",
|
||||
DetectPhoto: true,
|
||||
}
|
||||
m = coryCommon.ImgOCR(ocr)
|
||||
case "2":
|
||||
err, urlBase64 := coryCommon.ImgDataBase64(join)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ocr = coryCommon.OcrReq{
|
||||
Image: urlBase64,
|
||||
IdCardSide: "back",
|
||||
}
|
||||
m = coryCommon.ImgOCR(ocr)
|
||||
case "3":
|
||||
urlBase64Two, err := coryCommon.EncodeAndUrlEncodeImage(join, 4)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ocr = coryCommon.OcrReq{
|
||||
Image: urlBase64Two,
|
||||
}
|
||||
m = coryCommon.ImgYhkOCR(ocr)
|
||||
}
|
||||
//合同4不进行校验
|
||||
if strType == "3" && len(m) < 3 {
|
||||
err = errors.New("银行卡无效,请重新上传!")
|
||||
return nil, err
|
||||
}
|
||||
if strType != "4" && len(m) < 1 {
|
||||
err = errors.New("身份证无效,请重新上传!")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//修改str的路径 resource/public 改成 file /resource/public/privacy/2023-08-10/16916519795176443.png
|
||||
str = strings.ReplaceAll(str, "resource/public", "file")
|
||||
m["ImgPath"] = "/" + str
|
||||
res = &wxApplet.ImgUploadRes{}
|
||||
res.MapKV = &m
|
||||
return
|
||||
}
|
||||
|
||||
// PacePhotoFunc 人脸检测()
|
||||
func (c *busConstructionUserController) PacePhotoFunc(ctx context.Context, req *wxApplet.PacePhotoReq) (res *wxApplet.PacePhotoRes, err error) {
|
||||
res = new(wxApplet.PacePhotoRes)
|
||||
res.Path, err = FaceDetectionFunc(ctx, req.File)
|
||||
return
|
||||
}
|
||||
|
||||
// List 列表 获取所有的图片资源(0~10)
|
||||
func (c *busConstructionUserController) List(ctx context.Context, req *wxApplet.BusConstructionUserSearchReq) (res *wxApplet.BusConstructionUserSearchRes, err error) {
|
||||
res, err = service.BusConstructionUser().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// PersonnelListFunc 人员列表(只返回id、头像、名称、电话)
|
||||
func (c *busConstructionUserController) PersonnelListFunc(ctx context.Context, req *wxApplet.PersonnelListReq) (res *wxApplet.PersonnelListRes, err error) {
|
||||
res, err = service.BusConstructionUser().PersonnelListFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// PersonnelInquiryFunc 查询在职施工人员(只返回id、名称)
|
||||
func (c *busConstructionUserController) PersonnelInquiryFunc(ctx context.Context, req *wxApplet.PersonnelInquiryReq) (res *wxApplet.PersonnelInquiryRes, err error) {
|
||||
res, err = service.BusConstructionUser().PersonnelInquiryFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 施工人员列表_文件上传【详情】
|
||||
func (c *busConstructionUserController) Get(ctx context.Context, req *wxApplet.BusConstructionUserGetReq) (res *wxApplet.BusConstructionUserGetRes, err error) {
|
||||
res = new(wxApplet.BusConstructionUserGetRes)
|
||||
res.BusConstructionUserInfoRes, err = service.BusConstructionUser().GetById(ctx, req.Id)
|
||||
//2、图片资源
|
||||
var dataInfo2 []*model.BusConstructionUserFileListRes
|
||||
dao.BusConstructionUserFile.Ctx(ctx).Where("user_id", res.Id).Where("user_img_type in (0,1,2,3)").Scan(&dataInfo2)
|
||||
res.ImgFileListTwo = dataInfo2
|
||||
//2、图片资源
|
||||
var dataInfo []*model.BusConstructionUserFileListRes
|
||||
daoTwo.BusConstructionUserFile.Ctx(ctx).As("a").
|
||||
LeftJoin("sys_dict_data", "a.user_img_type = b.dict_value and dict_type= 'user_img_type' ").As("b").
|
||||
Where("a.user_id", res.Id).
|
||||
Where("a.user_img_type in (4,5,6,7,8,10)"). //0,1,2,3,
|
||||
Fields("a.*,b.dict_label").
|
||||
Scan(&dataInfo)
|
||||
res.ImgFileList = dataInfo
|
||||
return
|
||||
}
|
||||
|
||||
// GetDetailsFunc 施工人员列表_详情
|
||||
func (c *busConstructionUserController) GetDetailsFunc(ctx context.Context, req *wxApplet.GetDetailsReq) (res *wxApplet.GetDetailsRes, err error) {
|
||||
res = new(wxApplet.GetDetailsRes)
|
||||
res, err = service.BusConstructionUser().GetDetailsFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加施工人员
|
||||
func (c *busConstructionUserController) Add(ctx context.Context, req *wxApplet.BusConstructionUserAddReq) (res *wxApplet.BusConstructionUserAddRes, err error) {
|
||||
res = new(wxApplet.BusConstructionUserAddRes)
|
||||
add, err := service.BusConstructionUser().Add(ctx, req)
|
||||
res.Id = add
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改施工人员
|
||||
func (c *busConstructionUserController) Edit(ctx context.Context, req *wxApplet.BusConstructionUserEditReq) (res *wxApplet.BusConstructionUserEditRes, err error) {
|
||||
err = service.BusConstructionUser().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除施工人员
|
||||
func (c *busConstructionUserController) Delete(ctx context.Context, req *wxApplet.BusConstructionUserDeleteReq) (res *wxApplet.BusConstructionUserDeleteRes, err error) {
|
||||
err = service.BusConstructionUser().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
// ChangeStateFunc 【小程序】变更施工人员在职/离职情况
|
||||
func (c *busConstructionUserController) ChangeStateFunc(ctx context.Context, req *wxApplet.ChangeStateReq) (res *wxApplet.ChangeStateRes, err error) {
|
||||
res = new(wxApplet.ChangeStateRes)
|
||||
err = service.BusConstructionUser().ChangeStateFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// GetByOpenId 【小程序】获取施工人员 获取部分图片资源(0,1,2,3)
|
||||
func (c *busConstructionUserController) GetByOpenId(ctx context.Context, req *wxApplet.BusConstructionUserByOpenIdGetReq) (res *wxApplet.BusConstructionUserByOpenIdGetRes, err error) {
|
||||
res = new(wxApplet.BusConstructionUserByOpenIdGetRes)
|
||||
res, err = service.BusConstructionUser().GetByOpenId(ctx, req.OpenId)
|
||||
//根据角色获取到所有的模块,然后对模块进行去重
|
||||
var swmi []*controllerModel.SysWechatModuleInfoRes
|
||||
g.DB().Model("sys_wxchat_role_module").As("a").
|
||||
Fields("DISTINCT b.name,b.id,b.list_order").
|
||||
LeftJoin("sys_wechat_module", "b", "a.module_id = b.id").
|
||||
Where("a.role_id in (?)", res.RoleIds).
|
||||
Order("b.list_order asc,b.id asc").Scan(&swmi)
|
||||
var mk []string
|
||||
for i := range swmi {
|
||||
mk = append(mk, swmi[i].Name)
|
||||
}
|
||||
res.ModuleName = mk
|
||||
return
|
||||
}
|
||||
|
||||
// WeatherFunc 【小程序】获取施工人员天气
|
||||
func (c *busConstructionUserController) WeatherFunc(ctx context.Context, req *wxApplet.WeatherReq) (res *wxApplet.WeatherRes, err error) {
|
||||
res = new(wxApplet.WeatherRes)
|
||||
we := coryCommon.Weather(req.Location)
|
||||
bodyData := []byte(we)
|
||||
err = json.Unmarshal(bodyData, &res)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to parse JSON data:", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GridPointFunc 【小程序】获取格点天气
|
||||
func (c *busConstructionUserController) GridPointFunc(ctx context.Context, req *wxApplet.GridPointFuncReq) (res *wxApplet.GridPointFuncRes, err error) {
|
||||
res = new(wxApplet.GridPointFuncRes)
|
||||
gp, err := coryCommon.GridPoint(req.Location)
|
||||
if err != nil {
|
||||
return
|
||||
} else {
|
||||
res.GridPointRes = gp
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// InverseGeocodingFunc 【小程序】逆地理编码
|
||||
func (c *busConstructionUserController) InverseGeocodingFunc(ctx context.Context, req *wxApplet.InverseGeocodingReq) (res *wxApplet.InverseGeocodingRes, err error) {
|
||||
res = new(wxApplet.InverseGeocodingRes)
|
||||
we := coryCommon.InverseGeocoding(req.Location)
|
||||
bodyData := []byte(we)
|
||||
err = json.Unmarshal(bodyData, &res)
|
||||
if err != nil {
|
||||
fmt.Println("Failed to parse JSON data:", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GroupLeader 【小程序】班组长成员列表
|
||||
func (c *busConstructionUserController) GroupLeader(ctx context.Context, req *wxApplet.GroupLeaderReq) (res *wxApplet.GroupLeaderRes, err error) {
|
||||
res = new(wxApplet.GroupLeaderRes)
|
||||
res, err = service.BusConstructionUser().GroupLeader(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// PayFunc 【小程序】薪水变更
|
||||
func (c *busConstructionUserController) PayFunc(ctx context.Context, req *wxApplet.PayFuncReq) (res *wxApplet.PayFuncRes, err error) {
|
||||
res = new(wxApplet.PayFuncRes)
|
||||
res, err = service.BusConstructionUser().PayFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AttendanceCountFunc 【小程序】出勤统计情况
|
||||
func (c *busConstructionUserController) AttendanceCountFunc(ctx context.Context, req *wxApplet.AttendanceReq) (res *wxApplet.AttendanceRes, err error) {
|
||||
res, err = service.BusConstructionUser().AttendanceFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// AttendanceCountListFunc 【小程序】出勤人员列表
|
||||
func (c *busConstructionUserController) AttendanceCountListFunc(ctx context.Context, req *wxApplet.AttendanceListReq) (res *wxApplet.AttendanceListRes, err error) {
|
||||
res, err = service.BusConstructionUser().AttendanceCountListFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ProjectRecordFunc 【小程序】是否开启小程序项目备案project_record
|
||||
func (c *busConstructionUserController) ProjectRecordFunc(ctx context.Context, req *wxApplet.ProjectRecordReq) (res *wxApplet.ProjectRecordRes, err error) {
|
||||
res = new(wxApplet.ProjectRecordRes)
|
||||
res, err = service.BusConstructionUser().ProjectRecordFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// HumanFaceFunc 【小程序】更换实名认证的人脸照片
|
||||
func (c *busConstructionUserController) HumanFaceFunc(ctx context.Context, req *wxApplet.HumanFaceReq) (res *wxApplet.HumanFaceReqRes, err error) {
|
||||
res = new(wxApplet.HumanFaceReqRes)
|
||||
res, err = service.BusConstructionUser().HumanFaceFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// SubscriptionFunc 【小程序】小程序变更消息订阅状态
|
||||
func (c *busConstructionUserController) SubscriptionFunc(ctx context.Context, req *wxApplet.SubscriptionFuncReq) (res *wxApplet.SubscriptionFuncRes, err error) {
|
||||
res, err = service.BusConstructionUser().SubscriptionFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ChangePayFunc 【小程序】根据openid改变当前微信用户的项目id
|
||||
func (c *busConstructionUserController) ChangePayFunc(ctx context.Context, req *wxApplet.ChangePayReq) (res *wxApplet.ChangePayRes, err error) {
|
||||
err = service.BusConstructionUser().ChangePayFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// OpenidByFounder 【小程序】获取当前用户当前项目的打卡坐标
|
||||
func (c *busConstructionUserController) OpenidByFounder(ctx context.Context, req *wxApplet.OpenidByFounderReq) (res *wxApplet.OpenidByFounderRes, err error) {
|
||||
res = new(wxApplet.OpenidByFounderRes)
|
||||
res, err = OpenidByFounderFunc(ctx, req.Openid)
|
||||
return
|
||||
}
|
||||
|
||||
func OpenidByFounderFunc(ctx context.Context, openid string) (res *wxApplet.OpenidByFounderRes, err error) {
|
||||
res = new(wxApplet.OpenidByFounderRes)
|
||||
var fz []*wxApplet.FangzhengEntity
|
||||
var pp []*wxApplet.ProjectPunchEntity
|
||||
g.Try(ctx, func(ctx context.Context) {
|
||||
pid, err := dao.BusConstructionUser.Ctx(ctx).Where("openid", openid).Fields("project_id").Value()
|
||||
value, err := dao.SysProject.Ctx(ctx).Where("id", pid).Fields("CONCAT(lng,',',lat) as jwd").Value()
|
||||
if err == nil {
|
||||
res.LongAndLat = value.String()
|
||||
}
|
||||
type fzEntity struct {
|
||||
Name string `json:"name" dc:"方正名称"`
|
||||
Detail string `json:"detail" dc:"方正边界坐标"`
|
||||
}
|
||||
//方正坐标范围
|
||||
var fe []*fzEntity
|
||||
err = dao.QianqiFangzhen.Ctx(ctx).Where("project_id", pid).Fields("name", "detail").Scan(&fe)
|
||||
for _, data := range fe {
|
||||
jsonData := data.Detail
|
||||
var fzTwo *wxApplet.FangzhengEntity
|
||||
err = json.Unmarshal([]byte(jsonData), &fzTwo)
|
||||
for i, position := range fzTwo.Entity {
|
||||
//坐标转换
|
||||
fzTwo.Entity[i].Lng, fzTwo.Entity[i].Lat = coryCommon.WGS84toGCJ02(position.Lng, position.Lat)
|
||||
}
|
||||
fzTwo.FangzhengName = data.Name
|
||||
fz = append(fz, fzTwo)
|
||||
}
|
||||
//打卡坐标范围
|
||||
var ppe []*fzEntity
|
||||
err = g.DB().Model("sys_project_punch_range").Ctx(ctx).Where("project_id", pid).Fields("punch_name as name", "punch_range as detail").Scan(&ppe)
|
||||
for _, data := range ppe {
|
||||
jsonData := data.Detail
|
||||
var arr []*wxApplet.Position
|
||||
err = json.Unmarshal([]byte(jsonData), &arr)
|
||||
for i := range arr {
|
||||
arr[i].Lng, arr[i].Lat = coryCommon.WGS84toGCJ02(arr[i].Lng, arr[i].Lat)
|
||||
}
|
||||
ppeTwo := wxApplet.ProjectPunchEntity{
|
||||
PunchName: data.Name,
|
||||
Entity: arr,
|
||||
}
|
||||
pp = append(pp, &ppeTwo)
|
||||
}
|
||||
liberr.ErrIsNil(ctx, err, "获取数据失败!")
|
||||
return
|
||||
})
|
||||
res.FangzhengEntity = fz
|
||||
res.ProjectPunchEntity = pp
|
||||
return
|
||||
}
|
||||
|
||||
// ActionPathFunc 根据openid获取到当前人的行动轨迹(前提是当前人有安全帽)
|
||||
func (c *busConstructionUserController) ActionPathFunc(ctx context.Context, req *wxApplet.ActionPathReq) (res *wxApplet.ActionPathRes, err error) {
|
||||
res = new(wxApplet.ActionPathRes)
|
||||
res.LatAndLonList, err = service.BusConstructionUser().ActionPathFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// CameraListFunc 获取摄像头列表(坐标进行转换了的)
|
||||
func (c *busConstructionUserController) CameraListFunc(ctx context.Context, req *wxApplet.QianqiCameraSearchReq) (res *wxApplet.QianqiCameraSearchRes, err error) {
|
||||
res = new(wxApplet.QianqiCameraSearchRes)
|
||||
data, err := systemService.QianqiCamera().NotPageList(ctx, req)
|
||||
res = data
|
||||
return
|
||||
}
|
||||
|
||||
// EditNameAndDetail 修改摄像头
|
||||
func (c *busConstructionUserController) EditNameAndDetail(ctx context.Context, req *wxApplet.QianqiCameraEditNameAndDetailReq) (res *wxApplet.QianqiCameraEditNameAndDetailRes, err error) {
|
||||
detailReq := system.QianqiCameraEditNameAndDetailReq{
|
||||
CameraName: req.CameraName,
|
||||
CameraCode: req.CameraCode,
|
||||
Detail: req.Detail,
|
||||
}
|
||||
err = systemService.QianqiCamera().WxEditNameAndDetail(ctx, &detailReq)
|
||||
return
|
||||
}
|
||||
|
||||
// ReissueACardWxAddFunc 《补卡申请》提交补卡申请
|
||||
func (c *busConstructionUserController) ReissueACardWxAddFunc(ctx context.Context, req *wxApplet.ReissueACardWxAddReq) (res *wxApplet.ReissueACardWxAddRes, err error) {
|
||||
err = systemService.BusReissueACard().ReissueACardWxAdd(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ReissueACardWxGetByIdFunc 《补卡申请》(我)补卡申请记录查看
|
||||
func (c *busConstructionUserController) ReissueACardWxGetByIdFunc(ctx context.Context, req *wxApplet.ReissueACardWxGetByIdReq) (res *wxApplet.ReissueACardWxGetByIdRes, err error) {
|
||||
res = new(wxApplet.ReissueACardWxGetByIdRes)
|
||||
res, err = systemService.BusReissueACard().ReissueACardWxGetByIdFunc(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ReissueACardWxGetByIdTeamFunc 《补卡申请》班组长查看自己需要同意或拒绝的补卡申请
|
||||
func (c *busConstructionUserController) ReissueACardWxGetByIdTeamFunc(ctx context.Context, req *wxApplet.ReissueACardWxGetByIdTeamReq) (res *wxApplet.ReissueACardWxGetByIdTeamRes, err error) {
|
||||
res = new(wxApplet.ReissueACardWxGetByIdTeamRes)
|
||||
res, err = systemService.BusReissueACard().ReissueACardWxGetByIdTeam(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// ReissueACardWxEditTeamFunc 《补卡申请》班组长审批修改提交补卡申请的状态
|
||||
func (c *busConstructionUserController) ReissueACardWxEditTeamFunc(ctx context.Context, req *wxApplet.ReissueACardWxEditTeamReq) (res *wxApplet.ReissueACardWxGetByIdTeamRes, err error) {
|
||||
err = systemService.BusReissueACard().ReissueACardWxEditTeam(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// JobForemanSumnumberFunc 《补卡申请》班组长未读的补卡申请有多少条?
|
||||
func (c *busConstructionUserController) JobForemanSumnumberFunc(ctx context.Context, req *wxApplet.JobForemanSumnumberReq) (res *wxApplet.JobForemanSumnumberRes, err error) {
|
||||
res = new(wxApplet.JobForemanSumnumberRes)
|
||||
number, err := systemService.BusReissueACard().JobForemanSumnumberFunc(ctx, req)
|
||||
res.Number = number
|
||||
return
|
||||
}
|
||||
|
||||
// BusConstructiomUserSignatureAddFunc 【签名】给指定用户新增签名
|
||||
func (c *busConstructionUserController) BusConstructiomUserSignatureAddFunc(ctx context.Context, req *wxApplet.BusConstructiomUserSignatureAddReq) (res *wxApplet.BusConstructiomUserSignatureAddRes, err error) {
|
||||
res = new(wxApplet.BusConstructiomUserSignatureAddRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
m := g.DB().Model("bus_constructiom_user_signature").Safe()
|
||||
//0、图片上传
|
||||
str, imgErr := coryCommon.UploadFile(ctx, req.Sign, coryCommon.Helmet)
|
||||
liberr.ErrIsNil(ctx, imgErr, "签名错误!")
|
||||
//1、删除指定openid的数据
|
||||
value, _ := m.Where("openid", req.Openid).Fields("signature").Value()
|
||||
os.Remove(strings.ReplaceAll(coryCommon.GetCWD()+"/"+value.String(), "\\", "/"))
|
||||
_, err := m.Where("openid", req.Openid).Delete()
|
||||
liberr.ErrIsNil(ctx, err, "添加失败")
|
||||
//2、新增指定用户签名
|
||||
g2 := g.Map{
|
||||
"openid": req.Openid,
|
||||
"signature": str,
|
||||
}
|
||||
_, err = m.Insert(g2)
|
||||
liberr.ErrIsNil(ctx, err, "添加失败")
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// BusConstructiomUserSignatureQueryFunc 【签名】查询指定用户签名信息
|
||||
func (c *busConstructionUserController) BusConstructiomUserSignatureQueryFunc(ctx context.Context, req *wxApplet.BusConstructiomUserSignatureQueryReq) (res *wxApplet.BusConstructiomUserSignatureQueryRes, err error) {
|
||||
res = new(wxApplet.BusConstructiomUserSignatureQueryRes)
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
var signature *model.BusConstructiomUserSignatureRes
|
||||
err = g.DB().Model("bus_constructiom_user_signature").Where("openid", req.Openid).Scan(&signature)
|
||||
liberr.ErrIsNil(ctx, err, "获取数据失败")
|
||||
res.Signature = signature
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func FaceDetectionFunc(ctx context.Context, file *ghttp.UploadFile) (path string, err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
//1、获取文件相对路径
|
||||
str, err := coryCommon.UploadFileTwo(ctx, file, coryCommon.Portrait+"/")
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
getwd, err := os.Getwd()
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
join := gfile.Join(getwd, str)
|
||||
//2、根据绝对路径获取到base64
|
||||
urlBase64Two, err := coryCommon.EncodeAndUrlEncodeImage(join, 2)
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
//3、检测是否是人脸
|
||||
hfReq := &coryCommon.HumanFaceReq{}
|
||||
hfReq.Image = urlBase64Two
|
||||
hfReq.ImageType = "BASE64"
|
||||
hfReq.FaceField = "face_type,quality"
|
||||
err = coryCommon.HumanFace(hfReq)
|
||||
if err != nil {
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
return
|
||||
}
|
||||
path = strings.Replace(str, "resource/public", "/wxfile", 1)
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-07 11:17:55
|
||||
// 生成路径: internal/app/wxApplet/controller/bus_construction_user_file.go
|
||||
// 生成人:gfast
|
||||
// desc:微信用户的文件存储
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type busConstructionUserFileController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var BusConstructionUserFile = new(busConstructionUserFileController)
|
||||
|
||||
// List 列表
|
||||
func (c *busConstructionUserFileController) List(ctx context.Context, req *wxApplet.BusConstructionUserFileSearchReq) (res *wxApplet.BusConstructionUserFileSearchRes, err error) {
|
||||
res, err = service.BusConstructionUserFile().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取微信用户的文件存储
|
||||
func (c *busConstructionUserFileController) Get(ctx context.Context, req *wxApplet.BusConstructionUserFileGetReq) (res *wxApplet.BusConstructionUserFileGetRes, err error) {
|
||||
res = new(wxApplet.BusConstructionUserFileGetRes)
|
||||
res.BusConstructionUserFileInfoRes, err = service.BusConstructionUserFile().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加微信用户的文件存储
|
||||
func (c *busConstructionUserFileController) Add(ctx context.Context, req *wxApplet.BusConstructionUserFileAddReq) (res *wxApplet.BusConstructionUserFileAddRes, err error) {
|
||||
err = service.BusConstructionUserFile().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改微信用户的文件存储
|
||||
func (c *busConstructionUserFileController) Edit(ctx context.Context, req *wxApplet.BusConstructionUserFileEditReq) (res *wxApplet.BusConstructionUserFileEditRes, err error) {
|
||||
err = service.BusConstructionUserFile().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除微信用户的文件存储
|
||||
func (c *busConstructionUserFileController) Delete(ctx context.Context, req *wxApplet.BusConstructionUserFileDeleteReq) (res *wxApplet.BusConstructionUserFileDeleteRes, err error) {
|
||||
err = service.BusConstructionUserFile().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-07 11:17:55
|
||||
// 生成路径: internal/app/wxApplet/controller/bus_construction_user_post.go
|
||||
// 生成人:gfast
|
||||
// desc:施工人员岗位
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type busConstructionUserPostController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var BusConstructionUserPost = new(busConstructionUserPostController)
|
||||
|
||||
// List 列表
|
||||
func (c *busConstructionUserPostController) List(ctx context.Context, req *wxApplet.BusConstructionUserPostSearchReq) (res *wxApplet.BusConstructionUserPostSearchRes, err error) {
|
||||
res, err = service.BusConstructionUserPost().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取施工人员岗位
|
||||
func (c *busConstructionUserPostController) Get(ctx context.Context, req *wxApplet.BusConstructionUserPostGetReq) (res *wxApplet.BusConstructionUserPostGetRes, err error) {
|
||||
res = new(wxApplet.BusConstructionUserPostGetRes)
|
||||
res.BusConstructionUserPostInfoRes, err = service.BusConstructionUserPost().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加施工人员岗位
|
||||
func (c *busConstructionUserPostController) Add(ctx context.Context, req *wxApplet.BusConstructionUserPostAddReq) (res *wxApplet.BusConstructionUserPostAddRes, err error) {
|
||||
err = service.BusConstructionUserPost().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改施工人员岗位
|
||||
func (c *busConstructionUserPostController) Edit(ctx context.Context, req *wxApplet.BusConstructionUserPostEditReq) (res *wxApplet.BusConstructionUserPostEditRes, err error) {
|
||||
err = service.BusConstructionUserPost().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除施工人员岗位
|
||||
func (c *busConstructionUserPostController) Delete(ctx context.Context, req *wxApplet.BusConstructionUserPostDeleteReq) (res *wxApplet.BusConstructionUserPostDeleteRes, err error) {
|
||||
err = service.BusConstructionUserPost().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
72
internal/app/wxApplet/controller/bus_labourservice.go
Normal file
72
internal/app/wxApplet/controller/bus_labourservice.go
Normal file
@ -0,0 +1,72 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-14 11:24:31
|
||||
// 生成路径: internal/app/wxApplet/controller/bus_labourservice.go
|
||||
// 生成人:gfast
|
||||
// desc:劳务公司
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type busLabourserviceController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var BusLabourservice = new(busLabourserviceController)
|
||||
|
||||
// List 列表
|
||||
func (c *busLabourserviceController) List(ctx context.Context, req *wxApplet.BusLabourserviceSearchReq) (res *wxApplet.BusLabourserviceSearchRes, err error) {
|
||||
res, err = service.BusLabourservice().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取劳务公司
|
||||
func (c *busLabourserviceController) Get(ctx context.Context, req *wxApplet.BusLabourserviceGetReq) (res *wxApplet.BusLabourserviceGetRes, err error) {
|
||||
res = new(wxApplet.BusLabourserviceGetRes)
|
||||
res.BusLabourserviceInfoRes, err = service.BusLabourservice().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加劳务公司
|
||||
func (c *busLabourserviceController) Add(ctx context.Context, req *wxApplet.BusLabourserviceAddReq) (res *wxApplet.BusLabourserviceAddRes, err error) {
|
||||
err = service.BusLabourservice().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改劳务公司
|
||||
func (c *busLabourserviceController) Edit(ctx context.Context, req *wxApplet.BusLabourserviceEditReq) (res *wxApplet.BusLabourserviceEditRes, err error) {
|
||||
err = service.BusLabourservice().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除劳务公司
|
||||
func (c *busLabourserviceController) Delete(ctx context.Context, req *wxApplet.BusLabourserviceDeleteReq) (res *wxApplet.BusLabourserviceDeleteRes, err error) {
|
||||
err = service.BusLabourservice().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
// PcAdd pc劳务公司资料新增
|
||||
func (c *busLabourserviceController) PcAdd(ctx context.Context, req *wxApplet.BusPcAddReq) (res *wxApplet.BusPcAddRes, err error) {
|
||||
err = service.BusLabourservice().PcAdd(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// PcDel pc劳务公司资料删除
|
||||
func (c *busLabourserviceController) PcDel(ctx context.Context, req *wxApplet.BusPcDelReq) (res *wxApplet.BusPcDelRes, err error) {
|
||||
err = service.BusLabourservice().PcDel(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// PcFind pc劳务公司资料查询
|
||||
func (c *busLabourserviceController) PcFind(ctx context.Context, req *wxApplet.BusPcFindReq) (res *wxApplet.BusPcFindRes, err error) {
|
||||
res, err = service.BusLabourservice().PcFind(ctx, req)
|
||||
return
|
||||
}
|
||||
54
internal/app/wxApplet/controller/sys_project_team.go
Normal file
54
internal/app/wxApplet/controller/sys_project_team.go
Normal file
@ -0,0 +1,54 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-15 09:34:52
|
||||
// 生成路径: internal/app/wxApplet/controller/sys_project_team.go
|
||||
// 生成人:gfast
|
||||
// desc:项目班组
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type sysProjectTeamController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var SysProjectTeam = new(sysProjectTeamController)
|
||||
|
||||
// List 列表
|
||||
func (c *sysProjectTeamController) List(ctx context.Context, req *wxApplet.SysProjectTeamSearchReq) (res *wxApplet.SysProjectTeamSearchRes, err error) {
|
||||
res, err = service.SysProjectTeam().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取项目班组
|
||||
func (c *sysProjectTeamController) Get(ctx context.Context, req *wxApplet.SysProjectTeamGetReq) (res *wxApplet.SysProjectTeamGetRes, err error) {
|
||||
res = new(wxApplet.SysProjectTeamGetRes)
|
||||
res.SysProjectTeamInfoRes, err = service.SysProjectTeam().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加项目班组
|
||||
func (c *sysProjectTeamController) Add(ctx context.Context, req *wxApplet.SysProjectTeamAddReq) (res *wxApplet.SysProjectTeamAddRes, err error) {
|
||||
err = service.SysProjectTeam().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改项目班组
|
||||
func (c *sysProjectTeamController) Edit(ctx context.Context, req *wxApplet.SysProjectTeamEditReq) (res *wxApplet.SysProjectTeamEditRes, err error) {
|
||||
err = service.SysProjectTeam().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除项目班组
|
||||
func (c *sysProjectTeamController) Delete(ctx context.Context, req *wxApplet.SysProjectTeamDeleteReq) (res *wxApplet.SysProjectTeamDeleteRes, err error) {
|
||||
err = service.SysProjectTeam().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
54
internal/app/wxApplet/controller/sys_project_team_member.go
Normal file
54
internal/app/wxApplet/controller/sys_project_team_member.go
Normal file
@ -0,0 +1,54 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-15 09:34:52
|
||||
// 生成路径: internal/app/wxApplet/controller/sys_project_team_member.go
|
||||
// 生成人:gfast
|
||||
// desc:项目班组下的成员
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type sysProjectTeamMemberController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var SysProjectTeamMember = new(sysProjectTeamMemberController)
|
||||
|
||||
// List 列表
|
||||
func (c *sysProjectTeamMemberController) List(ctx context.Context, req *wxApplet.SysProjectTeamMemberSearchReq) (res *wxApplet.SysProjectTeamMemberSearchRes, err error) {
|
||||
res, err = service.SysProjectTeamMember().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取项目班组下的成员
|
||||
func (c *sysProjectTeamMemberController) Get(ctx context.Context, req *wxApplet.SysProjectTeamMemberGetReq) (res *wxApplet.SysProjectTeamMemberGetRes, err error) {
|
||||
res = new(wxApplet.SysProjectTeamMemberGetRes)
|
||||
res.SysProjectTeamMemberInfoRes, err = service.SysProjectTeamMember().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加项目班组下的成员
|
||||
func (c *sysProjectTeamMemberController) Add(ctx context.Context, req *wxApplet.SysProjectTeamMemberAddReq) (res *wxApplet.SysProjectTeamMemberAddRes, err error) {
|
||||
err = service.SysProjectTeamMember().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改项目班组下的成员
|
||||
func (c *sysProjectTeamMemberController) Edit(ctx context.Context, req *wxApplet.SysProjectTeamMemberEditReq) (res *wxApplet.SysProjectTeamMemberEditRes, err error) {
|
||||
err = service.SysProjectTeamMember().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除项目班组下的成员
|
||||
func (c *sysProjectTeamMemberController) Delete(ctx context.Context, req *wxApplet.SysProjectTeamMemberDeleteReq) (res *wxApplet.SysProjectTeamMemberDeleteRes, err error) {
|
||||
err = service.SysProjectTeamMember().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
67
internal/app/wxApplet/controller/sys_project_team_squad.go
Normal file
67
internal/app/wxApplet/controller/sys_project_team_squad.go
Normal file
@ -0,0 +1,67 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-30 15:24:06
|
||||
// 生成路径: internal/app/wxApplet/controller/sys_project_team_squad.go
|
||||
// 生成人:gfast
|
||||
// desc:站班会
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/dao"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type sysProjectTeamSquadController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var SysProjectTeamSquad = new(sysProjectTeamSquadController)
|
||||
|
||||
// List 列表
|
||||
func (c *sysProjectTeamSquadController) List(ctx context.Context, req *wxApplet.SysProjectTeamSquadSearchReq) (res *wxApplet.SysProjectTeamSquadSearchRes, err error) {
|
||||
res, err = service.SysProjectTeamSquad().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取站班会
|
||||
func (c *sysProjectTeamSquadController) Get(ctx context.Context, req *wxApplet.SysProjectTeamSquadGetReq) (res *wxApplet.SysProjectTeamSquadGetRes, err error) {
|
||||
res = new(wxApplet.SysProjectTeamSquadGetRes)
|
||||
res.SysProjectTeamSquadInfoRes, err = service.SysProjectTeamSquad().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加站班会
|
||||
func (c *sysProjectTeamSquadController) Add(ctx context.Context, req *wxApplet.SysProjectTeamSquadAddReq) (res *wxApplet.SysProjectTeamSquadAddRes, err error) {
|
||||
err = service.SysProjectTeamSquad().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改站班会
|
||||
func (c *sysProjectTeamSquadController) Edit(ctx context.Context, req *wxApplet.SysProjectTeamSquadEditReq) (res *wxApplet.SysProjectTeamSquadEditRes, err error) {
|
||||
err = service.SysProjectTeamSquad().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除站班会
|
||||
func (c *sysProjectTeamSquadController) Delete(ctx context.Context, req *wxApplet.SysProjectTeamSquadDeleteReq) (res *wxApplet.SysProjectTeamSquadDeleteRes, err error) {
|
||||
err = service.SysProjectTeamSquad().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *sysProjectTeamSquadController) Count(ctx context.Context, req *wxApplet.SysProjectTeamSquadCountReq) (res *wxApplet.SysProjectTeamSquadCountRes, err error) {
|
||||
count, err := dao.SysProjectTeamSquad.Ctx(ctx).Count()
|
||||
res.Number = count
|
||||
return
|
||||
}
|
||||
|
||||
// List 列表
|
||||
func (c *sysProjectTeamSquadController) SelectByOpenidTeamSquadSearchFunc(ctx context.Context, req *wxApplet.SelectByOpenidTeamSquadSearchReq) (res *wxApplet.SelectByOpenidTeamSquadSearchRes, err error) {
|
||||
res, err = service.SysProjectTeamSquad().SelectByOpenidTeamSquadSearch(ctx, req)
|
||||
return
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
// ==========================================================================
|
||||
// GFast自动生成controller操作代码。
|
||||
// 生成日期:2023-08-21 09:19:15
|
||||
// 生成路径: internal/app/wxApplet/controller/sys_user_project_relevancy.go
|
||||
// 生成人:gfast
|
||||
// desc:系统用户与项目关联
|
||||
// company:云南奇讯科技有限公司
|
||||
// ==========================================================================
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
)
|
||||
|
||||
type sysUserProjectRelevancyController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var SysUserProjectRelevancy = new(sysUserProjectRelevancyController)
|
||||
|
||||
// List 列表
|
||||
func (c *sysUserProjectRelevancyController) List(ctx context.Context, req *wxApplet.SysUserProjectRelevancySearchReq) (res *wxApplet.SysUserProjectRelevancySearchRes, err error) {
|
||||
res, err = service.SysUserProjectRelevancy().List(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Get 获取系统用户与项目关联
|
||||
func (c *sysUserProjectRelevancyController) Get(ctx context.Context, req *wxApplet.SysUserProjectRelevancyGetReq) (res *wxApplet.SysUserProjectRelevancyGetRes, err error) {
|
||||
res = new(wxApplet.SysUserProjectRelevancyGetRes)
|
||||
res.SysUserProjectRelevancyInfoRes, err = service.SysUserProjectRelevancy().GetById(ctx, req.Id)
|
||||
return
|
||||
}
|
||||
|
||||
// Add 添加系统用户与项目关联
|
||||
func (c *sysUserProjectRelevancyController) Add(ctx context.Context, req *wxApplet.SysUserProjectRelevancyAddReq) (res *wxApplet.SysUserProjectRelevancyAddRes, err error) {
|
||||
err = service.SysUserProjectRelevancy().Add(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 修改系统用户与项目关联
|
||||
func (c *sysUserProjectRelevancyController) Edit(ctx context.Context, req *wxApplet.SysUserProjectRelevancyEditReq) (res *wxApplet.SysUserProjectRelevancyEditRes, err error) {
|
||||
err = service.SysUserProjectRelevancy().Edit(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除系统用户与项目关联
|
||||
func (c *sysUserProjectRelevancyController) Delete(ctx context.Context, req *wxApplet.SysUserProjectRelevancyDeleteReq) (res *wxApplet.SysUserProjectRelevancyDeleteRes, err error) {
|
||||
err = service.SysUserProjectRelevancy().Delete(ctx, req.Ids)
|
||||
return
|
||||
}
|
||||
200
internal/app/wxApplet/controller/wx_login.go
Normal file
200
internal/app/wxApplet/controller/wx_login.go
Normal file
@ -0,0 +1,200 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/crypto/gmd5"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
"github.com/medivhzhan/weapp/v3"
|
||||
"github.com/medivhzhan/weapp/v3/auth"
|
||||
"github.com/tiger1103/gfast/v3/api/v1/common/coryCommon"
|
||||
"github.com/tiger1103/gfast/v3/api/wxApplet/wxApplet"
|
||||
systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/dao"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/model/do"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/model/entity"
|
||||
se "github.com/tiger1103/gfast/v3/internal/app/system/service"
|
||||
wxDao "github.com/tiger1103/gfast/v3/internal/app/wxApplet/dao"
|
||||
wxModel "github.com/tiger1103/gfast/v3/internal/app/wxApplet/model/do"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/wxApplet/service"
|
||||
"github.com/tiger1103/gfast/v3/library/libUtils"
|
||||
"github.com/tiger1103/gfast/v3/library/liberr"
|
||||
)
|
||||
|
||||
type WXLoginController struct {
|
||||
systemController.BaseController
|
||||
}
|
||||
|
||||
var WXLogin = new(WXLoginController)
|
||||
|
||||
func (e *WXLoginController) BusLogin(ctx context.Context, req *wxApplet.LoginReq) (res *wxApplet.LoginRes, err error) {
|
||||
res = &wxApplet.LoginRes{}
|
||||
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
appId, err := g.Cfg().Get(gctx.New(), "wx.appId")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
appSecret, err := g.Cfg().Get(gctx.New(), "wx.appSecret")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
sdk := weapp.NewClient(appId.String(), appSecret.String())
|
||||
cli := sdk.NewAuth()
|
||||
//// 登录凭证校验
|
||||
rsp, err := cli.Code2Session(&auth.Code2SessionRequest{
|
||||
Appid: appId.String(),
|
||||
Secret: appSecret.String(),
|
||||
JsCode: req.Code,
|
||||
GrantType: "authorization_code",
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if rsp.ErrCode != 0 {
|
||||
err = rsp.GetResponseError()
|
||||
return
|
||||
}
|
||||
user := wxApplet.BusConstructionUserAddReq{}
|
||||
user.Openid = rsp.Openid
|
||||
res.Openid = user.Openid
|
||||
value, err := dao.BusConstructionUser.Ctx(ctx).Where("openid=?", user.Openid).Fields("head_icon").Value()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result := 0
|
||||
if value != nil {
|
||||
result = 1
|
||||
}
|
||||
// 上传微信头像
|
||||
str, err := coryCommon.UploadFileTwo(ctx, req.HeadIcon, coryCommon.Helmet)
|
||||
if err != nil {
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
return
|
||||
}
|
||||
replace := strings.Replace(str, "resource/public", "/wxfile", 1)
|
||||
// 删除以前的头像
|
||||
if strings.Contains(value.String(), "/wxfile/") {
|
||||
s := strings.Replace(value.String(), "/wxfile/", coryCommon.GetCWD()+"/resource/public/", 1)
|
||||
os.Remove(filepath.ToSlash(s))
|
||||
}
|
||||
if result == 0 {
|
||||
// user.HeadIcon = req.HeadIcon
|
||||
//user.NickName = req.NickName
|
||||
//user.HeadIcon = replace
|
||||
_, err := service.BusConstructionUser().Add(ctx, &user)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
_, err = dao.BusConstructionUser.Ctx(ctx).Data(g.Map{
|
||||
//"head_icon": req.HeadIcon,
|
||||
"nick_name": req.NickName,
|
||||
"head_icon": replace,
|
||||
}).Where("openid=?", user.Openid).Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
res.Token = gettoken(ctx, user.Openid, user)
|
||||
return
|
||||
})
|
||||
return err
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//func gettoken(ctx context.Context, openid string, user wxApplet.BusConstructionUserAddReq) string {
|
||||
// key := gmd5.MustEncryptString(openid)
|
||||
// token, err := se.GfToken().GenerateToken(ctx, key+key, user)
|
||||
// fmt.Println("创建的token", token)
|
||||
// fmt.Println(err)
|
||||
// token = "Bearer " + token
|
||||
// fmt.Println("更改的-----", token)
|
||||
// return token
|
||||
//}
|
||||
|
||||
func gettoken(ctx context.Context, openid string, user wxApplet.BusConstructionUserAddReq) string {
|
||||
encryptedKey := gmd5.MustEncryptString(openid)
|
||||
|
||||
key := openid + "-" + encryptedKey
|
||||
authToken, _ := se.GfToken().GenerateToken(ctx, key, user)
|
||||
|
||||
return "Bearer " + authToken
|
||||
}
|
||||
|
||||
// IsBindApp 是否绑定 App
|
||||
func (e *WXLoginController) IsBindApp(ctx context.Context, req *wxApplet.IsBindAppReq) (*wxApplet.IsBindAppRes, error) {
|
||||
exist, err := dao.BusConstructionUser.Ctx(ctx).As("bcu").
|
||||
InnerJoin("sys_user AS su", `bcu.user_name COLLATE utf8mb4_general_ci = su.user_name COLLATE utf8mb4_general_ci
|
||||
AND bcu.phone COLLATE utf8mb4_general_ci = su.mobile COLLATE utf8mb4_general_ci`).
|
||||
Where("bcu.openid", req.Openid).
|
||||
Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 如果已绑定 App 则返回 1,否则返回 0
|
||||
if exist > 0 {
|
||||
return &wxApplet.IsBindAppRes{IsBind: 1}, nil
|
||||
}
|
||||
|
||||
return &wxApplet.IsBindAppRes{IsBind: 0}, nil
|
||||
}
|
||||
|
||||
// AppletBindApp 小程序绑定 App
|
||||
func (e *WXLoginController) AppletBindApp(ctx context.Context, req *wxApplet.AppletBindAppReq) (*wxApplet.AppletBindAppRes, error) {
|
||||
// 获取小程序用户信息
|
||||
busConstructUser := entity.BusConstructionUser{}
|
||||
if err := dao.BusConstructionUser.Ctx(ctx).Where(dao.BusConstructionUser.Columns().Openid, req.Openid).Scan(&busConstructUser); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 判断当前用户的手机号和用户名是否为空
|
||||
if busConstructUser.Phone == "" || busConstructUser.UserName == "" {
|
||||
return nil, fmt.Errorf("当前用户的手机号和用户名为空")
|
||||
}
|
||||
|
||||
exist, err := dao.SysUser.Ctx(ctx).Where(dao.SysUser.Columns().UserNickname, busConstructUser.UserName).
|
||||
Where(dao.SysUser.Columns().Mobile, busConstructUser.Phone).Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 判断是否已绑定 App
|
||||
if exist > 0 {
|
||||
return nil, fmt.Errorf("当前用户已经绑定了 App")
|
||||
}
|
||||
|
||||
passwordSalt := grand.S(10) // 密码盐值
|
||||
encryptedPassword := libUtils.EncryptPassword(req.Password, passwordSalt) // 加密密码
|
||||
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
// 创建用户
|
||||
userId, err := dao.SysUser.Ctx(ctx).InsertAndGetId(do.SysUser{
|
||||
UserName: busConstructUser.UserName, // 用户名
|
||||
UserNickname: busConstructUser.NickName, // 用户昵称
|
||||
Mobile: busConstructUser.Phone, // 手机号
|
||||
UserPassword: encryptedPassword, // 密码
|
||||
UserSalt: passwordSalt, // 密码盐
|
||||
Sex: busConstructUser.Sex, // 性别
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "创建用户失败")
|
||||
|
||||
// 关联后台项目
|
||||
_, err = wxDao.SysUserProjectRelevancy.Ctx(ctx).Insert(wxModel.SysUserProjectRelevancy{
|
||||
UserId: userId, // 用户 ID
|
||||
ProjectId: busConstructUser.ProjectId, // 项目 ID
|
||||
})
|
||||
liberr.ErrIsNil(ctx, err, "关联后台管理项目失败")
|
||||
})
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
Reference in New Issue
Block a user