package ${package.Controller};

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.fastjson.JSON;
import ${package.Entity}.${entity};
import ${package.Mapper}.${entity}Mapper;
import org.json.JSONObject;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * <p>
    * ${table.comment!}
    * </p>
 *${entity}表数据处理
 * @author ${author}
 * @since ${date}
 */
@Component("${entity}bean")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {
    </#if>
 @Autowired
    ${entity}Mapper i${entity}Mapper;

   /**
    * 保存
    * @param object
    * @param response
    * @param request
    */
  public  void  saveMethod(JSONObject object, HttpServletResponse response, HttpServletRequest request){
    ${entity} entity = JSON.parseObject(object.getString("${entity}"), ${entity}.class);
        i${entity}Mapper.insert(entity);

  }

    /**
     * 单数据删除
     * @param object
     * @param response
     * @param request
     */
    public  void  delsingleMethod(JSONObject object, HttpServletResponse response,HttpServletRequest request){
        String dataid=request.getParameter("ID");
        i${entity}Mapper.deleteById(dataid);

    }

   /**
     * 单数据更新
     * @param object
     * @param response
     * @param request
     */
    public  void  updateMethod(JSONObject object, HttpServletResponse response,HttpServletRequest request){
        ${entity} entity = JSON.parseObject(object.getString("${entity}"), ${entity}.class);
        i${entity}Mapper.updateById(entity);

    }
}
</#if>
