/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright team,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* team, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.springblade.modules.team.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
import com.github.xiaoymin.knife4j.annotations.ApiSort;
|
import io.swagger.annotations.*;
|
import lombok.AllArgsConstructor;
|
import org.apache.poi.ss.formula.functions.T;
|
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springblade.core.launch.constant.AppConstant;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tenant.annotation.TenantDS;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.utils.Func;
|
import org.springblade.modules.jurisdiction.service.JurisdictionService;
|
import org.springblade.modules.jurisdiction.vo.JurisdictionVO;
|
import org.springblade.modules.team.entity.Team;
|
import org.springblade.modules.team.service.ITeamService;
|
import org.springblade.modules.team.vo.TeamVO;
|
import org.springblade.modules.team.wrapper.TeamWrapper;
|
import org.springframework.web.bind.annotation.*;
|
import springfox.documentation.annotations.ApiIgnore;
|
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 控制器
|
*
|
* @author Chill
|
*/
|
@TenantDS
|
@RestController
|
@RequestMapping("/team")
|
@AllArgsConstructor
|
@ApiSort(2)
|
@Api(value = "队伍管理", tags = "队伍管理接口")
|
public class TeamController extends BladeController {
|
|
private final ITeamService teamService;
|
private final JurisdictionService jurisdictionService;
|
|
/**
|
* 详情
|
*/
|
@GetMapping("/detail")
|
@ApiOperationSupport(order = 1)
|
@ApiOperation(value = "详情", notes = "传入team")
|
public R<TeamVO> detail(Team team) {
|
Team detail = teamService.getOne(Condition.getQueryWrapper(team));
|
return R.data(TeamWrapper.build().entityVO(detail));
|
}
|
|
/**
|
* 分页
|
*/
|
@GetMapping("/list")
|
@ApiOperationSupport(order = 2)
|
@ApiOperation(value = "分页", notes = "传入team")
|
public R<IPage<TeamVO>> list(@ApiIgnore @RequestParam Map<String, Object> team, Query query) {
|
IPage<Team> pages = teamService.page(Condition.getPage(query), Condition.getQueryWrapper(team, Team.class));
|
return R.data(TeamWrapper.build().pageVO(pages));
|
}
|
|
/**
|
* 多表联合查询自定义分页
|
*/
|
@GetMapping("/page")
|
@ApiOperationSupport(order = 3)
|
@ApiOperation(value = "分页", notes = "传入team")
|
public R<IPage<TeamVO>> page(@ApiIgnore TeamVO team, Query query) {
|
IPage<TeamVO> pages = teamService.selectTeamPage(Condition.getPage(query), team);
|
return R.data(pages);
|
}
|
|
/**
|
* 新增
|
*/
|
@PostMapping("/save")
|
@ApiOperationSupport(order = 4)
|
@ApiOperation(value = "新增", notes = "传入team")
|
public R save(@RequestBody Team team) {
|
return R.status(teamService.save(team));
|
}
|
|
/**
|
* 修改
|
*/
|
@PostMapping("/update")
|
@ApiOperationSupport(order = 5)
|
@ApiOperation(value = "修改", notes = "传入team")
|
public R update(@RequestBody Team team) {
|
return R.status(teamService.updateById(team));
|
}
|
|
/**
|
* 新增或修改
|
*/
|
@PostMapping("/submit")
|
@ApiOperationSupport(order = 6)
|
@ApiOperation(value = "新增或修改", notes = "传入team")
|
public R submit(@RequestBody Team team) {
|
return R.status(teamService.saveOrUpdate(team));
|
}
|
|
/**
|
* 删除
|
*/
|
@PostMapping("/remove")
|
@ApiOperationSupport(order = 7)
|
@ApiOperation(value = "逻辑删除", notes = "传入team")
|
public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
|
boolean temp = teamService.removeByIds(Func.toLongList(ids));
|
return R.status(temp);
|
}
|
|
/**
|
* 生成默认队伍
|
*/
|
@GetMapping("/addTeam")
|
@ApiOperationSupport(order = 3)
|
@ApiOperation(value = "分页", notes = "传入team")
|
public R<IPage<TeamVO>> addTeam() {
|
List<Map> list = jurisdictionService.listJur();
|
for (int i = 0; i < list.size(); i++) {
|
String name = list.get(i).get("title").toString().split("派出所")[0];
|
Team team = new Team();
|
team.setIsBrand("0");
|
team.setIsDeleted(0);
|
team.setName(name + "义警队");
|
team.setNumber(20);
|
team.setPolice(list.get(i).get("id").toString());
|
teamService.saveOrUpdate(team);
|
}
|
return R.data(null);
|
}
|
|
}
|