Merge remote-tracking branch 'origin/master'

pull/1/head
wangtongzhou 2019-05-15 20:24:10 +08:00
commit 051bdeff27
118 changed files with 1047 additions and 1071 deletions

View File

@ -65,12 +65,12 @@ export default {
*query({ payload }, { call, put }) { *query({ payload }, { call, put }) {
const response = yield call(queryRole, payload); const response = yield call(queryRole, payload);
message.info('!'); message.info('!');
const { count, roles } = response.data; const { total, list } = response.data;
yield put({ yield put({
type: 'querySuccess', type: 'querySuccess',
payload: { payload: {
list: roles, list: list,
count, count: total,
}, },
}); });
}, },

View File

@ -65,13 +65,29 @@ function List ({ dataSource, loading, pagination, searchParams, dispatch,
const columns = [ const columns = [
{ {
title: '', title: '',
dataIndex: 'username' dataIndex: 'username'
}, },
{ {
title: '', title: '',
dataIndex: 'nickname', dataIndex: 'nickname',
}, },
{
title: '',
dataIndex: 'roles',
render(roles) {
let text = '';
if (roles) {
for (let i in roles) {
if (i > 0) {
text += ' ';
}
text += roles[i].name;
}
}
return (<span>{text}</span>);
}
},
{ {
title: '', title: '',
dataIndex: 'status', dataIndex: 'status',
@ -174,7 +190,7 @@ const SearchForm = Form.create()(props => {
<Form onSubmit={handleSubmit} layout="inline"> <Form onSubmit={handleSubmit} layout="inline">
<Row gutter={{ md: 8, lg: 24, xl: 48 }}> <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
<Col md={8} sm={24}> <Col md={8} sm={24}>
<FormItem label="昵称"> <FormItem label="员工姓名">
{getFieldDecorator('nickname')(<Input placeholder="请输入" />)} {getFieldDecorator('nickname')(<Input placeholder="请输入" />)}
</FormItem> </FormItem>
</Col> </Col>
@ -251,18 +267,18 @@ const AddOrUpdateForm = Form.create()(props => {
okText='' okText=''
onCancel={() => handleModalVisible()} onCancel={() => handleModalVisible()}
> >
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="用户名"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="账号">
{form.getFieldDecorator('username', { {form.getFieldDecorator('username', {
rules: [{ required: true, message: ''}, rules: [{ required: true, message: ''},
{max: 16, min:6, message: ' 6-16 '}, {max: 16, min:6, message: ' 6-16 '},
{ validator: (rule, value, callback) => checkTypeWithEnglishAndNumbers(rule, value, callback, '')} { validator: (rule, value, callback) => checkTypeWithEnglishAndNumbers(rule, value, callback, '')}
], ],
initialValue: formVals.username, initialValue: formVals.username,
})(<Input placeholder="请输入" />)} })(<Input placeholder="请输入" />)}
</FormItem> </FormItem>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="昵称"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="员工姓名">
{form.getFieldDecorator('nickname', { {form.getFieldDecorator('nickname', {
rules: [{ required: true, message: ''}, rules: [{ required: true, message: ''},
{max: 10, message: ' 10'}], {max: 10, message: ' 10'}],
initialValue: formVals.nickname, initialValue: formVals.nickname,
})(<Input placeholder="请输入" />)} })(<Input placeholder="请输入" />)}

View File

@ -143,7 +143,7 @@ class RoleList extends PureComponent {
type: 'roleList/query', type: 'roleList/query',
payload: { payload: {
name: '', name: '',
pageNo: 0, pageNo: 1,
pageSize: 10, pageSize: 10,
}, },
}); });
@ -277,11 +277,11 @@ class RoleList extends PureComponent {
}; };
const columns = [ const columns = [
{ // {
title: 'id', // title: 'id',
dataIndex: 'id', // dataIndex: 'id',
render: text => <strong>{text}</strong>, // render: text => <strong>{text}</strong>,
}, // },
{ {
title: '', title: '',
dataIndex: 'name', dataIndex: 'name',
@ -289,7 +289,7 @@ class RoleList extends PureComponent {
{ {
title: '', title: '',
dataIndex: 'createTime', dataIndex: 'createTime',
sorter: true, // sorter: true,
render: val => <span>{moment(val).format('YYYY-MM-DD')}</span>, render: val => <span>{moment(val).format('YYYY-MM-DD')}</span>,
}, },
{ {
@ -325,7 +325,7 @@ class RoleList extends PureComponent {
type="primary" type="primary"
onClick={() => this.handleModalVisible(true, 'add', {})} onClick={() => this.handleModalVisible(true, 'add', {})}
> >
</Button> </Button>
</div> </div>
</div> </div>

View File

@ -26,6 +26,11 @@
<artifactId>spring-webmvc</artifactId> <artifactId>spring-webmvc</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<!-- DB 相关 --> <!-- DB 相关 -->
<dependency> <dependency>
<groupId>org.mybatis</groupId> <groupId>org.mybatis</groupId>
@ -36,6 +41,10 @@
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId> <artifactId>mybatis-plus-annotation</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
</dependency>
<!-- RPC 相关 --> <!-- RPC 相关 -->
<dependency> <dependency>

View File

@ -0,0 +1,22 @@
package cn.iocoder.common.framework.mybatis;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.StringUtils;
/**
* MyBatis Plus QueryWrapper
*
* 1. xxxIfPresent
*
* @param <T>
*/
public class QueryWrapperX<T> extends QueryWrapper<T> {
public QueryWrapperX<T> likeIfPresent(String column, String val) {
if (StringUtils.hasText(val)) {
return (QueryWrapperX<T>) super.like(column, val);
}
return this;
}
}

View File

@ -1,9 +1,8 @@
package cn.iocoder.common.framework.util; package cn.iocoder.common.framework.util;
import java.util.Arrays; import java.util.*;
import java.util.Collection; import java.util.function.Function;
import java.util.HashSet; import java.util.stream.Collectors;
import java.util.Set;
public class CollectionUtil { public class CollectionUtil {
@ -14,4 +13,21 @@ public class CollectionUtil {
public static <T> Set<T> asSet(T... objs) { public static <T> Set<T> asSet(T... objs) {
return new HashSet<>(Arrays.asList(objs)); return new HashSet<>(Arrays.asList(objs));
} }
}
public static <T, U> List<U> convertList(List<T> from, Function<T, U> func) {
return from.stream().map(func).collect(Collectors.toList());
}
public static <T, U> Set<U> convertSet(List<T> from, Function<T, U> func) {
return from.stream().map(func).collect(Collectors.toSet());
}
public static <T, K, V> Map<K, V> convertMap(List<T> from, Function<T, K> keyFunc, Function<T, V> valueFunc) {
return from.stream().collect(Collectors.toMap(keyFunc, valueFunc));
}
public static <T, K> Map<K, T> convertMap(List<T> from, Function<T, K> keyFunc) {
return from.stream().collect(Collectors.toMap(keyFunc, item -> item));
}
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.common.framework.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
@ApiModel("分页参数")
public class PageParam {
@ApiModelProperty(value = "页码,从 1 开始", required = true,example = "1")
@NotNull(message = "页码不能为空")
@Min(value = 1, message = "页码最小值为 1")
private Integer pageNo;
@ApiModelProperty(value = "每页条数,最大值为 100", required = true, example = "10")
@NotNull(message = "每页条数不能为空")
@Range(min = 1, max = 100, message = "条数范围为 [1, 100]")
private Integer pageSize;
public Integer getPageNo() {
return pageNo;
}
public PageParam setPageNo(Integer pageNo) {
this.pageNo = pageNo;
return this;
}
public Integer getPageSize() {
return pageSize;
}
public PageParam setPageSize(Integer pageSize) {
this.pageSize = pageSize;
return this;
}
public final int getOffset() {
return (pageNo - 1) * pageSize;
}
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.common.framework.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
@ApiModel("分页结果")
public final class PageResult<T> implements Serializable {
@ApiModelProperty(value = "数据", required = true)
private List<T> list;
@ApiModelProperty(value = "总量", required = true)
private Integer total;
public List<T> getList() {
return list;
}
public PageResult<T> setList(List<T> list) {
this.list = list;
return this;
}
public Integer getTotal() {
return total;
}
public PageResult<T> setTotal(Integer total) {
this.total = total;
return this;
}
}

View File

@ -7,8 +7,8 @@ import cn.iocoder.common.framework.util.HttpUtil;
import cn.iocoder.common.framework.util.MallUtil; import cn.iocoder.common.framework.util.MallUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.SystemLogService; import cn.iocoder.mall.admin.api.SystemLogService;
import cn.iocoder.mall.admin.api.dto.AccessLogAddDTO; import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogAddDTO;
import cn.iocoder.mall.admin.api.dto.ExceptionLogAddDTO; import cn.iocoder.mall.admin.api.dto.systemlog.ExceptionLogAddDTO;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.config.annotation.Reference;

View File

@ -4,7 +4,7 @@ import cn.iocoder.common.framework.util.HttpUtil;
import cn.iocoder.common.framework.util.MallUtil; import cn.iocoder.common.framework.util.MallUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.SystemLogService; import cn.iocoder.mall.admin.api.SystemLogService;
import cn.iocoder.mall.admin.api.dto.AccessLogAddDTO; import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogAddDTO;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.config.annotation.Reference;

View File

@ -18,7 +18,7 @@
- [ ] 订单管理 - [ ] 订单管理
- [ ] 销售单 开发中 - [ ] 销售单 开发中
- [ ] 售后单 开发中 - [ ] 售后单 开发中
- [ ] 订单评价【待认领 - [ ] 订单评价【开发中
- [ ] 会员管理 - [ ] 会员管理
- [ ] 会员资料 20%【待认领】 - [ ] 会员资料 20%【待认领】
- TODO 需要补充 - TODO 需要补充
@ -31,8 +31,8 @@
- [ ] 限制折扣 20% 【待认领】 - [ ] 限制折扣 20% 【待认领】
- [ ] 多人拼团【待认领】 - [ ] 多人拼团【待认领】
- [ ] 系统管理 - [ ] 系统管理
- [ ] 员工管理 - [x] 员工管理
- [ ] 角色管理 - [x] 角色管理 <!--【前端页面需要细化下】-->
- [ ] 权限管理 - [ ] 权限管理
- [ ] 短信管理 - [ ] 短信管理
- [ ] 短信模板 - [ ] 短信模板

View File

@ -63,6 +63,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- 测试相关 --> <!-- 测试相关 -->
<dependency> <dependency>

View File

@ -4,7 +4,7 @@ import cn.iocoder.common.framework.util.HttpUtil;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.DataDictService; import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.CartService; import cn.iocoder.mall.order.api.CartService;
import cn.iocoder.mall.order.api.OrderService; import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.bo.*; import cn.iocoder.mall.order.api.bo.*;

View File

@ -3,7 +3,7 @@ package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.DataDictService; import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.OrderLogisticsService; import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO; import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO; import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;

View File

@ -2,7 +2,7 @@ package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.DataDictService; import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.OrderReturnService; import cn.iocoder.mall.order.api.OrderReturnService;
import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO; import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
import cn.iocoder.mall.order.api.constant.DictKeyConstants; import cn.iocoder.mall.order.api.constant.DictKeyConstants;

View File

@ -1,6 +1,14 @@
spring: spring:
application: application:
name: order-application name: order-application
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:12088
metric:
charset: UTF-8
eager: false
# server # server
server: server:

View File

@ -4,7 +4,7 @@ import cn.iocoder.common.framework.constant.DeletedStatusEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.DataDictService; import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.order.api.OrderLogisticsService; import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.OrderReturnService; import cn.iocoder.mall.order.api.OrderReturnService;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO; import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;

View File

@ -7,7 +7,7 @@ spring:
password: ${MALL_MYSQL_PASSWORD} password: ${MALL_MYSQL_PASSWORD}
# mybatis # mybatis
mybatis: #mybatis:
# config-location: classpath:mybatis-config.xml # config-location: classpath:mybatis-config.xml
# mapper-locations: classpath:mapper/*.xml # mapper-locations: classpath:mapper/*.xml
# type-aliases-package: cn.iocoder.mall.order.biz.dataobject # type-aliases-package: cn.iocoder.mall.order.biz.dataobject
@ -21,6 +21,7 @@ mybatis-plus:
id-type: auto id-type: auto
mapper-locations: classpath*:mapper/*.xml mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.order.biz.dataobject type-aliases-package: cn.iocoder.mall.order.biz.dataobject
config-location: classpath:mybatis-config.xml
# dubbo # dubbo
dubbo: dubbo:

View File

@ -70,6 +70,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -1,6 +1,14 @@
spring: spring:
application: application:
name: pay-application name: pay-application
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:12088
metric:
charset: UTF-8
eager: false
# server # server
server: server:

18
pom.xml
View File

@ -38,6 +38,7 @@
<curator.version>2.13.0</curator.version> <curator.version>2.13.0</curator.version>
<!-- <curator.version>4.0.1</curator.version>--> <!-- <curator.version>4.0.1</curator.version>-->
<!-- <zookeeper.version>3.4.14</zookeeper.version>--> <!-- <zookeeper.version>3.4.14</zookeeper.version>-->
<swagger.version>1.5.21</swagger.version>
<springfox-swagger.version>2.9.2</springfox-swagger.version> <springfox-swagger.version>2.9.2</springfox-swagger.version>
<swagger-bootstrap-ui.version>1.9.3</swagger-bootstrap-ui.version> <swagger-bootstrap-ui.version>1.9.3</swagger-bootstrap-ui.version>
<mybatis-spring-boot-starter.version>2.0.0</mybatis-spring-boot-starter.version> <mybatis-spring-boot-starter.version>2.0.0</mybatis-spring-boot-starter.version>
@ -46,6 +47,7 @@
<xxl-job.version>2.0.1</xxl-job.version> <xxl-job.version>2.0.1</xxl-job.version>
<guava.version>27.0.1-jre</guava.version> <guava.version>27.0.1-jre</guava.version>
<rocketmq-spring-boot-starter.version>2.0.1</rocketmq-spring-boot-starter.version> <rocketmq-spring-boot-starter.version>2.0.1</rocketmq-spring-boot-starter.version>
<sentinel.version>0.9.0.RELEASE</sentinel.version>
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version> <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
<org.projectlombok.version>1.16.14</org.projectlombok.version> <org.projectlombok.version>1.16.14</org.projectlombok.version>
@ -87,6 +89,11 @@
<version>${springboot.version}</version> <version>${springboot.version}</version>
</dependency> </dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
@ -143,6 +150,11 @@
<artifactId>mybatis-plus-annotation</artifactId> <artifactId>mybatis-plus-annotation</artifactId>
<version>${mybatis-plus.version}</version> <version>${mybatis-plus.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
@ -221,6 +233,12 @@
<artifactId>spring-boot-admin-starter-client</artifactId> <artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin-starter-client.version}</version> <version>${spring-boot-admin-starter-client.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>${sentinel.version}</version>
</dependency>
<!-- Test 相关 --> <!-- Test 相关 -->

View File

@ -59,6 +59,12 @@
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
</dependency> </dependency>
<!-- 监控 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- 测试相关 --> <!-- 测试相关 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -1,6 +1,14 @@
spring: spring:
application: application:
name: product-application name: product-application
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:12088
metric:
charset: UTF-8
eager: false
# server # server
server: server:

View File

@ -70,6 +70,12 @@
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
</dependency> </dependency>
<!-- 监控 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- 测试相关 --> <!-- 测试相关 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -1,6 +1,14 @@
spring: spring:
application: application:
name: promotion-application name: promotion-application
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:12088
metric:
charset: UTF-8
eager: false
# server # server
server: server:

View File

@ -26,7 +26,7 @@ mybatis-plus:
id-type: auto id-type: auto
mapper-locations: classpath*:mapper/*.xml mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.promotion.biz.dataobject type-aliases-package: cn.iocoder.mall.promotion.biz.dataobject
config-location: classpath:mybatis-config.xml
# dubbo # dubbo
dubbo: dubbo:
application: application:

View File

@ -59,6 +59,12 @@
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
</dependency> </dependency>
<!-- 监控 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- 测试相关 --> <!-- 测试相关 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -1,6 +1,14 @@
spring: spring:
application: application:
name: search-application name: search-application
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:12088
metric:
charset: UTF-8
eager: false
# server # server
server: server:

View File

@ -61,8 +61,8 @@
<artifactId>spring-boot-admin-starter-client</artifactId> <artifactId>spring-boot-admin-starter-client</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency> </dependency>
<!-- 测试相关 --> <!-- 测试相关 -->

View File

@ -1,27 +1,25 @@
package cn.iocoder.mall.admin.application.controller.admins; package cn.iocoder.mall.admin.application.controller.admins;
import cn.iocoder.common.framework.constant.MallConstants; import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.util.CollectionUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.admin.api.AdminService; import cn.iocoder.mall.admin.api.AdminService;
import cn.iocoder.mall.admin.api.ResourceService; import cn.iocoder.mall.admin.api.ResourceService;
import cn.iocoder.mall.admin.api.RoleService; import cn.iocoder.mall.admin.api.RoleService;
import cn.iocoder.mall.admin.api.bo.ResourceBO; import cn.iocoder.mall.admin.api.bo.resource.ResourceBO;
import cn.iocoder.mall.admin.api.bo.RoleBO; import cn.iocoder.mall.admin.api.bo.role.RoleBO;
import cn.iocoder.mall.admin.api.bo.admin.AdminBO; import cn.iocoder.mall.admin.api.bo.admin.AdminBO;
import cn.iocoder.mall.admin.api.bo.admin.AdminPageBO;
import cn.iocoder.mall.admin.api.constant.ResourceConstants; import cn.iocoder.mall.admin.api.constant.ResourceConstants;
import cn.iocoder.mall.admin.api.dto.admin.AdminAddDTO; import cn.iocoder.mall.admin.api.dto.admin.*;
import cn.iocoder.mall.admin.api.dto.admin.AdminPageDTO;
import cn.iocoder.mall.admin.api.dto.admin.AdminUpdateDTO;
import cn.iocoder.mall.admin.application.convert.AdminConvert; import cn.iocoder.mall.admin.application.convert.AdminConvert;
import cn.iocoder.mall.admin.application.convert.ResourceConvert; import cn.iocoder.mall.admin.application.convert.ResourceConvert;
import cn.iocoder.mall.admin.application.vo.AdminMenuTreeNodeVO; import cn.iocoder.mall.admin.application.vo.admin.AdminMenuTreeNodeVO;
import cn.iocoder.mall.admin.application.vo.AdminPageVO; import cn.iocoder.mall.admin.application.vo.admin.AdminRoleVO;
import cn.iocoder.mall.admin.application.vo.AdminRoleVO; import cn.iocoder.mall.admin.application.vo.admin.AdminVO;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -38,8 +36,10 @@ public class AdminController {
@Reference(validation = "true", version = "${dubbo.provider.ResourceService.version}") @Reference(validation = "true", version = "${dubbo.provider.ResourceService.version}")
private ResourceService resourceService; private ResourceService resourceService;
@Reference(validation = "true", version = "${dubbo.provider.AdminService.version}") @Reference(validation = "true", version = "${dubbo.provider.AdminService.version}")
private AdminService adminService; private AdminService adminService;
@Reference(validation = "true", version = "${dubbo.provider.RoleService.version}") @Reference(validation = "true", version = "${dubbo.provider.RoleService.version}")
private RoleService roleService; private RoleService roleService;
@ -51,7 +51,8 @@ public class AdminController {
@GetMapping("/menu_resource_tree") @GetMapping("/menu_resource_tree")
@ApiOperation(value = "获得当前登陆的管理员拥有的菜单权限", notes = "以树结构返回") @ApiOperation(value = "获得当前登陆的管理员拥有的菜单权限", notes = "以树结构返回")
public CommonResult<List<AdminMenuTreeNodeVO>> menuResourceTree() { public CommonResult<List<AdminMenuTreeNodeVO>> menuResourceTree() {
List<ResourceBO> resources = resourceService.getResourcesByTypeAndRoleIds(ResourceConstants.TYPE_MENU, AdminSecurityContextHolder.getContext().getRoleIds()); List<ResourceBO> resources = resourceService.getResourcesByTypeAndRoleIds(ResourceConstants.TYPE_MENU,
AdminSecurityContextHolder.getContext().getRoleIds());
// 创建 AdminMenuTreeNodeVO Map // 创建 AdminMenuTreeNodeVO Map
Map<Integer, AdminMenuTreeNodeVO> treeNodeMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 的原因,是为了排序 。实际也可以用 Stream API ,就是太丑了。 Map<Integer, AdminMenuTreeNodeVO> treeNodeMap = new LinkedHashMap<>(); // 使用 LinkedHashMap 的原因,是为了排序 。实际也可以用 Stream API ,就是太丑了。
resources.stream().sorted(Comparator.comparing(ResourceBO::getSort)).forEach(resourceBO -> treeNodeMap.put(resourceBO.getId(), ResourceConvert.INSTANCE.convert(resourceBO))); resources.stream().sorted(Comparator.comparing(ResourceBO::getSort)).forEach(resourceBO -> treeNodeMap.put(resourceBO.getId(), ResourceConvert.INSTANCE.convert(resourceBO)));
@ -77,9 +78,8 @@ public class AdminController {
@GetMapping("/url_resource_list") @GetMapping("/url_resource_list")
@ApiOperation(value = "获得当前登陆的管理员拥有的 URL 权限列表") @ApiOperation(value = "获得当前登陆的管理员拥有的 URL 权限列表")
// @ApiModelProperty(value = "data", example = "['/admin/role/add', '/admin/role/update']") 没效果
public CommonResult<Set<String>> urlResourceList() { public CommonResult<Set<String>> urlResourceList() {
List<ResourceBO> resources = resourceService.getResourcesByTypeAndRoleIds(ResourceConstants.TYPE_URL, AdminSecurityContextHolder.getContext().getRoleIds()); List<ResourceBO> resources = resourceService.getResourcesByTypeAndRoleIds(ResourceConstants.TYPE_BUTTON, AdminSecurityContextHolder.getContext().getRoleIds());
return success(resources.stream().map(ResourceBO::getHandler).collect(Collectors.toSet())); return success(resources.stream().map(ResourceBO::getHandler).collect(Collectors.toSet()));
} }
@ -87,15 +87,16 @@ public class AdminController {
@GetMapping("/page") @GetMapping("/page")
@ApiOperation(value = "管理员分页") @ApiOperation(value = "管理员分页")
@ApiImplicitParams({ public CommonResult<PageResult<AdminVO>> page(AdminPageDTO adminPageDTO) {
@ApiImplicitParam(name = "nickname", value = "昵称,模糊匹配", example = "小王"), PageResult<AdminBO> page = adminService.getAdminPage(adminPageDTO);
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"), PageResult<AdminVO> resultPage = AdminConvert.INSTANCE.convertAdminVOPage(page);
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"), // 拼接结果
}) if (!resultPage.getList().isEmpty()) {
public CommonResult<AdminPageVO> page(AdminPageDTO adminPageDTO) { // 查询角色数组
// CommonResult<AdminPageBO> result = adminService.getAdminPage(new AdminPageDTO().setNickname(nickname).setPageNo(pageNo).setPageSize(pageSize)); Map<Integer, Collection<RoleBO>> roleMap = adminService.getAdminRolesMap(CollectionUtil.convertList(resultPage.getList(), AdminBO::getId));
CommonResult<AdminPageBO> result = adminService.getAdminPage(adminPageDTO); resultPage.getList().forEach(admin -> admin.setRoles(AdminConvert.INSTANCE.convertAdminVORoleList(roleMap.get(admin.getId()))));
return AdminConvert.INSTANCE.convert(result); }
return success(resultPage);
} }
@PostMapping("/add") @PostMapping("/add")
@ -106,46 +107,30 @@ public class AdminController {
@PostMapping("/update") @PostMapping("/update")
@ApiOperation(value = "更新管理员") @ApiOperation(value = "更新管理员")
@ApiImplicitParams({ public CommonResult<Boolean> update(AdminUpdateDTO adminUpdateDTO) {
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1"), return success(adminService.updateAdmin(AdminSecurityContextHolder.getContext().getAdminId(), adminUpdateDTO));
@ApiImplicitParam(name = "username", value = "账号", required = true, example = "15601691300"),
@ApiImplicitParam(name = "nickname", value = "昵称", required = true, example = "小王"),
@ApiImplicitParam(name = "password", value = "密码", example = "buzhidao"),
})
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("username") String username,
@RequestParam("nickname") String nickname,
@RequestParam(value = "password", required = false) String password) {
AdminUpdateDTO adminUpdateDTO = new AdminUpdateDTO().setId(id).setUsername(username).setNickname(nickname).setPassword(password);
return adminService.updateAdmin(AdminSecurityContextHolder.getContext().getAdminId(), adminUpdateDTO);
} }
@PostMapping("/update_status") @PostMapping("/update_status")
@ApiOperation(value = "更新管理员状态") @ApiOperation(value = "更新管理员状态")
@ApiImplicitParams({ public CommonResult<Boolean> updateStatus(AdminUpdateStatusDTO adminUpdateStatusDTO) {
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1"), return success(adminService.updateAdminStatus(AdminSecurityContextHolder.getContext().getAdminId(), adminUpdateStatusDTO));
@ApiImplicitParam(name = "status", value = "状态。1 - 开启2 - 禁用", required = true, example = "1"),
})
public CommonResult<Boolean> updateStatus(@RequestParam("id") Integer id,
@RequestParam("status") Integer status) {
return adminService.updateAdminStatus(AdminSecurityContextHolder.getContext().getAdminId(), id, status);
} }
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation(value = "删除管理员") @ApiOperation(value = "删除管理员")
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1") @ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1")
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) { public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
return adminService.deleteAdmin(AdminSecurityContextHolder.getContext().getAdminId(), id); return success(adminService.deleteAdmin(AdminSecurityContextHolder.getContext().getAdminId(), id));
} }
@GetMapping("/role_list") @GetMapping("/role_list")
@ApiOperation(value = "指定管理员拥有的角色列表") @ApiOperation(value = "指定管理员拥有的角色列表")
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1") @ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1")
public CommonResult<List<AdminRoleVO>> roleList(@RequestParam("id") Integer id) { public CommonResult<List<AdminRoleVO>> roleList(@RequestParam("id") Integer id) {
// 获得管理员拥有的角色集合
Set<Integer> adminRoleIdSet = roleService.getRoleList(id).getData();
// 获得所有角色数组 // 获得所有角色数组
List<RoleBO> allRoleList = roleService.getRoleList().getData(); List<RoleBO> allRoleList = adminService.getRoleList(id);
Set<Integer> adminRoleIdSet = CollectionUtil.convertSet(allRoleList, RoleBO::getId);
// 转换出返回结果 // 转换出返回结果
List<AdminRoleVO> result = AdminConvert.INSTANCE.convert(allRoleList); List<AdminRoleVO> result = AdminConvert.INSTANCE.convert(allRoleList);
// 设置每个角色是否赋予给改管理员 // 设置每个角色是否赋予给改管理员
@ -155,13 +140,8 @@ public class AdminController {
@PostMapping("/assign_role") @PostMapping("/assign_role")
@ApiOperation(value = "分配给管理员角色") @ApiOperation(value = "分配给管理员角色")
@ApiImplicitParams({ public CommonResult<Boolean> assignRole(AdminAssignRoleDTO adminAssignRoleDTO) {
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1"), return success(adminService.assignAdminRole(AdminSecurityContextHolder.getContext().getAdminId(), adminAssignRoleDTO));
@ApiImplicitParam(name = "roleIds", value = "角色编号集合", required = true, example = "1,2,3"),
})
public CommonResult<Boolean> assignRole(@RequestParam("id") Integer id,
@RequestParam("roleIds")Set<Integer> roleIds) {
return adminService.assignRole(AdminSecurityContextHolder.getContext().getAdminId(), id, roleIds);
} }
} }

View File

@ -2,12 +2,12 @@ package cn.iocoder.mall.admin.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.DataDictService; import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.admin.api.dto.DataDictAddDTO; import cn.iocoder.mall.admin.api.dto.datadict.DataDictAddDTO;
import cn.iocoder.mall.admin.api.dto.DataDictUpdateDTO; import cn.iocoder.mall.admin.api.dto.datadict.DataDictUpdateDTO;
import cn.iocoder.mall.admin.application.convert.DataDictConvert; import cn.iocoder.mall.admin.application.convert.DataDictConvert;
import cn.iocoder.mall.admin.application.vo.DataDictEnumVO; import cn.iocoder.mall.admin.application.vo.datadict.DataDictEnumVO;
import cn.iocoder.mall.admin.application.vo.DataDictVO; import cn.iocoder.mall.admin.application.vo.datadict.DataDictVO;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;

View File

@ -2,7 +2,7 @@ package cn.iocoder.mall.admin.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.OAuth2Service; import cn.iocoder.mall.admin.api.OAuth2Service;
import cn.iocoder.mall.admin.api.bo.OAuth2AccessTokenBO; import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AccessTokenBO;
import cn.iocoder.mall.admin.application.convert.PassportConvert; import cn.iocoder.mall.admin.application.convert.PassportConvert;
import cn.iocoder.mall.admin.application.vo.PassportLoginVO; import cn.iocoder.mall.admin.application.vo.PassportLoginVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;

View File

@ -2,17 +2,15 @@ package cn.iocoder.mall.admin.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.ResourceService; import cn.iocoder.mall.admin.api.ResourceService;
import cn.iocoder.mall.admin.api.bo.ResourceBO; import cn.iocoder.mall.admin.api.bo.resource.ResourceBO;
import cn.iocoder.mall.admin.api.constant.ResourceConstants; import cn.iocoder.mall.admin.api.constant.ResourceConstants;
import cn.iocoder.mall.admin.api.dto.ResourceAddDTO; import cn.iocoder.mall.admin.api.dto.resource.ResourceAddDTO;
import cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO; import cn.iocoder.mall.admin.api.dto.resource.ResourceUpdateDTO;
import cn.iocoder.mall.admin.application.convert.ResourceConvert; import cn.iocoder.mall.admin.application.convert.ResourceConvert;
import cn.iocoder.mall.admin.application.vo.ResourceTreeNodeVO; import cn.iocoder.mall.admin.application.vo.resource.ResourceTreeNodeVO;
import cn.iocoder.mall.admin.application.vo.ResourceVO;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,6 +21,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController @RestController
@RequestMapping("admins/resource") @RequestMapping("admins/resource")
@Api("资源模块") @Api("资源模块")
@ -55,55 +55,26 @@ public class ResourceController {
.filter(node -> node.getPid().equals(ResourceConstants.PID_ROOT)) .filter(node -> node.getPid().equals(ResourceConstants.PID_ROOT))
.sorted(Comparator.comparing(ResourceTreeNodeVO::getSort)) .sorted(Comparator.comparing(ResourceTreeNodeVO::getSort))
.collect(Collectors.toList()); .collect(Collectors.toList());
return CommonResult.success(rootNodes); return success(rootNodes);
} }
@PostMapping("/add") @PostMapping("/add")
@ApiOperation(value = "创建资源", notes = "例如说菜单资源Url 资源") @ApiOperation(value = "创建资源", notes = "例如说菜单资源Url 资源")
@ApiImplicitParams({ public CommonResult<ResourceBO> add(ResourceAddDTO resourceAddDTO) {
@ApiImplicitParam(name = "name", value = "资源名字(标识)", required = true, example = "admin/info"), return success(resourceService.addResource(AdminSecurityContextHolder.getContext().getAdminId(), resourceAddDTO));
@ApiImplicitParam(name = "type", value = "资源类型。1 代表【菜单】2 代表【Url】", required = true, example = "1"),
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
@ApiImplicitParam(name = "displayName", value = "菜单展示名", required = true, example = "商品管理"),
@ApiImplicitParam(name = "pid", value = "父级资源编号", required = true, example = "1"),
@ApiImplicitParam(name = "handler", value = "操作", example = "/order/list"),
})
public CommonResult<ResourceVO> add(@RequestParam("name") String name,
@RequestParam("type") Integer type,
@RequestParam("sort") Integer sort,
@RequestParam("displayName") String displayName,
@RequestParam("pid") Integer pid,
@RequestParam(value = "handler", required = false) String handler) {
ResourceAddDTO resourceAddDTO = new ResourceAddDTO().setName(name).setType(type).setSort(sort)
.setDisplayName(displayName).setPid(pid).setHandler(handler);
return ResourceConvert.INSTANCE.convert3(resourceService.addResource(AdminSecurityContextHolder.getContext().getAdminId(), resourceAddDTO));
} }
@PostMapping("/update") @PostMapping("/update")
@ApiOperation(value = "更新资源") @ApiOperation(value = "更新资源")
@ApiImplicitParams({ public CommonResult<Boolean> update(ResourceUpdateDTO resourceUpdateDTO) {
@ApiImplicitParam(name = "id", value = "资源编号", required = true, example = "1"), return success(resourceService.updateResource(AdminSecurityContextHolder.getContext().getAdminId(), resourceUpdateDTO));
@ApiImplicitParam(name = "name", value = "资源名字(标识)", required = true, example = "admin/info"),
@ApiImplicitParam(name = "sort", value = "排序", required = true, example = "1"),
@ApiImplicitParam(name = "displayName", value = "菜单展示名", required = true, example = "商品管理"),
@ApiImplicitParam(name = "pid", value = "父级资源编号", required = true, example = "1"),
@ApiImplicitParam(name = "handler", value = "操作", example = "/order/list"),
})
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("name") String name,
@RequestParam("sort") Integer sort,
@RequestParam("displayName") String displayName,
@RequestParam("pid") Integer pid,
@RequestParam(value = "handler", required = false) String handler) {
ResourceUpdateDTO resourceUpdateDTO = new ResourceUpdateDTO().setId(id).setName(name).setSort(sort).setDisplayName(displayName).setPid(pid).setHandler(handler);
return resourceService.updateResource(AdminSecurityContextHolder.getContext().getAdminId(), resourceUpdateDTO);
} }
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation(value = "删除资源") @ApiOperation(value = "删除资源")
@ApiImplicitParam(name = "id", value = "资源编号", required = true, example = "1") @ApiImplicitParam(name = "id", value = "资源编号", required = true, example = "1")
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) { public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
return resourceService.deleteResource(AdminSecurityContextHolder.getContext().getAdminId(), id); return success(resourceService.deleteResource(AdminSecurityContextHolder.getContext().getAdminId(), id));
} }
} }

View File

@ -2,20 +2,20 @@ package cn.iocoder.mall.admin.application.controller.admins;
import cn.iocoder.common.framework.util.CollectionUtil; import cn.iocoder.common.framework.util.CollectionUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.admin.api.ResourceService; import cn.iocoder.mall.admin.api.ResourceService;
import cn.iocoder.mall.admin.api.RoleService; import cn.iocoder.mall.admin.api.RoleService;
import cn.iocoder.mall.admin.api.bo.ResourceBO; import cn.iocoder.mall.admin.api.bo.resource.ResourceBO;
import cn.iocoder.mall.admin.api.bo.RolePageBO; import cn.iocoder.mall.admin.api.bo.role.RoleBO;
import cn.iocoder.mall.admin.api.constant.ResourceConstants; import cn.iocoder.mall.admin.api.constant.ResourceConstants;
import cn.iocoder.mall.admin.api.dto.RoleAddDTO; import cn.iocoder.mall.admin.api.dto.role.RoleAddDTO;
import cn.iocoder.mall.admin.api.dto.RolePageDTO; import cn.iocoder.mall.admin.api.dto.role.RoleAssignResourceDTO;
import cn.iocoder.mall.admin.api.dto.RoleUpdateDTO; import cn.iocoder.mall.admin.api.dto.role.RolePageDTO;
import cn.iocoder.mall.admin.api.dto.role.RoleUpdateDTO;
import cn.iocoder.mall.admin.application.convert.ResourceConvert; import cn.iocoder.mall.admin.application.convert.ResourceConvert;
import cn.iocoder.mall.admin.application.convert.RoleConvert; import cn.iocoder.mall.admin.application.vo.role.RoleResourceTreeNodeVO;
import cn.iocoder.mall.admin.application.vo.RolePageVO;
import cn.iocoder.mall.admin.application.vo.RoleResourceTreeNodeVO;
import cn.iocoder.mall.admin.application.vo.RoleVO;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -25,56 +25,42 @@ import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController @RestController
@RequestMapping("admins/role") @RequestMapping("admins/role")
@Api("角色模块")
public class RoleController { public class RoleController {
@Reference(validation = "true", version = "${dubbo.provider.RoleService.version}") @Reference(validation = "true", version = "${dubbo.provider.RoleService.version}")
private RoleService roleService; private RoleService roleService;
@Reference(validation = "true", version = "${dubbo.provider.ResourceService.version}") @Reference(validation = "true", version = "${dubbo.provider.ResourceService.version}")
private ResourceService resourceService; private ResourceService resourceService;
@GetMapping("/page") @GetMapping("/page")
@ApiOperation(value = "角色分页") @ApiOperation(value = "角色分页")
@ApiImplicitParams({ public CommonResult<PageResult<RoleBO>> page(RolePageDTO rolePageDTO) {
@ApiImplicitParam(name = "name", value = "角色名,模糊匹配", required = true, example = "系统管理员"), return success(roleService.getRolePage(rolePageDTO));
@ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"),
})
public CommonResult<RolePageVO> page(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
CommonResult<RolePageBO> result = roleService.getRolePage(new RolePageDTO().setName(name).setPageNo(pageNo).setPageSize(pageSize));
return RoleConvert.INSTANCE.convert2(result);
} }
@PostMapping("/add") @PostMapping("/add")
@ApiOperation(value = "创建角色") @ApiOperation(value = "创建角色")
@ApiImplicitParams({ public CommonResult<RoleBO> add(RoleAddDTO roleAddDTO) {
@ApiImplicitParam(name = "name", value = "角色", required = true, example = "系统管理员"), return success(roleService.addRole(AdminSecurityContextHolder.getContext().getAdminId(), roleAddDTO));
})
public CommonResult<RoleVO> add(@RequestParam("name") String name) {
RoleAddDTO roleAddDTO = new RoleAddDTO().setName(name);
return RoleConvert.INSTANCE.convert(roleService.addRole(AdminSecurityContextHolder.getContext().getAdminId(), roleAddDTO));
} }
@PostMapping("/update") @PostMapping("/update")
@ApiOperation(value = "更新角色") @ApiOperation(value = "更新角色")
@ApiImplicitParams({ public CommonResult<Boolean> update(RoleUpdateDTO roleUpdateDTO) {
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1"), return success(roleService.updateRole(AdminSecurityContextHolder.getContext().getAdminId(), roleUpdateDTO));
@ApiImplicitParam(name = "name", value = "角色名", required = true, example = "系统管理员"),
})
public CommonResult<Boolean> update(@RequestParam("id") Integer id,
@RequestParam("name") String name) {
RoleUpdateDTO roleUpdateDTO = new RoleUpdateDTO().setId(id).setName(name);
return roleService.updateRole(AdminSecurityContextHolder.getContext().getAdminId(), roleUpdateDTO);
} }
@PostMapping("/delete") @PostMapping("/delete")
@ApiOperation(value = "删除角色") @ApiOperation(value = "删除角色")
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1") @ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1")
public CommonResult<Boolean> delete(@RequestParam("id") Integer id) { public CommonResult<Boolean> delete(@RequestParam("id") Integer id) {
return roleService.deleteRole(AdminSecurityContextHolder.getContext().getAdminId(), id); return success(roleService.deleteRole(AdminSecurityContextHolder.getContext().getAdminId(), id));
} }
@SuppressWarnings("Duplicates") @SuppressWarnings("Duplicates")
@ -110,7 +96,7 @@ public class RoleController {
// 第三步,设置角色是否有该角色 // 第三步,设置角色是否有该角色
treeNodeMap.values().forEach(nodeVO -> nodeVO.setAssigned(roleResources.contains(nodeVO.getId()))); treeNodeMap.values().forEach(nodeVO -> nodeVO.setAssigned(roleResources.contains(nodeVO.getId())));
// 返回结果 // 返回结果
return CommonResult.success(rootNodes); return success(rootNodes);
} }
@PostMapping("/assign_resource") @PostMapping("/assign_resource")
@ -119,9 +105,8 @@ public class RoleController {
@ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1"), @ApiImplicitParam(name = "id", value = "角色编号", required = true, example = "1"),
@ApiImplicitParam(name = "resourceIds", value = "资源数组", required = true, example = "1,2,3"), @ApiImplicitParam(name = "resourceIds", value = "资源数组", required = true, example = "1,2,3"),
}) })
public CommonResult<Boolean> assignResource(@RequestParam("id") Integer id, public CommonResult<Boolean> assignResource(RoleAssignResourceDTO roleAssignResourceDTO) {
@RequestParam(value = "resourceIds", required = false) Set<Integer> resourceIds) { return success(roleService.assignRoleResource(AdminSecurityContextHolder.getContext().getAdminId(), roleAssignResourceDTO));
return roleService.assignResource(AdminSecurityContextHolder.getContext().getAdminId(), id, resourceIds);
} }
} }

View File

@ -1,18 +1,18 @@
package cn.iocoder.mall.admin.application.convert; package cn.iocoder.mall.admin.application.convert;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.admin.api.bo.role.RoleBO;
import cn.iocoder.mall.admin.api.bo.admin.AdminBO; import cn.iocoder.mall.admin.api.bo.admin.AdminBO;
import cn.iocoder.mall.admin.api.bo.admin.AdminPageBO; import cn.iocoder.mall.admin.application.vo.admin.AdminInfoVO;
import cn.iocoder.mall.admin.api.bo.RoleBO; import cn.iocoder.mall.admin.application.vo.admin.AdminRoleVO;
import cn.iocoder.mall.admin.application.vo.AdminInfoVO; import cn.iocoder.mall.admin.application.vo.admin.AdminVO;
import cn.iocoder.mall.admin.application.vo.AdminPageVO;
import cn.iocoder.mall.admin.application.vo.AdminRoleVO;
import cn.iocoder.mall.admin.application.vo.AdminVO;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContext; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContext;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.Collection;
import java.util.List; import java.util.List;
@Mapper @Mapper
@ -29,10 +29,12 @@ public interface AdminConvert {
@Mappings({}) @Mappings({})
CommonResult<AdminVO> convert2(CommonResult<AdminBO> result); CommonResult<AdminVO> convert2(CommonResult<AdminBO> result);
@Mappings({})
CommonResult<AdminPageVO> convert(CommonResult<AdminPageBO> result);
@Mappings({}) @Mappings({})
List<AdminRoleVO> convert(List<RoleBO> roleList); List<AdminRoleVO> convert(List<RoleBO> roleList);
@Mappings({})
PageResult<AdminVO> convertAdminVOPage(PageResult<AdminBO> page);
List<AdminVO.Role> convertAdminVORoleList(Collection<RoleBO> list);
} }

View File

@ -1,9 +1,9 @@
package cn.iocoder.mall.admin.application.convert; package cn.iocoder.mall.admin.application.convert;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.admin.application.vo.DataDictVO; import cn.iocoder.mall.admin.application.vo.datadict.DataDictVO;
import cn.iocoder.mall.admin.application.vo.DataDictValueVO; import cn.iocoder.mall.admin.application.vo.datadict.DataDictValueVO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -30,4 +30,4 @@ public interface DataDictConvert {
@Mappings({}) @Mappings({})
List<DataDictValueVO> convert2(List<DataDictBO> dataDictBOs); List<DataDictValueVO> convert2(List<DataDictBO> dataDictBOs);
} }

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.admin.application.convert; package cn.iocoder.mall.admin.application.convert;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.bo.OAuth2AccessTokenBO; import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AccessTokenBO;
import cn.iocoder.mall.admin.application.vo.PassportLoginVO; import cn.iocoder.mall.admin.application.vo.PassportLoginVO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
@ -18,4 +18,4 @@ public interface PassportConvert {
@Mappings({}) @Mappings({})
CommonResult<PassportLoginVO> convert(CommonResult<OAuth2AccessTokenBO> oauth2AccessTokenBO); CommonResult<PassportLoginVO> convert(CommonResult<OAuth2AccessTokenBO> oauth2AccessTokenBO);
} }

View File

@ -1,11 +1,11 @@
package cn.iocoder.mall.admin.application.convert; package cn.iocoder.mall.admin.application.convert;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.bo.ResourceBO; import cn.iocoder.mall.admin.api.bo.resource.ResourceBO;
import cn.iocoder.mall.admin.application.vo.AdminMenuTreeNodeVO; import cn.iocoder.mall.admin.application.vo.admin.AdminMenuTreeNodeVO;
import cn.iocoder.mall.admin.application.vo.ResourceTreeNodeVO; import cn.iocoder.mall.admin.application.vo.resource.ResourceTreeNodeVO;
import cn.iocoder.mall.admin.application.vo.ResourceVO; import cn.iocoder.mall.admin.application.vo.resource.ResourceVO;
import cn.iocoder.mall.admin.application.vo.RoleResourceTreeNodeVO; import cn.iocoder.mall.admin.application.vo.role.RoleResourceTreeNodeVO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -30,4 +30,4 @@ public interface ResourceConvert {
@Mappings({}) @Mappings({})
CommonResult<ResourceVO> convert3(CommonResult<ResourceBO> resourceBO); CommonResult<ResourceVO> convert3(CommonResult<ResourceBO> resourceBO);
} }

View File

@ -1,31 +1,11 @@
package cn.iocoder.mall.admin.application.convert; package cn.iocoder.mall.admin.application.convert;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.bo.RoleBO;
import cn.iocoder.mall.admin.api.bo.RolePageBO;
import cn.iocoder.mall.admin.application.vo.RolePageVO;
import cn.iocoder.mall.admin.application.vo.RoleVO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper @Mapper
public interface RoleConvert { public interface RoleConvert {
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class); RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
@Mappings({}) }
RoleVO convert(RoleBO roleBO);
@Mappings({})
List<RoleVO> convert(List<RoleBO> roleBO);
@Mappings({})
CommonResult<RoleVO> convert(CommonResult<RoleBO> resourceBO);
@Mappings({})
CommonResult<RolePageVO> convert2(CommonResult<RolePageBO> resourceBO);
}

View File

@ -1,20 +0,0 @@
package cn.iocoder.mall.admin.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@ApiModel("管理员分页 VO")
@Data
@Accessors(chain = true)
public class AdminPageVO {
@ApiModelProperty(value = "管理员数组")
private List<AdminVO> list;
@ApiModelProperty(value = "管理员总数")
private Integer total;
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.mall.admin.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@ApiModel("管理员 VO")
@Data
@Accessors(chain = true)
public class AdminVO {
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
private String username;
@ApiModelProperty(value = "昵称", required = true, example = "小王")
private String nickname;
@ApiModelProperty(value = "账号状态", required = true, example = "1")
private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
private Date createTime;
}

View File

@ -1,20 +0,0 @@
package cn.iocoder.mall.admin.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@ApiModel("角色分页 VO")
@Data
@Accessors(chain = true)
public class RolePageVO {
@ApiModelProperty(value = "角色数组")
private List<RoleVO> roles;
@ApiModelProperty(value = "角色总数")
private Integer count;
}

View File

@ -1,22 +0,0 @@
package cn.iocoder.mall.admin.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@ApiModel("角色 VO")
@Data
@Accessors(chain = true)
public class RoleVO {
@ApiModelProperty(value = "角色编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "角色名字", required = true, example = "系统管理员")
private String name;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
private Date createTime;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.admin;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -12,7 +12,7 @@ import java.util.Set;
@Accessors(chain = true) @Accessors(chain = true)
public class AdminInfoVO { public class AdminInfoVO {
@ApiModelProperty(value = "管理员比那好", required = true, example = "1") @ApiModelProperty(value = "管理员编号", required = true, example = "1")
private Integer adminId; private Integer adminId;
@ApiModelProperty(value = "角色编号的数组", required = true, example = "[1, 2]") @ApiModelProperty(value = "角色编号的数组", required = true, example = "[1, 2]")
private Set<Integer> roleIds; private Set<Integer> roleIds;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.admin;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.admin;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -0,0 +1,31 @@
package cn.iocoder.mall.admin.application.vo.admin;
import cn.iocoder.mall.admin.api.bo.admin.AdminBO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@ApiModel("管理员 VO")
@Data
@Accessors(chain = true)
public class AdminVO extends AdminBO {
private List<Role> roles;
@ApiModel("管理员 VO - 角色")
@Data
@Accessors(chain = true)
public static class Role {
@ApiModelProperty(value = "角色编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "角色名", required = true, example = "码神")
private String name;
}
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.datadict;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.datadict;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.datadict;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application; package cn.iocoder.mall.admin.application.vo.oauth2;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.resource;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.resource;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.application.vo; package cn.iocoder.mall.admin.application.vo.role;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

View File

@ -1,6 +1,14 @@
spring: spring:
application: application:
name: admin-application name: admin-application
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:12088
metric:
charset: UTF-8
eager: false
# server # server
server: server:

View File

@ -6,7 +6,7 @@ import cn.iocoder.common.framework.util.HttpUtil;
import cn.iocoder.common.framework.util.MallUtil; import cn.iocoder.common.framework.util.MallUtil;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.OAuth2Service; import cn.iocoder.mall.admin.api.OAuth2Service;
import cn.iocoder.mall.admin.api.bo.OAuth2AuthenticationBO; import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AuthenticationBO;
import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum; import cn.iocoder.mall.admin.api.constant.AdminErrorCodeEnum;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContext; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContext;
import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder; import cn.iocoder.mall.admin.sdk.context.AdminSecurityContextHolder;

View File

@ -21,8 +21,8 @@
<!-- Web 相关 --> <!-- Web 相关 -->
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.swagger</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>swagger-annotations</artifactId>
</dependency> </dependency>
<!-- 工具类相关 --> <!-- 工具类相关 -->

View File

@ -1,32 +1,52 @@
package cn.iocoder.mall.admin.api; package cn.iocoder.mall.admin.api;
import cn.iocoder.common.framework.constant.CommonStatusEnum; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.common.framework.validator.InEnum; import cn.iocoder.mall.admin.api.bo.role.RoleBO;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.bo.admin.AdminBO; import cn.iocoder.mall.admin.api.bo.admin.AdminBO;
import cn.iocoder.mall.admin.api.bo.admin.AdminPageBO; import cn.iocoder.mall.admin.api.dto.admin.*;
import cn.iocoder.mall.admin.api.dto.admin.AdminAddDTO;
import cn.iocoder.mall.admin.api.dto.admin.AdminPageDTO;
import cn.iocoder.mall.admin.api.dto.admin.AdminUpdateDTO;
import java.util.Set; import java.util.Collection;
import java.util.List;
import java.util.Map;
/** /**
* Service * Service
*/ */
public interface AdminService { public interface AdminService {
CommonResult<AdminPageBO> getAdminPage(AdminPageDTO adminPageDTO); PageResult<AdminBO> getAdminPage(AdminPageDTO adminPageDTO);
AdminBO addAdmin(Integer adminId, AdminAddDTO adminAddDTO); AdminBO addAdmin(Integer adminId, AdminAddDTO adminAddDTO);
CommonResult<Boolean> updateAdmin(Integer adminId, AdminUpdateDTO adminUpdateDTO); Boolean updateAdmin(Integer adminId, AdminUpdateDTO adminUpdateDTO);
CommonResult<Boolean> updateAdminStatus(Integer adminId, Integer updateAdminId, Boolean updateAdminStatus(Integer adminId, AdminUpdateStatusDTO adminUpdateStatusDTO);
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") Integer status);
CommonResult<Boolean> deleteAdmin(Integer adminId, Integer updateAdminId); Boolean deleteAdmin(Integer adminId, Integer updateAdminId);
CommonResult<Boolean> assignRole(Integer adminId, Integer updateAdminId, Set<Integer> roleIds); /**
*
*
* @param adminIds
* @return
*/
Map<Integer, Collection<RoleBO>> getAdminRolesMap(Collection<Integer> adminIds);
/**
*
*
* @param adminId
* @return
*/
List<RoleBO> getRoleList(Integer adminId);
/**
*
*
* @param adminId
* @param adminAssignRoleDTO
* @return true
*/
Boolean assignAdminRole(Integer adminId, AdminAssignRoleDTO adminAssignRoleDTO);
} }

View File

@ -1,9 +1,9 @@
package cn.iocoder.mall.admin.api; package cn.iocoder.mall.admin.api;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.admin.api.dto.DataDictAddDTO; import cn.iocoder.mall.admin.api.dto.datadict.DataDictAddDTO;
import cn.iocoder.mall.admin.api.dto.DataDictUpdateDTO; import cn.iocoder.mall.admin.api.dto.datadict.DataDictUpdateDTO;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;

View File

@ -1,8 +1,8 @@
package cn.iocoder.mall.admin.api; package cn.iocoder.mall.admin.api;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.bo.OAuth2AccessTokenBO; import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AccessTokenBO;
import cn.iocoder.mall.admin.api.bo.OAuth2AuthenticationBO; import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AuthenticationBO;
import java.util.Set; import java.util.Set;
@ -30,4 +30,4 @@ public interface OAuth2Service {
// TODO @see 刷新 token // TODO @see 刷新 token
} }

View File

@ -1,9 +1,8 @@
package cn.iocoder.mall.admin.api; package cn.iocoder.mall.admin.api;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.admin.api.bo.resource.ResourceBO;
import cn.iocoder.mall.admin.api.bo.ResourceBO; import cn.iocoder.mall.admin.api.dto.resource.ResourceAddDTO;
import cn.iocoder.mall.admin.api.dto.ResourceAddDTO; import cn.iocoder.mall.admin.api.dto.resource.ResourceUpdateDTO;
import cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import java.util.List; import java.util.List;
@ -28,10 +27,10 @@ public interface ResourceService {
*/ */
List<ResourceBO> getResourcesByType(@Nullable Integer type); List<ResourceBO> getResourcesByType(@Nullable Integer type);
CommonResult<ResourceBO> addResource(Integer adminId, ResourceAddDTO resourceAddDTO); ResourceBO addResource(Integer adminId, ResourceAddDTO resourceAddDTO);
CommonResult<Boolean> updateResource(Integer adminId, ResourceUpdateDTO resourceUpdateDTO); Boolean updateResource(Integer adminId, ResourceUpdateDTO resourceUpdateDTO);
CommonResult<Boolean> deleteResource(Integer adminId, Integer resourceId); Boolean deleteResource(Integer adminId, Integer resourceId);
} }

View File

@ -1,38 +1,32 @@
package cn.iocoder.mall.admin.api; package cn.iocoder.mall.admin.api;
import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.admin.api.bo.RoleBO; import cn.iocoder.mall.admin.api.bo.role.RoleBO;
import cn.iocoder.mall.admin.api.bo.RolePageBO; import cn.iocoder.mall.admin.api.dto.role.RoleAddDTO;
import cn.iocoder.mall.admin.api.dto.RoleAddDTO; import cn.iocoder.mall.admin.api.dto.role.RoleAssignResourceDTO;
import cn.iocoder.mall.admin.api.dto.RolePageDTO; import cn.iocoder.mall.admin.api.dto.role.RolePageDTO;
import cn.iocoder.mall.admin.api.dto.RoleUpdateDTO; import cn.iocoder.mall.admin.api.dto.role.RoleUpdateDTO;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set;
public interface RoleService { public interface RoleService {
CommonResult<RolePageBO> getRolePage(RolePageDTO rolePageDTO); PageResult<RoleBO> getRolePage(RolePageDTO rolePageDTO);
/**
*
*
* @param adminId
* @return
*/
CommonResult<Set<Integer>> getRoleList(Integer adminId);
/** /**
* @return * @return
*/ */
CommonResult<List<RoleBO>> getRoleList(); List<RoleBO> getRoleList();
CommonResult<RoleBO> addRole(Integer adminId, RoleAddDTO roleAddDTO); List<RoleBO> getRoleList(Collection<Integer> ids);
CommonResult<Boolean> updateRole(Integer adminId, RoleUpdateDTO roleUpdateDTO); RoleBO addRole(Integer adminId, RoleAddDTO roleAddDTO);
CommonResult<Boolean> deleteRole(Integer adminId, Integer roleId); Boolean updateRole(Integer adminId, RoleUpdateDTO roleUpdateDTO);
CommonResult<Boolean> assignResource(Integer adminId, Integer roleId, Set<Integer> resourceIds); Boolean deleteRole(Integer adminId, Integer roleId);
} Boolean assignRoleResource(Integer adminId, RoleAssignResourceDTO roleAssignResourceDTO);
}

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.admin.api; package cn.iocoder.mall.admin.api;
import cn.iocoder.mall.admin.api.dto.AccessLogAddDTO; import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogAddDTO;
import cn.iocoder.mall.admin.api.dto.ExceptionLogAddDTO; import cn.iocoder.mall.admin.api.dto.systemlog.ExceptionLogAddDTO;
/** /**
* Service * Service

View File

@ -1,49 +0,0 @@
package cn.iocoder.mall.admin.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* BO
*/
@Data
@Accessors(chain = true)
public class ResourceBO implements Serializable {
/**
*
*/
private Integer id;
/**
*
*/
private String name;
/**
*
*/
private Integer type;
/**
*
*/
private Integer sort;
/**
*
*/
private String displayName;
/**
*
*/
private Date createTime;
/**
*
*/
private Integer pid;
/**
*
*/
private String handler;
}

View File

@ -1,25 +0,0 @@
package cn.iocoder.mall.admin.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* BO
*/
@Data
@Accessors(chain = true)
public class RolePageBO implements Serializable {
/**
*
*/
private List<RoleBO> roles;
/**
*
*/
private Integer count;
}

View File

@ -22,7 +22,7 @@ public class AdminBO implements Serializable {
@ApiModelProperty(value = "昵称", required = true, example = "小王") @ApiModelProperty(value = "昵称", required = true, example = "小王")
private String nickname; private String nickname;
@ApiModelProperty(value = "账号状态", required = true, example = "1", dataType= "CommonStatusEnum") @ApiModelProperty(value = "账号状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
private Integer status; private Integer status;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.bo; package cn.iocoder.mall.admin.api.bo.datadict;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.bo; package cn.iocoder.mall.admin.api.bo.oauth2;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.bo; package cn.iocoder.mall.admin.api.bo.oauth2;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;

View File

@ -0,0 +1,40 @@
package cn.iocoder.mall.admin.api.bo.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
@ApiModel("资源 BO")
@Data
@Accessors(chain = true)
public class ResourceBO implements Serializable {
@ApiModelProperty(value = "资源编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "资源类型", required = true, example = "1")
private Integer type;
@ApiModelProperty(value = "排序", required = true, example = "1")
private Integer sort;
@ApiModelProperty(value = "菜单展示名", required = true, example = "商品管理")
private String displayName;
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
private Integer pid;
@ApiModelProperty(value = "操作", required = true, example = "/order/list")
private String handler;
@ApiModelProperty(value = "图标", example = "add")
private String icon;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
private Date createTime;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.bo; package cn.iocoder.mall.admin.api.bo.role;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;

View File

@ -28,6 +28,7 @@ public enum AdminErrorCodeEnum {
ADMIN_STATUS_EQUALS(1002002003, "账号已经是该状态"), ADMIN_STATUS_EQUALS(1002002003, "账号已经是该状态"),
ADMIN_DELETE_ONLY_DISABLE(1002002004, "只有关闭的账号才可以删除"), ADMIN_DELETE_ONLY_DISABLE(1002002004, "只有关闭的账号才可以删除"),
ADMIN_ADMIN_STATUS_CAN_NOT_UPDATE(1002002005, "管理员的账号状态不允许变更"), ADMIN_ADMIN_STATUS_CAN_NOT_UPDATE(1002002005, "管理员的账号状态不允许变更"),
ADMIN_ASSIGN_ROLE_NOT_EXISTS(1002002006, "分配员工角色时,有角色不存在"),
// ========== 资源模块 1002003000 ========== // ========== 资源模块 1002003000 ==========
RESOURCE_NAME_DUPLICATE(1002003000, "已经存在该名字的资源"), RESOURCE_NAME_DUPLICATE(1002003000, "已经存在该名字的资源"),
@ -35,6 +36,7 @@ public enum AdminErrorCodeEnum {
RESOURCE_PARENT_ERROR(1002003002, "不能设置自己为父资源"), RESOURCE_PARENT_ERROR(1002003002, "不能设置自己为父资源"),
RESOURCE_NOT_EXISTS(1002003003, "资源不存在"), RESOURCE_NOT_EXISTS(1002003003, "资源不存在"),
RESOURCE_EXISTS_CHILDREN(1002003004, "存在子资源,无法删除"), RESOURCE_EXISTS_CHILDREN(1002003004, "存在子资源,无法删除"),
RESOURCE_PARENT_NOT_MENU(1002003005, "父资源的类型必须是菜单"),
// ========== 角色模块 1002004000 ========== // ========== 角色模块 1002004000 ==========
ROLE_NOT_EXISTS(1002004000, "角色不存在"), ROLE_NOT_EXISTS(1002004000, "角色不存在"),
@ -62,4 +64,4 @@ public enum AdminErrorCodeEnum {
return message; return message;
} }
} }

View File

@ -10,13 +10,13 @@ public interface ResourceConstants {
*/ */
Integer TYPE_MENU = 1; Integer TYPE_MENU = 1;
/** /**
* - URL * -
*/ */
Integer TYPE_URL = 2; Integer TYPE_BUTTON = 2;
/** /**
* - * -
*/ */
Integer PID_ROOT = 0; Integer PID_ROOT = 0;
} }

View File

@ -1,46 +0,0 @@
package cn.iocoder.mall.admin.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* DTO
*/
@Data
@Accessors(chain = true)
public class ResourceAddDTO implements Serializable {
/**
*
*/
@NotEmpty(message = "资源名字不能为空")
private String name;
/**
*
*/
@NotNull(message = "类型不能为空")
private Integer type;
/**
*
*/
@NotNull(message = "类型不能为空")
private Integer sort;
/**
*
*/
@NotEmpty(message = "资源名字不能为空")
private String displayName;
/**
*
*/
private Integer pid;
/**
*
*/
private String handler;
}

View File

@ -1,46 +0,0 @@
package cn.iocoder.mall.admin.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* DTO
*/
@Data
@Accessors(chain = true)
public class ResourceUpdateDTO implements Serializable {
/**
*
*/
@NotNull(message = "资源编号不能为空")
private Integer id;
/**
*
*/
@NotEmpty(message = "资源名字不能为空")
private String name;
/**
*
*/
@NotNull(message = "类型不能为空")
private Integer sort;
/**
*
*/
@NotEmpty(message = "资源名字不能为空")
private String displayName;
/**
*
*/
private Integer pid;
/**
*
*/
private String handler;
}

View File

@ -1,45 +0,0 @@
package cn.iocoder.mall.admin.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* DTO
*/
@Data
@Accessors(chain = true)
public class RolePageDTO implements Serializable {
private Integer pageNo;
private Integer pageSize;
private String name;
public Integer getPageNo() {
return pageNo;
}
public RolePageDTO setPageNo(Integer pageNo) {
this.pageNo = pageNo;
return this;
}
public Integer getPageSize() {
return pageSize;
}
public RolePageDTO setPageSize(Integer pageSize) {
this.pageSize = pageSize;
return this;
}
public String getName() {
return name;
}
public RolePageDTO setName(String name) {
this.name = name;
return this;
}
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.mall.admin.api.dto.admin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Set;
@ApiModel("管理员分配角色 DTO")
@Data
@Accessors(chain = true)
public class AdminAssignRoleDTO {
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
@NotNull(message = "管理员编号不能为空")
private Integer id;
@ApiModelProperty(value = "角色编号数组", example = "1")
private Set<Integer> roleIds;
}

View File

@ -1,26 +1,20 @@
package cn.iocoder.mall.admin.api.dto.admin; package cn.iocoder.mall.admin.api.dto.admin;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull; @ApiModel(value = "管理员分页 DTO")
import java.io.Serializable;
/**
* DTO
*/
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class AdminPageDTO implements Serializable { public class AdminPageDTO extends PageParam {
/** /**
* *
*/ */
@ApiModelProperty(value = "昵称,模糊匹配", example = "小王")
private String nickname; private String nickname;
@NotNull(message = "页码不能为空")
private Integer pageNo;
@NotNull(message = "每页条数不能为空")
private Integer pageSize;
} }

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.admin.api.dto.admin; package cn.iocoder.mall.admin.api.dto.admin;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
@ -11,40 +11,27 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.io.Serializable; import java.io.Serializable;
/** @ApiModel("管理员更新 DTO")
* DTO
*/
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "管理员编号", required = true, example = "1"),
@ApiImplicitParam(name = "username", value = "账号", required = true, example = "15601691300"),
@ApiImplicitParam(name = "nickname", value = "昵称", required = true, example = "小王"),
@ApiImplicitParam(name = "password", value = "密码", example = "buzhidao"),
})
public class AdminUpdateDTO implements Serializable { public class AdminUpdateDTO implements Serializable {
/** @ApiModelProperty(value = "管理员编号", required = true, example = "1")
*
*/
@NotNull(message = "管理员编号不能为空") @NotNull(message = "管理员编号不能为空")
private Integer id; private Integer id;
/**
* @ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
*/
@NotEmpty(message = "登陆账号不能为空") @NotEmpty(message = "登陆账号不能为空")
@Length(min = 6, max = 16, message = "账号长度为 6-16 位") @Length(min = 6, max = 16, message = "账号长度为 6-16 位")
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
private String username; private String username;
/**
* @ApiModelProperty(value = "昵称", required = true, example = "小王")
*/
@NotEmpty(message = "昵称不能为空") @NotEmpty(message = "昵称不能为空")
@Length(max = 10, message = "昵称长度最大为 10 位") @Length(max = 10, message = "昵称长度最大为 10 位")
private String nickname; private String nickname;
/**
* @ApiModelProperty(value = "密码", example = "buzhidao")
*/
@Length(min = 6, max = 16, message = "密码长度为 6-16 位") @Length(min = 6, max = 16, message = "密码长度为 6-16 位")
private String password; private String password;

View File

@ -0,0 +1,26 @@
package cn.iocoder.mall.admin.api.dto.admin;
import cn.iocoder.common.framework.constant.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
@ApiModel("管理员更新状态 DTO")
@Data
@Accessors(chain = true)
public class AdminUpdateStatusDTO {
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
@NotNull(message = "管理员编号不能为空")
private Integer id;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.dto; package cn.iocoder.mall.admin.api.dto.datadict;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.dto; package cn.iocoder.mall.admin.api.dto.datadict;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;

View File

@ -0,0 +1,43 @@
package cn.iocoder.mall.admin.api.dto.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@ApiModel("资源添加 DTO")
@Data
@Accessors(chain = true)
public class ResourceAddDTO implements Serializable {
@ApiModelProperty(value = "资源类型。1 代表【菜单】2 代表【按钮】", required = true, example = "1")
@NotNull(message = "类型不能为空")
private Integer type;
@ApiModelProperty(value = "排序", required = true, example = "1")
@NotNull(message = "类型不能为空")
private Integer sort;
@ApiModelProperty(value = "菜单展示名", required = true, example = "商品管理")
@NotEmpty(message = "资源名字不能为空")
private String displayName;
@ApiModelProperty(value = "父级资源编号", required = true, example = "1")
@NotNull(message = "父级资源编号不能为空")
private Integer pid;
@ApiModelProperty(value = "操作", example = "/order/list")
private String handler;
@ApiModelProperty(value = "图标", example = "add")
private String icon;
@ApiModelProperty(value = "权限标识数组", example = "system.order.add,system.order.update")
private List<String> permissions;
}

View File

@ -0,0 +1,47 @@
package cn.iocoder.mall.admin.api.dto.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@ApiModel("资源更新 DTO")
@Data
@Accessors(chain = true)
public class ResourceUpdateDTO implements Serializable {
@ApiModelProperty(value = "资源编号", required = true, example = "1")
@NotNull(message = "资源编号不能为空")
private Integer id;
@ApiModelProperty(value = "资源类型。1 代表【菜单】2 代表【按钮】", required = true, example = "1")
@NotNull(message = "类型不能为空")
private Integer type;
@ApiModelProperty(value = "排序", required = true, example = "1")
@NotNull(message = "类型不能为空")
private Integer sort;
@ApiModelProperty(value = "菜单展示名", required = true, example = "商品管理")
@NotEmpty(message = "资源名字不能为空")
private String displayName;
@ApiModelProperty(value = "父级资源编号", required = true, example = "1")
@NotNull(message = "父级资源编号不能为空")
private Integer pid;
@ApiModelProperty(value = "操作", example = "/order/list")
private String handler;
@ApiModelProperty(value = "图标", example = "add")
private String icon;
@ApiModelProperty(value = "权限标识数组", example = "system.order.add,system.order.update")
private List<String> permissions;
}

View File

@ -1,21 +1,19 @@
package cn.iocoder.mall.admin.api.dto; package cn.iocoder.mall.admin.api.dto.role;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import java.io.Serializable; import java.io.Serializable;
/** @ApiModel("角色添加 DTO")
* DTO
*/
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class RoleAddDTO implements Serializable { public class RoleAddDTO implements Serializable {
/** @ApiModelProperty(name = "name", value = "角色名字(标识)", required = true, example = "系统管理员")
*
*/
@NotEmpty(message = "角色名字不能为空") @NotEmpty(message = "角色名字不能为空")
private String name; private String name;

View File

@ -0,0 +1,23 @@
package cn.iocoder.mall.admin.api.dto.role;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Set;
@ApiModel("角色分配资源 DTO")
@Data
@Accessors(chain = true)
public class RoleAssignResourceDTO {
@ApiModelProperty(value = "角色编号", required = true, example = "1")
@NotNull(message = "角色编号不能为空")
private Integer id;
@ApiModelProperty(value = "资源编号数组", example = "1,2")
private Set<Integer> resourceIds;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.mall.admin.api.dto.role;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ApiModel("角色分页 DTO")
@Data
@Accessors(chain = true)
public class RolePageDTO extends PageParam {
@ApiModelProperty( value = "角色名,模糊匹配", example = "系统管理员")
private String name;
}

View File

@ -1,5 +1,7 @@
package cn.iocoder.mall.admin.api.dto; package cn.iocoder.mall.admin.api.dto.role;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@ -7,21 +9,16 @@ import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
/** @ApiModel("角色添加 DTO")
* DTO
*/
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class RoleUpdateDTO implements Serializable { public class RoleUpdateDTO implements Serializable {
/** @ApiModelProperty(value = "角色编号", required = true, example = "1")
*
*/
@NotNull(message = "角色编号不能为空") @NotNull(message = "角色编号不能为空")
private Integer id; private Integer id;
/**
* @ApiModelProperty(value = "角色名", required = true, example = "系统管理员")
*/
@NotEmpty(message = "角色名字不能为空") @NotEmpty(message = "角色名字不能为空")
private String name; private String name;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.dto; package cn.iocoder.mall.admin.api.dto.systemlog;
import lombok.Data; import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.admin.api.dto; package cn.iocoder.mall.admin.api.dto.systemlog;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;

View File

@ -2,6 +2,7 @@ package cn.iocoder.mall.admin.config;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.injector.ISqlInjector; import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -19,4 +20,9 @@ public class DatabaseConfiguration {
return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除 return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除
} }
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor(); // MyBatis Plus 分页插件
}
} }

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.admin.convert; package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.admin.api.dto.AccessLogAddDTO; import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogAddDTO;
import cn.iocoder.mall.admin.api.dto.ExceptionLogAddDTO; import cn.iocoder.mall.admin.api.dto.systemlog.ExceptionLogAddDTO;
import cn.iocoder.mall.admin.dataobject.AccessLogDO; import cn.iocoder.mall.admin.dataobject.AccessLogDO;
import cn.iocoder.mall.admin.dataobject.ExceptionLogDO; import cn.iocoder.mall.admin.dataobject.ExceptionLogDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;

View File

@ -1,10 +1,13 @@
package cn.iocoder.mall.admin.convert; package cn.iocoder.mall.admin.convert;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.admin.api.bo.admin.AdminBO; import cn.iocoder.mall.admin.api.bo.admin.AdminBO;
import cn.iocoder.mall.admin.api.dto.admin.AdminAddDTO; import cn.iocoder.mall.admin.api.dto.admin.AdminAddDTO;
import cn.iocoder.mall.admin.api.dto.admin.AdminUpdateDTO; import cn.iocoder.mall.admin.api.dto.admin.AdminUpdateDTO;
import cn.iocoder.mall.admin.dataobject.AdminDO; import cn.iocoder.mall.admin.dataobject.AdminDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -27,4 +30,9 @@ public interface AdminConvert {
@Mappings({}) @Mappings({})
List<AdminBO> convert(List<AdminDO> adminBOs); List<AdminBO> convert(List<AdminDO> adminBOs);
@Mappings({
@Mapping(source = "records", target = "list"),
})
PageResult<AdminBO> convert(IPage<AdminDO> page);
} }

View File

@ -1,8 +1,8 @@
package cn.iocoder.mall.admin.convert; package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.admin.api.bo.DataDictBO; import cn.iocoder.mall.admin.api.bo.datadict.DataDictBO;
import cn.iocoder.mall.admin.api.dto.DataDictAddDTO; import cn.iocoder.mall.admin.api.dto.datadict.DataDictAddDTO;
import cn.iocoder.mall.admin.api.dto.DataDictUpdateDTO; import cn.iocoder.mall.admin.api.dto.datadict.DataDictUpdateDTO;
import cn.iocoder.mall.admin.dataobject.DataDictDO; import cn.iocoder.mall.admin.dataobject.DataDictDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -22,4 +22,4 @@ public interface DataDictConvert {
List<DataDictBO> convert(List<DataDictDO> dataDictDOs); List<DataDictBO> convert(List<DataDictDO> dataDictDOs);
} }

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.admin.convert; package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.admin.api.bo.OAuth2AccessTokenBO; import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AccessTokenBO;
import cn.iocoder.mall.admin.api.bo.OAuth2AuthenticationBO; import cn.iocoder.mall.admin.api.bo.oauth2.OAuth2AuthenticationBO;
import cn.iocoder.mall.admin.dataobject.AdminRoleDO; import cn.iocoder.mall.admin.dataobject.AdminRoleDO;
import cn.iocoder.mall.admin.dataobject.OAuth2AccessTokenDO; import cn.iocoder.mall.admin.dataobject.OAuth2AccessTokenDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
@ -35,4 +35,4 @@ public interface OAuth2Convert {
.setRoleIds(adminRoleDOs.stream().map(AdminRoleDO::getRoleId).collect(Collectors.toSet())); .setRoleIds(adminRoleDOs.stream().map(AdminRoleDO::getRoleId).collect(Collectors.toSet()));
} }
} }

View File

@ -1,11 +1,14 @@
package cn.iocoder.mall.admin.convert; package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.admin.api.bo.ResourceBO; import cn.iocoder.common.framework.util.StringUtil;
import cn.iocoder.mall.admin.api.dto.ResourceAddDTO; import cn.iocoder.mall.admin.api.bo.resource.ResourceBO;
import cn.iocoder.mall.admin.api.dto.ResourceUpdateDTO; import cn.iocoder.mall.admin.api.dto.resource.ResourceAddDTO;
import cn.iocoder.mall.admin.api.dto.resource.ResourceUpdateDTO;
import cn.iocoder.mall.admin.dataobject.ResourceDO; import cn.iocoder.mall.admin.dataobject.ResourceDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.List; import java.util.List;
@ -15,7 +18,9 @@ public interface ResourceConvert {
ResourceConvert INSTANCE = Mappers.getMapper(ResourceConvert.class); ResourceConvert INSTANCE = Mappers.getMapper(ResourceConvert.class);
@Mappings({}) @Mappings({
@Mapping(source = "permissions", target = "permissions", qualifiedByName = "translateListFromString")
})
ResourceBO convert(ResourceDO resourceDO); ResourceBO convert(ResourceDO resourceDO);
@Mappings({}) @Mappings({})
@ -27,4 +32,9 @@ public interface ResourceConvert {
@Mappings({}) @Mappings({})
ResourceDO convert(ResourceUpdateDTO resourceUpdateDTO); ResourceDO convert(ResourceUpdateDTO resourceUpdateDTO);
} @Named("translateListFromString")
default List<String> translateListFromString(String picUrls) {
return StringUtil.split(picUrls, ",");
}
}

View File

@ -1,10 +1,13 @@
package cn.iocoder.mall.admin.convert; package cn.iocoder.mall.admin.convert;
import cn.iocoder.mall.admin.api.bo.RoleBO; import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.admin.api.dto.RoleAddDTO; import cn.iocoder.mall.admin.api.bo.role.RoleBO;
import cn.iocoder.mall.admin.api.dto.RoleUpdateDTO; import cn.iocoder.mall.admin.api.dto.role.RoleAddDTO;
import cn.iocoder.mall.admin.api.dto.role.RoleUpdateDTO;
import cn.iocoder.mall.admin.dataobject.RoleDO; import cn.iocoder.mall.admin.dataobject.RoleDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -27,4 +30,9 @@ public interface RoleConvert {
@Mappings({}) @Mappings({})
List<RoleBO> convert(List<RoleDO> roleDOs); List<RoleBO> convert(List<RoleDO> roleDOs);
} @Mappings({
@Mapping(source = "records", target = "list"),
})
PageResult<RoleBO> convert(IPage<RoleDO> page);
}

View File

@ -1,13 +1,15 @@
package cn.iocoder.mall.admin.dao; package cn.iocoder.mall.admin.dao;
import cn.iocoder.common.framework.mybatis.QueryWrapperX;
import cn.iocoder.mall.admin.api.dto.admin.AdminPageDTO;
import cn.iocoder.mall.admin.dataobject.AdminDO; import cn.iocoder.mall.admin.dataobject.AdminDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public interface AdminMapper extends BaseMapper<AdminDO> { public interface AdminMapper extends BaseMapper<AdminDO> {
@ -15,12 +17,9 @@ public interface AdminMapper extends BaseMapper<AdminDO> {
return selectOne(new QueryWrapper<AdminDO>().eq("username", username)); return selectOne(new QueryWrapper<AdminDO>().eq("username", username));
} }
List<AdminDO> selectListByNicknameLike(@Param("nickname") String nickname, default IPage<AdminDO> selectPage(AdminPageDTO adminPageDTO) {
@Param("offset") Integer offset, return selectPage(new Page<>(adminPageDTO.getPageNo(), adminPageDTO.getPageSize()),
@Param("limit") Integer limit); new QueryWrapperX<AdminDO>().likeIfPresent("nickname", adminPageDTO.getNickname()));
}
Integer selectCountByNicknameLike(@Param("nickname") String nickname);
int update(AdminDO admin);
} }

View File

@ -1,20 +1,27 @@
package cn.iocoder.mall.admin.dao; package cn.iocoder.mall.admin.dao;
import cn.iocoder.mall.admin.dataobject.AdminRoleDO; import cn.iocoder.mall.admin.dataobject.AdminRoleDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List; import java.util.List;
@Repository @Repository
public interface AdminRoleMapper { public interface AdminRoleMapper extends BaseMapper<AdminRoleDO> {
List<AdminRoleDO> selectByAdminId(@Param("adminId") Integer adminId); List<AdminRoleDO> selectByAdminId(@Param("adminId") Integer adminId);
default List<AdminRoleDO> selectListByAdminIds(Collection<Integer> adminIds) {
return selectList(new QueryWrapper<AdminRoleDO>().in("admin_id", adminIds));
}
int updateToDeletedByAdminId(@Param("adminId") Integer adminId); int updateToDeletedByAdminId(@Param("adminId") Integer adminId);
int updateToDeletedByRoleId(@Param("roleId") Integer roleId); int updateToDeletedByRoleId(@Param("roleId") Integer roleId);
void insertList(@Param("adminRoleDOs") List<AdminRoleDO> adminRoleDOs); void insertList(@Param("adminRoleDOs") List<AdminRoleDO> adminRoleDOs);
} }

View File

@ -1,29 +1,31 @@
package cn.iocoder.mall.admin.dao; package cn.iocoder.mall.admin.dao;
import cn.iocoder.common.framework.mybatis.QueryWrapperX;
import cn.iocoder.mall.admin.api.dto.role.RolePageDTO;
import cn.iocoder.mall.admin.dataobject.RoleDO; import cn.iocoder.mall.admin.dataobject.RoleDO;
import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set;
@Repository @Repository
public interface RoleMapper { public interface RoleMapper extends BaseMapper<RoleDO> {
void insert(RoleDO roleDO); default List<RoleDO> selectListByIds(Collection<Integer> ids) {
return selectList(new QueryWrapper<RoleDO>().in("id", ids));
}
int update(RoleDO roleDO); default List<RoleDO> selectList() {
return selectList(new QueryWrapper<>());
}
RoleDO selectById(@Param("id") Integer id); default IPage<RoleDO> selectPage(RolePageDTO rolePageDTO) {
return selectPage(new Page<>(rolePageDTO.getPageNo(), rolePageDTO.getPageSize()),
new QueryWrapperX<RoleDO>().likeIfPresent("name", rolePageDTO.getName()));
}
List<RoleDO> selectListByNameLike(@Param("name") String name, }
@Param("offset") Integer offset,
@Param("limit") Integer limit);
Integer selectCountByNameLike(@Param("name") String name);
List<RoleDO> selectListByIds(@Param("ids") Set<Integer> ids);
List<RoleDO> selectList();
}

Some files were not shown because too many files have changed in this diff Show More