package com.sa.ibiz.demo.mob.controller.demo;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.sql.Timestamp;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.sa.ibiz.demo.ibizutil.domain.ActionResult;
import com.sa.ibiz.demo.demo.service.YCSQService;
import com.sa.ibiz.demo.ibizutil.domain.AutoCompleteItem;
import com.sa.ibiz.demo.demo.domain.YCSQ;
import com.sa.ibiz.demo.demo.service.dto.YCSQSearchFilter;
import com.sa.ibiz.demo.mob.controller.demo.vo.*;
import org.springframework.cglib.beans.BeanGenerator;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.util.StringUtils;
import java.io.IOException;
import com.sa.ibiz.demo.ibizutil.errors.BadRequestAlertException;
import org.springframework.validation.annotation.Validated;
import org.springframework.http.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import com.sa.ibiz.demo.ibizutil.domain.RedirectResult;
import javax.validation.constraints.NotBlank;
import com.sa.ibiz.demo.ibizutil.domain.AutoCompleteItem;
import java.math.BigInteger;
import com.alibaba.fastjson.JSONObject;

@RestController
@RequestMapping("/mob/demo/ycsq")
public class YCSQController{



    @Autowired
	private YCSQService ycsqService;
	/**
	 * 获取服务对象
	*/
	protected YCSQService getService(){
		return this.ycsqService;
	}



	@PostMapping(value="mobform10editform/update")
	public ResponseEntity<YCSQ_EditForm_MobForm10> mobForm10EditFormUpdate(@Validated @RequestBody YCSQ_EditForm_MobForm10 form){
            YCSQ entity =form.toYCSQ();
            getService().update(entity);
            form.fromYCSQ(entity);
            form.setSrfuf("1");
            return ResponseEntity.ok().body(form);
	}
	@GetMapping(value="mobform10editform/remove")
	public ResponseEntity<YCSQ_EditForm_MobForm10> mobForm10EditFormRemove(@Validated @NotBlank(message = "srfkey不允许为空") @RequestParam("srfkey")String srfkey){
            YCSQ_EditForm_MobForm10 form=new YCSQ_EditForm_MobForm10();
            YCSQ entity = new YCSQ();
            entity.setYcsqid(srfkey);
            getService().remove(entity);
            form.setSrfuf("0");
            form.fromYCSQ(entity);
            return ResponseEntity.ok().body(form);
	}
	@PostMapping(value="mobform10editform/getdraft")
	public ResponseEntity<YCSQ_EditForm_MobForm10> mobForm10EditFormGetDraft(@RequestBody YCSQ_EditForm_MobForm10 form){
        if(!StringUtils.isEmpty(form.getSrfsourcekey()))
        {
            YCSQ sourceEntity =new YCSQ();
            sourceEntity.setYcsqid(form.getSrfsourcekey());
            this.getService().get(sourceEntity);

			YCSQ targetEntity =new YCSQ();
			sourceEntity.copyTo(targetEntity);
			form.fromYCSQ(targetEntity,false);
            form.setSrfuf("0");
            return ResponseEntity.ok().body(form);
         }
            YCSQ entity =form.toYCSQ();
            getService().getDraft(entity);
            form.fromYCSQ(entity);
            form.setSrfuf("0");
            return ResponseEntity.ok().body(form);
	}
	@GetMapping(value="mobform10editform/get")
	public ResponseEntity<YCSQ_EditForm_MobForm10> mobForm10EditFormGet(@Validated @NotBlank(message = "srfkey不允许为空") @RequestParam("srfkey")String srfkey){
            YCSQ_EditForm_MobForm10 form=new YCSQ_EditForm_MobForm10();
            YCSQ entity = new YCSQ();
            entity.setYcsqid(srfkey);
            entity=getService().get(entity);
            form.setSrfuf("1");
            form.fromYCSQ(entity);
            return ResponseEntity.ok().body(form);
	}
	@PostMapping(value="mobform10editform/create")
	public ResponseEntity<YCSQ_EditForm_MobForm10> mobForm10EditFormCreate(@Validated @RequestBody YCSQ_EditForm_MobForm10 form){
            YCSQ entity =form.toYCSQ();
            getService().create(entity);
            form.fromYCSQ(entity);
            form.setSrfuf("1");
            return ResponseEntity.ok().body(form);
	}



	@PostMapping(value="mobform20editform/update")
	public ResponseEntity<YCSQ_EditForm_MobForm20> mobForm20EditFormUpdate(@Validated @RequestBody YCSQ_EditForm_MobForm20 form){
            YCSQ entity =form.toYCSQ();
            getService().update(entity);
            form.fromYCSQ(entity);
            form.setSrfuf("1");
            return ResponseEntity.ok().body(form);
	}
	@GetMapping(value="mobform20editform/remove")
	public ResponseEntity<YCSQ_EditForm_MobForm20> mobForm20EditFormRemove(@Validated @NotBlank(message = "srfkey不允许为空") @RequestParam("srfkey")String srfkey){
            YCSQ_EditForm_MobForm20 form=new YCSQ_EditForm_MobForm20();
            YCSQ entity = new YCSQ();
            entity.setYcsqid(srfkey);
            getService().remove(entity);
            form.setSrfuf("0");
            form.fromYCSQ(entity);
            return ResponseEntity.ok().body(form);
	}
	@PostMapping(value="mobform20editform/getdraft")
	public ResponseEntity<YCSQ_EditForm_MobForm20> mobForm20EditFormGetDraft(@RequestBody YCSQ_EditForm_MobForm20 form){
        if(!StringUtils.isEmpty(form.getSrfsourcekey()))
        {
            YCSQ sourceEntity =new YCSQ();
            sourceEntity.setYcsqid(form.getSrfsourcekey());
            this.getService().get(sourceEntity);

			YCSQ targetEntity =new YCSQ();
			sourceEntity.copyTo(targetEntity);
			form.fromYCSQ(targetEntity,false);
            form.setSrfuf("0");
            return ResponseEntity.ok().body(form);
         }
            YCSQ entity =form.toYCSQ();
            getService().getDraft(entity);
            form.fromYCSQ(entity);
            form.setSrfuf("0");
            return ResponseEntity.ok().body(form);
	}
	@GetMapping(value="mobform20editform/get")
	public ResponseEntity<YCSQ_EditForm_MobForm20> mobForm20EditFormGet(@Validated @NotBlank(message = "srfkey不允许为空") @RequestParam("srfkey")String srfkey){
            YCSQ_EditForm_MobForm20 form=new YCSQ_EditForm_MobForm20();
            YCSQ entity = new YCSQ();
            entity.setYcsqid(srfkey);
            entity=getService().get(entity);
            form.setSrfuf("1");
            form.fromYCSQ(entity);
            return ResponseEntity.ok().body(form);
	}
	@PostMapping(value="mobform20editform/create")
	public ResponseEntity<YCSQ_EditForm_MobForm20> mobForm20EditFormCreate(@Validated @RequestBody YCSQ_EditForm_MobForm20 form){
            YCSQ entity =form.toYCSQ();
            getService().create(entity);
            form.fromYCSQ(entity);
            form.setSrfuf("1");
            return ResponseEntity.ok().body(form);
	}
 }