Commit 4c3c758b authored by Junling Bu's avatar Junling Bu
Browse files

feat[litemall-admin, litemall-admin-api, litemall-db]: 支持权限管理

parent 835fd6f8
......@@ -3,6 +3,7 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
......@@ -28,6 +29,7 @@ public class AdminIssueController {
private LitemallIssueService issueService;
@RequiresPermissions("admin:issue:list")
@RequiresPermissionsDesc(menu={"商城管理" , "通用问题"}, button="查询")
@GetMapping("/list")
public Object list(String question,
@RequestParam(defaultValue = "1") Integer page,
......@@ -56,6 +58,7 @@ public class AdminIssueController {
}
@RequiresPermissions("admin:issue:create")
@RequiresPermissionsDesc(menu={"商城管理" , "通用问题"}, button="添加")
@PostMapping("/create")
public Object create(@RequestBody LitemallIssue issue) {
Object error = validate(issue);
......@@ -74,6 +77,7 @@ public class AdminIssueController {
}
@RequiresPermissions("admin:issue:update")
@RequiresPermissionsDesc(menu={"商城管理" , "通用问题"}, button="编辑")
@PostMapping("/update")
public Object update(@RequestBody LitemallIssue issue) {
Object error = validate(issue);
......@@ -88,6 +92,7 @@ public class AdminIssueController {
}
@RequiresPermissions("admin:issue:delete")
@RequiresPermissionsDesc(menu={"商城管理" , "通用问题"}, button="删除")
@PostMapping("/delete")
public Object delete(@RequestBody LitemallIssue issue) {
Integer id = issue.getId();
......
......@@ -3,6 +3,7 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
......@@ -28,6 +29,7 @@ public class AdminKeywordController {
private LitemallKeywordService keywordService;
@RequiresPermissions("admin:keyword:list")
@RequiresPermissionsDesc(menu={"商城管理" , "关键词"}, button="查询")
@GetMapping("/list")
public Object list(String keyword, String url,
@RequestParam(defaultValue = "1") Integer page,
......@@ -56,6 +58,7 @@ public class AdminKeywordController {
}
@RequiresPermissions("admin:keyword:create")
@RequiresPermissionsDesc(menu={"商城管理" , "关键词"}, button="添加")
@PostMapping("/create")
public Object create(@RequestBody LitemallKeyword keywords) {
Object error = validate(keywords);
......@@ -67,6 +70,7 @@ public class AdminKeywordController {
}
@RequiresPermissions("admin:keyword:read")
@RequiresPermissionsDesc(menu={"商城管理" , "关键词"}, button="详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
LitemallKeyword brand = keywordService.findById(id);
......@@ -74,6 +78,7 @@ public class AdminKeywordController {
}
@RequiresPermissions("admin:keyword:update")
@RequiresPermissionsDesc(menu={"商城管理" , "关键词"}, button="编辑")
@PostMapping("/update")
public Object update(@RequestBody LitemallKeyword keywords) {
Object error = validate(keywords);
......@@ -87,6 +92,7 @@ public class AdminKeywordController {
}
@RequiresPermissions("admin:keyword:delete")
@RequiresPermissionsDesc(menu={"商城管理" , "关键词"}, button="删除")
@PostMapping("/delete")
public Object delete(@RequestBody LitemallKeyword keyword) {
Integer id = keyword.getId();
......
......@@ -7,6 +7,7 @@ import com.github.binarywang.wxpay.service.WxPayService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.notify.NotifyService;
import org.linlinjava.litemall.core.notify.NotifyType;
import org.linlinjava.litemall.core.util.JacksonUtil;
......@@ -62,6 +63,7 @@ public class AdminOrderController {
private NotifyService notifyService;
@RequiresPermissions("admin:order:list")
@RequiresPermissionsDesc(menu={"商城管理" , "订单管理"}, button="查询")
@GetMapping("/list")
public Object list(Integer userId, String orderSn,
@RequestParam(required = false) List<Short> orderStatusArray,
......@@ -80,6 +82,7 @@ public class AdminOrderController {
}
@RequiresPermissions("admin:order:read")
@RequiresPermissionsDesc(menu={"商城管理" , "订单管理"}, button="详情")
@GetMapping("/detail")
public Object detail(@NotNull Integer id) {
LitemallOrder order = orderService.findById(id);
......@@ -106,11 +109,11 @@ public class AdminOrderController {
* 1. 管理员登录微信官方支付平台点击退款操作进行退款
* 2. 管理员登录litemall管理后台点击退款操作进行订单状态修改和商品库存回库
*
* @param adminId 管理员ID
* @param body 订单信息,{ orderId:xxx }
* @return 订单退款操作结果
*/
@RequiresPermissions("admin:order:refund")
@RequiresPermissionsDesc(menu={"商城管理" , "订单管理"}, button="订单退款")
@PostMapping("refund")
public Object refund(@RequestBody String body) {
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
......@@ -202,13 +205,13 @@ public class AdminOrderController {
* 1. 检测当前订单是否能够发货
* 2. 设置订单发货状态
*
* @param adminId 管理员ID
* @param body 订单信息,{ orderId:xxx, shipSn: xxx, shipChannel: xxx }
* @return 订单操作结果
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@RequiresPermissions("admin:order:ship")
@RequiresPermissionsDesc(menu={"商城管理" , "订单管理"}, button="订单发货")
@PostMapping("ship")
public Object ship(@RequestBody String body) {
Integer orderId = JacksonUtil.parseInteger(body, "orderId");
......@@ -248,13 +251,13 @@ public class AdminOrderController {
/**
* 回复订单商品
*
* @param adminId 管理员ID
* @param body 订单信息,{ orderId:xxx }
* @return 订单操作结果
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@RequiresPermissions("admin:order:reply")
@RequiresPermissionsDesc(menu={"商城管理" , "订单管理"}, button="订单商品回复")
@PostMapping("reply")
public Object reply(@RequestBody String body) {
Integer commentId = JacksonUtil.parseInteger(body, "commentId");
......
package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.admin.util.AdminResponseCode;
import org.linlinjava.litemall.admin.util.PermVo;
import org.linlinjava.litemall.admin.util.PermissionUtil;
import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallAdmin;
import org.linlinjava.litemall.db.domain.LitemallBrand;
import org.linlinjava.litemall.db.domain.LitemallPermission;
import org.linlinjava.litemall.db.domain.LitemallRole;
import org.linlinjava.litemall.db.service.LitemallPermissionService;
import org.linlinjava.litemall.db.service.LitemallRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.*;
import static org.linlinjava.litemall.admin.util.AdminResponseCode.ROLE_NAME_EXIST;
@RestController
@RequestMapping("/admin/role")
@Validated
public class AdminRoleController {
private final Log logger = LogFactory.getLog(AdminRoleController.class);
@Autowired
private LitemallRoleService roleService;
@Autowired
private LitemallPermissionService permissionService;
@RequiresPermissions("admin:role:list")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="查询")
@GetMapping("/list")
public Object list(String name,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
List<LitemallRole> roleList = roleService.querySelective(name, page, limit, sort, order);
int total = roleService.countSelective(name, page, limit, sort, order);
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", roleList);
return ResponseUtil.ok(data);
}
@RequiresPermissions("admin:role:list")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="查询")
@GetMapping("/options")
public Object options(){
List<LitemallRole> roleList = roleService.queryAll();
List<Map<String, Object>> options = new ArrayList<>(roleList.size());
for (LitemallRole role : roleList) {
Map<String, Object> option = new HashMap<>(2);
option.put("value", role.getId());
option.put("label", role.getName());
options.add(option);
}
return ResponseUtil.ok(options);
}
@RequiresPermissions("admin:role:read")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
LitemallRole role = roleService.findById(id);
return ResponseUtil.ok(role);
}
private Object validate(LitemallRole role) {
String name = role.getName();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
return null;
}
@RequiresPermissions("admin:role:create")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="添加")
@PostMapping("/create")
public Object create(@RequestBody LitemallRole role) {
Object error = validate(role);
if (error != null) {
return error;
}
if (roleService.checkExist(role.getName())){
return ResponseUtil.fail(ROLE_NAME_EXIST, "角色已经存在");
}
roleService.add(role);
return ResponseUtil.ok(role);
}
@RequiresPermissions("admin:role:update")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="编辑")
@PostMapping("/update")
public Object update(@RequestBody LitemallRole role) {
Object error = validate(role);
if (error != null) {
return error;
}
roleService.updateById(role);
return ResponseUtil.ok();
}
@RequiresPermissions("admin:role:delete")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="删除")
@PostMapping("/delete")
public Object delete(@RequestBody LitemallRole role) {
Integer id = role.getId();
if (id == null) {
return ResponseUtil.badArgument();
}
roleService.deleteById(id);
return ResponseUtil.ok();
}
@Autowired
private ApplicationContext context;
private List<PermVo> systemPermissions = null;
private List<PermVo> getSystemPermissions(){
final String basicPackage = "org.linlinjava.litemall.admin";
if(systemPermissions == null){
systemPermissions = PermissionUtil.listPermissions(context, basicPackage);
}
return systemPermissions;
}
private Set<String> getSystemPermissionsString(){
getSystemPermissions();
Set<String> permissions = new HashSet<String>();
for(PermVo permVo : systemPermissions){
permissions.add(permVo.getId());
}
return permissions;
}
private Set<String> getAssignedPermissions(Integer roleId){
// 这里需要注意的是,如果存在超级权限*,那么这里需要转化成当前所有系统权限。
// 之所以这么做,是因为前端不能识别超级权限,所以这里需要转换一下。
Set<String> assignedPermissions = null;
if(permissionService.checkSuperPermission(roleId)){
assignedPermissions = getSystemPermissionsString();
}
else{
assignedPermissions = permissionService.queryByRoleId(roleId);
}
return assignedPermissions;
}
/**
* 管理员的权限情况
*
* @return 系统所有权限列表和管理员已分配权限
*/
@RequiresPermissions("admin:role:permission")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="授权")
@GetMapping("/permissions")
public Object getPermissions(Integer roleId) {
List<PermVo> systemPermissions = getSystemPermissions();
Set<String> assignedPermissions = getAssignedPermissions(roleId);
Map<String, Object> data = new HashMap<>();
data.put("systemPermissions", systemPermissions);
data.put("assignedPermissions", assignedPermissions);
return ResponseUtil.ok(data);
}
/**
* 更新管理员的权限
*
* @param body
* @return
*/
@RequiresPermissions("admin:role:permission")
@RequiresPermissionsDesc(menu={"系统管理" , "角色管理"}, button="授权")
@PostMapping("/permissions")
public Object updatePermissions(@RequestBody String body) {
Integer roleId = JacksonUtil.parseInteger(body, "roleId");
List<String> permissions = JacksonUtil.parseStringList(body, "permissions");
// 如果修改的角色是超级权限,则拒绝修改。
if(permissionService.checkSuperPermission(roleId)){
return ResponseUtil.fail(AdminResponseCode.ROLE_SUPER_SUPERMISSION, "当前角色的超级权限不能变更");
}
// 先删除旧的权限,再更新新的权限
permissionService.deleteByRoleId(roleId);
for(String permission : permissions){
LitemallPermission litemallPermission = new LitemallPermission();
litemallPermission.setRoleId(roleId);
litemallPermission.setPermission(permission);
permissionService.add(litemallPermission);
}
return ResponseUtil.ok();
}
}
......@@ -3,6 +3,7 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.admin.util.StatVo;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.service.StatService;
......@@ -25,6 +26,7 @@ public class AdminStatController {
private StatService statService;
@RequiresPermissions("admin:stat:user")
@RequiresPermissionsDesc(menu={"统计管理" , "用户统计"}, button="查询")
@GetMapping("/user")
public Object statUser() {
List<Map> rows = statService.statUser();
......@@ -36,6 +38,7 @@ public class AdminStatController {
}
@RequiresPermissions("admin:stat:order")
@RequiresPermissionsDesc(menu={"统计管理" , "订单统计"}, button="查询")
@GetMapping("/order")
public Object statOrder() {
List<Map> rows = statService.statOrder();
......@@ -48,6 +51,7 @@ public class AdminStatController {
}
@RequiresPermissions("admin:stat:goods")
@RequiresPermissionsDesc(menu={"统计管理" , "商品统计"}, button="查询")
@GetMapping("/goods")
public Object statGoods() {
List<Map> rows = statService.statGoods();
......
......@@ -3,6 +3,7 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.storage.StorageService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
......@@ -33,6 +34,7 @@ public class AdminStorageController {
private LitemallStorageService litemallStorageService;
@RequiresPermissions("admin:storage:list")
@RequiresPermissionsDesc(menu={"系统管理" , "对象存储"}, button="查询")
@GetMapping("/list")
public Object list(String key, String name,
@RequestParam(defaultValue = "1") Integer page,
......@@ -49,6 +51,7 @@ public class AdminStorageController {
}
@RequiresPermissions("admin:storage:create")
@RequiresPermissionsDesc(menu={"系统管理" , "对象存储"}, button="上传")
@PostMapping("/create")
public Object create(@RequestParam("file") MultipartFile file) throws IOException {
String originalFilename = file.getOriginalFilename();
......@@ -59,6 +62,7 @@ public class AdminStorageController {
}
@RequiresPermissions("admin:storage:read")
@RequiresPermissionsDesc(menu={"系统管理" , "对象存储"}, button="详情")
@PostMapping("/read")
public Object read(@NotNull Integer id) {
LitemallStorage storageInfo = litemallStorageService.findById(id);
......@@ -68,7 +72,8 @@ public class AdminStorageController {
return ResponseUtil.ok(storageInfo);
}
@RequiresPermissions("admin:storage:delete")
@RequiresPermissions("admin:storage:update")
@RequiresPermissionsDesc(menu={"系统管理" , "对象存储"}, button="编辑")
@PostMapping("/update")
public Object update(@RequestBody LitemallStorage litemallStorage) {
if (litemallStorageService.update(litemallStorage) == 0) {
......@@ -78,6 +83,7 @@ public class AdminStorageController {
}
@RequiresPermissions("admin:storage:delete")
@RequiresPermissionsDesc(menu={"系统管理" , "对象存储"}, button="删除")
@PostMapping("/delete")
public Object delete(@RequestBody LitemallStorage litemallStorage) {
String key = litemallStorage.getKey();
......
......@@ -3,6 +3,7 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
......@@ -29,6 +30,7 @@ public class AdminTopicController {
private LitemallTopicService topicService;
@RequiresPermissions("admin:topic:list")
@RequiresPermissionsDesc(menu={"推广管理" , "专题管理"}, button="查询")
@GetMapping("/list")
public Object list(String title, String subtitle,
@RequestParam(defaultValue = "1") Integer page,
......@@ -61,6 +63,7 @@ public class AdminTopicController {
}
@RequiresPermissions("admin:topic:create")
@RequiresPermissionsDesc(menu={"推广管理" , "专题管理"}, button="添加")
@PostMapping("/create")
public Object create(@RequestBody LitemallTopic topic) {
Object error = validate(topic);
......@@ -72,6 +75,7 @@ public class AdminTopicController {
}
@RequiresPermissions("admin:topic:read")
@RequiresPermissionsDesc(menu={"推广管理" , "专题管理"}, button="详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
LitemallTopic topic = topicService.findById(id);
......@@ -79,6 +83,7 @@ public class AdminTopicController {
}
@RequiresPermissions("admin:topic:update")
@RequiresPermissionsDesc(menu={"推广管理" , "专题管理"}, button="编辑")
@PostMapping("/update")
public Object update(@RequestBody LitemallTopic topic) {
Object error = validate(topic);
......@@ -92,6 +97,7 @@ public class AdminTopicController {
}
@RequiresPermissions("admin:topic:delete")
@RequiresPermissionsDesc(menu={"推广管理" , "专题管理"}, button="删除")
@PostMapping("/delete")
public Object delete(@RequestBody LitemallTopic topic) {
topicService.deleteById(topic.getId());
......
......@@ -3,6 +3,7 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.util.RegexUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.util.bcrypt.BCryptPasswordEncoder;
......@@ -32,6 +33,7 @@ public class AdminUserController {
private LitemallUserService userService;
@RequiresPermissions("admin:user:list")
@RequiresPermissionsDesc(menu={"用户管理" , "会员管理"}, button="查询")
@GetMapping("/list")
public Object list(String username, String mobile,
@RequestParam(defaultValue = "1") Integer page,
......@@ -48,6 +50,7 @@ public class AdminUserController {
}
@RequiresPermissions("admin:user:list")
@RequiresPermissionsDesc(menu={"用户管理" , "会员管理"}, button="查询")
@GetMapping("/username")
public Object username(@NotEmpty String username) {
int total = userService.countSeletive(username, null, null, null, null, null);
......@@ -80,6 +83,7 @@ public class AdminUserController {
}
@RequiresPermissions("admin:user:create")
@RequiresPermissionsDesc(menu={"用户管理" , "会员管理"}, button="添加")
@PostMapping("/create")
public Object create(@RequestBody LitemallUser user) {
Object error = validate(user);
......@@ -110,6 +114,7 @@ public class AdminUserController {
}
@RequiresPermissions("admin:user:update")
@RequiresPermissionsDesc(menu={"用户管理" , "会员管理"}, button="编辑")
@PostMapping("/update")
public Object update(@RequestBody LitemallUser user) {
Object error = validate(user);
......
package org.linlinjava.litemall.admin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.linlinjava.litemall.admin.util.PermVo;
import org.linlinjava.litemall.admin.util.PermissionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.List;
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class PermissionTest {
@Autowired
private ApplicationContext context;
@Test
public void test() {
final String basicPackage = "org.linlinjava.litemall.admin";
List<PermVo> permVoList = PermissionUtil.listPermissions(context, basicPackage);
permVoList.stream().forEach(System.out::println);
}
}
......@@ -22,6 +22,7 @@
},
"dependencies": {
"@tinymce/tinymce-vue": "1.1.0",
"@riophae/vue-treeselect": "0.0.37",
"v-charts": "1.19.0",
"axios": "0.18.0",
"clipboard": "1.7.1",
......
import request from '@/utils/request'
export function listRole(query) {
return request({
url: '/role/list',
method: 'get',
params: query
})
}
export function createRole(data) {
return request({
url: '/role/create',
method: 'post',
data
})
}
export function readRole(data) {
return request({
url: '/role/read',
method: 'get',
data
})
}
export function updateRole(data) {
return request({
url: '/role/update',
method: 'post',
data
})
}
export function deleteRole(data) {
return request({
url: '/role/delete',
method: 'post',
data
})
}
export function getPermission(query) {
return request({
url: '/role/permissions',
method: 'get',
params: query
})
}
export function updatePermission(data) {
return request({
url: '/role/permissions',
method: 'post',
data
})
}
export function roleOptions(query) {
return request({
url: '/role/options',
method: 'get',
params: query
})
}
......@@ -279,6 +279,12 @@ export const asyncRouterMap = [
name: 'admin',
meta: { title: '管理员', noCache: true }
},
{
path: 'role',
component: () => import('@/views/sys/role'),
name: 'role',
meta: { title: '角色管理', noCache: true }
},
{
path: 'os',
component: () => import('@/views/sys/os'),
......@@ -363,6 +369,12 @@ export const asyncRouterMap = [
component: Layout,
redirect: 'noredirect',
children: [
{
path: 'my',
component: () => import('@/views/profile/my'),
name: 'my',
meta: { title: '个人信息', noCache: true }
},
{
path: 'password',
component: () => import('@/views/profile/password'),
......
......@@ -32,7 +32,7 @@ service.interceptors.response.use(
const res = response.data
if (res.errno === 501) {
MessageBox.alert('系统未登录,请重新登录', '未登录', {
MessageBox.alert('系统未登录,请重新登录', '错误', {
confirmButtonText: '确定',
type: 'error'
}).then(() => {
......@@ -53,6 +53,24 @@ service.interceptors.response.use(
type: 'error'
})
return Promise.reject('error')
} else if (res.errno === 504) {
MessageBox.alert('更新数据已经失效,请刷新页面重新操作', '警告', {
confirmButtonText: '确定',
type: 'error'
})
return Promise.reject('error')
} else if (res.errno === 505) {
MessageBox.alert('更新失败,请再尝试一次', '警告', {
confirmButtonText: '确定',
type: 'error'
})
return Promise.reject('error')
} else if (res.errno === 506) {
MessageBox.alert('没有操作权限,请联系管理员授权', '错误', {
confirmButtonText: '确定',
type: 'error'
})
return Promise.reject('error')
} else if (res.errno !== 0) {
// 非5xx的错误属于业务错误,留给具体页面处理
return Promise.reject(response)
......
......@@ -21,6 +21,12 @@
</template>
</el-table-column>
<el-table-column align="center" label="管理员角色" prop="roleIds">
<template slot-scope="scope">
<el-tag v-for="roleId in scope.row.roleIds" :key="roleId" type="primary" style="margin-right: 20px;"> {{ formatRole(roleId) }} </el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="操作" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
......@@ -46,6 +52,15 @@
<i v-else class="el-icon-plus avatar-uploader-icon"/>
</el-upload>
</el-form-item>
<el-form-item label="管理员角色" prop="roleIds">
<el-select v-model="dataForm.roleIds" multiple placeholder="请选择">
<el-option
v-for="item in roleOptions"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
......@@ -85,6 +100,7 @@
<script>
import { listAdmin, createAdmin, updateAdmin, deleteAdmin } from '@/api/admin'
import { roleOptions } from '@/api/role'
import { uploadPath } from '@/api/storage'
import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
......@@ -97,6 +113,7 @@ export default {
uploadPath,
list: null,
total: 0,
roleOptions: null,
listLoading: true,
listQuery: {
page: 1,
......@@ -109,7 +126,8 @@ export default {
id: undefined,
username: undefined,
password: undefined,
avatar: undefined
avatar: undefined,
roleIds: []
},
dialogFormVisible: false,
dialogStatus: '',
......@@ -135,8 +153,21 @@ export default {
},
created() {
this.getList()
roleOptions()
.then(response => {
this.roleOptions = response.data.data
})
},
methods: {
formatRole(roleId) {
for (let i = 0; i < this.roleOptions.length; i++) {
if (roleId === this.roleOptions[i].value) {
return this.roleOptions[i].label
}
}
return ''
},
getList() {
this.listLoading = true
listAdmin(this.listQuery)
......@@ -160,7 +191,8 @@ export default {
id: undefined,
username: undefined,
password: undefined,
avatar: undefined
avatar: undefined,
roleIds: []
}
},
uploadAvatar: function(response) {
......
<template>
<div class="app-container">
<!-- 查询和其他操作 -->
<div class="filter-container">
<el-input v-model="listQuery.rolename" clearable class="filter-item" style="width: 200px;" placeholder="请输入角色名称"/>
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
<el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">添加</el-button>
</div>
<!-- 查询结果 -->
<el-table v-loading="listLoading" :data="list" size="small" element-loading-text="正在查询中。。。" border fit highlight-current-row>
<el-table-column align="center" label="角色名称" prop="name" sortable/>
<el-table-column align="center" label="说明" prop="desc"/>
<el-table-column align="center" label="操作" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
<el-button type="primary" size="mini" @click="handlePermission(scope.row)">授权</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
<!-- 添加或修改对话框 -->
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
<el-form ref="dataForm" :rules="rules" :model="dataForm" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
<el-form-item label="角色名称" prop="name">
<el-input v-model="dataForm.name"/>
</el-form-item>
<el-form-item label="说明" prop="desc">
<el-input v-model="dataForm.desc"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button v-if="dialogStatus=='create'" type="primary" @click="createData">确定</el-button>
<el-button v-else type="primary" @click="updateData">确定</el-button>
</div>
</el-dialog>
<!-- 权限配置对话框 -->
<el-dialog :visible.sync="permissionDialogFormVisible" title="权限配置">
<el-tree
ref="tree"
:data="systemPermissions"
:default-checked-keys="assignedPermissions"
show-checkbox
node-key="id"
highlight-current/>
<div slot="footer" class="dialog-footer">
<el-button @click="permissionDialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="updatePermission">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listRole, createRole, updateRole, deleteRole, getPermission, updatePermission } from '@/api/role'
import Pagination from '@/components/Pagination'
export default {
name: 'Role',
components: { Pagination },
data() {
return {
list: null,
total: 0,
listLoading: true,
listQuery: {
page: 1,
limit: 20,
name: undefined,
sort: 'add_time',
order: 'desc'
},
dataForm: {
id: undefined,
name: undefined,
desc: undefined
},
dialogFormVisible: false,
dialogStatus: '',
textMap: {
update: '编辑',
create: '创建'
},
rules: {
name: [
{ required: true, message: '角色名称不能为空', trigger: 'blur' }
]
},
permissionDialogFormVisible: false,
systemPermissions: null,
assignedPermissions: null,
permissionForm: {
roleId: undefined,
permissions: []
}
}
},
created() {
this.getList()
},
methods: {
getList() {
this.listLoading = true
listRole(this.listQuery)
.then(response => {
this.list = response.data.data.items
this.total = response.data.data.total
this.listLoading = false
})
.catch(() => {
this.list = []
this.total = 0
this.listLoading = false
})
},
handleFilter() {
this.listQuery.page = 1
this.getList()
},
resetForm() {
this.dataForm = {
id: undefined,
name: undefined,
desc: undefined
}
},
handleCreate() {
this.resetForm()
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
createData() {
this.$refs['dataForm'].validate(valid => {
if (valid) {
createRole(this.dataForm)
.then(response => {
this.list.unshift(response.data.data)
this.dialogFormVisible = false
this.$notify.success({
title: '成功',
message: '添加角色成功'
})
})
.catch(response => {
this.$notify.error({
title: '失败',
message: response.data.errmsg
})
})
}
})
},
handleUpdate(row) {
this.dataForm = Object.assign({}, row)
this.dialogStatus = 'update'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
updateData() {
this.$refs['dataForm'].validate(valid => {
if (valid) {
updateRole(this.dataForm)
.then(() => {
for (const v of this.list) {
if (v.id === this.dataForm.id) {
const index = this.list.indexOf(v)
this.list.splice(index, 1, this.dataForm)
break
}
}
this.dialogFormVisible = false
this.$notify.success({
title: '成功',
message: '更新管理员成功'
})
})
.catch(response => {
this.$notify.error({
title: '失败',
message: response.data.errmsg
})
})
}
})
},
handleDelete(row) {
deleteRole(row)
.then(response => {
this.$notify.success({
title: '成功',
message: '删除管理员成功'
})
const index = this.list.indexOf(row)
this.list.splice(index, 1)
})
.catch(response => {
this.$notify.error({
title: '失败',
message: response.data.errmsg
})
})
},
handlePermission(row) {
this.permissionDialogFormVisible = true
this.permissionForm.roleId = row.id
getPermission({ roleId: row.id })
.then(response => {
this.systemPermissions = response.data.data.systemPermissions
this.assignedPermissions = response.data.data.assignedPermissions
})
},
updatePermission() {
this.permissionForm.permissions = this.$refs.tree.getCheckedKeys(true)
updatePermission(this.permissionForm)
.then(response => {
this.permissionDialogFormVisible = false
this.$notify.success({
title: '成功',
message: '授权成功'
})
})
.catch(response => {
this.$notify.error({
title: '失败',
message: response.data.errmsg
})
})
}
}
}
</script>
......@@ -64,6 +64,8 @@
</table>
<table tableName="litemall_admin">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="role_ids" javaType="java.lang.Integer[]"
typeHandler="org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler"/>
</table>
<table tableName="litemall_brand">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
......@@ -166,5 +168,11 @@
<table tableName="litemall_coupon_user">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="litemall_role">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="litemall_permission">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallPermission;
import org.linlinjava.litemall.db.domain.LitemallPermissionExample;
public interface LitemallPermissionMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
long countByExample(LitemallPermissionExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int deleteByExample(LitemallPermissionExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int insert(LitemallPermission record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int insertSelective(LitemallPermission record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallPermission selectOneByExample(LitemallPermissionExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallPermission selectOneByExampleSelective(@Param("example") LitemallPermissionExample example, @Param("selective") LitemallPermission.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallPermission> selectByExampleSelective(@Param("example") LitemallPermissionExample example, @Param("selective") LitemallPermission.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
List<LitemallPermission> selectByExample(LitemallPermissionExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallPermission selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallPermission.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
LitemallPermission selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallPermission selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallPermission record, @Param("example") LitemallPermissionExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallPermission record, @Param("example") LitemallPermissionExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallPermission record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallPermission record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallPermissionExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_permission
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}
\ No newline at end of file
package org.linlinjava.litemall.db.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.domain.LitemallRole;
import org.linlinjava.litemall.db.domain.LitemallRoleExample;
public interface LitemallRoleMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
long countByExample(LitemallRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int deleteByExample(LitemallRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int deleteByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int insert(LitemallRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int insertSelective(LitemallRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallRole selectOneByExample(LitemallRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallRole selectOneByExampleSelective(@Param("example") LitemallRoleExample example, @Param("selective") LitemallRole.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<LitemallRole> selectByExampleSelective(@Param("example") LitemallRoleExample example, @Param("selective") LitemallRole.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
List<LitemallRole> selectByExample(LitemallRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallRole selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") LitemallRole.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
LitemallRole selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallRole selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") LitemallRole record, @Param("example") LitemallRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int updateByExample(@Param("record") LitemallRole record, @Param("example") LitemallRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(LitemallRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
*/
int updateByPrimaryKey(LitemallRole record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByExample(@Param("example") LitemallRoleExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_role
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int logicalDeleteByPrimaryKey(Integer id);
}
\ No newline at end of file
......@@ -104,6 +104,15 @@ public class LitemallAdmin {
*/
private Boolean deleted;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_admin.role_ids
*
* @mbg.generated
*/
private Integer[] roleIds;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_admin.id
......@@ -320,6 +329,30 @@ public class LitemallAdmin {
this.deleted = deleted;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_admin.role_ids
*
* @return the value of litemall_admin.role_ids
*
* @mbg.generated
*/
public Integer[] getRoleIds() {
return roleIds;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_admin.role_ids
*
* @param roleIds the value for litemall_admin.role_ids
*
* @mbg.generated
*/
public void setRoleIds(Integer[] roleIds) {
this.roleIds = roleIds;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_admin
......@@ -341,6 +374,7 @@ public class LitemallAdmin {
sb.append(", addTime=").append(addTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", deleted=").append(deleted);
sb.append(", roleIds=").append(roleIds);
sb.append("]");
return sb.toString();
}
......@@ -371,7 +405,8 @@ public class LitemallAdmin {
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
&& (this.getAddTime() == null ? other.getAddTime() == null : this.getAddTime().equals(other.getAddTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
&& (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()))
&& (Arrays.equals(this.getRoleIds(), other.getRoleIds()));
}
/**
......@@ -393,6 +428,7 @@ public class LitemallAdmin {
result = prime * result + ((getAddTime() == null) ? 0 : getAddTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
result = prime * result + (Arrays.hashCode(getRoleIds()));
return result;
}
......@@ -423,7 +459,8 @@ public class LitemallAdmin {
avatar("avatar", "avatar", "VARCHAR", false),
addTime("add_time", "addTime", "TIMESTAMP", false),
updateTime("update_time", "updateTime", "TIMESTAMP", false),
deleted("deleted", "deleted", "BIT", false);
deleted("deleted", "deleted", "BIT", false),
roleIds("role_ids", "roleIds", "VARCHAR", false);
/**
* This field was generated by MyBatis Generator.
......
......@@ -198,19 +198,50 @@ public class LitemallAdminExample {
* @mbg.generated
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> roleIdsCriteria;
protected List<Criterion> allCriteria;
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
roleIdsCriteria = new ArrayList<Criterion>();
}
public List<Criterion> getRoleIdsCriteria() {
return roleIdsCriteria;
}
protected void addRoleIdsCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
roleIdsCriteria.add(new Criterion(condition, value, "org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler"));
allCriteria = null;
}
protected void addRoleIdsCriterion(String condition, Integer[] value1, Integer[] value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
roleIdsCriteria.add(new Criterion(condition, value1, value2, "org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler"));
allCriteria = null;
}
public boolean isValid() {
return criteria.size() > 0;
return criteria.size() > 0
|| roleIdsCriteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
if (allCriteria == null) {
allCriteria = new ArrayList<Criterion>();
allCriteria.addAll(criteria);
allCriteria.addAll(roleIdsCriteria);
}
return allCriteria;
}
public List<Criterion> getCriteria() {
......@@ -222,6 +253,7 @@ public class LitemallAdminExample {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
allCriteria = null;
}
protected void addCriterion(String condition, Object value, String property) {
......@@ -229,6 +261,7 @@ public class LitemallAdminExample {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
allCriteria = null;
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
......@@ -236,6 +269,7 @@ public class LitemallAdminExample {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
allCriteria = null;
}
public Criteria andIdIsNull() {
......@@ -1465,6 +1499,148 @@ public class LitemallAdminExample {
addCriterion("deleted not between", value1, value2, "deleted");
return (Criteria) this;
}
public Criteria andRoleIdsIsNull() {
addCriterion("role_ids is null");
return (Criteria) this;
}
public Criteria andRoleIdsIsNotNull() {
addCriterion("role_ids is not null");
return (Criteria) this;
}
public Criteria andRoleIdsEqualTo(Integer[] value) {
addRoleIdsCriterion("role_ids =", value, "roleIds");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_admin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRoleIdsEqualToColumn(LitemallAdmin.Column column) {
addCriterion(new StringBuilder("role_ids = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRoleIdsNotEqualTo(Integer[] value) {
addRoleIdsCriterion("role_ids <>", value, "roleIds");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_admin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRoleIdsNotEqualToColumn(LitemallAdmin.Column column) {
addCriterion(new StringBuilder("role_ids <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRoleIdsGreaterThan(Integer[] value) {
addRoleIdsCriterion("role_ids >", value, "roleIds");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_admin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRoleIdsGreaterThanColumn(LitemallAdmin.Column column) {
addCriterion(new StringBuilder("role_ids > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRoleIdsGreaterThanOrEqualTo(Integer[] value) {
addRoleIdsCriterion("role_ids >=", value, "roleIds");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_admin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRoleIdsGreaterThanOrEqualToColumn(LitemallAdmin.Column column) {
addCriterion(new StringBuilder("role_ids >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRoleIdsLessThan(Integer[] value) {
addRoleIdsCriterion("role_ids <", value, "roleIds");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_admin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRoleIdsLessThanColumn(LitemallAdmin.Column column) {
addCriterion(new StringBuilder("role_ids < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRoleIdsLessThanOrEqualTo(Integer[] value) {
addRoleIdsCriterion("role_ids <=", value, "roleIds");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_admin
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRoleIdsLessThanOrEqualToColumn(LitemallAdmin.Column column) {
addCriterion(new StringBuilder("role_ids <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRoleIdsLike(Integer[] value) {
addRoleIdsCriterion("role_ids like", value, "roleIds");
return (Criteria) this;
}
public Criteria andRoleIdsNotLike(Integer[] value) {
addRoleIdsCriterion("role_ids not like", value, "roleIds");
return (Criteria) this;
}
public Criteria andRoleIdsIn(List<Integer[]> values) {
addRoleIdsCriterion("role_ids in", values, "roleIds");
return (Criteria) this;
}
public Criteria andRoleIdsNotIn(List<Integer[]> values) {
addRoleIdsCriterion("role_ids not in", values, "roleIds");
return (Criteria) this;
}
public Criteria andRoleIdsBetween(Integer[] value1, Integer[] value2) {
addRoleIdsCriterion("role_ids between", value1, value2, "roleIds");
return (Criteria) this;
}
public Criteria andRoleIdsNotBetween(Integer[] value1, Integer[] value2) {
addRoleIdsCriterion("role_ids not between", value1, value2, "roleIds");
return (Criteria) this;
}
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment