123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- package autocode
- import (
- "github.com/flipped-aurora/gin-vue-admin/server/global"
- "github.com/flipped-aurora/gin-vue-admin/server/model/autocode"
- autocodeReq "github.com/flipped-aurora/gin-vue-admin/server/model/autocode/request"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
- "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
- "github.com/flipped-aurora/gin-vue-admin/server/service"
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- )
- type UnitHistoryApi struct {
- }
- var unitHistoryService = service.ServiceGroupApp.AutoCodeServiceGroup.UnitHistoryService
- // CreateUnitHistory 创建UnitHistory
- // @Tags UnitHistory
- // @Summary 创建UnitHistory
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body autocode.UnitHistory true "创建UnitHistory"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /unitHistory/createUnitHistory [post]
- func (unitHistoryApi *UnitHistoryApi) CreateUnitHistory(c *gin.Context) {
- var unitHistory autocode.UnitHistory
- _ = c.ShouldBindJSON(&unitHistory)
- if err := unitHistoryService.CreateUnitHistory(unitHistory); err != nil {
- global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
- response.FailWithMessage("创建失败", c)
- } else {
- response.OkWithMessage("创建成功", c)
- }
- }
- // DeleteUnitHistory 删除UnitHistory
- // @Tags UnitHistory
- // @Summary 删除UnitHistory
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body autocode.UnitHistory true "删除UnitHistory"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
- // @Router /unitHistory/deleteUnitHistory [delete]
- func (unitHistoryApi *UnitHistoryApi) DeleteUnitHistory(c *gin.Context) {
- var unitHistory autocode.UnitHistory
- _ = c.ShouldBindJSON(&unitHistory)
- if err := unitHistoryService.DeleteUnitHistory(unitHistory); err != nil {
- global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
- response.FailWithMessage("删除失败", c)
- } else {
- response.OkWithMessage("删除成功", c)
- }
- }
- // DeleteUnitHistoryByIds 批量删除UnitHistory
- // @Tags UnitHistory
- // @Summary 批量删除UnitHistory
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body request.IdsReq true "批量删除UnitHistory"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
- // @Router /unitHistory/deleteUnitHistoryByIds [delete]
- func (unitHistoryApi *UnitHistoryApi) DeleteUnitHistoryByIds(c *gin.Context) {
- var IDS request.IdsReq
- _ = c.ShouldBindJSON(&IDS)
- if err := unitHistoryService.DeleteUnitHistoryByIds(IDS); err != nil {
- global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
- response.FailWithMessage("批量删除失败", c)
- } else {
- response.OkWithMessage("批量删除成功", c)
- }
- }
- // UpdateUnitHistory 更新UnitHistory
- // @Tags UnitHistory
- // @Summary 更新UnitHistory
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data body autocode.UnitHistory true "更新UnitHistory"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
- // @Router /unitHistory/updateUnitHistory [put]
- func (unitHistoryApi *UnitHistoryApi) UpdateUnitHistory(c *gin.Context) {
- var unitHistory autocode.UnitHistory
- _ = c.ShouldBindJSON(&unitHistory)
- if err := unitHistoryService.UpdateUnitHistory(unitHistory); err != nil {
- global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
- response.FailWithMessage("更新失败", c)
- } else {
- response.OkWithMessage("更新成功", c)
- }
- }
- // FindUnitHistory 用id查询UnitHistory
- // @Tags UnitHistory
- // @Summary 用id查询UnitHistory
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data query autocode.UnitHistory true "用id查询UnitHistory"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
- // @Router /unitHistory/findUnitHistory [get]
- func (unitHistoryApi *UnitHistoryApi) FindUnitHistory(c *gin.Context) {
- var unitHistory autocode.UnitHistory
- _ = c.ShouldBindQuery(&unitHistory)
- if err, reunitHistory := unitHistoryService.GetUnitHistory(unitHistory.ID); err != nil {
- global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
- response.FailWithMessage("查询失败", c)
- } else {
- response.OkWithData(gin.H{"reunitHistory": reunitHistory}, c)
- }
- }
- // GetUnitHistoryList 分页获取UnitHistory列表
- // @Tags UnitHistory
- // @Summary 分页获取UnitHistory列表
- // @Security ApiKeyAuth
- // @accept application/json
- // @Produce application/json
- // @Param data query autocodeReq.UnitHistorySearch true "分页获取UnitHistory列表"
- // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
- // @Router /unitHistory/getUnitHistoryList [get]
- func (unitHistoryApi *UnitHistoryApi) GetUnitHistoryList(c *gin.Context) {
- var pageInfo autocodeReq.UnitHistorySearch
- _ = c.ShouldBindQuery(&pageInfo)
- if err, list, total := unitHistoryService.GetUnitHistoryInfoList(pageInfo); err != nil {
- global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
- response.FailWithMessage("获取失败", c)
- } else {
- response.OkWithDetailed(response.PageResult{
- List: list,
- Total: total,
- Page: pageInfo.Page,
- PageSize: pageInfo.PageSize,
- }, "获取成功", c)
- }
- }
|