实现用户角色权限区域管理模块
This commit is contained in:
20
guigu-ssyx-parent/service/service-sys/pom.xml
Normal file
20
guigu-ssyx-parent/service/service-sys/pom.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>service</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-sys</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@@ -0,0 +1,23 @@
|
||||
package com.atguigu.ssyx.sys;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||
|
||||
/**
|
||||
* ClassName: ServiceSysApplication
|
||||
* Package: com.atguigu.ssyx.sys
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2023/9/14 15:36
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2WebMvc
|
||||
@MapperScan(value = "com.atguigu.ssyx.*.mapper")
|
||||
public class ServiceSysApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceSysApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package com.atguigu.ssyx.sys.controller;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.sys.Region;
|
||||
import com.atguigu.ssyx.sys.service.RegionService;
|
||||
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.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 地区表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Api(value = "地区接口", tags = "地区接口")
|
||||
@RestController
|
||||
@RequestMapping("/admin/sys/region")
|
||||
//@CrossOrigin
|
||||
public class RegionController {
|
||||
|
||||
@Autowired
|
||||
private RegionService regionService;
|
||||
|
||||
@ApiOperation("根据区域关键字查询区域列表信息")
|
||||
@GetMapping("findRegionByKeyword/{keyword}")
|
||||
public Result findRegionByKeyword(@PathVariable("keyword") String keyword) {
|
||||
try {
|
||||
List<Region> list = regionService.getRegionByKeyword(keyword);
|
||||
return Result.ok(list);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("根据区域关键字查询区域列表信息异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,85 @@
|
||||
package com.atguigu.ssyx.sys.controller;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.sys.RegionWare;
|
||||
import com.atguigu.ssyx.sys.service.RegionWareService;
|
||||
import com.atguigu.ssyx.vo.sys.RegionWareQueryVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 城市仓库关联表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Api(value = "开通区域接口", tags = "开通区域接口")
|
||||
@RestController
|
||||
@RequestMapping(value = "/admin/sys/regionWare")
|
||||
@CrossOrigin
|
||||
public class RegionWareController {
|
||||
@Resource
|
||||
private RegionWareService regionWareService;
|
||||
|
||||
@ApiOperation(value = "获取开通区域列表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result index(
|
||||
@ApiParam(name = "page", value = "当前页码", required = true)
|
||||
@PathVariable Long page,
|
||||
@ApiParam(name = "limit", value = "每页记录数", required = true)
|
||||
@PathVariable Long limit,
|
||||
@ApiParam(name = "regionWareVo", value = "查询对象", required = false)
|
||||
RegionWareQueryVo regionWareQueryVo) {
|
||||
try {
|
||||
Page<RegionWare> pageParam = new Page<>(page, limit);
|
||||
IPage<RegionWare> pageModel = regionWareService.selectPage(pageParam, regionWareQueryVo);
|
||||
return Result.ok(pageModel);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("获取开通区域列表异常", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增开通区域")
|
||||
@PostMapping("save")
|
||||
public Result save(@RequestBody RegionWare regionWare) {
|
||||
try {
|
||||
regionWareService.saveRegionWare(regionWare);
|
||||
return Result.ok(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("新增开通区域异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除开通区域")
|
||||
@DeleteMapping("remove/{id}")
|
||||
public Result remove(@PathVariable Long id) {
|
||||
try {
|
||||
boolean result = regionWareService.removeById(id);
|
||||
return result ? Result.ok(null) : Result.fail(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("删除开通区域异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "取消开通区域")
|
||||
@PostMapping("updateStatus/{id}/{status}")
|
||||
public Result updateStatus(@PathVariable Long id, @PathVariable Integer status) {
|
||||
try {
|
||||
regionWareService.updateStatus(id, status);
|
||||
return Result.ok(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("删除开通区域异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,45 @@
|
||||
package com.atguigu.ssyx.sys.controller;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.common.result.Result;
|
||||
import com.atguigu.ssyx.model.sys.Ware;
|
||||
import com.atguigu.ssyx.sys.service.WareService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author yovinchen
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Api(value = "仓库接口", tags = "仓库接口")
|
||||
@RestController
|
||||
@RequestMapping("/admin/sys/ware")
|
||||
@CrossOrigin
|
||||
public class WareController {
|
||||
|
||||
@Autowired
|
||||
private WareService wareService;
|
||||
|
||||
@ApiOperation("查询所有仓库列表")
|
||||
@GetMapping("findAllList")
|
||||
public Result findAllList() {
|
||||
try {
|
||||
List<Ware> list = wareService.list();
|
||||
return Result.ok(list);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询所有仓库列表异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,18 @@
|
||||
package com.atguigu.ssyx.sys.mapper;
|
||||
|
||||
import com.atguigu.ssyx.model.sys.Region;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 地区表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface RegionMapper extends BaseMapper<Region> {
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.atguigu.ssyx.sys.mapper;
|
||||
|
||||
import com.atguigu.ssyx.model.sys.RegionWare;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 城市仓库关联表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface RegionWareMapper extends BaseMapper<RegionWare> {
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.atguigu.ssyx.sys.mapper;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.model.sys.Ware;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface WareMapper extends BaseMapper<Ware> {
|
||||
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.atguigu.ssyx.sys.mapper.RegionMapper">
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.atguigu.ssyx.sys.mapper.RegionWareMapper">
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.atguigu.ssyx.sys.mapper.WareMapper">
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,20 @@
|
||||
package com.atguigu.ssyx.sys.service;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.model.sys.Region;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 地区表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
public interface RegionService extends IService<Region> {
|
||||
|
||||
List<Region> getRegionByKeyword(String keyword);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.atguigu.ssyx.sys.service;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.model.sys.RegionWare;
|
||||
import com.atguigu.ssyx.vo.sys.RegionWareQueryVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 城市仓库关联表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
public interface RegionWareService extends IService<RegionWare> {
|
||||
|
||||
IPage<RegionWare> selectPage(Page<RegionWare> pageParam, RegionWareQueryVo regionWareQueryVo);
|
||||
|
||||
void saveRegionWare(RegionWare regionWare);
|
||||
|
||||
void updateStatus(Long id, Integer status);
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.atguigu.ssyx.sys.service;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.model.sys.Ware;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
public interface WareService extends IService<Ware> {
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.atguigu.ssyx.sys.service.impl;
|
||||
|
||||
|
||||
import com.atguigu.ssyx.model.sys.Region;
|
||||
import com.atguigu.ssyx.sys.mapper.RegionMapper;
|
||||
import com.atguigu.ssyx.sys.service.RegionService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 地区表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Service
|
||||
public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements RegionService {
|
||||
|
||||
@Override
|
||||
public List<Region> getRegionByKeyword(String keyword) {
|
||||
return baseMapper.selectList(new LambdaQueryWrapper<Region>().like(Region::getName, keyword));
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
package com.atguigu.ssyx.sys.service.impl;
|
||||
|
||||
import com.atguigu.ssyx.common.exception.SsyxException;
|
||||
import com.atguigu.ssyx.common.result.ResultCodeEnum;
|
||||
import com.atguigu.ssyx.model.sys.RegionWare;
|
||||
import com.atguigu.ssyx.sys.mapper.RegionWareMapper;
|
||||
import com.atguigu.ssyx.sys.service.RegionWareService;
|
||||
import com.atguigu.ssyx.vo.sys.RegionWareQueryVo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 城市仓库关联表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Service
|
||||
public class RegionWareServiceImpl extends ServiceImpl<RegionWareMapper, RegionWare> implements RegionWareService {
|
||||
|
||||
|
||||
@Resource
|
||||
RegionWareMapper regionWareMapper;
|
||||
|
||||
//开通区域列表
|
||||
@Override
|
||||
public IPage<RegionWare> selectPage(Page<RegionWare> pageParam, RegionWareQueryVo regionWareQueryVo) {
|
||||
String keyword = regionWareQueryVo.getKeyword();
|
||||
LambdaQueryWrapper<RegionWare> wrapper = new LambdaQueryWrapper<>();
|
||||
if (!StringUtils.isEmpty(keyword)) {
|
||||
wrapper
|
||||
.like(RegionWare::getRegionName, keyword)
|
||||
.or()
|
||||
.like(RegionWare::getWareName, keyword);
|
||||
}
|
||||
return baseMapper.selectPage(pageParam, wrapper);
|
||||
}
|
||||
|
||||
//添加开通区域
|
||||
@Override
|
||||
public void saveRegionWare(RegionWare regionWare) {
|
||||
LambdaQueryWrapper<RegionWare> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.eq(RegionWare::getRegionId, regionWare.getRegionId());
|
||||
Integer count = regionWareMapper.selectCount(queryWrapper);
|
||||
if (count > 0) {
|
||||
throw new SsyxException(ResultCodeEnum.REGION_OPEN);
|
||||
}
|
||||
baseMapper.insert(regionWare);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(Long id, Integer status) {
|
||||
RegionWare regionWare = baseMapper.selectById(id);
|
||||
regionWare.setStatus(status);
|
||||
baseMapper.updateById(regionWare);
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.atguigu.ssyx.sys.service.impl;
|
||||
|
||||
import com.atguigu.ssyx.model.sys.Ware;
|
||||
import com.atguigu.ssyx.sys.mapper.WareMapper;
|
||||
import com.atguigu.ssyx.sys.service.WareService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author atguigu
|
||||
* @since 2023-09-14
|
||||
*/
|
||||
@Service
|
||||
public class WareServiceImpl extends ServiceImpl<WareMapper, Ware> implements WareService {
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
server:
|
||||
port: 8202
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://82.157.68.223:3306/shequ-sys?characterEncoding=utf-8&useSSL=false
|
||||
username: shequ-sys
|
||||
password: shequ-sys
|
||||
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
@@ -0,0 +1,5 @@
|
||||
spring:
|
||||
application:
|
||||
name: service-sys
|
||||
profiles:
|
||||
active: dev
|
Reference in New Issue
Block a user