package ${package.Controller}; 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.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import com.hotent.base.model.CommonResult; import com.hotent.base.util.StringUtil; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; <#if restControllerStyle> import org.springframework.web.bind.annotation.RestController; <#else> import org.springframework.stereotype.Controller; <#if superControllerClassPackage??> import ${superControllerClassPackage}; import ${package.Entity}.${entity}; import ${package.Service}.${table.serviceName}; /** * ${table.comment!} 前端控制器 * <#if cfg.companyName??> * @company ${cfg.companyName} * @author ${author} <#if cfg.authorEmail??> * @email ${cfg.authorEmail} * @since ${date} */ <#if restControllerStyle> @RestController <#else> @Controller @RequestMapping("<#if package.ModuleName??>/${package.ModuleName}/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}/v1/") <#if kotlin> class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}() <#else> <#if superControllerClass??> public class ${table.controllerName} extends ${superControllerClass}<${table.serviceName}, ${entity}> { <#else> public class ${table.controllerName} { <#if cfg.type != "querySqldef"> /** * 根据id获取${table.comment!}数据详情 * @param id * @return * @throws Exception * ModelAndView */ @GetMapping(value="/getDetail") @ApiOperation(value="根据id获取${table.comment!}数据详情",httpMethod = "GET",notes = "根据id获取${table.comment!}数据详情") public CommonResult<${entity}> getDetail(@ApiParam(name="id",value="业务对象主键", required = true)@RequestParam(required=true) String id) throws Exception{ return CommonResult.<${entity}>ok().value(baseService.getDetail(id)); } /** * 新增,更新${table.comment!} * @param ${entity?uncap_first} * @throws Exception * @return * @exception */ @PostMapping(value="/save") @ApiOperation(value = "新增,更新${table.comment!}数据", httpMethod = "POST", notes = "新增,更新${table.comment!}数据") public CommonResult save(@ApiParam(name="${entity}",value="${table.comment!}对象", required = true)@RequestBody ${entity} ${entity?uncap_first}) throws Exception{ String msg = StringUtil.isEmpty(${entity?uncap_first}.getId()) ? "添加${table.comment!}成功" : "更新${table.comment!}成功"; baseService.createOrUpdate(${entity?uncap_first}); return CommonResult.ok().message(msg); } }