|
@@ -1,17 +1,28 @@
|
|
|
package com.fs.company.controller;
|
|
package com.fs.company.controller;
|
|
|
|
|
|
|
|
import com.fs.common.annotation.Log;
|
|
import com.fs.common.annotation.Log;
|
|
|
|
|
+import com.fs.common.constant.UserConstants;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
|
|
+import com.fs.common.core.domain.model.LoginUser;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
import com.fs.common.enums.BusinessType;
|
|
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
|
|
+import com.fs.common.utils.ServletUtils;
|
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
|
|
+import com.fs.company.domain.CompanyMenu;
|
|
|
import com.fs.company.domain.CompanyRole;
|
|
import com.fs.company.domain.CompanyRole;
|
|
|
|
|
+import com.fs.company.service.ICompanyMenuService;
|
|
|
import com.fs.company.service.ICompanyRoleService;
|
|
import com.fs.company.service.ICompanyRoleService;
|
|
|
|
|
+import com.fs.company.service.ICompanyUserService;
|
|
|
|
|
+import com.fs.framework.web.service.TokenService;
|
|
|
|
|
+import liquibase.pro.packaged.R;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -27,15 +38,28 @@ public class CompanyRoleController extends BaseController
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICompanyRoleService companyRoleService;
|
|
private ICompanyRoleService companyRoleService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICompanyRoleService roleService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICompanyUserService userService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICompanyMenuService menuService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TokenService tokenService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询角色信息列表
|
|
* 查询角色信息列表
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:list')")
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:list')")
|
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(CompanyRole companyRole)
|
|
|
|
|
|
|
+ public TableDataInfo list(CompanyRole role)
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
startPage();
|
|
startPage();
|
|
|
- List<CompanyRole> list = companyRoleService.selectCompanyRoleList(companyRole);
|
|
|
|
|
|
|
+ List<CompanyRole> list = roleService.selectCompanyRoleList(role);
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -45,11 +69,11 @@ public class CompanyRoleController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:export')")
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:export')")
|
|
|
@Log(title = "角色信息", businessType = BusinessType.EXPORT)
|
|
@Log(title = "角色信息", businessType = BusinessType.EXPORT)
|
|
|
@GetMapping("/export")
|
|
@GetMapping("/export")
|
|
|
- public AjaxResult export(CompanyRole companyRole)
|
|
|
|
|
|
|
+ public AjaxResult export(CompanyRole role)
|
|
|
{
|
|
{
|
|
|
- List<CompanyRole> list = companyRoleService.selectCompanyRoleList(companyRole);
|
|
|
|
|
|
|
+ List<CompanyRole> list = roleService.selectCompanyRoleList(role);
|
|
|
ExcelUtil<CompanyRole> util = new ExcelUtil<CompanyRole>(CompanyRole.class);
|
|
ExcelUtil<CompanyRole> util = new ExcelUtil<CompanyRole>(CompanyRole.class);
|
|
|
- return util.exportExcel(list, "companyRole");
|
|
|
|
|
|
|
+ return util.exportExcel(list, "销售角色数据");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -68,20 +92,80 @@ public class CompanyRoleController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:add')")
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:add')")
|
|
|
@Log(title = "角色信息", businessType = BusinessType.INSERT)
|
|
@Log(title = "角色信息", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody CompanyRole companyRole)
|
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody CompanyRole role)
|
|
|
{
|
|
{
|
|
|
- return toAjax(companyRoleService.insertCompanyRole(companyRole));
|
|
|
|
|
|
|
+ role.setCreateTime(new Date());
|
|
|
|
|
+ if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
|
|
|
|
+ {
|
|
|
|
|
+ return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
|
|
|
|
+ {
|
|
|
|
|
+ return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ role.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ return toAjax(roleService.insertRole(role));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 修改角色信息
|
|
* 修改角色信息
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:edit')")
|
|
@PreAuthorize("@ss.hasPermi('company:companyRole:edit')")
|
|
|
- @Log(title = "角色信息", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
|
+ @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody CompanyRole companyRole)
|
|
|
|
|
|
|
+ public AjaxResult edit(@RequestBody CompanyRole role)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
|
|
|
|
|
+ {
|
|
|
|
|
+ return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role)))
|
|
|
|
|
+ {
|
|
|
|
|
+ return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ role.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
+
|
|
|
|
|
+ if (roleService.updateRole(role) > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ // 更新缓存用户权限(销售端的token不行)
|
|
|
|
|
+// if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
|
|
|
|
|
+// {
|
|
|
|
|
+// loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
|
|
|
|
|
+// loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
|
|
|
|
+// tokenService.setLoginUser(loginUser);
|
|
|
|
|
+// }
|
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
|
+ }
|
|
|
|
|
+ return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改保存数据权限
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:companyRole:edit')")
|
|
|
|
|
+ @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
|
|
|
+ @PutMapping("/dataScope")
|
|
|
|
|
+ public AjaxResult dataScope(@RequestBody CompanyRole role)
|
|
|
|
|
+ {
|
|
|
|
|
+ return toAjax(roleService.authDataScope(role));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 状态修改
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:role:edit')")
|
|
|
|
|
+ @Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
|
|
|
+ @PutMapping("/changeStatus")
|
|
|
|
|
+ public AjaxResult changeStatus(@RequestBody CompanyRole role)
|
|
|
{
|
|
{
|
|
|
- return toAjax(companyRoleService.updateCompanyRole(companyRole));
|
|
|
|
|
|
|
+ CompanyRole companyRole=roleService.selectCompanyRoleById(role.getRoleId());
|
|
|
|
|
+ if(companyRole.getRoleKey().equals("admin")){
|
|
|
|
|
+ return AjaxResult.error("管理员角色不能修改状态");
|
|
|
|
|
+ }
|
|
|
|
|
+ role.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
+ return toAjax(roleService.updateRoleStatus(role));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -92,6 +176,20 @@ public class CompanyRoleController extends BaseController
|
|
|
@DeleteMapping("/{roleIds}")
|
|
@DeleteMapping("/{roleIds}")
|
|
|
public AjaxResult remove(@PathVariable Long[] roleIds)
|
|
public AjaxResult remove(@PathVariable Long[] roleIds)
|
|
|
{
|
|
{
|
|
|
- return toAjax(companyRoleService.deleteCompanyRoleByIds(roleIds));
|
|
|
|
|
|
|
+ return toAjax(roleService.deleteRoleByIds(roleIds));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取角色选择框列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('company:role:query')")
|
|
|
|
|
+ @GetMapping("/optionselect/{companyId}")
|
|
|
|
|
+ public AjaxResult optionselect(@PathVariable Long companyId)
|
|
|
|
|
+ {
|
|
|
|
|
+ CompanyRole role=new CompanyRole();
|
|
|
|
|
+ role.setCompanyId(companyId);
|
|
|
|
|
+ return AjaxResult.success(roleService.selectCompanyRoleList(role));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|