You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.3 KiB

package ${bussiPackage}.controller;
import com.enjoy.common.core.web.controller.BaseController;
import com.enjoy.common.core.web.domain.AjaxResult;
import com.enjoy.common.core.web.page.TableDataInfo;
import com.enjoy.common.log.annotation.Log;
import com.enjoy.common.log.enums.BusinessType;
import ${bussiPackage}.${entityPackage}.${entityName};
import ${bussiPackage}.dto.${entityName}DTO;
import ${bussiPackage}.vo.${entityName}VO;
import ${bussiPackage}.service.I${entityName}Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* @Description: ${tableVo.ftlDescription}
* @Author: ${author}
* @Date: ${.now?string["yyyy-MM-dd"]}
* @Version: V1.0
*/
@Slf4j
@Api(tags="${tableVo.ftlDescription}")
@RestController
@RequestMapping("/${entityName?uncap_first}")
public class ${entityName}Controller extends BaseController {
@Autowired
private I${entityName}Service ${entityName?uncap_first}Service;
/**
* 分页
*
* @param ${entityName?uncap_first}
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@ApiOperation(value="分页", notes="分页")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "分页参数:当前页", dataType = "String", paramType = "query"),
@ApiImplicitParam(name = "pageSize", value = "分页参数:每页数量", dataType = "String", paramType = "query")
})
@GetMapping(value = "/list")
public TableDataInfo queryPageList(${entityName} ${entityName?uncap_first},
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
startPage();
List<${entityName}> list = ${entityName?uncap_first}Service.list();
return getDataTable(list);
}
/**
* 全部
*/
@ApiOperation("全部")
@GetMapping("/listAll")
public AjaxResult listAll() {
return AjaxResult.success(${entityName?uncap_first}Service.list());
}
/**
* 详情
*/
@ApiOperation("详情")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
return AjaxResult.success(${entityName?uncap_first}Service.getById(id));
}
/**
* 新增
* @param ${entityName?uncap_first}
* @return
*/
@ApiOperation(value="新增", notes="新增")
@Log(title = "新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.save(${entityName?uncap_first});
return AjaxResult.success("新增成功");
}
/**
* 编辑
* @param ${entityName?uncap_first}
* @return
*/
@Log(title = "编辑", businessType = BusinessType.UPDATE)
@ApiOperation(value="编辑", notes="编辑")
@PutMapping
public AjaxResult edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
return AjaxResult.success("编辑成功!");
}
/**
* 删除
* @param id
* @return
*/
@Log(title = "删除", businessType = BusinessType.DELETE)
@ApiOperation(value="删除", notes="删除")
@DeleteMapping(value = "/delete")
public AjaxResult delete(@RequestParam(name="id",required=true) String id) {
${entityName?uncap_first}Service.removeById(id);
return AjaxResult.success("删除成功!");
}
/**
* 批量删除
* @param ids
* @return
*/
@Log(title = "批量删除", businessType = BusinessType.DELETE)
@ApiOperation(value="批量删除", notes="批量删除")
@DeleteMapping(value = "/deleteBatch")
public AjaxResult deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
return AjaxResult.success("批量删除成功!");
}
}