|
@@ -1,12 +1,14 @@
|
|
|
package com.fs.company.service.impl;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.*;
|
|
|
import com.fs.company.param.CompanyConfigParam;
|
|
|
import com.fs.company.param.CompanyParam;
|
|
|
+import com.fs.company.service.ICompanyRoleService;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.vo.CompanyCrmVO;
|
|
|
import com.fs.company.vo.CompanyNameVO;
|
|
@@ -14,6 +16,7 @@ import com.fs.company.vo.CompanyVO;
|
|
|
import com.fs.company.vo.DeptDataVO;
|
|
|
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
+import com.fs.store.config.CompanyMenuConfig;
|
|
|
import com.fs.store.config.StoreConfig;
|
|
|
import com.fs.store.domain.FsStoreOrder;
|
|
|
import com.fs.store.domain.FsStorePayment;
|
|
@@ -22,7 +25,6 @@ import com.fs.system.service.ISysConfigService;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -56,12 +58,18 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
private CompanyPostMapper postMapper;
|
|
|
@Autowired
|
|
|
private CompanyUserMapper userMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyRoleMenuMapper roleMenuMapper;
|
|
|
@Autowired
|
|
|
private CompanyUserRoleMapper userRoleMapper;
|
|
|
@Autowired
|
|
|
private CompanyUserPostMapper userPostMapper;
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICompanyRoleService roleService;
|
|
|
@Autowired
|
|
|
private CompanyMoneyLogsMapper moneyLogsMapper;
|
|
|
@Autowired
|
|
@@ -149,16 +157,33 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
post.setPostSort(0);
|
|
|
post.setStatus("0");
|
|
|
postMapper.insertCompanyPost(post);
|
|
|
- //创建角色
|
|
|
- CompanyRole role=new CompanyRole();
|
|
|
- role.setCompanyId(company.getCompanyId());
|
|
|
- role.setRoleName("管理员");
|
|
|
- role.setRoleKey("admin");
|
|
|
- role.setRoleSort(0);
|
|
|
- role.setStatus("0");
|
|
|
- roleMapper.insertCompanyRole(role);
|
|
|
- //添加用户
|
|
|
- CompanyUser user=new CompanyUser();
|
|
|
+
|
|
|
+ // 创建管理员角色(拥有全部权限)
|
|
|
+ CompanyRole adminRole = new CompanyRole();
|
|
|
+ adminRole.setCompanyId(company.getCompanyId());
|
|
|
+ adminRole.setRoleName("管理员");
|
|
|
+ adminRole.setRoleKey("admin");
|
|
|
+ adminRole.setRoleSort(0);
|
|
|
+ adminRole.setStatus("0");
|
|
|
+ roleMapper.insertCompanyRole(adminRole);
|
|
|
+
|
|
|
+ // 创建销售角色(新增部分,只有"我的"相关权限)
|
|
|
+ CompanyRole salesRole = new CompanyRole();
|
|
|
+ salesRole.setCompanyId(company.getCompanyId());
|
|
|
+ salesRole.setRoleName(company.getCompanyName() + "_销售");
|
|
|
+ salesRole.setRoleKey(company.getCompanyId()+"_sales");
|
|
|
+ salesRole.setRoleSort(1);
|
|
|
+ salesRole.setDataScope("5");
|
|
|
+ salesRole.setStatus("0");
|
|
|
+
|
|
|
+ //增加销售角色菜单权限
|
|
|
+ String json = configService.selectConfigByKey("companymenu.config");
|
|
|
+ CompanyMenuConfig config = JSONUtil.toBean(json, CompanyMenuConfig.class);
|
|
|
+ // 注意:此处需要额外处理销售角色的权限,设置为仅"我的"相关权限
|
|
|
+ salesRole.setMenuIds(config.getMenuIds());
|
|
|
+ roleService.insertRole(salesRole);
|
|
|
+ // 6. 创建管理员用户
|
|
|
+ CompanyUser user = new CompanyUser();
|
|
|
user.setCompanyId(company.getCompanyId());
|
|
|
user.setNickName("管理员");
|
|
|
|
|
@@ -173,9 +198,12 @@ public class CompanyServiceImpl implements ICompanyService
|
|
|
user.setIsDel(0);
|
|
|
user.setIsAudit(1);
|
|
|
userMapper.insertCompanyUser(user);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//添加用户角色表
|
|
|
CompanyUserRole userRole=new CompanyUserRole();
|
|
|
- userRole.setRoleId(role.getRoleId());
|
|
|
+ userRole.setRoleId(adminRole.getRoleId());
|
|
|
userRole.setUserId(user.getUserId());
|
|
|
userRoleMapper.insertCompanyUserRole(userRole);
|
|
|
//添加用户岗位表
|