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.
107 lines
3.7 KiB
107 lines
3.7 KiB
package {{ package.Controller }};
|
|
import {{ package.Entity }}.{{ table.entity }};
|
|
import {{ package.Service }}.{{ table.entity }}Service;
|
|
import {{ package.Common }}.vo.Result;
|
|
|
|
//--- import 固定引入 ---//
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import java.util.List;
|
|
//--- import 固定引入 ---//
|
|
|
|
/**
|
|
* <p>
|
|
* {{ table.comment }} 前端控制器
|
|
* </p>
|
|
* @Author: {{author}}
|
|
* @Date: {{date}}
|
|
* @Wechat: {{ wechat }}
|
|
*/
|
|
@Api(tags = "{{ table.comment }}")
|
|
{% if restControllerStyle %}
|
|
@RestController
|
|
{% else %}
|
|
@Controller
|
|
{% endif %}
|
|
@RequestMapping("{{ table.name }}")
|
|
public class {{ table.entity }}Controller {
|
|
|
|
@Resource
|
|
private {{ table.entity }}Service {{table.lowerEntity}}Service;
|
|
|
|
@ApiOperation(value = "{{ table.comment }}分页列表查询", response = {{ table.entity }}.class)
|
|
@PostMapping(value = "/page")
|
|
public Result<Page<{{ table.entity }}>> page(@Valid @RequestBody {{ table.entity }} param,@RequestHeader("token") String token,
|
|
@RequestHeader(value = "version", defaultValue = "1.0") String version) {
|
|
Page<{{ table.entity }}> page = {{table.lowerEntity}}Service.page(param);
|
|
return Result.OK(page);
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "{{ table.comment }}根据条件查询")
|
|
@PostMapping(value = "/info")
|
|
public Result<Object> info(@Valid @RequestBody {{ table.entity }} param,
|
|
@RequestHeader("token") String token,
|
|
@RequestHeader(value = "version", defaultValue = "1.0") String version) {
|
|
if (token ==null) {
|
|
return Result.error("token不能为空");
|
|
}
|
|
{{ table.entity }} data = {{table.lowerEntity}}Service.info(param);
|
|
return Result.OK(data);
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "{{ table.comment }}新增")
|
|
@PostMapping(value = "/add")
|
|
public Result add(@Valid @RequestBody {{ table.entity }} param,
|
|
@RequestHeader("token") String token,
|
|
@RequestHeader(value = "version", defaultValue = "1.0") String version) {
|
|
if (token ==null) {
|
|
return Result.error("token不能为空");
|
|
}
|
|
{{table.lowerEntity}}Service.add(param);
|
|
return Result.OK();
|
|
}
|
|
|
|
@ApiOperation(value = "{{ table.comment }}修改")
|
|
@PostMapping(value = "/modify")
|
|
public Result modify(@Valid @RequestBody {{ table.entity }} param,
|
|
@RequestHeader("token") String token,
|
|
@RequestHeader(value = "version", defaultValue = "1.0") String version) {
|
|
if (token ==null) {
|
|
return Result.error("token不能为空");
|
|
}
|
|
{{table.entity}} info = {{table.lowerEntity}}Service.info(Integer.valueOf(param.getId()));
|
|
if (info ==null) {
|
|
return Result.error(String.format("[%s]记录不存在", info));
|
|
}
|
|
{{table.lowerEntity}}Service.modify(param);
|
|
return Result.OK();
|
|
}
|
|
|
|
@ApiOperation(value = "{{ table.comment }}删除(单个条目)")
|
|
@GetMapping(value = "/remove/{id}")
|
|
public Result remove(@PathVariable Integer id,
|
|
@RequestHeader("token") String token,
|
|
@RequestHeader(value = "version", defaultValue = "1.0") String version) {
|
|
|
|
{{table.lowerEntity}}Service.remove(id);
|
|
return Result.OK();
|
|
}
|
|
|
|
@ApiOperation(value = "{{ table.comment }}删除(多个条目)")
|
|
@PostMapping(value = "/removes")
|
|
public Result removes(@Valid @RequestBody List<Integer> ids,
|
|
@RequestHeader("token") String token,
|
|
@RequestHeader(value = "version", defaultValue = "1.0") String version) {
|
|
{{table.lowerEntity}}Service.removes(ids);
|
|
return Result.OK();
|
|
}
|
|
|
|
|
|
}
|
|
|