From 42894b64e8c02bd0649f3ca720d6ee7e4b7795d3 Mon Sep 17 00:00:00 2001 From: liaoxuwei <5789413@qq.com> Date: Tue, 29 Aug 2023 15:38:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=B8=B8=E7=94=A8=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E6=94=B6=E8=97=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/web/UserModelCollectController.java | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/portal-manager/src/main/java/com/mortals/xhx/module/user/web/UserModelCollectController.java b/portal-manager/src/main/java/com/mortals/xhx/module/user/web/UserModelCollectController.java index 052cc538..faa2523e 100644 --- a/portal-manager/src/main/java/com/mortals/xhx/module/user/web/UserModelCollectController.java +++ b/portal-manager/src/main/java/com/mortals/xhx/module/user/web/UserModelCollectController.java @@ -1,24 +1,32 @@ package com.mortals.xhx.module.user.web; + +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.mortals.framework.annotation.RepeatSubmit; +import com.mortals.framework.exception.AppException; import com.mortals.framework.model.Context; import com.mortals.framework.service.IUser; +import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.StringUtils; import com.mortals.framework.utils.BeanUtil; import com.mortals.framework.utils.ReflectUtils; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; +import com.mortals.xhx.common.code.YesNoEnum; +import com.mortals.xhx.common.pdu.ModelPdu; +import com.mortals.xhx.feign.model.IApiModelFeign; +import com.mortals.xhx.feign.rsp.ApiResp; import com.mortals.xhx.module.user.model.UserModelCollectEntity; import com.mortals.xhx.module.user.service.UserModelCollectService; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; + /** * * 鐢ㄦ埛妯″潡鏀惰棌 @@ -30,6 +38,9 @@ import java.util.Map; @RequestMapping("user/model/collect") public class UserModelCollectController extends BaseCRUDJsonBodyMappingController<UserModelCollectService,UserModelCollectEntity,Long> { + @Autowired + private IApiModelFeign apiModelFeign; + public UserModelCollectController(){ super.setModuleDesc( "鐢ㄦ埛妯″潡鏀惰棌"); } @@ -46,7 +57,7 @@ public class UserModelCollectController extends BaseCRUDJsonBodyMappingControlle JSONObject ret = new JSONObject(); String busiDesc = "鏌ョ湅" + this.getModuleDesc(); Context context = this.getContext(); - + model.put("data", Collections.emptyList()); try { UserModelCollectEntity query = new UserModelCollectEntity(); query.setUserId(this.getCurUser().getId()); @@ -56,10 +67,24 @@ public class UserModelCollectController extends BaseCRUDJsonBodyMappingControlle entity.setUserId(this.getCurUser().getId()); entity.setRealName(this.getCurUser().getRealName()); entity.setModelIds(""); + }else { + if(StringUtils.isNotEmpty(entity.getModelIds())){ + List<Long> idList = new ArrayList(); + for(String id:entity.getModelIds().split(",")){ + Long idL = DataUtil.converStr2Long(id,0l); + idList.add(idL); + } + ModelPdu pdu = new ModelPdu(); + pdu.setIdList(idList); + String resp = apiModelFeign.getModelByQuery(pdu); + ApiResp<JSONObject> apiResp = JSON.parseObject(resp, ApiResp.class); + if (apiResp.getCode() != YesNoEnum.YES.getValue()) { + throw new AppException("鑾峰彇绔欑偣鍒楄〃淇℃伅澶辫触锛�" + apiResp.getMsg()); + } + model.put("data", apiResp.getData().get("data")); + } } - - model.putAll(model); - model.put("entity", entity); + model.put("message_info", busiDesc + "鎴愬姛"); if (!ObjectUtils.isEmpty(context) && !ObjectUtils.isEmpty(context.getUser())) { this.recordSysLog(this.request, busiDesc + " 銆愭垚鍔熴€�"); } @@ -68,9 +93,7 @@ public class UserModelCollectController extends BaseCRUDJsonBodyMappingControlle Object msg = model.get("message_info"); return this.createFailJsonResp(msg == null ? "绯荤粺寮傚父" : msg.toString()); } - - this.init(model, context); - ret.put("data", model); + ret.put("data", model.get("data")); ret.put("code", 1); ret.put("msg", model.remove("message_info")); return ret.toJSONString(); -- 2.24.3