WebRelatedRelationshipController.java 3.61 KB
package com.lhcredit.project.webbusiness.controller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;
import com.lhcredit.framework.web.page.TableDataInfo;
import com.lhcredit.project.business.TianYC.entity.param.RequestParams;
import com.lhcredit.project.business.frontUser.domain.FrontUserMon;
import com.lhcredit.project.business.relatedRelation.service.RelatedRelationShipService;
import com.lhcredit.project.business.searchLog.service.SearchLogServiceImpl;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

@Api(tags = "关联关系")
@RestController
@RequestMapping(("/api-V2.0/related"))
@RequiredArgsConstructor
public class WebRelatedRelationshipController extends BaseController {



    @Autowired
    private RelatedRelationShipService relatedRelationShipService;

    @Autowired
    private SearchLogServiceImpl searchLogService;


    /**
     * 企业关联关系查询
     * @param requestParams
     * @return
     */
    @PostMapping("/relationShipsByName")
    public AjaxResult getEnterpriseRelationShipsByName(@Validated @RequestBody RequestParams requestParams){

        if (StringUtils.isEmpty(requestParams.getName()) || StringUtils.isEmpty(requestParams.getId()))
            return AjaxResult.error("参数未传");
        //设置当前操作人姓名
        FrontUserMon loginUser=getUserInfo();
        requestParams.setHumanName(loginUser.getUserName());
//        requestParams.setHumanName("getUsername()");

        JSONObject ships = relatedRelationShipService.getEnterpriseRelationShipsByName(requestParams);
        if (ships == null){
            return AjaxResult.error("暂无数据");
        }
        TableDataInfo resData = new TableDataInfo();
        JSONArray data = ships.getJSONArray("data");
        resData.setRows(data);
//            Long total = ships.getLong("total");
//            resData.setTotal(total);
        return AjaxResult.success(resData);
    }


    /**
     * 查询 关联关系的链路列表
     * @param requestParams
     * @return
     */
    @PostMapping("/relationShipsLinkByName")
    public AjaxResult getRelationShipLinkList(@Validated @RequestBody RequestParams requestParams){

        if (StringUtils.isEmpty(requestParams.getName()) || StringUtils.isEmpty(requestParams.getId()))
            return AjaxResult.error("参数未传");

        JSONObject linkList = relatedRelationShipService.getRelationShipLinkListByName(requestParams);

        if (linkList == null){
            return AjaxResult.error(String.valueOf(2010),"暂无数据");
        }
        TableDataInfo resData = new TableDataInfo();
        JSONArray data = linkList.getJSONArray("data");
        resData.setRows(data);
        return AjaxResult.success(resData);
    }


    /**
     * 查询企业关联关系查询日志列表
     */
    /*@GetMapping("/list")
    public AjaxResult getEnterpriseRelatedRelationShipList(){

        //借助分页取前五条
        List<JSONObject> list = searchLogService.getSearchLogs(SearchLog.SearchType.RELATED_RELATIONSHIP.getKey(), getUsername());
        return AjaxResult.success(list);
    }*/




}