131 lines
4.8 KiB
Java
131 lines
4.8 KiB
Java
package com.gunshi.project.xyt.controller;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.gunshi.core.annotation.Get;
|
|
import com.gunshi.core.annotation.Post;
|
|
import com.gunshi.core.result.R;
|
|
import com.gunshi.project.xyt.entity.so.RescueTeamPageSo;
|
|
import com.gunshi.project.xyt.entity.vo.RescueTeamVo;
|
|
import com.gunshi.project.xyt.model.RescueTeamB;
|
|
import com.gunshi.project.xyt.model.RescueTeamBAutoMapper;
|
|
import com.gunshi.project.xyt.model.RescueTeamFile;
|
|
import com.gunshi.project.xyt.model.RescueTeamFileAutoDao;
|
|
import com.gunshi.project.xyt.service.AbstractModelWithAttachService;
|
|
import com.gunshi.project.xyt.service.RescueTeamService;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Description:
|
|
* Created by wanyan on 2024/3/18
|
|
*
|
|
* @author wanyan
|
|
* @version 1.0
|
|
*/
|
|
@Tag(name = "抢险队伍")
|
|
@RestController
|
|
@RequestMapping("/rescue/team")
|
|
public class RescueTeamBController extends AbstractCommonFileController implements
|
|
ICommonInsertWithAttach<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>,
|
|
ICommonUpdateByIdWithAttach<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>,
|
|
ICommonDeleteByIdWithAttach<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>,
|
|
ICommonQueryAttach<RescueTeamFile, Long, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>
|
|
{
|
|
|
|
@Autowired
|
|
private RescueTeamBAutoMapper rescueTeamBAutoMapper;
|
|
|
|
@Autowired
|
|
private RescueTeamFileAutoDao attachAutoDao;
|
|
|
|
@Autowired
|
|
private RescueTeamService rescueTeamService;
|
|
|
|
|
|
@Override
|
|
public Long getId(Serializable id) {
|
|
return Long.valueOf(id.toString());
|
|
}
|
|
|
|
@Override
|
|
public void customSetFieldForUpdate(RescueTeamB model) {
|
|
model.setTm(new Date());
|
|
rescueTeamService.updateDetailAndObj(model);
|
|
}
|
|
|
|
@Override
|
|
public AbstractModelWithAttachService<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao> getModelService() {
|
|
return rescueTeamService;
|
|
}
|
|
|
|
@Override
|
|
public void customSetFieldForInsert(RescueTeamB model) {
|
|
long teamId = IdWorker.getId();
|
|
model.setTeamId(teamId);
|
|
model.setTm(new Date());
|
|
rescueTeamService.saveDetailAndObj(model,teamId);
|
|
}
|
|
|
|
@Override
|
|
public String getGroupId() {
|
|
return "rescueTeamB";
|
|
}
|
|
|
|
|
|
/**
|
|
* 防汛准备-分页查询
|
|
*/
|
|
@Post(path = "/page/query", summary = "防汛准备-分页查询")
|
|
public R<Page<RescueTeamVo>> pageQuery(@RequestBody @Validated RescueTeamPageSo RescueTeamPageSo) {
|
|
return R.ok(rescueTeamService.pageQuery(RescueTeamPageSo));
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 列表查询
|
|
*/
|
|
@Get(path = "/list", summary = "列表查询")
|
|
public R<List<RescueTeamB>> list(@Schema(name = "teamName",description = "队伍名称") @RequestParam(name = "teamName",required = false) String teamName) {
|
|
LambdaQueryWrapper<RescueTeamB> queryWrapper = Wrappers.lambdaQuery();
|
|
if(StringUtils.isNotEmpty(teamName)){
|
|
queryWrapper.like(RescueTeamB::getTeamName,teamName);
|
|
}
|
|
return R.ok(rescueTeamBAutoMapper.selectList(queryWrapper));
|
|
}
|
|
|
|
/**
|
|
* 详情
|
|
*/
|
|
@Get(path = "/detail", summary = "详情")
|
|
public R<RescueTeamB> detail(@Schema(name = "teamId",description = "队伍ID") @RequestParam(name = "teamId") Long teamId) {
|
|
return R.ok(rescueTeamService.detail(teamId));
|
|
}
|
|
|
|
@Get(path ="/delete/{id}", summary = "删除")
|
|
public R<Boolean> delete(@Schema(name = "teamId") @PathVariable("teamId") Long teamId) {
|
|
return R.ok(rescueTeamService.delete(teamId));
|
|
}
|
|
|
|
@Override
|
|
public RescueTeamFileAutoDao getAttachAutoDao() {
|
|
return attachAutoDao;
|
|
}
|
|
|
|
@Override
|
|
public String getAttachBzIdName() {
|
|
return "team_id";
|
|
}
|
|
}
|