| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 | package controllerimport (	"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)}// UpDateApplyCapSort 拖拽排序func UpDateApplyCapSort(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.UpdateApplyCapSort(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)}// GetCapDetailByCapID 根据capID获取应用能力详情func GetCapDetailByCapID(c *gin.Context) {	capid := c.Query("capid")	validate := validator.New()	err := validate.Var(capid, "required")	if err != nil {		e.ResponseWithMsg(c, e.PleaseCheckTherRquiredFields, e.PleaseCheckTherRquiredFields.GetMsg())		return	}	id, rescode := Capabilities.GetCapabilitiesById(capid)	if rescode != e.SUCCESS {		e.ResponseWithMsg(c, rescode, rescode.GetMsg())		return	}	e.ResponseSuccess(c, id)}
 |