1 changed files with 155 additions and 0 deletions
@ -0,0 +1,155 @@ |
|||
package com.kms.web.controller.system; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
|
|||
import com.kms.common.utils.BaseEntityUtils; |
|||
|
|||
|
|||
import com.kms.common.utils.UserUtils; |
|||
import com.kms.system.domain.SysXzqh; |
|||
import com.kms.system.service.SysDeptService; |
|||
import com.kms.system.service.SysXzqhService; |
|||
import com.shuili.common.annotation.Log; |
|||
import com.shuili.common.core.controller.BaseController; |
|||
import com.shuili.common.core.domain.AjaxResult; |
|||
import com.shuili.common.core.domain.SearchParam; |
|||
import com.shuili.common.core.domain.entity.SysDept; |
|||
import com.shuili.common.core.domain.entity.SysUser; |
|||
import com.shuili.common.enums.BusinessType; |
|||
import com.shuili.common.utils.poi.ExcelUtil; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.DeleteMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 行政区划Controller |
|||
* |
|||
* @author kms |
|||
* @date 2023-12-04 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/xzqh/xzqh") |
|||
@Api(tags = "行政区划") |
|||
public class SysXzqhController extends BaseController |
|||
{ |
|||
@Autowired |
|||
private SysXzqhService sysXzqhService; |
|||
|
|||
@Autowired |
|||
private SysDeptService sysDeptService; |
|||
|
|||
|
|||
|
|||
|
|||
@GetMapping("/common") |
|||
public AjaxResult common(){ |
|||
SysUser user = UserUtils.getUser(); |
|||
String deptId = user.getDeptId(); |
|||
SysDept sysDept = sysDeptService.get(deptId); |
|||
String xzqhId = sysDept.getXzqhId(); |
|||
SysXzqh xzqh = sysXzqhService.getById(xzqhId); |
|||
String userName = user.getUserName(); |
|||
if (userName.equals("admin")) { |
|||
List<SysXzqh> list = sysXzqhService.list(); |
|||
return AjaxResult.success(list); |
|||
}else if (xzqh.getLayer().compareTo(BigDecimal.valueOf(1.000000000000000000000000000000)) == 0) { |
|||
String substring = xzqh.getXzqhdm().substring(0, 2); |
|||
QueryWrapper<SysXzqh> queryWrapper = new QueryWrapper<>(); |
|||
queryWrapper.likeRight("XZQHDM", substring); |
|||
List<SysXzqh> list = sysXzqhService.list(queryWrapper); |
|||
return AjaxResult.success(list); |
|||
} else if (xzqh.getLayer().compareTo(BigDecimal.valueOf(2.000000000000000000000000000000)) == 0) { |
|||
String substring = xzqh.getXzqhdm().substring(0, 4); |
|||
QueryWrapper<SysXzqh> queryWrapper = new QueryWrapper<>(); |
|||
queryWrapper.likeRight("XZQHDM", substring); |
|||
List<SysXzqh> list = sysXzqhService.list(queryWrapper); |
|||
return AjaxResult.success(list); |
|||
}else { |
|||
return AjaxResult.success(xzqh); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 查询行政区划列表 |
|||
*/ |
|||
@PostMapping("/list") |
|||
@ApiOperation("行政区划列表") |
|||
public IPage list(@RequestBody SearchParam<SysXzqh> sp) |
|||
{ |
|||
return sysXzqhService.selectPage(sp); |
|||
} |
|||
|
|||
/** |
|||
* 导出行政区划列表 |
|||
*/ |
|||
@Log(title = "行政区划导出", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
@ApiOperation("行政区划导出") |
|||
public AjaxResult export(@RequestBody SysXzqh sysXzqh) |
|||
{ |
|||
List<SysXzqh> list = sysXzqhService.listByIds(sysXzqh.getIds()); |
|||
ExcelUtil<SysXzqh> util = new ExcelUtil<>(SysXzqh.class); |
|||
return util.exportExcel(list, "xzqh"); |
|||
} |
|||
|
|||
/** |
|||
* 获取行政区划详细信息 |
|||
*/ |
|||
@ApiOperation(" 行政区划详情") |
|||
@GetMapping(value = "/{id}") |
|||
public AjaxResult getInfo(@PathVariable("id") String id) |
|||
{ |
|||
return AjaxResult.success(sysXzqhService.getById(id)); |
|||
} |
|||
|
|||
/** |
|||
* 新增行政区划 |
|||
*/ |
|||
@Log(title = "行政区划新增", businessType = BusinessType.INSERT) |
|||
@PostMapping |
|||
@ApiOperation("行政区划新增") |
|||
public AjaxResult add(@RequestBody SysXzqh sysXzqh) |
|||
{ |
|||
BaseEntityUtils.preInsert(sysXzqh); |
|||
return toAjax(sysXzqhService.save(sysXzqh)); |
|||
} |
|||
|
|||
/** |
|||
* 修改行政区划 |
|||
*/ |
|||
@ApiOperation("行政区划修改") |
|||
@Log(title = "行政区划修改", businessType = BusinessType.UPDATE) |
|||
@PutMapping |
|||
public AjaxResult edit(@RequestBody SysXzqh sysXzqh) |
|||
{ |
|||
return toAjax(sysXzqhService.updateById(sysXzqh)); |
|||
} |
|||
|
|||
/** |
|||
* 删除行政区划 |
|||
*/ |
|||
@ApiOperation("行政区划删除") |
|||
@Log(title = "行政区划删除", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{ids}") |
|||
public AjaxResult remove(@PathVariable String[] ids) |
|||
{ |
|||
return toAjax(sysXzqhService.removeByIds(Arrays.asList(ids))); |
|||
} |
|||
} |
Loading…
Reference in new issue