123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- "project_management/app/e"
- "project_management/app/model"
- "project_management/app/services"
- )
- var ApplyCap services.ApplyCap = &model.ApplyCap{}
- // ApplyAddCap 添加应用能力
- func ApplyAddCap(c *gin.Context) {
- var applyCap model.ApplyCapabilities
- if err := c.ShouldBindJSON(&applyCap); err != nil {
- e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
- return
- }
- validate := validator.New()
- if err := validate.Struct(applyCap); err != nil {
- e.ResponseWithMsg(c, e.ERROR, "请检查必填项")
- return
- }
- addCap := ApplyCap.ApplyAddCap(applyCap)
- if addCap != e.SUCCESS {
- e.ResponseWithMsg(c, addCap, addCap.GetMsg())
- return
- }
- e.ResponseSuccess(c, nil)
- }
- // GetApplyCapList 获取应用能力列表
- func GetApplyCapList(c *gin.Context) {
- appid := c.Query("appid")
- validate := validator.New()
- err := validate.Var(appid, "required")
- if err != nil {
- e.ResponseWithMsg(c, e.PleaseCheckTherRquiredFields, e.PleaseCheckTherRquiredFields.GetMsg())
- return
- }
- applycap, err := ApplyCap.ApplyCapList(appid)
- if err != nil {
- e.ResponseWithMsg(c, e.SUCCESS, err.Error())
- return
- }
- e.ResponseSuccess(c, applycap)
- }
- // UpDateApplyCap 更新应用能力
- func UpDateApplyCap(c *gin.Context) {
- var applyCap model.ApplyCap
- if err := c.ShouldBindJSON(&applyCap); err != nil {
- e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
- return
- }
- validate := validator.New()
- if err := validate.Struct(applyCap); err != nil {
- e.ResponseWithMsg(c, e.PleaseCheckTherRquiredFields, e.PleaseCheckTherRquiredFields.GetMsg())
- return
- }
- dateApplyCap := ApplyCap.UpDateApplyCap(applyCap)
- if dateApplyCap != e.SUCCESS {
- e.ResponseWithMsg(c, dateApplyCap, dateApplyCap.GetMsg())
- return
- }
- e.ResponseSuccess(c, nil)
- }
- // DeleteApplyCap 删除应用能力
- func DeleteApplyCap(c *gin.Context) {
- var applyCap model.ApplyCapabilities
- if err := c.ShouldBindJSON(&applyCap); err != nil {
- e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
- return
- }
- validate := validator.New()
- if err := validate.Struct(applyCap); err != nil {
- e.ResponseWithMsg(c, e.PleaseCheckTherRquiredFields, e.PleaseCheckTherRquiredFields.GetMsg())
- return
- }
- dateApplyCap := ApplyCap.DeleteApplyCAp(applyCap)
- if dateApplyCap != e.SUCCESS {
- e.ResponseWithMsg(c, dateApplyCap, dateApplyCap.GetMsg())
- return
- }
- e.ResponseSuccess(c, nil)
- }
|