first commit

This commit is contained in:
陈现府
2025-11-20 10:45:16 +08:00
commit 8355431361
2643 changed files with 291314 additions and 0 deletions
@@ -0,0 +1,140 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysProduct;
import com.mhd.system.domain.dto.SysAccountingRulesDTO;
import com.mhd.system.domain.vo.SysAccountingRulesVO;
import com.mhd.system.service.ISysAccountingRulesService;
import com.mhd.system.service.ISysProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 计费规则Controller
*
* @author mhd
* @date 2022-07-28
*/
@RestController
@RequestMapping("/rules")
public class SysAccountingRulesController extends BaseController
{
@Autowired
private ISysAccountingRulesService sysAccountingRulesService;
@Autowired
private ISysProductService iSysProductService;
/**
* 查询计费规则列表
*/
@RequiresPermissions("system:rules:list")
@GetMapping("/list")
public TableDataInfo list(SysAccountingRulesDTO sysAccountingRulesDTO)
{
startPage();
List<SysAccountingRulesVO> list = sysAccountingRulesService.selectSysAccountingRulesList(sysAccountingRulesDTO);
return getDataTable(list);
}
/**
* 查询所有产品名称
*/
@RequiresPermissions("system:rules:list")
@GetMapping("/product/list")
public TableDataInfo productList()
{
List<SysProduct> list = iSysProductService.selectSysProductList(null);
return getDataTable(list);
}
/**
* 查询所有计费规则
*/
@RequiresPermissions("system:rules:list")
@GetMapping("/rulesList/{accountingId}")
public TableDataInfo rulesList(@PathVariable("accountingId") Long accountingId)
{
if (accountingId != 0){
SysAccountingRulesDTO sysAccountingRulesDTO = new SysAccountingRulesDTO();
sysAccountingRulesDTO.setProductId(accountingId);
List<SysAccountingRulesVO> list = sysAccountingRulesService.selectSysAccountingRulesList(sysAccountingRulesDTO);
return getDataTable(list);
}else {
List<SysAccountingRulesVO> list = sysAccountingRulesService.selectSysAccountingRulesList(null);
return getDataTable(list);
}
}
/**
* 导出计费规则列表
*/
@RequiresPermissions("system:rules:export")
@Log(title = "计费规则", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysAccountingRulesDTO sysAccountingRulesDTO)
{
List<SysAccountingRulesVO> list = sysAccountingRulesService.selectSysAccountingRulesList(sysAccountingRulesDTO);
ExcelUtil<SysAccountingRulesVO> util = new ExcelUtil<SysAccountingRulesVO>(SysAccountingRulesVO.class);
util.exportExcel(response, list, "计费规则数据");
}
/**
* 获取计费规则详细信息
*/
@RequiresPermissions("system:rules:query")
@GetMapping(value = "/{accountingId}")
public AjaxResult getInfo(@PathVariable("accountingId") Long accountingId)
{
SysAccountingRulesVO sysAccountingRulesVO = sysAccountingRulesService.selectSysAccountingRulesByAccountingId(accountingId);
return AjaxResult.success(sysAccountingRulesVO);
}
/**
* 新增计费规则
*/
@RequiresPermissions("system:rules:add")
@Log(title = "计费规则", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysAccountingRulesDTO sysAccountingRulesDTO)
{
return toAjax(sysAccountingRulesService.insertSysAccountingRules(sysAccountingRulesDTO));
}
/**
* 修改计费规则
*/
@RequiresPermissions("system:rules:edit")
@Log(title = "计费规则", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysAccountingRulesDTO sysAccountingRulesDTO)
{
return toAjax(sysAccountingRulesService.updateSysAccountingRules(sysAccountingRulesDTO));
}
/**
* 删除计费规则
*/
@RequiresPermissions("system:rules:remove")
@Log(title = "计费规则", businessType = BusinessType.DELETE)
@DeleteMapping("/{accountingIds}")
public AjaxResult remove(@PathVariable Long[] accountingIds)
{
return toAjax(sysAccountingRulesService.deleteSysAccountingRulesByAccountingIds(accountingIds));
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysCompanyAgreement;
import com.mhd.system.service.ISysCompanyAgreementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 门户管理 -- 用户协议Controller
*
* @author mhd
* @date 2022-07-27
*/
@RestController
@RequestMapping("/agreement")
public class SysCompanyAgreementController extends BaseController
{
@Autowired
private ISysCompanyAgreementService sysCompanyAgreementService;
/**
* 查询门户管理 -- 用户协议列表
*/
@RequiresPermissions("system:agreement:list")
@GetMapping("/list")
public TableDataInfo list(SysCompanyAgreement sysCompanyAgreement)
{
startPage();
List<SysCompanyAgreement> list = sysCompanyAgreementService.selectSysCompanyAgreementList(sysCompanyAgreement);
return getDataTable(list);
}
/**
* 导出门户管理 -- 用户协议列表
*/
@RequiresPermissions("system:agreement:export")
@Log(title = "门户管理 -- 用户协议", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysCompanyAgreement sysCompanyAgreement)
{
List<SysCompanyAgreement> list = sysCompanyAgreementService.selectSysCompanyAgreementList(sysCompanyAgreement);
ExcelUtil<SysCompanyAgreement> util = new ExcelUtil<SysCompanyAgreement>(SysCompanyAgreement.class);
util.exportExcel(response, list, "门户管理 -- 用户协议数据");
}
/**
* 获取门户管理 -- 用户协议详细信息
*/
@RequiresPermissions("system:agreement:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysCompanyAgreementService.selectSysCompanyAgreementById(id));
}
/**
* 新增门户管理 -- 用户协议
*/
@RequiresPermissions("system:agreement:add")
@Log(title = "门户管理 -- 用户协议", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysCompanyAgreement sysCompanyAgreement)
{
return toAjax(sysCompanyAgreementService.insertSysCompanyAgreement(sysCompanyAgreement));
}
/**
* 修改门户管理 -- 用户协议
*/
@RequiresPermissions("system:agreement:edit")
@Log(title = "门户管理 -- 用户协议", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysCompanyAgreement sysCompanyAgreement)
{
return toAjax(sysCompanyAgreementService.updateSysCompanyAgreement(sysCompanyAgreement));
}
/**
* 删除门户管理 -- 用户协议
*/
@RequiresPermissions("system:agreement:remove")
@Log(title = "门户管理 -- 用户协议", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysCompanyAgreementService.deleteSysCompanyAgreementByIds(ids));
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysCompanyApp;
import com.mhd.system.service.ISysCompanyAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 门户管理--APP管理Controller
*
* @author mhd
* @date 2022-07-27
*/
@RestController
@RequestMapping("/app")
public class SysCompanyAppController extends BaseController
{
@Autowired
private ISysCompanyAppService sysCompanyAppService;
/**
* 查询门户管理--APP管理列表
*/
@RequiresPermissions("system:app:list")
@GetMapping("/list")
public TableDataInfo list(SysCompanyApp sysCompanyApp)
{
startPage();
List<SysCompanyApp> list = sysCompanyAppService.selectSysCompanyAppList(sysCompanyApp);
return getDataTable(list);
}
/**
* 导出门户管理--APP管理列表
*/
@RequiresPermissions("system:app:export")
@Log(title = "门户管理--APP管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysCompanyApp sysCompanyApp)
{
List<SysCompanyApp> list = sysCompanyAppService.selectSysCompanyAppList(sysCompanyApp);
ExcelUtil<SysCompanyApp> util = new ExcelUtil<SysCompanyApp>(SysCompanyApp.class);
util.exportExcel(response, list, "门户管理--APP管理数据");
}
/**
* 获取门户管理--APP管理详细信息
*/
@RequiresPermissions("system:app:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysCompanyAppService.selectSysCompanyAppById(id));
}
/**
* 新增门户管理--APP管理
*/
@RequiresPermissions("system:app:add")
@Log(title = "门户管理--APP管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysCompanyApp sysCompanyApp)
{
return toAjax(sysCompanyAppService.insertSysCompanyApp(sysCompanyApp));
}
/**
* 修改门户管理--APP管理
*/
@RequiresPermissions("system:app:edit")
@Log(title = "门户管理--APP管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysCompanyApp sysCompanyApp)
{
return toAjax(sysCompanyAppService.updateSysCompanyApp(sysCompanyApp));
}
/**
* 删除门户管理--APP管理
*/
@RequiresPermissions("system:app:remove")
@Log(title = "门户管理--APP管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysCompanyAppService.deleteSysCompanyAppByIds(ids));
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysCompanyBasics;
import com.mhd.system.service.ISysCompanyBasicsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 门户管理--基础信息Controller
*
* @author mhd
* @date 2022-07-27
*/
@RestController
@RequestMapping("/basics")
public class SysCompanyBasicsController extends BaseController
{
@Autowired
private ISysCompanyBasicsService sysCompanyBasicsService;
/**
* 查询门户管理--基础信息列表
*/
@RequiresPermissions("system:basics:list")
@GetMapping("/list")
public TableDataInfo list(SysCompanyBasics sysCompanyBasics)
{
startPage();
List<SysCompanyBasics> list = sysCompanyBasicsService.selectSysCompanyBasicsList(sysCompanyBasics);
return getDataTable(list);
}
/**
* 导出门户管理--基础信息列表
*/
@RequiresPermissions("system:basics:export")
@Log(title = "门户管理--基础信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysCompanyBasics sysCompanyBasics)
{
List<SysCompanyBasics> list = sysCompanyBasicsService.selectSysCompanyBasicsList(sysCompanyBasics);
ExcelUtil<SysCompanyBasics> util = new ExcelUtil<SysCompanyBasics>(SysCompanyBasics.class);
util.exportExcel(response, list, "门户管理--基础信息数据");
}
/**
* 获取门户管理--基础信息详细信息
*/
@RequiresPermissions("system:basics:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysCompanyBasicsService.selectSysCompanyBasicsById(id));
}
/**
* 新增门户管理--基础信息
*/
@RequiresPermissions("system:basics:add")
@Log(title = "门户管理--基础信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysCompanyBasics sysCompanyBasics)
{
return toAjax(sysCompanyBasicsService.insertSysCompanyBasics(sysCompanyBasics));
}
/**
* 修改门户管理--基础信息
*/
@RequiresPermissions("system:basics:edit")
@Log(title = "门户管理--基础信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysCompanyBasics sysCompanyBasics)
{
return toAjax(sysCompanyBasicsService.updateSysCompanyBasics(sysCompanyBasics));
}
/**
* 删除门户管理--基础信息
*/
@RequiresPermissions("system:basics:remove")
@Log(title = "门户管理--基础信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysCompanyBasicsService.deleteSysCompanyBasicsByIds(ids));
}
}
@@ -0,0 +1,159 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysCompany;
import com.mhd.system.service.ISysCompanyService;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 公司管理Controller
*
* @author mhd
* @date 2022-07-22
*/
@RestController
@RequestMapping("/company")
public class SysCompanyController extends BaseController
{
@Autowired
private ISysCompanyService sysCompanyService;
/**
* 查询公司管理列表
*/
@RequiresPermissions("system:company:list")
@GetMapping("/list")
public TableDataInfo list(SysCompany sysCompany)
{
startPage();
LoginUser user= SecurityUtils.getLoginUser();
if(!ObjectUtils.isEmpty(user)&&!user.getUsername().equals("admin")){
SysCompany company=sysCompanyService.selectSysCompanyByUserId(user.getUserid());
if(!ObjectUtils.isEmpty(company)){
sysCompany.setCompanyId(company.getCompanyId());
}
}
List<SysCompany> list = sysCompanyService.selectSysCompanyList(sysCompany);
return getDataTable(list);
}
/**
* 导出公司管理列表
*/
@RequiresPermissions("system:company:export")
@Log(title = "公司管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysCompany sysCompany)
{
List<SysCompany> list = sysCompanyService.selectSysCompanyList(sysCompany);
ExcelUtil<SysCompany> util = new ExcelUtil<SysCompany>(SysCompany.class);
util.exportExcel(response, list, "公司管理数据");
}
/**
* 获取公司管理详细信息
*/
@RequiresPermissions("system:company:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysCompanyService.selectSysCompanyById(id));
}
/**
* 新增公司管理
*/
@RequiresPermissions("system:company:add")
@Log(title = "公司管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysCompany sysCompany)
{
try{
return toAjax(sysCompanyService.insertSysCompany(sysCompany));
}catch(ServiceException e){
return AjaxResult.error(e.getMessage());
}catch(Exception e){
e.printStackTrace();
return toAjax(false);
}
}
/**
* 修改公司管理
*/
@RequiresPermissions("system:company:edit")
@Log(title = "公司管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysCompany sysCompany)
{
try{
return toAjax(sysCompanyService.updateSysCompany(sysCompany));
}catch(ServiceException e){
return AjaxResult.error(e.getMessage());
}catch(Exception e){
e.printStackTrace();
return toAjax(false);
}
}
/**
* 删除公司管理
*/
@RequiresPermissions("system:company:remove")
@Log(title = "公司管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysCompanyService.deleteSysCompanyByIds(ids));
}
/**
* 启用公司管理
*/
@RequiresPermissions("system:company:enable")
@GetMapping("/enable/{id}")
public AjaxResult enable(@PathVariable("id") Long id)
{
return toAjax(sysCompanyService.enableSysCompanyById(id));
}
/**
* 禁用公司管理
*/
@RequiresPermissions("system:company:disable")
@GetMapping("/disable/{id}")
public AjaxResult disable(@PathVariable("id") Long id)
{
return toAjax(sysCompanyService.disableSysCompanyById(id));
}
/**
* 加载公司列表树
*/
@GetMapping("/companyTreeselect/{level}")
public AjaxResult companyTreeselect(@PathVariable("level") Integer level)
{
LoginUser user= SecurityUtils.getLoginUser();
SysCompany sysCompany=new SysCompany();
if(!user.getUsername().equals("admin")){
SysCompany sysCompanyP=sysCompanyService.selectSysCompanyByUserId(user.getUserid());
sysCompany.setCompanyId(sysCompanyP.getCompanyId());
}
sysCompany.setLevel(level);
List<SysCompany> depts = sysCompanyService.selectCompanyList(sysCompany);
return AjaxResult.success(sysCompanyService.buildDeptTreeSelect(depts,level));
}
}
@@ -0,0 +1,125 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysComplaintfeedback;
import com.mhd.system.service.ISysComplaintfeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 意见投诉反馈Controller
*
* @author mhd
* @date 2022-07-29
*/
@RestController
@RequestMapping("/Complaintfeedback")
public class SysComplaintfeedbackController extends BaseController
{
@Autowired
private ISysComplaintfeedbackService sysComplaintfeedbackService;
/**
* 查询意见投诉反馈列表
*/
@RequiresPermissions("system:Complaintfeedback:list")
@GetMapping("/list")
public TableDataInfo list(SysComplaintfeedback sysComplaintfeedback)
{
startPage();
List<SysComplaintfeedback> list = sysComplaintfeedbackService.selectSysComplaintfeedbackList(sysComplaintfeedback);
return getDataTable(list);
}
/**
* 导出意见投诉反馈列表
*/
@RequiresPermissions("system:Complaintfeedback:export")
@Log(title = "意见投诉反馈", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysComplaintfeedback sysComplaintfeedback)
{
List<SysComplaintfeedback> list = sysComplaintfeedbackService.selectSysComplaintfeedbackList(sysComplaintfeedback);
ExcelUtil<SysComplaintfeedback> util = new ExcelUtil<SysComplaintfeedback>(SysComplaintfeedback.class);
util.exportExcel(response, list, "意见投诉反馈数据");
}
/**
* 获取详细信息
*/
@RequiresPermissions("system:Complaintfeedback:query")
@GetMapping(value = "/{feedbackId}")
public AjaxResult getInfo(@PathVariable("feedbackId") Long[] feedbackId)
{
return AjaxResult.success(sysComplaintfeedbackService.selectSysComplaintfeedbackByFeedbackId(feedbackId));
}
/**
* 新增意见投诉反馈
*/
@RequiresPermissions("system:Complaintfeedback:add")
@Log(title = "意见投诉反馈", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysComplaintfeedback sysComplaintfeedback)
{
return toAjax(sysComplaintfeedbackService.insertSysComplaintfeedback(sysComplaintfeedback));
}
/**
* 修改意见投诉反馈
*/
@RequiresPermissions("system:Complaintfeedback:edit")
@Log(title = "意见投诉反馈", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysComplaintfeedback sysComplaintfeedback)
{
return toAjax(sysComplaintfeedbackService.updateSysComplaintfeedback(sysComplaintfeedback));
}
/**
* 删除意见投诉反馈
*/
@RequiresPermissions("system:Complaintfeedback:remove")
@Log(title = "意见投诉反馈", businessType = BusinessType.DELETE)
@DeleteMapping("/{feedbackIds}")
public AjaxResult remove(@PathVariable Long[] feedbackIds)
{
return toAjax(sysComplaintfeedbackService.deleteSysComplaintfeedbackByFeedbackIds(feedbackIds));
}
/**
* 标记为已读
*/
@RequiresPermissions("system:Complaintfeedback:updateStatus")
@Log(title = "消息已读", businessType = BusinessType.UPDATE)
@GetMapping("/status/{feedbackIds}")
public AjaxResult updateStatus(@PathVariable("feedbackIds")Long[] feedbackIds) {
return toAjax(sysComplaintfeedbackService.updateStatus(feedbackIds));
}
/**
* 未读消息记录条数
*/
@GetMapping("/unReadNum/{feedbackIds}")
public AjaxResult unReadNum(@PathVariable("feedbackIds")Long feedbackIds) {
return AjaxResult.success(sysComplaintfeedbackService.unReadSum(feedbackIds));
}
}
@@ -0,0 +1,135 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysConfig;
import com.mhd.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.security.utils.SecurityUtils;
/**
* 参数配置 信息操作处理
*
* @author mhd
*/
@RestController
@RequestMapping("/config")
public class SysConfigController extends BaseController
{
@Autowired
private ISysConfigService configService;
/**
* 获取参数配置列表
*/
@RequiresPermissions("system:config:list")
@GetMapping("/list")
public TableDataInfo list(SysConfig config)
{
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
}
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:config:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysConfig config)
{
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
util.exportExcel(response, list, "参数数据");
}
/**
* 根据参数编号获取详细信息
*/
@GetMapping(value = "/{configId}")
public AjaxResult getInfo(@PathVariable Long configId)
{
return AjaxResult.success(configService.selectConfigById(configId));
}
/**
* 根据参数键名查询参数值
*/
@GetMapping(value = "/configKey/{configKey}")
public AjaxResult getConfigKey(@PathVariable String configKey)
{
return AjaxResult.success(configService.selectConfigByKey(configKey));
}
/**
* 新增参数配置
*/
@RequiresPermissions("system:config:add")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysConfig config)
{
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(SecurityUtils.getUsername());
return toAjax(configService.insertConfig(config));
}
/**
* 修改参数配置
*/
@RequiresPermissions("system:config:edit")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysConfig config)
{
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setUpdateBy(SecurityUtils.getUsername());
return toAjax(configService.updateConfig(config));
}
/**
* 删除参数配置
*/
@RequiresPermissions("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds)
{
configService.deleteConfigByIds(configIds);
return success();
}
/**
* 刷新参数缓存
*/
@RequiresPermissions("system:config:remove")
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
configService.resetConfigCache();
return AjaxResult.success();
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysDepartInterfaceInfo;
import com.mhd.system.service.ISysDepartInterfaceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 三方接口配置信息Controller
*
* @author mhd
* @date 2022-07-27
*/
@RestController
@RequestMapping("/info")
public class SysDepartInterfaceInfoController extends BaseController
{
@Autowired
private ISysDepartInterfaceInfoService sysDepartInterfaceInfoService;
/**
* 查询三方接口配置信息列表
*/
@RequiresPermissions("system:info:list")
@GetMapping("/list")
public TableDataInfo list(SysDepartInterfaceInfo sysDepartInterfaceInfo)
{
startPage();
List<SysDepartInterfaceInfo> list = sysDepartInterfaceInfoService.selectSysDepartInterfaceInfoList(sysDepartInterfaceInfo);
return getDataTable(list);
}
/**
* 导出三方接口配置信息列表
*/
@RequiresPermissions("system:info:export")
@Log(title = "三方接口配置信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysDepartInterfaceInfo sysDepartInterfaceInfo)
{
List<SysDepartInterfaceInfo> list = sysDepartInterfaceInfoService.selectSysDepartInterfaceInfoList(sysDepartInterfaceInfo);
ExcelUtil<SysDepartInterfaceInfo> util = new ExcelUtil<SysDepartInterfaceInfo>(SysDepartInterfaceInfo.class);
util.exportExcel(response, list, "三方接口配置信息数据");
}
/**
* 获取三方接口配置信息详细信息
*/
@RequiresPermissions("system:info:query")
@GetMapping(value = "/{departInfoId}")
public AjaxResult getInfo(@PathVariable("departInfoId") Long departInfoId)
{
return AjaxResult.success(sysDepartInterfaceInfoService.selectSysDepartInterfaceInfoByDepartInfoId(departInfoId));
}
/**
* 新增三方接口配置信息
*/
@RequiresPermissions("system:info:add")
@Log(title = "三方接口配置信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysDepartInterfaceInfo sysDepartInterfaceInfo)
{
return toAjax(sysDepartInterfaceInfoService.insertSysDepartInterfaceInfo(sysDepartInterfaceInfo));
}
/**
* 修改三方接口配置信息
*/
@RequiresPermissions("system:info:edit")
@Log(title = "三方接口配置信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysDepartInterfaceInfo sysDepartInterfaceInfo)
{
return toAjax(sysDepartInterfaceInfoService.updateSysDepartInterfaceInfo(sysDepartInterfaceInfo));
}
/**
* 删除三方接口配置信息
*/
@RequiresPermissions("system:info:remove")
@Log(title = "三方接口配置信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{departInfoIds}")
public AjaxResult remove(@PathVariable Long[] departInfoIds)
{
return toAjax(sysDepartInterfaceInfoService.deleteSysDepartInterfaceInfoByDepartInfoIds(departInfoIds));
}
}
@@ -0,0 +1,167 @@
package com.mhd.system.controller;
import java.util.Iterator;
import java.util.List;
import com.mhd.system.service.ISysDeptService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.domain.SysDept;
/**
* 部门信息
*
* @author mhd
*/
@RestController
@RequestMapping("/dept")
public class SysDeptController extends BaseController
{
@Autowired
private ISysDeptService deptService;
/**
* 获取部门列表
*/
@RequiresPermissions("system:dept:list")
@GetMapping("/list")
public AjaxResult list(SysDept dept)
{
List<SysDept> depts = deptService.selectDeptList(dept);
return AjaxResult.success(depts);
}
/**
* 查询部门列表(排除节点)
*/
@RequiresPermissions("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
{
List<SysDept> depts = deptService.selectDeptList(new SysDept());
Iterator<SysDept> it = depts.iterator();
while (it.hasNext())
{
SysDept d = (SysDept) it.next();
if (d.getDeptId().intValue() == deptId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
{
it.remove();
}
}
return AjaxResult.success(depts);
}
/**
* 根据部门编号获取详细信息
*/
@RequiresPermissions("system:dept:query")
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId)
{
deptService.checkDeptDataScope(deptId);
return AjaxResult.success(deptService.selectDeptById(deptId));
}
/**
* 获取部门下拉树列表
*/
@GetMapping("/treeselect")
public AjaxResult treeselect(SysDept dept)
{
List<SysDept> depts = deptService.selectDeptList(dept);
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
}
/**
* 加载对应角色部门列表树
*/
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult roleDeptTreeselect(@PathVariable("roleId") Long roleId)
{
List<SysDept> depts = deptService.selectDeptList(new SysDept());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.buildDeptTreeSelect(depts));
return ajax;
}
/**
* 新增部门
*/
@RequiresPermissions("system:dept:add")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept)
{
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(SecurityUtils.getUsername());
return toAjax(deptService.insertDept(dept));
}
/**
* 修改部门
*/
@RequiresPermissions("system:dept:edit")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept)
{
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(deptId))
{
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
{
return AjaxResult.error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(SecurityUtils.getUsername());
return toAjax(deptService.updateDept(dept));
}
/**
* 删除部门
*/
@RequiresPermissions("system:dept:remove")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId)
{
if (deptService.hasChildByDeptId(deptId))
{
return AjaxResult.error("存在下级部门,不允许删除");
}
/* if (deptService.checkDeptExistUser(deptId))
{
return AjaxResult.error("部门存在用户,不允许删除");
}*/
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
}
}
@@ -0,0 +1,170 @@
package com.mhd.system.controller;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.web.page.TableDataInfoApi;
import com.mhd.system.domain.vo.SysDictDataVO;
import com.mhd.system.service.ISysDictDataService;
import com.mhd.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.domain.SysDictData;
/**
* 数据字典信息
*
* @author mhd
*/
@RestController
@RequestMapping("/dict/data")
public class SysDictDataController extends BaseController
{
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
// @RequiresPermissions("system:dict:list")
@GetMapping("/list")
public TableDataInfo list(SysDictData dictData)
{
startPage();
List<SysDictData> list = dictDataService.selectDictList(dictData);
return getDataTable(list);
}
@PostMapping("/getDictDataList")
public R<List<SysDictData>> getDictDataList(@RequestBody SysDictData sysDictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(sysDictData);
return R.ok(list);
}
@GetMapping("/getList")
public AjaxResult getList(SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return AjaxResult.success(list);
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
// @RequiresPermissions("system:dict:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据");
}
/**
* 查询字典数据详细
*/
// @RequiresPermissions("system:dict:query")
@GetMapping(value = "/{dictCode}")
public AjaxResult getInfo(@PathVariable Long dictCode)
{
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
}
/**
* 根据字典类型查询字典数据信息
*/
@GetMapping(value = "/type/{dictType}")
public AjaxResult dictType(@PathVariable(value = "dictType") String dictType)
{
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data))
{
data = new ArrayList<SysDictData>();
}
return AjaxResult.success(data);
}
/**
* 根据字典类型查询字典数据信息
*/
@GetMapping(value = "/selectDictDataByOpen")
public AjaxResult getDictDataByOpen(@RequestParam("dictType") String dictType, @RequestParam("topOrgId") Long topOrgId) {
List<SysDictData> data = dictDataService.getDictDataByOpen(dictType,topOrgId);
if (StringUtils.isNull(data)) {
data = new ArrayList<SysDictData>();
}
return AjaxResult.success(data);
}
/**
* 新增字典类型
*/
// @RequiresPermissions("system:dict:add")
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictData dict)
{
return toAjax(dictDataService.insertDictData(dict));
}
/**
* 修改保存字典类型
*/
// @RequiresPermissions("system:dict:edit")
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
{
return toAjax(dictDataService.updateDictData(dict));
}
/**
* 删除字典类型
*/
// @RequiresPermissions("system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes)
{
dictDataService.deleteDictDataByIds(dictCodes);
return success();
}
/**
* @Description 获取全部数据字典
* @Author Alex
* @Date 2022/12/30 22:16
*/
@GetMapping("/datalist")
public AjaxResult datalist(SysDictData dictData)
{
SysDictDataVO sysDictDataVO = dictDataService.datalist(dictData);
return AjaxResult.success(sysDictDataVO);
}
@PostMapping("/findDatalist")
public AjaxResult findDatalist(@RequestBody SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return AjaxResult.success(list);
}
/**
* 查询银行卡字典信息(图标+银行名称)
* @return
*/
@GetMapping("/bankInfoList")
public AjaxResult bankInfoList()
{
return AjaxResult.success(dictDataService.bankInfoList());
}
}
@@ -0,0 +1,133 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.service.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.domain.SysDictType;
/**
* 数据字典信息
*
* @author mhd
*/
@RestController
@RequestMapping("/dict/type")
public class SysDictTypeController extends BaseController
{
@Autowired
private ISysDictTypeService dictTypeService;
// @RequiresPermissions("system:dict:list")
@GetMapping("/list")
public TableDataInfo list(SysDictType dictType)
{
startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list);
}
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
// @RequiresPermissions("system:dict:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictType dictType)
{
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
util.exportExcel(response, list, "字典类型");
}
/**
* 查询字典类型详细
*/
// @RequiresPermissions("system:dict:query")
@GetMapping(value = "/{dictId}")
public AjaxResult getInfo(@PathVariable Long dictId)
{
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
}
/**
* 新增字典类型
*/
// @RequiresPermissions("system:dict:add")
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictType dict)
{
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setCreateBy(SecurityUtils.getUsername());
return toAjax(dictTypeService.insertDictType(dict));
}
/**
* 修改字典类型
*/
// @RequiresPermissions("system:dict:edit")
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
{
if (UserConstants.NOT_UNIQUE.equals(dictTypeService.checkDictTypeUnique(dict)))
{
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setUpdateBy(SecurityUtils.getUsername());
return toAjax(dictTypeService.updateDictType(dict));
}
/**
* 删除字典类型
*/
// @RequiresPermissions("system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds)
{
dictTypeService.deleteDictTypeByIds(dictIds);
return success();
}
/**
* 刷新字典缓存
*/
// @RequiresPermissions("system:dict:remove")
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
dictTypeService.resetDictCache();
return AjaxResult.success();
}
/**
* 获取字典选择框列表
*/
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return AjaxResult.success(dictTypes);
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysEquipmentGps;
import com.mhd.system.service.ISysEquipmentGpsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 设备管理 -- GPS管理Controller
*
* @author mhd
* @date 2022-07-28
*/
@RestController
@RequestMapping("/gps")
public class SysEquipmentGpsController extends BaseController
{
@Autowired
private ISysEquipmentGpsService sysEquipmentGpsService;
/**
* 查询设备管理 -- GPS管理列表
*/
@RequiresPermissions("system:gps:list")
@GetMapping("/list")
public TableDataInfo list(SysEquipmentGps sysEquipmentGps)
{
startPage();
List<SysEquipmentGps> list = sysEquipmentGpsService.selectSysEquipmentGpsList(sysEquipmentGps);
return getDataTable(list);
}
/**
* 导出设备管理 -- GPS管理列表
*/
@RequiresPermissions("system:gps:export")
@Log(title = "设备管理 -- GPS管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysEquipmentGps sysEquipmentGps)
{
List<SysEquipmentGps> list = sysEquipmentGpsService.selectSysEquipmentGpsList(sysEquipmentGps);
ExcelUtil<SysEquipmentGps> util = new ExcelUtil<SysEquipmentGps>(SysEquipmentGps.class);
util.exportExcel(response, list, "设备管理 -- GPS管理数据");
}
/**
* 获取设备管理 -- GPS管理详细信息
*/
@RequiresPermissions("system:gps:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysEquipmentGpsService.selectSysEquipmentGpsById(id));
}
/**
* 新增设备管理 -- GPS管理
*/
@RequiresPermissions("system:gps:add")
@Log(title = "设备管理 -- GPS管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysEquipmentGps sysEquipmentGps)
{
return toAjax(sysEquipmentGpsService.insertSysEquipmentGps(sysEquipmentGps));
}
/**
* 修改设备管理 -- GPS管理
*/
@RequiresPermissions("system:gps:edit")
@Log(title = "设备管理 -- GPS管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysEquipmentGps sysEquipmentGps)
{
return toAjax(sysEquipmentGpsService.updateSysEquipmentGps(sysEquipmentGps));
}
/**
* 删除设备管理 -- GPS管理
*/
@RequiresPermissions("system:gps:remove")
@Log(title = "设备管理 -- GPS管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysEquipmentGpsService.deleteSysEquipmentGpsByIds(ids));
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysEquipmentPrinter;
import com.mhd.system.service.ISysEquipmentPrinterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 设备管理 -- 打印机管理Controller
*
* @author mhd
* @date 2022-07-28
*/
@RestController
@RequestMapping("/printer")
public class SysEquipmentPrinterController extends BaseController
{
@Autowired
private ISysEquipmentPrinterService sysEquipmentPrinterService;
/**
* 查询设备管理 -- 打印机管理列表
*/
@RequiresPermissions("system:printer:list")
@GetMapping("/list")
public TableDataInfo list(SysEquipmentPrinter sysEquipmentPrinter)
{
startPage();
List<SysEquipmentPrinter> list = sysEquipmentPrinterService.selectSysEquipmentPrinterList(sysEquipmentPrinter);
return getDataTable(list);
}
/**
* 导出设备管理 -- 打印机管理列表
*/
@RequiresPermissions("system:printer:export")
@Log(title = "设备管理 -- 打印机管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysEquipmentPrinter sysEquipmentPrinter)
{
List<SysEquipmentPrinter> list = sysEquipmentPrinterService.selectSysEquipmentPrinterList(sysEquipmentPrinter);
ExcelUtil<SysEquipmentPrinter> util = new ExcelUtil<SysEquipmentPrinter>(SysEquipmentPrinter.class);
util.exportExcel(response, list, "设备管理 -- 打印机管理数据");
}
/**
* 获取设备管理 -- 打印机管理详细信息
*/
@RequiresPermissions("system:printer:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysEquipmentPrinterService.selectSysEquipmentPrinterById(id));
}
/**
* 新增设备管理 -- 打印机管理
*/
@RequiresPermissions("system:printer:add")
@Log(title = "设备管理 -- 打印机管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysEquipmentPrinter sysEquipmentPrinter)
{
return toAjax(sysEquipmentPrinterService.insertSysEquipmentPrinter(sysEquipmentPrinter));
}
/**
* 修改设备管理 -- 打印机管理
*/
@RequiresPermissions("system:printer:edit")
@Log(title = "设备管理 -- 打印机管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysEquipmentPrinter sysEquipmentPrinter)
{
return toAjax(sysEquipmentPrinterService.updateSysEquipmentPrinter(sysEquipmentPrinter));
}
/**
* 删除设备管理 -- 打印机管理
*/
@RequiresPermissions("system:printer:remove")
@Log(title = "设备管理 -- 打印机管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysEquipmentPrinterService.deleteSysEquipmentPrinterByIds(ids));
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysEquipmentTemplate;
import com.mhd.system.service.ISysEquipmentTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 设备管理 -- 打印模板Controller
*
* @author mhd
* @date 2022-07-28
*/
@RestController
@RequestMapping("/template")
public class SysEquipmentTemplateController extends BaseController
{
@Autowired
private ISysEquipmentTemplateService sysEquipmentTemplateService;
/**
* 查询设备管理 -- 打印模板列表
*/
@RequiresPermissions("system:template:list")
@GetMapping("/list")
public TableDataInfo list(SysEquipmentTemplate sysEquipmentTemplate)
{
startPage();
List<SysEquipmentTemplate> list = sysEquipmentTemplateService.selectSysEquipmentTemplateList(sysEquipmentTemplate);
return getDataTable(list);
}
/**
* 导出设备管理 -- 打印模板列表
*/
@RequiresPermissions("system:template:export")
@Log(title = "设备管理 -- 打印模板", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysEquipmentTemplate sysEquipmentTemplate)
{
List<SysEquipmentTemplate> list = sysEquipmentTemplateService.selectSysEquipmentTemplateList(sysEquipmentTemplate);
ExcelUtil<SysEquipmentTemplate> util = new ExcelUtil<SysEquipmentTemplate>(SysEquipmentTemplate.class);
util.exportExcel(response, list, "设备管理 -- 打印模板数据");
}
/**
* 获取设备管理 -- 打印模板详细信息
*/
@RequiresPermissions("system:template:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(sysEquipmentTemplateService.selectSysEquipmentTemplateById(id));
}
/**
* 新增设备管理 -- 打印模板
*/
@RequiresPermissions("system:template:add")
@Log(title = "设备管理 -- 打印模板", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysEquipmentTemplate sysEquipmentTemplate)
{
return toAjax(sysEquipmentTemplateService.insertSysEquipmentTemplate(sysEquipmentTemplate));
}
/**
* 修改设备管理 -- 打印模板
*/
@RequiresPermissions("system:template:edit")
@Log(title = "设备管理 -- 打印模板", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysEquipmentTemplate sysEquipmentTemplate)
{
return toAjax(sysEquipmentTemplateService.updateSysEquipmentTemplate(sysEquipmentTemplate));
}
/**
* 删除设备管理 -- 打印模板
*/
@RequiresPermissions("system:template:remove")
@Log(title = "设备管理 -- 打印模板", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sysEquipmentTemplateService.deleteSysEquipmentTemplateByIds(ids));
}
}
@@ -0,0 +1,53 @@
package com.mhd.system.controller;
import java.util.List;
import com.mhd.system.domain.dto.SysLogininforDTO;
import com.mhd.system.service.ISysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.security.annotation.InnerAuth;
import com.mhd.system.api.domain.SysLogininforPo;
/**
* 系统访问记录
*
* @author mhd
*/
@RestController
@RequestMapping("/logininfor")
public class SysLogininforController extends BaseController
{
@Autowired
private ISysLogininforService logininforService;
@GetMapping("/list")
public TableDataInfo list(SysLogininforDTO sysLogininforDto)
{
startPage();
List<SysLogininforPo> list = logininforService.selectLogininforList(sysLogininforDto);
return getDataTable(list);
}
@DeleteMapping("/clean")
public AjaxResult clean()
{
logininforService.cleanLogininfor();
return AjaxResult.success();
}
@InnerAuth
@PostMapping
public AjaxResult add(@RequestBody SysLogininforPo logininfor)
{
return toAjax(logininforService.insertLogininfor(logininfor));
}
}
@@ -0,0 +1,176 @@
package com.mhd.system.controller;
import java.util.List;
import com.mhd.system.domain.SysMenu;
import com.mhd.system.service.ISysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.security.utils.SecurityUtils;
/**
* 菜单信息
*
* @author mhd
*/
@RestController
@RequestMapping("/menu")
public class SysMenuController extends BaseController
{
@Autowired
private ISysMenuService menuService;
/**
* 获取菜单列表
*/
@RequiresPermissions("system:menu:list")
@GetMapping("/list")
public AjaxResult list(SysMenu menu)
{
Long userId = SecurityUtils.getLoginUser().getUserid();
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
return AjaxResult.success(menus);
}
/**
* 根据菜单编号获取详细信息
*/
@RequiresPermissions("system:menu:query")
@GetMapping(value = "/{menuId}")
public AjaxResult getInfo(@PathVariable Long menuId)
{
return AjaxResult.success(menuService.selectMenuById(menuId));
}
/**
* 获取菜单下拉树列表
*/
@GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu menu)
{
Long userId = SecurityUtils.getLoginUser().getUserid();
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
}
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{
Long userId = SecurityUtils.getLoginUser().getUserid();
List<SysMenu> menus = menuService.selectMenuList(userId);
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
/**
* 新增菜单
*/
@RequiresPermissions("system:menu:add")
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysMenu menu)
{
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
}
menu.setCreateBy(SecurityUtils.getUsername());
return toAjax(menuService.insertMenu(menu));
}
/**
* 修改菜单
*/
@RequiresPermissions("system:menu:edit")
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
{
if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu)))
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头");
}
else if (menu.getMenuId().equals(menu.getParentId()))
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
}
menu.setUpdateBy(SecurityUtils.getUsername());
return toAjax(menuService.updateMenu(menu));
}
/**
* 删除菜单
*/
@RequiresPermissions("system:menu:remove")
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}")
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.hasChildByMenuId(menuId))
{
return AjaxResult.error("存在子菜单,不允许删除");
}
if (menuService.checkMenuExistRole(menuId))
{
return AjaxResult.error("菜单已分配,不允许删除");
}
return toAjax(menuService.deleteMenuById(menuId));
}
/**
* 获取路由信息
*
* @return 路由信息
*/
@GetMapping("getRouters")
public AjaxResult getRouters()
{
Long userId = SecurityUtils.getLoginUser().getUserid();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus));
}
/**
* 加载对应角色菜单列表树
*/
@GetMapping(value = "/productMenuTreeselect/{productId}")
public AjaxResult productMenuTreeselect(@PathVariable("productId") Long productId)
{
Long userId = SecurityUtils.getLoginUser().getUserid();
List<SysMenu> menus = menuService.selectMenuList(userId);
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByProductId(productId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysMsgCenter;
import com.mhd.system.service.ISysMsgCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 消息中心-站内Controller
*
* @author mhd
* @date 2022-07-27
*/
@RestController
@RequestMapping("/center")
public class SysMsgCenterController extends BaseController
{
@Autowired
private ISysMsgCenterService sysMsgCenterService;
/**
* 查询消息中心-站内列表
*/
@RequiresPermissions("system:center:list")
@GetMapping("/list")
public TableDataInfo list(SysMsgCenter sysMsgCenter)
{
startPage();
List<SysMsgCenter> list = sysMsgCenterService.selectSysMsgCenterList(sysMsgCenter);
return getDataTable(list);
}
/**
* 导出消息中心-站内列表
*/
@RequiresPermissions("system:center:export")
@Log(title = "消息中心-站内", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysMsgCenter sysMsgCenter)
{
List<SysMsgCenter> list = sysMsgCenterService.selectSysMsgCenterList(sysMsgCenter);
ExcelUtil<SysMsgCenter> util = new ExcelUtil<SysMsgCenter>(SysMsgCenter.class);
util.exportExcel(response, list, "消息中心-站内数据");
}
/**
* 获取消息中心-站内详细信息
*/
@RequiresPermissions("system:center:query")
@GetMapping(value = "/{msgCenterId}")
public AjaxResult getInfo(@PathVariable("msgCenterId") Long msgCenterId)
{
return AjaxResult.success(sysMsgCenterService.selectSysMsgCenterByMsgCenterId(msgCenterId));
}
/**
* 新增消息中心-站内
*/
@RequiresPermissions("system:center:add")
@Log(title = "消息中心-站内", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysMsgCenter sysMsgCenter)
{
return toAjax(sysMsgCenterService.insertSysMsgCenter(sysMsgCenter));
}
/**
* 修改消息中心-站内
*/
@RequiresPermissions("system:center:edit")
@Log(title = "消息中心-站内", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysMsgCenter sysMsgCenter)
{
return toAjax(sysMsgCenterService.updateSysMsgCenter(sysMsgCenter));
}
/**
* 删除消息中心-站内
*/
@RequiresPermissions("system:center:remove")
@Log(title = "消息中心-站内", businessType = BusinessType.DELETE)
@DeleteMapping("/{msgCenterIds}")
public AjaxResult remove(@PathVariable Long[] msgCenterIds)
{
return toAjax(sysMsgCenterService.deleteSysMsgCenterByMsgCenterIds(msgCenterIds));
}
}
@@ -0,0 +1,107 @@
package com.mhd.system.controller;
import java.util.List;
import com.mhd.system.domain.SysMsgPush;
import com.mhd.system.domain.dto.SysMsgPushDTO;
import com.mhd.system.service.ISysMsgPushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 消息推送Controller
*
* @author mhd
* @date 2022-07-27
*/
@RestController
@RequestMapping("/push")
public class SysMsgPushController extends BaseController
{
@Autowired
private ISysMsgPushService sysMsgPushService;
/**
* 查询消息推送列表
*/
@RequiresPermissions("system:push:list")
@GetMapping("/list")
public TableDataInfo list(SysMsgPushDTO sysMsgPushDto)
{
startPage();
List<SysMsgPush> list = sysMsgPushService.selectSysMsgPushList(sysMsgPushDto);
return getDataTable(list);
}
/**
* 导出消息推送列表
*/
/* @RequiresPermissions("system:push:export")
@Log(title = "消息推送", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysMsgPush sysMsgPush)
{
List<SysMsgPush> list = sysMsgPushService.selectSysMsgPushList(sysMsgPush);
ExcelUtil<SysMsgPush> util = new ExcelUtil<SysMsgPush>(SysMsgPush.class);
util.exportExcel(response, list, "消息推送数据");
}*/
/**
* 获取消息推送详细信息
*/
@RequiresPermissions("system:push:query")
@GetMapping(value = "/{msgPushId}")
public AjaxResult getInfo(@PathVariable("msgPushId") Long msgPushId)
{
return AjaxResult.success(sysMsgPushService.selectSysMsgPushByMsgPushId(msgPushId));
}
/**
* 新增消息推送
*/
@RequiresPermissions("system:push:add")
@Log(title = "消息推送", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysMsgPush sysMsgPush)
{
return toAjax(sysMsgPushService.insertSysMsgPush(sysMsgPush));
}
/**
* 修改消息推送
*/
@RequiresPermissions("system:push:edit")
@Log(title = "消息推送", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysMsgPush sysMsgPush)
{
AjaxResult ajaxResult = toAjax(sysMsgPushService.updateSysMsgPush(sysMsgPush));
return ajaxResult;
}
/**
* 删除消息推送
*/
@RequiresPermissions("system:push:remove")
@Log(title = "消息推送", businessType = BusinessType.DELETE)
@DeleteMapping("/{msgIds}")
public AjaxResult remove(@PathVariable Long[] msgIds)
{
return toAjax(sysMsgPushService.deleteSysMsgPushByMsgIds(msgIds));
}
}
@@ -0,0 +1,93 @@
package com.mhd.system.controller;
import java.util.List;
import com.mhd.system.domain.SysNotice;
import com.mhd.system.service.ISysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.security.utils.SecurityUtils;
/**
* 公告 信息操作处理
*
* @author mhd
*/
@RestController
@RequestMapping("/notice")
public class SysNoticeController extends BaseController
{
@Autowired
private ISysNoticeService noticeService;
/**
* 获取通知公告列表
*/
@RequiresPermissions("system:notice:list")
@GetMapping("/list")
public TableDataInfo list(SysNotice notice)
{
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list);
}
/**
* 根据通知公告编号获取详细信息
*/
@RequiresPermissions("system:notice:query")
@GetMapping(value = "/{noticeId}")
public AjaxResult getInfo(@PathVariable Long noticeId)
{
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
}
/**
* 新增通知公告
*/
@RequiresPermissions("system:notice:add")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysNotice notice)
{
notice.setCreateBy(SecurityUtils.getUsername());
return toAjax(noticeService.insertNotice(notice));
}
/**
* 修改通知公告
*/
@RequiresPermissions("system:notice:edit")
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
{
notice.setUpdateBy(SecurityUtils.getUsername());
return toAjax(noticeService.updateNotice(notice));
}
/**
* 删除通知公告
*/
@RequiresPermissions("system:notice:remove")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}")
public AjaxResult remove(@PathVariable Long[] noticeIds)
{
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
}
}
@@ -0,0 +1,61 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.dto.SysOperLogDTO;
import com.mhd.system.service.ISysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.InnerAuth;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.system.api.domain.SysOperLogPo;
/**
* 操作日志记录
*
* @author mhd
*/
@RestController
@RequestMapping("/operlog")
public class SysOperlogController extends BaseController
{
@Autowired
private ISysOperLogService operLogService;
@GetMapping("/list")
public TableDataInfo list(SysOperLogDTO sysOperLogDTO)
{
startPage();
List<SysOperLogPo> list = operLogService.selectOperLogList(sysOperLogDTO);
return getDataTable(list);
}
@RequiresPermissions("system:operlog:remove")
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public AjaxResult clean()
{
operLogService.cleanOperLog();
return AjaxResult.success();
}
@InnerAuth
@PostMapping
public AjaxResult add(@RequestBody SysOperLogPo operLog)
{
return toAjax(operLogService.insertOperlog(operLog));
}
}
@@ -0,0 +1,107 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysPlatCompany;
import com.mhd.system.domain.dto.SysPlatCompanyDTO;
import com.mhd.system.domain.vo.SysPlatCompanyVO;
import com.mhd.system.service.ISysPlatCompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 公司系统平台Controller
*
* @author mhd
* @date 2022-07-26
*/
@RestController
@RequestMapping("/playCompany")
public class SysPlatCompanyController extends BaseController
{
@Autowired
private ISysPlatCompanyService sysPlatCompanyService;
/**
* 查询公司系统平台列表
*/
@RequiresPermissions("system:playCompany:list")
@GetMapping("/list")
public TableDataInfo list(SysPlatCompanyDTO sysPlatCompanyDTO)
{
startPage();
List<SysPlatCompanyVO> list = sysPlatCompanyService.selectSysPlatCompanyList(sysPlatCompanyDTO);
return getDataTable(list);
}
/**
* 导出公司系统平台列表
*/
@RequiresPermissions("system:playCompany:export")
@Log(title = "公司系统平台", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysPlatCompanyDTO sysPlatCompanyDTO)
{
List<SysPlatCompanyVO> list = sysPlatCompanyService.selectSysPlatCompanyList(sysPlatCompanyDTO);
ExcelUtil<SysPlatCompanyVO> util = new ExcelUtil<SysPlatCompanyVO>(SysPlatCompanyVO.class);
util.exportExcel(response, list, "公司系统平台数据");
}
/**
* 获取公司系统平台详细信息
*/
@RequiresPermissions("system:playCompany:query")
@GetMapping(value = "/{sysPlatId}")
public AjaxResult getInfo(@PathVariable("sysPlatId") Long sysPlatId)
{
return AjaxResult.success(sysPlatCompanyService.selectSysPlatCompanyBySysPlatId(sysPlatId));
}
/**
* 新增公司系统平台
*/
@RequiresPermissions("system:playCompany:add")
@Log(title = "公司系统平台", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysPlatCompany sysPlatCompany)
{
return toAjax(sysPlatCompanyService.insertSysPlatCompany(sysPlatCompany));
}
/**
* 修改公司系统平台
*/
@RequiresPermissions("system:playCompany:edit")
@Log(title = "公司系统平台", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysPlatCompany sysPlatCompany)
{
return toAjax(sysPlatCompanyService.updateSysPlatCompany(sysPlatCompany));
}
/**
* 删除公司系统平台
*/
@RequiresPermissions("system:playCompany:remove")
@Log(title = "公司系统平台", businessType = BusinessType.DELETE)
@DeleteMapping("/{sysPlatIds}")
public AjaxResult remove(@PathVariable Long[] sysPlatIds)
{
return toAjax(sysPlatCompanyService.deleteSysPlatCompanyBySysPlatIds(sysPlatIds));
}
}
@@ -0,0 +1,132 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysPost;
import com.mhd.system.service.ISysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.security.utils.SecurityUtils;
/**
* 岗位信息操作处理
*
* @author mhd
*/
@RestController
@RequestMapping("/post")
public class SysPostController extends BaseController
{
@Autowired
private ISysPostService postService;
/**
* 获取岗位列表
*/
@RequiresPermissions("system:post:list")
@GetMapping("/list")
public TableDataInfo list(SysPost post)
{
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
}
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:post:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysPost post)
{
List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
util.exportExcel(response, list, "岗位数据");
}
/**
* 根据岗位编号获取详细信息
*/
@RequiresPermissions("system:post:query")
@GetMapping(value = "/{postId}")
public AjaxResult getInfo(@PathVariable Long postId)
{
return AjaxResult.success(postService.selectPostById(postId));
}
/**
* 新增岗位
*/
@RequiresPermissions("system:post:add")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysPost post)
{
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setCreateBy(SecurityUtils.getUsername());
return toAjax(postService.insertPost(post));
}
/**
* 修改岗位
*/
@RequiresPermissions("system:post:edit")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysPost post)
{
if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post)))
{
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post)))
{
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setUpdateBy(SecurityUtils.getUsername());
return toAjax(postService.updatePost(post));
}
/**
* 删除岗位
*/
@RequiresPermissions("system:post:remove")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}")
public AjaxResult remove(@PathVariable Long[] postIds)
{
return toAjax(postService.deletePostByIds(postIds));
}
/**
* 获取岗位选择框列表
*/
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
List<SysPost> posts = postService.selectPostAll();
return AjaxResult.success(posts);
}
}
@@ -0,0 +1,118 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysProduct;
import com.mhd.system.domain.dto.SysProductDTO;
import com.mhd.system.domain.vo.TreeSelect;
import com.mhd.system.service.ISysProductService;
import com.mhd.system.service.ISysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 系统产品Controller
*
* @author mhd
* @date 2022-07-21
*/
@RestController
@RequestMapping("/product")
public class SysProductController extends BaseController
{
@Autowired
private ISysProductService sysProductService;
@Autowired
private ISysRoleService roleService;
/**
* 查询系统产品列表
*/
@RequiresPermissions("system:product:list")
@GetMapping("/list")
public TableDataInfo list(SysProduct sysProduct)
{
startPage();
List<SysProduct> list = sysProductService.selectSysProductList(sysProduct);
return getDataTable(list);
}
/**
* 导出系统产品列表
*/
@RequiresPermissions("system:product:export")
@Log(title = "系统产品", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysProduct sysProduct)
{
List<SysProduct> list = sysProductService.selectSysProductList(sysProduct);
ExcelUtil<SysProduct> util = new ExcelUtil<SysProduct>(SysProduct.class);
util.exportExcel(response, list, "系统产品数据");
}
/**
* 获取系统产品详细信息
*/
@RequiresPermissions("system:product:query")
@GetMapping(value = "/{productId}")
public AjaxResult getInfo(@PathVariable("productId") Long productId)
{
return AjaxResult.success(sysProductService.selectSysProductByProductId(productId));
}
/**
* 新增系统产品
*/
@RequiresPermissions("system:product:add")
@Log(title = "系统产品", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysProductDTO sysProduct)
{
return toAjax(sysProductService.insertSysProduct(sysProduct));
}
/**
* 修改系统产品
*/
@RequiresPermissions("system:product:edit")
@Log(title = "系统产品", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysProductDTO sysProduct)
{
return toAjax(sysProductService.updateSysProduct(sysProduct));
}
/**
* 删除系统产品
*/
@RequiresPermissions("system:product:remove")
@Log(title = "系统产品", businessType = BusinessType.DELETE)
@DeleteMapping("/{productIds}")
public AjaxResult remove(@PathVariable Long[] productIds)
{
return toAjax(sysProductService.deleteSysProductByProductIds(productIds));
}
@RequiresPermissions("system:product:list")
@GetMapping("/prodectTreeList")
public AjaxResult prodectTreeList()
{
List<TreeSelect> list = sysProductService.selectProductTreeList();
return AjaxResult.success(list);
}
}
@@ -0,0 +1,105 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysProductMenu;
import com.mhd.system.service.ISysProductMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 【请填写功能名称】Controller
*
* @author mhd
* @date 2022-07-21
*/
@RestController
@RequestMapping("/product/menu")
public class SysProductMenuController extends BaseController
{
@Autowired
private ISysProductMenuService sysProductMenuService;
/**
* 查询【请填写功能名称】列表
*/
@RequiresPermissions("system:menu:list")
@GetMapping("/list")
public TableDataInfo list(SysProductMenu sysProductMenu)
{
startPage();
List<SysProductMenu> list = sysProductMenuService.selectSysProductMenuList(sysProductMenu);
return getDataTable(list);
}
/**
* 导出【请填写功能名称】列表
*/
@RequiresPermissions("system:menu:export")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysProductMenu sysProductMenu)
{
List<SysProductMenu> list = sysProductMenuService.selectSysProductMenuList(sysProductMenu);
ExcelUtil<SysProductMenu> util = new ExcelUtil<SysProductMenu>(SysProductMenu.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
* 获取【请填写功能名称】详细信息
*/
@RequiresPermissions("system:menu:query")
@GetMapping(value = "/{productId}")
public AjaxResult getInfo(@PathVariable("productId") Long productId)
{
return AjaxResult.success(sysProductMenuService.selectSysProductMenuByProductId(productId));
}
/**
* 新增【请填写功能名称】
*/
@RequiresPermissions("system:menu:add")
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysProductMenu sysProductMenu)
{
return toAjax(sysProductMenuService.insertSysProductMenu(sysProductMenu));
}
/**
* 修改【请填写功能名称】
*/
@RequiresPermissions("system:menu:edit")
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysProductMenu sysProductMenu)
{
return toAjax(sysProductMenuService.updateSysProductMenu(sysProductMenu));
}
/**
* 删除【请填写功能名称】
*/
@RequiresPermissions("system:menu:remove")
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
@DeleteMapping("/{productIds}")
public AjaxResult remove(@PathVariable Long[] productIds)
{
return toAjax(sysProductMenuService.deleteSysProductMenuByProductIds(productIds));
}
}
@@ -0,0 +1,160 @@
package com.mhd.system.controller;
import java.util.Arrays;
import com.mhd.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.utils.file.FileTypeUtils;
import com.mhd.common.core.utils.file.MimeTypeUtils;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.service.TokenService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.RemoteFileService;
import com.mhd.system.api.domain.SysFile;
import com.mhd.system.api.domain.SysUser;
import com.mhd.system.api.model.LoginUser;
/**
* 个人信息 业务处理
*
* @author mhd
*/
@RestController
@RequestMapping("/user/profile")
public class SysProfileController extends BaseController
{
@Autowired
private ISysUserService userService;
@Autowired
private TokenService tokenService;
@Autowired
private RemoteFileService remoteFileService;
/**
* 个人信息
*/
@GetMapping
public AjaxResult profile()
{
String username = SecurityUtils.getLoginUser().getUsername();
SysUser user = userService.selectUserByUserName(username);
AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(username));
ajax.put("postGroup", userService.selectUserPostGroup(username));
return ajax;
}
/**
* 修改用户
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user)
{
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser sysUser = loginUser.getSysUser();
user.setUserName(sysUser.getUserName());
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUserId(sysUser.getUserId());
user.setPassword(null);
if (userService.updateUserProfile(user) > 0)
{
// 更新缓存用户信息
loginUser.getSysUser().setNickName(user.getNickName());
loginUser.getSysUser().setPhonenumber(user.getPhonenumber());
loginUser.getSysUser().setEmail(user.getEmail());
loginUser.getSysUser().setSex(user.getSex());
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改个人信息异常,请联系管理员");
}
/**
* 重置密码
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword)
{
String username = SecurityUtils.getLoginUser().getUsername();
SysUser user = userService.selectUserByUserName(username);
String password = user.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
return AjaxResult.error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password))
{
return AjaxResult.error("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0)
{
// 更新缓存用户密码
LoginUser loginUser = SecurityUtils.getLoginUser();
loginUser.getSysUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改密码异常,请联系管理员");
}
/**
* 头像上传
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file)
{
if (!file.isEmpty())
{
LoginUser loginUser = SecurityUtils.getLoginUser();
String extension = FileTypeUtils.getExtension(file);
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION))
{
return AjaxResult.error("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
}
R<SysFile> fileResult = remoteFileService.upload(file);
if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData()))
{
return AjaxResult.error("文件服务异常,请联系管理员");
}
String url = fileResult.getData().getUrl();
if (userService.updateUserAvatar(loginUser.getUsername(), url))
{
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", url);
// 更新缓存用户头像
loginUser.getSysUser().setAvatar(url);
tokenService.setLoginUser(loginUser);
return ajax;
}
}
return AjaxResult.error("上传图片异常,请联系管理员");
}
}
@@ -0,0 +1,253 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.api.model.LoginUser;
import com.mhd.system.domain.SysCompany;
import com.mhd.system.domain.SysUserRole;
import com.mhd.system.service.ISysCompanyService;
import com.mhd.system.service.ISysRoleService;
import com.mhd.system.service.ISysUserService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.domain.SysRole;
import com.mhd.system.api.domain.SysUser;
/**
* 角色信息
*
* @author mhd
*/
@RestController
@RequestMapping("/role")
public class SysRoleController extends BaseController
{
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysUserService userService;
@Autowired
private ISysCompanyService companyService ;
@RequiresPermissions("system:role:list")
@GetMapping("/list")
public TableDataInfo list(SysRole role)
{
startPage();
LoginUser loginUser= SecurityUtils.getLoginUser();//获取登录人信息
if(loginUser.getUsername().equals("admin")){
role.setCreateBy(loginUser.getUsername());
}else{
boolean isTrue=false;
for (String roleA:loginUser.getRoles() ) {
if(roleA.equals("platform_admin")){
SysCompany sysCompany=companyService.selectSysCompanyByUserId(loginUser.getUserid());
if(ObjectUtils.isNotEmpty(sysCompany)){
role.setCompanyId(sysCompany.getCompanyId());
isTrue=true;
break;
}
}
}
if(isTrue==false){
role.setCreateBy(loginUser.getUsername());
}
}
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:role:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysRole role)
{
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
util.exportExcel(response, list, "角色数据");
}
/**
* 根据角色编号获取详细信息
*/
@RequiresPermissions("system:role:query")
@GetMapping(value = "/{roleId}")
public AjaxResult getInfo(@PathVariable Long roleId)
{
roleService.checkRoleDataScope(roleId);
return AjaxResult.success(roleService.selectRoleById(roleId));
}
/**
* 新增角色
*/
@RequiresPermissions("system:role:add")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysRole 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() + "'失败,角色权限已存在");
}
LoginUser loginUser= SecurityUtils.getLoginUser();//获取登录人信息
if(loginUser.getUsername().equals("admin")){
role.setCreateBy(SecurityUtils.getUsername());
}else{
role.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
}
return toAjax(roleService.insertRole(role));
}
/**
* 修改保存角色
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
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());
return toAjax(roleService.updateRole(role));
}
/**
* 修改保存数据权限
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
public AjaxResult dataScope(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role));
}
/**
* 状态修改
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(SecurityUtils.getUsername());
return toAjax(roleService.updateRoleStatus(role));
}
/**
* 删除角色
*/
@RequiresPermissions("system:role:remove")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public AjaxResult remove(@PathVariable Long[] roleIds)
{
return toAjax(roleService.deleteRoleByIds(roleIds));
}
/**
* 获取角色选择框列表
*/
@RequiresPermissions("system:role:query")
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
return AjaxResult.success(roleService.selectRoleAll());
}
/**
* 查询已分配用户角色列表
*/
@RequiresPermissions("system:role:list")
@GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
}
/**
* 查询未分配用户角色列表
*/
@RequiresPermissions("system:role:list")
@GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
}
/**
* 取消授权用户
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
{
return toAjax(roleService.deleteAuthUser(userRole));
}
/**
* 批量取消授权用户
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
/**
* 批量选择用户授权
*/
@RequiresPermissions("system:role:edit")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
{
roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
}
@@ -0,0 +1,118 @@
package com.mhd.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.domain.SysTenantManagement;
import com.mhd.system.domain.dto.SysTenantManagementDTO;
import com.mhd.system.domain.vo.SysTenantManagementVO;
import com.mhd.system.service.ISysTenantManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.page.TableDataInfo;
/**
* 租户管理Controller
*
* @author mhd
* @date 2022-07-31
*/
@RestController
@RequestMapping("/management")
public class SysTenantManagementController extends BaseController
{
@Autowired
private ISysTenantManagementService sysTenantManagementService;
/**
* 查询租户管理列表
*/
@RequiresPermissions("system:management:list")
@GetMapping("/list")
public TableDataInfo list(SysTenantManagementDTO sysTenantManagement)
{
startPage();
List<SysTenantManagementVO> list = sysTenantManagementService.selectSysTenantManagementList(sysTenantManagement);
return getDataTable(list);
}
/**
* 导出租户管理列表
*/
@RequiresPermissions("system:management:export")
@Log(title = "租户管理", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysTenantManagementDTO sysTenantManagement)
{
List<SysTenantManagementVO> list = sysTenantManagementService.selectSysTenantManagementList(sysTenantManagement);
ExcelUtil<SysTenantManagementVO> util = new ExcelUtil<SysTenantManagementVO>(SysTenantManagementVO.class);
util.exportExcel(response, list, "租户管理数据");
}
/**
* 获取租户管理详细信息
*/
@RequiresPermissions("system:management:query")
@GetMapping(value = "/{tenantId}")
public AjaxResult getInfo(@PathVariable("tenantId") Long tenantId)
{
return AjaxResult.success(sysTenantManagementService.selectSysTenantManagementByTenantId(tenantId));
}
/**
* 新增租户管理
*/
@RequiresPermissions("system:management:add")
@Log(title = "租户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysTenantManagement sysTenantManagement)
{
return toAjax(sysTenantManagementService.insertSysTenantManagement(sysTenantManagement));
}
/**
* 修改租户管理
*/
@RequiresPermissions("system:management:edit")
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysTenantManagement sysTenantManagement)
{
return toAjax(sysTenantManagementService.updateSysTenantManagement(sysTenantManagement));
}
/**
* 状态修改
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysTenantManagement sysTenantManagement)
{
sysTenantManagement.setUpdateBy(SecurityUtils.getUsername());
return toAjax(sysTenantManagementService.updateStatus(sysTenantManagement));
}
/**
* 删除租户管理
*/
@RequiresPermissions("system:management:remove")
@Log(title = "租户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{tenantIds}")
public AjaxResult remove(@PathVariable Long[] tenantIds)
{
return toAjax(sysTenantManagementService.deleteSysTenantManagementByTenantIds(tenantIds));
}
}
@@ -0,0 +1,326 @@
package com.mhd.system.controller;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.mhd.system.domain.SysCompany;
import com.mhd.system.service.*;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.mhd.common.core.constant.UserConstants;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.annotation.InnerAuth;
import com.mhd.common.security.annotation.RequiresPermissions;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.domain.SysRole;
import com.mhd.system.api.domain.SysUser;
import com.mhd.system.api.model.LoginUser;
/**
* 用户信息
*
* @author mhd
*/
@RestController
@RequestMapping("/user")
public class SysUserController extends BaseController
{
@Autowired
private ISysUserService userService;
@Autowired
private ISysRoleService roleService;
@Autowired
private ISysPostService postService;
@Autowired
private ISysPermissionService permissionService;
@Autowired
private ISysConfigService configService;
@Autowired
private ISysCompanyService companyService ;
/**
* 获取用户列表
*/
@RequiresPermissions("system:user:list")
@GetMapping("/list")
public TableDataInfo list(SysUser user)
{
startPage();
LoginUser loginUser= SecurityUtils.getLoginUser();//获取登录人信息
for (String role:loginUser.getRoles() ) {
if(role.equals("admin")){
break;
}else if(role.equals("platform_admin")){
SysCompany sysCompany=companyService.selectSysCompanyByUserId(loginUser.getUserid());
if(ObjectUtils.isNotEmpty(sysCompany)){
user.setCompanyId(sysCompany.getCompanyId());
break;
}
}
}
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user)
{
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@RequiresPermissions("system:user:import")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = SecurityUtils.getLoginUser().getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message);
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.importTemplateExcel(response, "用户数据");
}
/**
* 获取当前用户信息
*/
@InnerAuth
@GetMapping("/info/{username}")
public R<LoginUser> info(@PathVariable("username") String username)
{
SysUser sysUser = userService.selectUserByUserName(username);
if (StringUtils.isNull(sysUser))
{
return R.fail("用户名或密码错误");
}
// 角色集合
Set<String> roles = permissionService.getRolePermission(sysUser.getUserId());
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(sysUser.getUserId());
LoginUser sysUserVo = new LoginUser();
sysUserVo.setSysUser(sysUser);
sysUserVo.setRoles(roles);
sysUserVo.setPermissions(permissions);
return R.ok(sysUserVo);
}
/**
* 注册用户信息
*/
@InnerAuth
@PostMapping("/register")
public R<Boolean> register(@RequestBody SysUser sysUser)
{
String username = sysUser.getUserName();
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
return R.fail("当前系统没有开启注册功能!");
}
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
{
return R.fail("保存用户'" + username + "'失败,注册账号已存在");
}
return R.ok(userService.registerUser(sysUser));
}
/**
* 获取用户信息
*
* @return 用户信息
*/
@GetMapping("getInfo")
public AjaxResult getInfo()
{
Long userId = SecurityUtils.getLoginUser().getUserid();
// 角色集合
Set<String> roles = permissionService.getRolePermission(userId);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(userId);
AjaxResult ajax = AjaxResult.success();
ajax.put("user", userService.selectUserById(userId));
ajax.put("roles", roles);
ajax.put("permissions", permissions);
return ajax;
}
/**
* 根据用户编号获取详细信息
*/
@RequiresPermissions("system:user:query")
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
{
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId))
{
SysUser sysUser = userService.selectUserById(userId);
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
}
return ajax;
}
/**
* 新增用户
*/
@RequiresPermissions("system:user:add")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysUser user)
{
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName())))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
}
else if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setCreateBy(SecurityUtils.getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}
/**
* 修改用户
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
else if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.updateUser(user));
}
/**
* 删除用户
*/
@RequiresPermissions("system:user:remove")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable Long[] userIds)
{
if (ArrayUtils.contains(userIds, SecurityUtils.getUserId()))
{
return AjaxResult.error("当前用户不能删除");
}
return toAjax(userService.deleteUserByIds(userIds));
}
/**
* 重置密码
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd")
public AjaxResult resetPwd(@RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.resetPwd(user));
}
/**
* 状态修改
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysUser user)
{
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.updateUserStatus(user));
}
/**
* 根据用户编号获取授权角色
*/
@RequiresPermissions("system:user:query")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId)
{
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
ajax.put("user", user);
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return ajax;
}
/**
* 用户授权角色
*/
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
{
userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds);
return success();
}
}
@@ -0,0 +1,57 @@
package com.mhd.system.controller;
import java.util.Collection;
import java.util.List;
import com.mhd.common.core.utils.PageUtils;
import com.mhd.system.domain.SysUserOnline;
import com.mhd.system.domain.dto.SysUserOnlineDTO;
import com.mhd.system.service.ISysUserOnlineService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.mhd.common.core.constant.CacheConstants;
import com.mhd.common.core.web.controller.BaseController;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.core.web.page.TableDataInfo;
import com.mhd.common.redis.service.RedisService;
/**
* 在线用户监控
*
* @author mhd
*/
@RestController
@RequestMapping("/online")
public class SysUserOnlineController extends BaseController
{
@Autowired
private ISysUserOnlineService userOnlineService;
@Autowired
private RedisService redisService;
@ApiOperation("统计当前在线人数")
@GetMapping("currentlyOnline")
public AjaxResult currentlyOnline() {
Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
return AjaxResult.success(keys.size());
}
@ApiOperation("在线用户列表")
@GetMapping("/list")
public TableDataInfo list(SysUserOnlineDTO sysUserOnlineDTO) {
List<SysUserOnline> userOnlineList = userOnlineService.list(sysUserOnlineDTO);
int size = userOnlineList.size();
List<SysUserOnline> list = PageUtils.subList(userOnlineList, sysUserOnlineDTO.getPageSize(), sysUserOnlineDTO.getPageNum());
return getDataTable(list, size);
}
@ApiOperation("强退用户")
@PostMapping("/forceLogout")
public AjaxResult forceLogout(@RequestBody SysUserOnlineDTO sysUserOnlineDTO) {
userOnlineService.forceLogout(sysUserOnlineDTO);
return AjaxResult.success();
}
}