123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package ${package.Controller};
- #foreach($field in ${table.fields})
- #if(${field.name.equals("name")})
- #set($hasName=true)
- #end
- #end
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- #if(${restControllerStyle})
- import org.springframework.web.bind.annotation.RestController;
- #else
- import org.springframework.stereotype.Controller;
- #end
- #if(${superControllerClassPackage})
- import ${superControllerClassPackage};
- #end
- import ${package.Service}.${table.serviceName};
- import ${package.Entity}.${table.entityName};
- import ${cfg.resp};
- import org.springframework.web.bind.annotation.*;
- #if(${hasName})
- import ${cfg.pullDownModel};
- #end
- import ${cfg.basePkg}.utils.ConvertUtil;
- import ${cfg.basePkg}.utils.HttpKit;
- import ${cfg.basePkg}.exception.ErrorCode;
- import java.util.Date;
- import java.util.List;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import org.springframework.http.MediaType;
- import org.springframework.web.multipart.MultipartFile;
- /**
- * $!{table.comment}
- *
- * @author ${author}
- * @since ${date}
- */
- #if(${restControllerStyle})
- @RestController
- #else
- @Controller
- #end
- ##@RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
- @RequestMapping("${table.entityPath}")
- @Slf4j
- #if(${kotlin})
- class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
- #else
- #if(${superControllerClass})
- public class ${table.controllerName} extends ${superControllerClass} {
- #else
- public class ${table.controllerName} {
- #end
- @Autowired
- private ${table.serviceName} ${table.entityPath}Service;
- /**
- * $!{table.comment}列表
- */
- @GetMapping("")
- public RestResponse<Page<${table.entityName}>> page(${table.entityName} ${table.entityPath}, Page page){
- Page<${table.entityName}> pages=${table.entityPath}Service.selectPage(page,${table.entityPath});
- return RestResponse.data(pages);
- }
- /**
- * $!{table.comment}详情
- */
- @GetMapping("/{id}")
- public RestResponse<${table.entityName}> detail(@PathVariable Long id){
- ${table.entityName} x${table.entityName} =${table.entityPath}Service.detail(id);
- return RestResponse.data(x${table.entityName});
- }
- /**
- * $!{table.comment}新增
- */
- @PostMapping("")
- public RestResponse<Boolean> save(@RequestBody ${table.entityName} ${table.entityPath}) {
- Boolean ret = ${table.entityPath}Service.add(${table.entityPath});
- return RestResponse.data(ret);
- }
- /**
- * $!{table.comment}更新
- */
- @PutMapping("")
- public RestResponse<Boolean> update(@RequestBody ${table.entityName} ${table.entityPath}) {
- Boolean ret = ${table.entityPath}Service.update(${table.entityPath});
- return RestResponse.data(ret);
- }
- /**
- * $!{table.comment}删除
- */
- @DeleteMapping("/{id}")
- public RestResponse<Boolean> delete(@PathVariable Long id) {
- Boolean ret = ${table.entityPath}Service.delete(id);
- return RestResponse.data(ret);
- }
- #if(${hasName})
- /**
- * $!{table.comment}下拉列表
- */
- @GetMapping("/simpleAll")
- public RestResponse<List<PullDownModel>> simpleAll(){
- LambdaQueryWrapper<${table.entityName}> lambdaQueryWrapper = new LambdaQueryWrapper<${table.entityName}>()
- .select(${table.entityName}::getId,${table.entityName}::getName)
- .eq(${table.entityName}::getDeleted,false);
- List<${table.entityName}> list= ${table.entityPath}Service.list(lambdaQueryWrapper);
- List<PullDownModel> ret=ConvertUtil.copyList(list, PullDownModel.class);
- return RestResponse.data(ret);
- }
- #end
- }
- #end
|