{{#*inline 'getRequestPath' method appEntity}}
{{#if appEntity.appDERSPaths}}
    {{#each appEntity.appDERSPaths as | singlePaths |}}
if (!requestPath && {{#each singlePaths as | path |}}context['{{lowerCase path}}']{{#unless @last}} && {{/unless}}{{/each}}) {
 	requestPath = `/{{#each singlePaths as | path |}}{{lowerCase (pluralize path)}}/${encodeURIComponent(context['{{lowerCase path}}'])}/{{/each}}{{lowerCase (pluralize appEntity.codeName)}}{{~#if method.needResourceKey}}/${encodeURIComponent(context['{{lowerCase appEntity.codeName}}'])}{{/if~}}{{~#if method.requestPath}}{{method.requestPath}}{{/if~}}`;
}
    {{/each}}
if (!requestPath) {
    requestPath = `/{{lowerCase (pluralize appEntity.codeName)}}{{~#if method.needResourceKey}}/${encodeURIComponent(context['{{lowerCase appEntity.codeName}}'])}{{/if~}}{{~#if method.requestPath}}{{method.requestPath}}{{/if~}}`;
}
{{else}}
requestPath = `/{{lowerCase (pluralize appEntity.codeName)}}{{~#if method.needResourceKey}}/${encodeURIComponent(context['{{lowerCase appEntity.codeName}}'])}{{/if~}}{{~#if method.requestPath}}{{method.requestPath}}{{/if~}}`;
{{/if}}
{{/inline}}
/**
 * {{appMethod.codeName}}
 *
 * @param {IParam} [context={}]
 * @param {IParam | IParam[]} [data]
 * @returns {Promise<any>}
 * @memberof {{pascalCase appEntity.codeName}}ServiceBase
 */
public async {{appMethod.codeName}}(context: IContext = {}, data: IParam | IParam[]): Promise<any> {
	data = data ? data : {};
	let requestPath = '';
  	{{> getRequestPath method=appMethod appEntity=appEntity}}
{{#eq appMethod.methodType 'SELECT'}}
  	{{#or (eq appMethod.requestMethod 'POST') (eq appMethod.requestMethod 'PUT')}}
  	{{> @macro/entity/handle-input.hbs appMethod=appMethod}}
  	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
  	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
  	{{else}}
  	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath);
  	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
  	{{/or}}
  	return res;
{{else eq appMethod.methodType 'FETCH'}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
	return res;
{{else eq appMethod.methodType 'FETCHTEMP'}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
	return res;
{{else}}
	{{!-- 无参数 --}}
	{{#eq appMethod.requestParamType 'NONE'}}
		{{#neq appMethod.codeName 'GetDraft'}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{else}}
	data['{{lowerCase appEntity.codeName}}'] = undefined;
		{{#if appEntity.keyPSAppDEField}}
	data['{{lowerCase appEntity.keyPSAppDEField.codeName}}'] = undefined;
		{{/if}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{/neq}}
	{{/eq}}
  	{{!-- 指定属性 --}}
	{{#eq appMethod.requestParamType 'FIELD'}}
		{{#eq appMethod.requestMethod 'GET'}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
	{{!-- 待补充后续行为 --}}
		{{else eq appMethod.requestMethod 'POST'}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{else eq appMethod.requestMethod 'DELETE'}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{else}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{/eq}}
	{{/eq}}
	{{!-- 数据对象 --}}
	{{#eq appMethod.requestParamType 'ENTITY'}}
		{{#eq appMethod.codeName 'Update'}}
		{{!-- 待补充前置行为 --}}
	{{> @macro/entity/handle-input.hbs appMethod=appMethod}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{else eq appMethod.codeName 'Create'}}
	{{!-- 待补充前置行为 --}}
	if (!data.srffrontuf || data.srffrontuf != 1) {
		{{#if appEntity.keyPSAppDEField}}
		data.{{lowerCase appEntity.keyPSAppDEField.codeName}} = null;
		{{/if}}
	}
	if (data.srffrontuf != null) {
		delete data.srffrontuf;
	}
	{{> @macro/entity/handle-input.hbs appMethod=appMethod}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{else}}
	{{> @macro/entity/handle-input.hbs appMethod=appMethod}}
	const res = await this.http.{{lowerCase appMethod.requestMethod}}(requestPath, data);
	{{> @macro/entity/handle-output.hbs appMethod=appMethod}}
		{{/eq}}
	{{/eq}}
  	return res;
{{/eq}}
}
