123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- package residual_analysis
- import (
- "encoding/json"
- "eta/eta_api/controllers"
- "eta/eta_api/models"
- "eta/eta_api/models/residual_analysis_model"
- "eta/eta_api/services/residual_analysis_service"
- )
- // ResidualAnalysisController 残差分析
- type ResidualAnalysisController struct {
- controllers.BaseAuthController
- }
- // ResidualAnalysisPreview
- // @Title 残差分析预览
- // @Description 残差分析预览
- // @Success 200 {object} residual_analysis_model.ResidualAnalysisResp
- // @router /residual/analysis/preview [post]
- func (this *ResidualAnalysisController) ResidualAnalysisPreview() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req residual_analysis_model.ResidualAnalysisReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.EdbInfoIdA == req.EdbInfoIdB {
- br.Msg = "自变量指标和因变量指标不能相同"
- br.ErrMsg = "自变量指标和因变量指标不能相同"
- return
- }
- resp, err := residual_analysis_service.ResidualAnalysisPreview(req)
- if err != nil {
- br.Ret = 403
- br.Msg = "获取失败"
- br.ErrMsg = err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // ContrastPreview
- // @Title 对比指标预览
- // @Description 对比指标预览
- // @Success 200 {object} residual_analysis_model.ResidualAnalysisChartEdbInfoMapping
- // @router /contrast/preview [get]
- func (this *ResidualAnalysisController) ContrastPreview() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- IndexCode := this.GetString("IndexCode")
- if IndexCode == "" {
- br.Ret = 403
- br.Msg = "IndexCode不能为空"
- br.ErrMsg = "IndexCode不能为空"
- return
- }
- resp, err := residual_analysis_service.ContrastPreview(IndexCode)
- if err != nil {
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // SaveResidualAnalysis
- // @Title 保存残差分析指标
- // @Description 保存残差分析指标
- // @Success 200
- // @router /save/residual/analysis [post]
- func (this *ResidualAnalysisController) SaveResidualAnalysis() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req residual_analysis_model.ResidualAnalysisIndexSaveReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ClassifyId == 0 {
- br.Msg = "分类id不能为空"
- br.ErrMsg = "分类id不能为空"
- return
- }
- if req.Source == 0 {
- br.Msg = "来源不能为空"
- br.ErrMsg = "来源不能为空"
- return
- }
- err = residual_analysis_service.SaveResidualAnalysis(req, sysUser)
- if err != nil {
- br.Ret = 403
- br.Msg = err.Error()
- br.ErrMsg = err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "添加成功"
- }
- // SaveResidualAnalysisConfig
- // @Title 保存残差指标配置
- // @Description 保存残差指标配置
- // @Success 200
- // @router /save/residual/analysis/config [post]
- func (this *ResidualAnalysisController) SaveResidualAnalysisConfig() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req residual_analysis_model.ResidualAnalysisReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- configId, err := residual_analysis_service.SaveResidualAnalysisConfig(req, sysUser)
- if err != nil {
- br.Ret = 403
- br.Msg = "保存失败"
- br.ErrMsg = err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "添加成功"
- br.Data = configId
- }
- // ResidualAnalysisDetail
- // @Title 残差分析指标详情
- // @Description 残差分析指标详情
- // @Success 200 {object} []*data_manage.EdbInfoList
- // @router /residual/analysis/detail [get]
- func (this *ResidualAnalysisController) ResidualAnalysisDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- EdbInfoId, err := this.GetInt("EdbInfoId")
- if err != nil {
- br.Msg = "EdbInfoId参数异常!"
- br.ErrMsg = "EdbInfoId参数解析失败,Err:" + err.Error()
- }
- if EdbInfoId <= 0 {
- br.Msg = "EdbInfoId参数异常!"
- br.ErrMsg = "EdbInfoId参数异常!"
- }
- resp, err := residual_analysis_service.ResidualAnalysisDetail(EdbInfoId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = err.Error()
- br.Ret = 403
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // CheckResidualAnalysisExist
- // @Title 校验残差指标是否存在
- // @Description 校验残差指标是否存在
- // @Success 200 {object}
- // @router /check/residual/analysis/exist [get]
- func (this *ResidualAnalysisController) CheckResidualAnalysisExist() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- configId, err := this.GetInt("ConfigId")
- if err != nil {
- br.Msg = "EdbInfoId参数异常!"
- br.ErrMsg = "EdbInfoId参数解析失败,Err:" + err.Error()
- }
- if configId <= 0 {
- br.Msg = "ConfigId参数异常!"
- br.ErrMsg = "ConfigId参数异常!"
- }
- resp, err := residual_analysis_service.CheckResidualAnalysisExist(configId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = err.Error()
- br.Ret = 403
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|