<commit_before>package com.java110.api.listener.junkRequirement;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.api.bmo.junkRequirement.IJunkRequirementBMO;
import com.java110.api.listener.AbstractServiceApiListener;
import com.java110.core.annotation.Java110Listener;
import com.java110.core.context.DataFlowContext;
import com.java110.entity.center.AppService;
import com.java110.event.service.api.ServiceDataFlowEvent;
import com.java110.utils.constant.CommonConstant;
import com.java110.utils.constant.ServiceCodeJunkRequirementConstant;
import com.java110.utils.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;


/**
 * 保存旧货市场侦听
 * add by wuxw 2019-06-30
 */
@Java110Listener("updateJunkRequirementListener")
public class UpdateJunkRequirementListener extends AbstractServiceApiListener {

    @Autowired
    private IJunkRequirementBMO junkRequirementBMOImpl;

    @Override
    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {

        Assert.hasKeyAndValue(reqJson, "junkRequirementId", "junkRequirementId不能为空");
        Assert.hasKeyAndValue(reqJson, "typeCd", "请求报文中未包含typeCd");
        Assert.hasKeyAndValue(reqJson, "classification", "请求报文中未包含classification");
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
        Assert.hasKeyAndValue(reqJson, "context", "请求报文中未包含context");
        Assert.hasKeyAndValue(reqJson, "referencePrice", "请求报文中未包含referencePrice");
        Assert.hasKeyAndValue(reqJson, "publishUserId", "请求报文中未包含publishUserId");
        Assert.hasKeyAndValue(reqJson, "publishUserName", "请求报文中未包含publishUserName");
        Assert.hasKeyAndValue(reqJson, "publishUserLink", "请求报文中未包含publishUserLink");

    }

    @Override
    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {

        HttpHeaders header = new HttpHeaders();
        context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
        JSONArray businesses = new JSONArray();

        AppService service = event.getAppService();

        //添加单元信息
        businesses.add(junkRequirementBMOImpl.updateJunkRequirement(reqJson, context));

        ResponseEntity<String> responseEntity = junkRequirementBMOImpl.callService(context, service.getServiceCode(), businesses);

        context.setResponseEntity(responseEntity);
    }

    @Override
    public String getServiceCode() {
        return ServiceCodeJunkRequirementConstant.UPDATE_JUNKREQUIREMENT;
    }

    @Override
    public HttpMethod getHttpMethod() {
        return HttpMethod.POST;
    }

    @Override
    public int getOrder() {<commit_msg>旧货市场只能 修改状态，其他额不允许修改<commit_after>package com.java110.api.listener.junkRequirement;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.api.bmo.junkRequirement.IJunkRequirementBMO;
import com.java110.api.listener.AbstractServiceApiListener;
import com.java110.core.annotation.Java110Listener;
import com.java110.core.context.DataFlowContext;
import com.java110.entity.center.AppService;
import com.java110.event.service.api.ServiceDataFlowEvent;
import com.java110.utils.constant.CommonConstant;
import com.java110.utils.constant.ServiceCodeJunkRequirementConstant;
import com.java110.utils.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;


/**
 * 保存旧货市场侦听
 * add by wuxw 2019-06-30
 */
@Java110Listener("updateJunkRequirementListener")
public class UpdateJunkRequirementListener extends AbstractServiceApiListener {

    @Autowired
    private IJunkRequirementBMO junkRequirementBMOImpl;

    @Override
    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {

        Assert.hasKeyAndValue(reqJson, "junkRequirementId", "junkRequirementId不能为空");
//        Assert.hasKeyAndValue(reqJson, "typeCd", "请求报文中未包含typeCd");
//        Assert.hasKeyAndValue(reqJson, "classification", "请求报文中未包含classification");
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
//        Assert.hasKeyAndValue(reqJson, "context", "请求报文中未包含context");
//        Assert.hasKeyAndValue(reqJson, "referencePrice", "请求报文中未包含referencePrice");
//        Assert.hasKeyAndValue(reqJson, "publishUserId", "请求报文中未包含publishUserId");
//        Assert.hasKeyAndValue(reqJson, "publishUserName", "请求报文中未包含publishUserName");
//        Assert.hasKeyAndValue(reqJson, "publishUserLink", "请求报文中未包含publishUserLink");
        Assert.hasKeyAndValue(reqJson, "state", "请求报文中未包含state");
    }

    @Override
    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {

        HttpHeaders header = new HttpHeaders();
        context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
        JSONArray businesses = new JSONArray();

        AppService service = event.getAppService();

        JSONObject paramObj = new JSONObject();
        paramObj.put("junkRequirementId",reqJson.getString("junkRequirementId"));
        paramObj.put("communityId",reqJson.getString("communityId"));
        paramObj.put("state",reqJson.getString("state"));

        //添加单元信息
        businesses.add(junkRequirementBMOImpl.updateJunkRequirement(paramObj, context));

        ResponseEntity<String> responseEntity = junkRequirementBMOImpl.callService(context, service.getServiceCode(), businesses);

        context.setResponseEntity(responseEntity);
    }

    @Override
    public String getServiceCode() {
        return ServiceCodeJunkRequirementConstant.UPDATE_JUNKREQUIREMENT;
    }

    @Override
    public HttpMethod getHttpMethod() {
        return HttpMethod.POST;
    }

    @Override
    public int getOrder() {
{'fraction_non_alphanumeric': 0.10003317850033179, 'fraction_numerical': 0.014598540145985401, 'mean_word_length': 4.96930693069307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3877802', 'n_tokens_mistral': 1908, 'n_tokens_neox': 1900, 'n_words': 267}