<#ibiztemplate>
TARGET=PSAPPDATAENTITY
</#ibiztemplate>

package ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.rest;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.domain.${de.codeName};
import org.springframework.beans.factory.annotation.Autowired;
import ${pub.getPKGCodeName()}.${de.getPSSystemModule().codeName?lower_case}.service.${de.codeName}Service;

@RestController
public class ${de.codeName}Controller{

<#assign appReqUrl="/" +app.getPKGCodeName()?lower_case + "/"+de.getPSSystemModule().codeName?lower_case +"/"+de.codeName?lower_case ><#comment>当前实体请求路径</#comment>
<#comment>注入当前实体的服务对象</#comment>
    @Autowired
    private ${de.codeName}Service ${de.codeName?lower_case}Service;

<#list item.getPSControls() as ctrl><#comment>输出实体所使用到的部件（实体用到的部件可能有：表格、表单、树视图等）</#comment>
    <#if ctrl.getControlType() == 'FORM'><#comment>本示例中只展示表单</#comment>
        <#list ctrl.getPSAjaxControlHandler().getPSAjaxHandlerActions() as action><#comment>输出表单行为：(新建、编辑、删除等)</#comment>
        <#if action.getPSDEAction??  && action.getPSDEAction()??>
            <#assign ctrltype=ctrl.getControlType()>
    @PostMapping(value="${appReqUrl}/${ctrl.getCodeName()?lower_case}${srfclassname(ctrltype)?lower_case}/${action.getPSDEAction().getCodeName()?lower_case}")
    public ${de.codeName}  ${srfmethodname(ctrl.getCodeName())}${srfclassname(ctrltype)}${action.getPSDEAction().getCodeName()}(${de.codeName} entity){
        this.${de.codeName?lower_case}Service.${srfmethodname(action.getPSDEAction().getCodeName())}(entity);
            return entity;
    }
        </#if>
        </#list>
    </#if>
</#list>
}

