package com.stylefeng.guns.modular.system.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.modular.system.model.TCountryVo;
|
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.stylefeng.guns.modular.system.model.TCountry;
|
import com.stylefeng.guns.modular.system.service.ITCountryService;
|
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2022-12-29 10:50:35
|
*/
|
@Controller
|
@Api(tags = "国家、洲、地区")
|
@RequestMapping("/api/tCountry")
|
public class TCountryController extends BaseController {
|
|
|
@Autowired
|
private ITCountryService tCountryService;
|
|
|
|
|
@ApiOperation(value = "国家列表",notes="国家列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "type", value = "1country 2state 3city ", required = true, dataType = "int"),
|
})
|
@GetMapping(value = "/list")
|
@ResponseBody
|
public Object list(String name,int pageNumber,int pageSize,int type) {
|
Page<TCountry> tCountryPage = new Page<>(pageNumber, pageSize);
|
if(name ==null || "".equals(name)){
|
Page<TCountry> tCountryPage1 = tCountryService.selectPage(tCountryPage, new EntityWrapper<TCountry>().eq("type", type).eq("remove",0).orderBy("create_time",false));
|
return new SuccessTip(tCountryPage1);
|
}else {
|
Page<TCountry> tCountryPage1 = tCountryService.selectPage(tCountryPage, new EntityWrapper<TCountry>().eq("type", type).like("name", name).eq("remove",0).orderBy("create_time",false));
|
return new SuccessTip(tCountryPage1);
|
}
|
}
|
@ApiOperation(value = "洲列表",notes="洲列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "countryName", value = "国家名称", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "name", value = "洲名称", required = false, dataType = "String"),
|
})
|
@GetMapping(value = "/stateList")
|
@ResponseBody
|
public Object stateList(String countryName,String name,int pageNumber,int pageSize) {
|
Page<TCountryVo> tCountryPage = new Page<>(pageNumber, pageSize);
|
List tCountryPage1 = tCountryService.getStateList(tCountryPage,countryName, name);
|
tCountryPage.setRecords(tCountryPage1);
|
return new SuccessTip(tCountryPage);
|
}
|
|
@ApiOperation(value = "地区列表",notes="地区列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "pageNumber", value = "pageNumber", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "pageSize", value = "pageSize", required = true, dataType = "int",paramType = "query"),
|
@ApiImplicitParam(name = "countryName", value = "国家名称", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "stateName", value = "洲名称", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "String"),
|
})
|
@GetMapping(value = "/cityList")
|
@ResponseBody
|
public Object cityList(String countryName,String stateName,String name,int pageNumber,int pageSize) {
|
Page<TCountryVo> tCountryPage = new Page<>(pageNumber, pageSize);
|
List tCountryPage1 = tCountryService.getcityList(tCountryPage, countryName,stateName,name);
|
tCountryPage.setRecords(tCountryPage1);
|
return new SuccessTip(tCountryPage);
|
}
|
|
|
@ApiOperation(value = "所有国家列表",notes="所有国家列表")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "type", value = "1country 2state 3city ", required = true, dataType = "int"),
|
})
|
@GetMapping(value = "/allList")
|
@ResponseBody
|
public Object allList(String name,int type) {
|
if(name ==null || "".equals(name)){
|
List tCountryPage1 = tCountryService.selectList( new EntityWrapper<TCountry>().eq("type", type).eq("remove",0).orderBy("create_time",false));
|
return new SuccessTip(tCountryPage1);
|
}else {
|
List tCountryPage1 = tCountryService.selectList( new EntityWrapper<TCountry>().eq("type", type).like("name", name).eq("remove",0).orderBy("create_time",false));
|
return new SuccessTip(tCountryPage1);
|
}
|
}
|
|
|
@ApiOperation(value = "根据id获取下一级",notes="根据id获取下一级")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int"),
|
})
|
@GetMapping(value = "/nextList")
|
@ResponseBody
|
public Object nextList(int id) {
|
return new SuccessTip(tCountryService.selectList(new EntityWrapper<TCountry>().eq("parent_id",id).eq("remove",0)));
|
}
|
|
|
/**
|
* 新增
|
*/
|
@ApiOperation(value = "新增国家",notes="新增国家")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@PostMapping(value = "/add")
|
@ResponseBody
|
public Object add(TCountry tCountry) {
|
tCountry.setCreateTime(new Date());
|
tCountryService.insert(tCountry);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除
|
*/
|
@ApiOperation(value = "删除国家",notes="删除国家")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "tCountryId", value = "国家Id", required = true, dataType = "int"),
|
})
|
@DeleteMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tCountryId) {
|
TCountry tCountry = tCountryService.selectById(tCountryId);
|
tCountry.setRemove(1);
|
tCountryService.updateById(tCountry);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改
|
*/
|
@ApiOperation(value = "修改国家",notes="修改国家")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@PostMapping(value = "/update")
|
@ResponseBody
|
public Object update(TCountry tCountry) {
|
tCountry.setUpdateTime(new Date());
|
tCountryService.updateById(tCountry);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 详情
|
*/
|
@RequestMapping(value = "/detail/{tCountryId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tCountryId") Integer tCountryId) {
|
return tCountryService.selectById(tCountryId);
|
}
|
}
|