12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250 |
- package v1
- import (
- "git.getensh.com/common/gopkgs/logger"
- "git.getensh.com/common/gopkgs/tasker/httptasker"
- "git.getensh.com/common/gopkgs/util"
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- "net/http"
- "property-applete-gateway/errors"
- param_v1 "property-applete-gateway/param/v1"
- "property-applete-gateway/pb"
- "property-applete-gateway/pb/v1"
- "property-applete-gateway/utils"
- )
- //
- // @Summary 添加楼栋
- // @Description 添加楼栋
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.BuildingAddBody true "信息"
- // @Success 200 {object} v1.BuildingAddResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/building [post]
- func (c *Controller) BuildingAdd(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.BuildingAddRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.BuildingAddBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.BuildingAddResponse{}
- rpcReq := &v1.BuildingAddRequest{
- GardenId:tokenInfo.GardenId,
- BuildingNumber:req.BuildingNumber,
- BuildingName:req.BuildingName,
- BuildingArea:req.BuildingArea,
- BuildingUsedArea:req.BuildingUsedArea,
- Comment:req.Comment,
- }
- rpcRsp, err := pb.Garden.BuildingAdd(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.BuildingAdd"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenAddBuilding,
- Origin:nil,
- Target:req.BuildingAddBody,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 更改楼栋
- // @Description 更改楼栋
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.BuildingUpdateBody true "信息"
- // @Success 200 {object} v1.BuildingUpdateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/building [put]
- func (c *Controller) BuildingUpdate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.BuildingUpdateRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.BuildingUpdateBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.BuildingUpdateResponse{}
- rpcReq := &v1.BuildingUpdateRequest{
- GardenId:tokenInfo.GardenId,
- BuildingNumber:req.BuildingNumber,
- BuildingName:req.BuildingName,
- BuildingArea:req.BuildingArea,
- BuildingUsedArea:req.BuildingUsedArea,
- Comment:req.Comment,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.BuildingUpdate(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.BuildingUpdate"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenUpdateBuilding,
- Origin:rpcRsp.Origin,
- Target:req.BuildingUpdateBody,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 删除楼栋
- // @Description 删除楼栋
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param id query int true "id"
- // @Success 200 {object} v1.BuildingDelResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/building [delete]
- func (c *Controller) BuildingDel(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.BuildingDelRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.BuildingDelQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.BuildingDelResponse{}
- rpcReq := &v1.BuildingDelRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.BuildingDel(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.BuildingDel"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenDelBuilding,
- Origin:rpcRsp.Origin,
- Target:nil,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 楼栋列表
- // @Description 楼栋列表
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param page query int false " "
- // @Param page_size query int false " "
- // @Param building_number query string false "楼栋编号"
- // @Success 200 {object} v1.BuildingListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/building [get]
- func (c *Controller) BuildingList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.BuildingListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.BuildingListQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.BuildingListResponse{}
- rpcReq := &v1.BuildingListRequest{
- GardenId:tokenInfo.GardenId,
- BuildingNumber:req.BuildingNumber,
- Page:req.Page,
- PageSize:req.PageSize,
- }
- rpcRsp, err := pb.Garden.BuildingList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.BuildingList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.BuildingItem, 0)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 添加单元
- // @Description 添加单元
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.UnitAddBody true "信息"
- // @Success 200 {object} v1.UnitAddResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/unit [post]
- func (c *Controller) UnitAdd(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.UnitAddRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.UnitAddBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.UnitAddResponse{}
- rpcReq := &v1.UnitAddRequest{
- GardenId:tokenInfo.GardenId,
- UnitNumber:req.UnitNumber,
- UnitName:req.UnitName,
- UnitLayers:req.UnitLayers,
- BuildingId:req.BuildingId,
- HasLift:req.HasLift,
- }
- rpcRsp, err := pb.Garden.UnitAdd(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.UnitAdd"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenAddUnit,
- Origin:nil,
- Target:req.UnitAddBody,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 更改单元
- // @Description 更改单元
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.UnitUpdateBody true "信息"
- // @Success 200 {object} v1.UnitUpdateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/unit [put]
- func (c *Controller) UnitUpdate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.UnitUpdateRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.UnitUpdateBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.UnitUpdateResponse{}
- rpcReq := &v1.UnitUpdateRequest{
- GardenId:tokenInfo.GardenId,
- UnitNumber:req.UnitNumber,
- UnitName:req.UnitName,
- UnitLayers:req.UnitLayers,
- BuildingId:req.BuildingId,
- HasLift:req.HasLift,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.UnitUpdate(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.UnitUpdate"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenUpdateUnit,
- Origin:rpcRsp.Origin,
- Target:req.UnitUpdateBody,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 删除单元
- // @Description 删除单元
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param id query int true "id"
- // @Success 200 {object} v1.UnitDelResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/unit [delete]
- func (c *Controller) UnitDel(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.UnitDelRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.UnitDelQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.UnitDelResponse{}
- rpcReq := &v1.UnitDelRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.UnitDel(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.UnitDel"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenDelUnit,
- Origin:rpcRsp.Origin,
- Target:nil,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 单元列表
- // @Description 单元列表
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param page query int false " "
- // @Param page_size query int false " "
- // @Param unit_number query int false "单元编号"
- // @Param building_id query int false "楼栋id"
- // @Success 200 {object} v1.UnitListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/unit [get]
- func (c *Controller) UnitList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.UnitListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.UnitListQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.UnitListResponse{}
- rpcReq := &v1.UnitListRequest{
- GardenId:tokenInfo.GardenId,
- UnitNumber:req.UnitNumber,
- BuildingId:req.BuildingId,
- Page:req.Page,
- PageSize:req.PageSize,
- }
- rpcRsp, err := pb.Garden.UnitList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.UnitList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.UnitItem, 0)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 添加房屋
- // @Description 添加房屋
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.HouseAddBody true "信息"
- // @Success 200 {object} v1.HouseAddResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/house [post]
- func (c *Controller) HouseAdd(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseAddRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseAddBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.HouseAddResponse{}
- rpcReq := &v1.HouseAddRequest{
- GardenId:tokenInfo.GardenId,
- UnitId:req.UnitId,
- HouseNumber:req.HouseNumber,
- HouseType:req.HouseType,
- HouseUsedArea:req.HouseUsedArea,
- HouseArea:req.HouseArea,
- Layer:req.Layer,
- RoomCount:req.RoomCount,
- HallCount:req.HallCount,
- }
- rpcRsp, err := pb.Garden.HouseAdd(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.HouseAdd"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenAddHouse,
- Origin:nil,
- Target:req.HouseAddBody,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 更改房屋
- // @Description 更改房屋
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.HouseUpdateBody true "信息"
- // @Success 200 {object} v1.HouseUpdateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/house [put]
- func (c *Controller) HouseUpdate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseUpdateRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.HouseUpdateBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.HouseUpdateResponse{}
- rpcReq := &v1.HouseUpdateRequest{
- GardenId:tokenInfo.GardenId,
- UnitId:req.UnitId,
- HouseNumber:req.HouseNumber,
- HouseType:req.HouseType,
- HouseUsedArea:req.HouseUsedArea,
- HouseArea:req.HouseArea,
- Layer:req.Layer,
- RoomCount:req.RoomCount,
- HallCount:req.HallCount,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.HouseUpdate(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.HouseUpdate"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenUpdateHouse,
- Origin:rpcRsp.Origin,
- Target:req.HouseUpdateBody,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 删除房屋
- // @Description 删除房屋
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param id query int true "id"
- // @Success 200 {object} v1.HouseDelResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/house [delete]
- func (c *Controller) HouseDel(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseDelRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseDelQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.HouseDelResponse{}
- rpcReq := &v1.HouseDelRequest{
- GardenId:tokenInfo.GardenId,
- Id:req.Id,
- }
- rpcRsp, err := pb.Garden.HouseDel(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.HouseDel"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- logReq := OperationLogRequest{
- Module:ModuleGarden,
- Action:ActionGardenDelHouse,
- Origin:rpcRsp.Origin,
- Target:nil,
- UserName:tokenInfo.UserName,
- Uid:tokenInfo.Uid,
- Cid:tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- }
- go OperationLogAdd(&logReq)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 房屋列表
- // @Description 房屋列表
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param page query int false " "
- // @Param page_size query int false " "
- // @Param house_number query int false "门牌号"
- // @Param building_id query int false "楼栋id"
- // @Param unit_id query int false "单元id"
- // @Param household_id query int false "住户uid"
- // @Param house_type query int false "房屋类型 1 住宅 2 商铺 3 办公"
- // @Param house_rent query bool false "是否用于房屋租赁 true 是 false 否"
- // @Success 200 {object} v1.HouseListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/house [get]
- func (c *Controller) HouseList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.HouseListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.HouseListQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.HouseListResponse{}
- rpcReq := &v1.HouseListRequest{
- GardenId:tokenInfo.GardenId,
- HouseNumber:req.HouseNumber,
- HouseType:req.HouseType,
- BuildingId:req.BuildingId,
- UnitId:req.UnitId,
- Page:req.Page,
- PageSize:req.PageSize,
- Uid:req.HouseholdUid,
- HouseRent:req.HouseRent,
- }
- rpcRsp, err := pb.Garden.HouseList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.HouseList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.HouseItem, 0)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 批量添加
- // @Description 批量添加
- // @Tags 楼盘管理
- // @Accept json
- // @Produce json
- // @Param token header string true "token"
- // @Param body body v1.BatchHouseAddBody true "信息"
- // @Success 200 {object} v1.HouseAddResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/buildings/batch [post]
- func (c *Controller) BatchHouseAdd(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.BatchHouseAddRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.BatchHouseAddBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.BatchHouseAddResponse{}
- rpcReq := &v1.BatchHouseAddRequest{
- GardenId:tokenInfo.GardenId,
- }
- rpcReq.Buildings = make([]*v1.BatchBuildingItem, len(req.Buildings))
- for i, _ := range req.Buildings {
- rpcReq.Buildings[i] = &req.Buildings[i]
- }
- rpcReq.Units = make([]*v1.BatchUnitItem, len(req.Units))
- for i, _ := range req.Units {
- rpcReq.Units[i] = &req.Units[i]
- }
- rpcReq.Houses = make([]*v1.BatchHouseItem, len(req.Houses))
- for i, _ := range req.Houses {
- rpcReq.Houses[i] = &req.Houses[i]
- }
- _, err = pb.Garden.BatchHouseAdd(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.BatchHouseAdd"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 小区信息
- // @Description 小区信息
- // @Tags 小区
- // @Accept json
- // @Produce json
- // @Param token header string true " "
- // @Success 200 {object} v1.GardenInfoResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/garden [get]
- func (c *Controller) GardenInfo(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.GardenInfoRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.GardenInfoResponse{}
- rpcReq := &v1.GardenInfosRequest{
- Ids:[]int64{tokenInfo.GardenId},
- }
- rpcRsp, err := pb.System.GardenInfos(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "Garden.GardenInfos"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- return errors.ErrRecordNotFound
- }
- resp.Data = *rpcRsp.List[0]
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 修改小区普通信息
- // @Description 修改小区普通信息
- // @Tags 小区
- // @Accept json
- // @Produce json
- // @Param token header string true " "
- // @Param body body v1.GardenUpdateBody true "小区信息"
- // @Success 200 {object} v1.GardenUpdateResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/garden [put]
- func (c *Controller) GardenUpdate(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.GardenUpdateRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.GardenUpdateBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.GardenUpdateResponse{}
- rpcReq := &v1.GardenUpdateRequest{
- //Province: req.Province,
- //ProvinceCode: req.ProvinceCode,
- //City: req.City,
- //CityCode: req.CityCode,
- //Area: req.Area,
- //AreaCode: req.AreaCode,
- //Street: req.Street,
- //StreetCode: req.StreetCode,
- //Committee: req.Committee,
- //CommitteeCode: req.CommitteeCode,
- PropertyPerson: req.PropertyPerson,
- PropertyPhone: req.PropertyPhone,
- //GardenName: req.GardenName,
- GardenAddr: req.GardenAddr,
- Cid: tokenInfo.Cid,
- Id:tokenInfo.GardenId,
- GardenPic:req.GardenPic,
- GardenDesc:req.GardenDesc,
- Lnt:req.Lnt,
- Lat:req.Lat,
- }
- _, err = pb.System.GardenUpdate(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.GardenUpdate"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 申请修改小区关键信息
- // @Description 申请修改小区关键信息
- // @Tags 小区
- // @Accept json
- // @Produce json
- // @Param token header string true " "
- // @Param body body v1.GardenKeyInfoChangeBody true "小区信息"
- // @Success 200 {object} v1.GardenKeyInfoChangeResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/garden/key_info [put]
- func (c *Controller) GardenKeyInfoChange(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.GardenKeyInfoChangeRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.GardenKeyInfoChangeBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.GardenKeyInfoChangeResponse{}
- rpcReq := &v1.GardenKeyInfoChangeRequest{
- Province: req.Province,
- ProvinceCode: req.ProvinceCode,
- City: req.City,
- CityCode: req.CityCode,
- Area: req.Area,
- AreaCode: req.AreaCode,
- Street: req.Street,
- StreetCode: req.StreetCode,
- Committee: req.Committee,
- CommitteeCode: req.CommitteeCode,
- Cid: tokenInfo.Cid,
- Id:tokenInfo.GardenId,
- GardenName:req.GardenName,
- }
- _, err = pb.System.GardenKeyInfoChange(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.GardenKeyInfoChange"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- //
- // @Summary 小区关键信息申请列表
- // @Description 小区关键信息申请列表
- // @Tags 小区
- // @Accept json
- // @Produce json
- // @Param token header string true " "
- // @Param page query int false " "
- // @Param page_size query int false " "
- // @Param status query int false "0不过率 1 待审核 2 审核通过 3 未通过 "
- // @Success 200 {object} v1.GardenKeyInfoChangeListResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/garden/key_info [get]
- func (c *Controller) GardenKeyInfoChangeList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.GardenKeyInfoChangeListRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, &req.GardenKeyInfoChangeListQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- tokenInfo, err := utils.GetSubjectValue(ctx)
- if err != nil {
- return err
- }
- // 响应数据
- resp := param_v1.GardenKeyInfoChangeListResponse{}
- rpcReq := &v1.GardenKeyInfoChangeListRequest{
- Cid: tokenInfo.Cid,
- GardenId:tokenInfo.GardenId,
- Status:req.Status,
- Page:req.Page,
- PageSize:req.PageSize,
- }
- rpcRsp, err := pb.System.GardenKeyInfoChangeList(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "pb.Garden.GardenKeyInfoChangeList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if rpcRsp.List == nil {
- rpcRsp.List = make([]*v1.GardenKeyInfoData, 0)
- }
- resp.Data = *rpcRsp
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
|