diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysModuleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysModuleController.java new file mode 100644 index 0000000000000000000000000000000000000000..13a768eee2d0656c8cead10c52c81afb516bdf99 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysModuleController.java @@ -0,0 +1,95 @@ +package com.ruoyi.web.controller.system; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysModule; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.service.ISysModuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + + +/** + * 功能模块管理Controller + * + * @author Kelsey + */ +@RestController +@RequestMapping("/system/module") +public class SysModuleController extends BaseController { + + @Autowired + private ISysModuleService moduleService; + + /** + * 分页查询功能模块配置 + */ + @PreAuthorize("@ss.hasPermi('system:module:list')") + @GetMapping("/list") + public TableDataInfo list(SysModule module) { + IPage page = moduleService.selectModuleList(getPage(), module); + return getDataTable(page); + } + + /** + * 查询单模块配置详情 + */ + @PreAuthorize("@ss.hasPermi('system:module:query')") + @GetMapping(value = "/{moduleId}") + public AjaxResult getInfo(@PathVariable Long moduleId) { + return success(moduleService.selectModuleById(moduleId)); + } + + /** + * 新增功能模块配置 + */ + @PreAuthorize("@ss.hasPermi('system:module:add')") + @Log(title = "功能模块", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysModule module) { + // 检查模块名称是否唯一 + if (!moduleService.checkModuleNameUnique(module)) { + return error("新增功能模块'" + module.getModuleName() + "'失败,模块名称已存在"); + } + // 检查关联表名是否唯一 + if (!moduleService.checkTableNameUnique(module)) { + return error("新增功能模块'" + module.getTableName() + "'失败,关联表名已存在"); + } + module.setCreateBy(getUsername()); + return toAjax(moduleService.insertModule(module)); + } + + /** + * 修改功能模块配置 + */ + @PreAuthorize("@ss.hasPermi('system:module:edit')") + @Log(title = "功能模块", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysModule module) { + // 检查模块名称是否唯一 + if (!moduleService.checkModuleNameUnique(module)) { + return error("修改功能模块'" + module.getModuleName() + "'失败,模块名称已存在"); + } + // 检查关联表名是否唯一 + if (!moduleService.checkTableNameUnique(module)) { + return error("修改功能模块'" + module.getTableName() + "'失败,关联表名已存在"); + } + module.setUpdateBy(getUsername()); + return toAjax(moduleService.updateModule(module)); + } + + /** + * 删除功能模块配置 + */ + @PreAuthorize("@ss.hasPermi('system:module:remove')") + @Log(title = "功能模块", businessType = BusinessType.DELETE) + @DeleteMapping("/{moduleIds}") + public AjaxResult remove(@PathVariable Long[] moduleIds) { + return toAjax(moduleService.deleteModuleByIds(moduleIds)); + } +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOrderController.java new file mode 100644 index 0000000000000000000000000000000000000000..6a5174bbce80f00f7ab53632c98038429a19950d --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysOrderController.java @@ -0,0 +1,114 @@ +package com.ruoyi.web.controller.system; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysOrder; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.system.mapper.SysOrderMapper; +import com.ruoyi.system.service.ISysOrderService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.UUID; + +/** + * 订单信息管理Controller + * + * @author Kelsey + */ +@RestController +@RequestMapping("/system/order") +public class SysOrderController extends BaseController { + + @Autowired + private ISysOrderService orderService; + + @Autowired + private SysOrderMapper orderMapper; + + @Autowired + private SysDeptMapper deptMapper; + + /** + * 查询订单列表(分页) + */ + @PreAuthorize("@ss.hasPermi('system:order:list')") + @GetMapping("/list") + public TableDataInfo list(SysOrder order) { + IPage list = orderMapper.selectOrderList(getPage(), order); + return getDataTable(list); + } + + /** + * 导出订单列表 + */ + @Log(title = "订单管理", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:order:export')") + @PostMapping("/export") + public void export(HttpServletResponse response, SysOrder order) { + List list = orderService.selectOrderList(order); + ExcelUtil util = new ExcelUtil<>(SysOrder.class); + util.exportExcel(response, list, "订单数据"); + } + + /** + * 根据订单编号查询订单详情 + */ + @PreAuthorize("@ss.hasPermi('system:order:query')") + @GetMapping(value = "/{orderNo}") + public AjaxResult getInfo(@PathVariable("orderNo") String orderNo) { + return success(orderService.selectOrderByNo(orderNo)); + } + + /** + * 新增订单 + */ + @PreAuthorize("@ss.hasPermi('system:order:add')") + @Log(title = "订单管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysOrder order) { + // 校验订单是否存在 + if (orderService.checkOrderExist(order)) { + return AjaxResult.error("新增订单编号" + order.getOrderNo() + "失败,订单已存在"); + } + // 初始化订单信息 + order.setOrderNo(UUID.randomUUID().toString()); + order.setDeptId(getDeptId()); + order.setUserId(getUserId()); + order.setDeptName(deptMapper.selectDeptById(getDeptId()).getDeptName()); + order.setUserName(getUsername()); + order.setOrderStatus("待付款"); + order.setCreateBy(getUsername()); + return toAjax(orderService.insertOrder(order)); + } + + /** + * 修改订单 + */ + @PreAuthorize("@ss.hasPermi('system:order:edit')") + @Log(title = "订单管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysOrder order) { + order.setUpdateBy(getUsername()); + return toAjax(orderService.updateOrder(order)); + } + + /** + * 删除订单 + */ + @PreAuthorize("@ss.hasPermi('system:order:remove')") + @Log(title = "订单管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{orderIds}") + public AjaxResult remove(@PathVariable Long[] orderIds) { + return toAjax(orderService.deleteOrderByIds(orderIds)); + } +} \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysSalaryController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysSalaryController.java new file mode 100644 index 0000000000000000000000000000000000000000..62162855c62e809523c00e5a376702c0b40c54df --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysSalaryController.java @@ -0,0 +1,123 @@ +package com.ruoyi.web.controller.system; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.system.mapper.SysSalaryMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +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.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysSalary; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.service.ISysSalaryService; + +/** + * 薪资信息管理Controller + * + * @author Kelsey + */ +@RestController +@RequestMapping("/system/salary") +public class SysSalaryController extends BaseController { + + @Autowired + private ISysSalaryService salaryService; + + @Autowired + private SysSalaryMapper salaryMapper; + + @Autowired + private SysDeptMapper deptMapper; + + /** + * 查询薪资信息列表 + */ + @PreAuthorize("@ss.hasPermi('system:salary:list')") + @GetMapping("/list") + public TableDataInfo list(SysSalary salary) { + IPage list = salaryMapper.selectSalaryList(getPage(),salary); + return getDataTable(list); + } + + /** + * 导出薪资信息列表 + */ + @Log(title = "薪资管理", businessType = BusinessType.EXPORT) + @PreAuthorize("@ss.hasPermi('system:salary:export')") + @PostMapping("/export") + public void export(HttpServletResponse response, SysSalary salary) { + List list = salaryService.selectSalaryList(salary); + ExcelUtil util = new ExcelUtil(SysSalary.class); + util.exportExcel(response, list, "薪资数据"); + } + + /** + * 获取薪资信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:salary:query')") + @GetMapping(value = "/{salaryId}") + public AjaxResult getInfo(@PathVariable("salaryId") Long salaryId) { + return success(salaryService.selectSalaryById(salaryId)); + } + + /** + * 修改保存薪资信息 + */ + @PreAuthorize("@ss.hasPermi('system:salary:edit')") + @Log(title = "薪资管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody SysSalary salary) { + // 校验该用户在该月份是否存在薪资信息 + if (!salaryService.checkSalaryExist(salary)) { + return AjaxResult.error("修改薪资失败,该用户" + salary.getUserId() + "在" + salary.getSalaryMonth() + "已存在薪资信息"); + } + salary.setUpdateBy(getUsername()); + return toAjax(salaryService.updateSalary(salary)); + } + + /** + * 删除薪资信息 + */ + @PreAuthorize("@ss.hasPermi('system:salary:remove')") + @Log(title = "薪资管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{salaryIds}") + public AjaxResult remove(@PathVariable Long[] salaryIds) { + return toAjax(salaryService.deleteSalaryByIds(salaryIds)); + } + + /** + * 新增保存薪资信息 + */ + @PreAuthorize("@ss.hasPermi('system:salary:add')") + @Log(title = "薪资管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody SysSalary salary) { + // 校验该用户在该月份是否存在薪资信息 + if (!salaryService.checkSalaryExist(salary)) { + return AjaxResult.error("新增薪资失败,该用户" + salary.getUserId() + "在" + salary.getSalaryMonth() + "已存在薪资信息"); + } + // 初始化薪资信息 + salary.setUserId(getUserId()); + salary.setUserName(getUsername()); + salary.setDeptId(getDeptId()); + salary.setDeptName(deptMapper.selectDeptById(getDeptId()).getDeptName()); + salary.setStatus("0"); + salary.setCreateBy(getUsername()); + return toAjax(salaryService.insertSalary(salary)); + } +} \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysModule.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysModule.java index 866cf13dcd6a9a6b3d9a387faa2f00d208c766b2..6eb28cdbd23b3ec01136043d343ec2008039f908 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysModule.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysModule.java @@ -31,8 +31,6 @@ public class SysModule extends BaseEntity { /** 数据权限优先级 */ @Excel(name = "数据权限优先级") private Integer level; - /** 删除标志 */ - private String delFlag; public Long getModuleId() { return moduleId; @@ -76,12 +74,6 @@ public class SysModule extends BaseEntity { public void setLevel(Integer level) { this.level = level; } - public String getDelFlag() { - return delFlag; - } - public void setDelFlag(String delFlag) { - this.delFlag = delFlag; - } @Override public String toString() { @@ -93,7 +85,6 @@ public class SysModule extends BaseEntity { ", dataScope=" + dataScope + ", scopeExpr='" + scopeExpr + '\'' + ", level=" + level + - ", delFlag='" + delFlag + '\'' + '}'; } } \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysSalary.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysSalary.java index 94dafd1d96ee739752da517a84756dce786631f7..d1fd98e18e6af33eb771dad808e5104e51cd96ec 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysSalary.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysSalary.java @@ -26,12 +26,6 @@ public class SysSalary extends BaseEntity { /** 部门名称 */ @Excel(name = "部门名称") private String deptName; - /** 岗位id */ - @Excel(name = "岗位ID", cellType = Excel.ColumnType.NUMERIC) - private Long postId; - /** 岗位名称 */ - @Excel(name = "岗位名称") - private String postName; /** 薪资月份 */ @Excel(name = "薪资月份") private String salaryMonth; @@ -59,8 +53,7 @@ public class SysSalary extends BaseEntity { /** 备注 */ @Excel(name = "备注") private String remark; - /** 删除标志 */ - private String delFlag; + // getter/setter public Long getSalaryId() { return salaryId; } public void setSalaryId(Long salaryId) { this.salaryId = salaryId; } @@ -72,10 +65,6 @@ public class SysSalary extends BaseEntity { public void setDeptId(Long deptId) { this.deptId = deptId; } public String getDeptName() { return deptName; } public void setDeptName(String deptName) { this.deptName = deptName; } - public Long getPostId() { return postId; } - public void setPostId(Long postId) { this.postId = postId; } - public String getPostName() { return postName; } - public void setPostName(String postName) { this.postName = postName; } public String getSalaryMonth() { return salaryMonth; } public void setSalaryMonth(String salaryMonth) { this.salaryMonth = salaryMonth; } public BigDecimal getBaseSalary() { return baseSalary; } @@ -94,8 +83,6 @@ public class SysSalary extends BaseEntity { public void setStatus(String status) { this.status = status; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } - public String getDelFlag() { return delFlag; } - public void setDelFlag(String delFlag) { this.delFlag = delFlag; } @Override public String toString() { return "SysSalary{" + @@ -104,8 +91,6 @@ public class SysSalary extends BaseEntity { ", userName='" + userName + '\'' + ", deptId=" + deptId + ", deptName='" + deptName + '\'' + - ", postId=" + postId + - ", postName='" + postName + '\'' + ", salaryMonth='" + salaryMonth + '\'' + ", baseSalary=" + baseSalary + ", bonus=" + bonus + @@ -115,7 +100,6 @@ public class SysSalary extends BaseEntity { ", netSalary=" + netSalary + ", status='" + status + '\'' + ", remark='" + remark + '\'' + - ", delFlag='" + delFlag + '\'' + '}'; } } \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/DataPermissionInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/DataPermissionInterceptor.java index 7bc348c8c79b5a4ada8e49f321d1a37101a714d3..b8ebf72e901a3bb203fc4c11b4fa871e3c797eb7 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/DataPermissionInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/DataPermissionInterceptor.java @@ -8,13 +8,16 @@ import net.sf.jsqlparser.JSQLParserException; import net.sf.jsqlparser.expression.Expression; import net.sf.jsqlparser.expression.operators.conditional.AndExpression; import net.sf.jsqlparser.parser.CCJSqlParserUtil; +import net.sf.jsqlparser.schema.Column; import net.sf.jsqlparser.schema.Table; import net.sf.jsqlparser.statement.Statement; +import net.sf.jsqlparser.statement.insert.Insert; import net.sf.jsqlparser.statement.select.PlainSelect; import net.sf.jsqlparser.statement.select.Select; import org.apache.ibatis.executor.Executor; import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlCommandType; import org.apache.ibatis.mapping.SqlSource; import org.apache.ibatis.plugin.*; import org.apache.ibatis.session.ResultHandler; @@ -31,9 +34,11 @@ import com.ruoyi.common.enums.DataScopeType; /** * MyBatis全局数据权限拦截器 + * 支持SELECT、INSERT、UPDATE、DELETE操作的权限控制 */ @Intercepts({ - @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}) + @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}), + @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}) }) public class DataPermissionInterceptor implements Interceptor { @@ -56,11 +61,27 @@ public class DataPermissionInterceptor implements Interceptor { Object parameter = args[1]; BoundSql boundSql = ms.getBoundSql(parameter); String originalSql = boundSql.getSql(); + SqlCommandType sqlCommandType = ms.getSqlCommandType(); + // 根据SQL类型进行不同处理 + if (sqlCommandType == SqlCommandType.SELECT) { + return handleSelectOperation(invocation, ms, parameter, boundSql, originalSql, args); + } else if (sqlCommandType == SqlCommandType.INSERT) { + return handleInsertOperation(invocation, ms, parameter, boundSql, originalSql, args); + } + + // 其他操作类型直接放行 + return invocation.proceed(); + } + + /** + * 处理SELECT操作 + */ + private Object handleSelectOperation(Invocation invocation, MappedStatement ms, Object parameter, + BoundSql boundSql, String originalSql, Object[] args) throws Throwable { // 1. 解析SQL,提取表名 String tableName = parseTableNameFromSql(originalSql); if (tableName == null) { - // 打印警告日志 logger.warn("数据权限拦截器未能解析表名,SQL已放行:{}", originalSql); return invocation.proceed(); } @@ -104,39 +125,63 @@ public class DataPermissionInterceptor implements Interceptor { MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql)); args[0] = newMs; - // 执行SQL并在成功后记录部门-日期访问计数 + // redis统计部门-日期访问次数 Object result = invocation.proceed(); try { incrementDeptDailyAccess(currentUser.getDeptId()); } catch (Exception e) { - // 计数失败不影响主流程 logger.warn("记录部门日访问计数失败,deptId={}", currentUser.getDeptId(), e); } - // 记录审计日志(查询操作) - try { - Integer ds = effectiveModule.getDataScope(); - DataScopeType dsType = DataScopeType.fromCode(ds); - String scopeLabel = dsType != null ? dsType.getLabel() : "未知"; - String scopeExpr = (dsType == DataScopeType.CUSTOM) ? String.valueOf(effectiveModule.getScopeExpr()) : ""; - String day = LocalDate.now().format(DAY_FMT); - // 按日志要求:谁、什么时候、访问了什么表、什么部门的数据范围、操作类型 - logger.info( - "数据权限审计 | 日期={} 用户ID={} 用户名={} 角色={} | 操作={} | 表={} | 部门范围={} | 过滤条件={} 自定义表达式={}", - day, - currentUser.getUserId(), - currentUser.getUserName(), - effectiveModule.getRoleId().toString(), - "SELECT", - tableName, - scopeLabel, - filterSql, - scopeExpr - ); - } catch (Exception logEx) { - logger.warn("审计日志记录失败", logEx); + // 记录日志 + logger.info("SELECT操作 | 用户={} 部门ID={} 表={} 权限范围={}", + currentUser.getUserName(), currentUser.getDeptId(), + tableName, + effectiveModule != null ? effectiveModule.getDataScope() : "无配置"); + + return result; + } + + /** + * 处理INSERT操作 + */ + private Object handleInsertOperation(Invocation invocation, MappedStatement ms, Object parameter, + BoundSql boundSql, String originalSql, Object[] args) throws Throwable { + // 1. 获取当前用户 + SysUser currentUser = SecurityUtils.getLoginUser().getUser(); + + // 2. 超管权限验证 + if (currentUser.isAdmin()) { + if (currentUser.getDeptId() == null) { + throw new RuntimeException("无所属部门的超级管理员无法进行Insert操作"); + } + // 有部门ID的超管直接放行 + logger.info("超级管理员(部门ID={})执行INSERT操作,直接放行", currentUser.getDeptId()); + return invocation.proceed(); } + // 3. 普通用户必须有部门ID + if (currentUser.getDeptId() == null) { + throw new RuntimeException("普通用户必须指定部门ID才能执行INSERT操作"); + } + + // 4. 自动注入部门ID到INSERT语句 + String newSql = injectDeptIdToInsertSql(originalSql, currentUser.getDeptId()); + if (!newSql.equals(originalSql)) { + BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), newSql, boundSql.getParameterMappings(), boundSql.getParameterObject()); + MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql)); + args[0] = newMs; + } + + // 5. 执行INSERT操作 + Object result = invocation.proceed(); + + // 6. 记录简单日志 + logger.info("INSERT操作 | 用户={} 部门ID={} 表={} 部门ID注入={}", + currentUser.getUserName(), currentUser.getDeptId(), + parseTableNameFromInsertSql(originalSql), + newSql.equals(originalSql) ? "失败" : "成功"); + return result; } @@ -148,7 +193,7 @@ public class DataPermissionInterceptor implements Interceptor { @Override public void setProperties(Properties properties) {} - // 解析SQL表名(单表) + // 解析SELECT SQL表名(单表) private String parseTableNameFromSql(String sql) { try { Statement statement = CCJSqlParserUtil.parse(sql); @@ -159,7 +204,22 @@ public class DataPermissionInterceptor implements Interceptor { return table.getName(); } } catch (JSQLParserException | ClassCastException e) { - logger.error("解析SQL表名失败", e); + logger.error("解析SELECT SQL表名失败", e); + } + return null; + } + + // 解析INSERT SQL表名 + private String parseTableNameFromInsertSql(String sql) { + try { + Statement statement = CCJSqlParserUtil.parse(sql); + if (statement instanceof Insert) { + Insert insert = (Insert) statement; + Table table = insert.getTable(); + return table.getName(); + } + } catch (JSQLParserException | ClassCastException e) { + logger.error("解析INSERT SQL表名失败", e); } return null; } @@ -177,7 +237,7 @@ public class DataPermissionInterceptor implements Interceptor { return scopeType.buildFilterSql(tableAlias, user, module.getScopeExpr()); } - // 注入过滤条件到SQL + // 注入过滤条件到SELECT SQL private String injectFilterToSql(String sql, String filterSql) { try { Statement statement = CCJSqlParserUtil.parse(sql); @@ -199,6 +259,46 @@ public class DataPermissionInterceptor implements Interceptor { return sql; } + // 自动注入部门ID到INSERT SQL + private String injectDeptIdToInsertSql(String sql, Long deptId) { + // 检查是否已经包含dept_id列 + if (sql.toLowerCase().contains("dept_id")) { + logger.info("INSERT语句已包含dept_id列,无需注入"); + return sql; + } + + try { + // 使用简单的字符串替换方式 + // 找到列名部分和VALUES部分 + int columnsStart = sql.indexOf("(") + 1; + int columnsEnd = sql.indexOf(")"); + int valuesStart = sql.indexOf("VALUES") + 6; + int valuesEnd = sql.lastIndexOf(")"); + + if (columnsStart > 0 && columnsEnd > columnsStart && valuesStart > 6 && valuesEnd > valuesStart) { + // 在列名后添加dept_id + String columns = sql.substring(columnsStart, columnsEnd); + String newColumns = columns + ", dept_id"; + + // 在VALUES后添加dept_id的值 + String values = sql.substring(valuesStart, valuesEnd); + String newValues = values + ", " + deptId; + + // 构建新的SQL + String newSql = sql.substring(0, columnsStart) + newColumns + + sql.substring(columnsEnd, valuesStart) + newValues + + sql.substring(valuesEnd); + + logger.info("成功注入部门ID {} 到INSERT语句", deptId); + return newSql; + } + } catch (Exception e) { + logger.warn("注入部门ID失败,使用原始SQL: {}", e.getMessage()); + } + + return sql; + } + // 复制MappedStatement private MappedStatement copyFromMappedStatement(MappedStatement ms, SqlSource newSqlSource) { MappedStatement.Builder builder = new MappedStatement.Builder(ms.getConfiguration(), ms.getId(), newSqlSource, ms.getSqlCommandType()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysModuleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysModuleMapper.java index e902252b0554373353b8db34194071bf10e92618..e81b9b6378c348b8eeb770c7838e78b0e5d95bb3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysModuleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysModuleMapper.java @@ -1,5 +1,6 @@ package com.ruoyi.system.mapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.common.core.domain.entity.SysModule; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -10,11 +11,75 @@ import java.util.List; public interface SysModuleMapper { /** * 根据表名查询功能模块(默认权限) + * + * @param tableName 表名 + * @return 功能模块 默认权限 */ SysModule selectModuleByTableName(@Param("tableName") String tableName); /** * 根据表名和角色ID查询功能模块权限配置 + * + * @param tableName 表名 + * @param roleIds 角色ID列表 + * @return 功能模块权限配置列表 */ List selectModuleByTableNameAndRoleIds(@Param("tableName") String tableName, @Param("roleIds") List roleIds); -} \ No newline at end of file + + /** + * 分页查询功能模块列表 + * + * @param page 分页信息 + * @param module 功能模块信息 + * @return 功能模块列表 + */ + IPage selectModuleList(IPage page, @Param("module") SysModule module); + + /** + * 根据ID查询模块 + * + * @param moduleId 模块ID + * @return 功能模块信息 + */ + SysModule selectModuleById(Long moduleId); + + /** + * 新增模块 + * + * @param module 功能模块信息 + * @return 结果 + */ + int insertModule(SysModule module); + + /** + * 修改模块 + * + * @param module 功能模块信息 + * @return 结果 + */ + int updateModule(SysModule module); + + /** + * 批量删除模块 + * + * @param moduleIds 模块ID列表 + * @return 结果 + */ + int deleteModuleByIds(Long[] moduleIds); + + /** + * 检查模块名称是否存在 + * + * @param moduleName 模块名称 + * @return 功能模块信息 + */ + SysModule checkModuleNameExist(String moduleName); + + /** + * 检查关联表名是否存在 + * + * @param tableName 关联表名 + * @return 功能模块信息 + */ + SysModule checkTableNameExist(String tableName); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOrderMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOrderMapper.java index 562f9afe3b46f2d1446b765e85d6eed0585803a9..436622dc5a94e610f219c32d660b3d88306be586 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOrderMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOrderMapper.java @@ -1,8 +1,72 @@ package com.ruoyi.system.mapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.common.core.domain.entity.SysOrder; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + /** * 订单信息表 数据层 */ public interface SysOrderMapper { -} \ No newline at end of file + IPage selectOrderList(IPage page, @Param("order") SysOrder order); + + /** + * 查询订单列表 + * + * @param order 订单信息 + * @return 订单列表 + */ + public List selectOrderList(@Param("order") SysOrder order); + + /** + * 查询订单详情 + * + * @param orderId 订单ID + * @return 订单详情 + */ + public SysOrder selectOrderById(Long orderId); + + /** + * 新增订单 + * + * @param order 订单 + * @return 结果 + */ + public int insertOrder(SysOrder order); + + /** + * 修改订单 + * + * @param order 订单 + * @return 结果 + */ + public int updateOrder(SysOrder order); + + /** + * 删除订单 + * + * @param orderId 订单ID + * @return 结果 + */ + public int deleteOrderById(Long orderId); + + /** + * 批量删除订单 + * + * @param orderIds 订单ID数组 + * @return 结果 + */ + public int deleteOrderByIds(Long[] orderIds); + + /** + * 根据订单号查询订单 + * + * @param orderNo 订单号 + * @return 订单 + */ + public SysOrder selectOrderByNo(String orderNo); + +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysSalaryMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysSalaryMapper.java index a03029992648e6ed451567142ac9ed9c00d015e3..88427ad930427932f32cd7276d60e7ea5558a804 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysSalaryMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysSalaryMapper.java @@ -1,8 +1,81 @@ package com.ruoyi.system.mapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.common.core.domain.entity.SysSalary; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + /** * 薪资信息表 数据层 + * + * @author Kelsey */ public interface SysSalaryMapper { + /** + * 查询薪资数据集合(分页) + * + * @param page 分页参数 + * @param salary 薪资信息 + * @return 薪资数据集合 + */ + IPage selectSalaryList(IPage page, @Param("salary") SysSalary salary); + + /** + * 查询薪资数据集合 + * + * @param salary 薪资信息 + * @return 薪资数据集合 + */ + public List selectSalaryList(@Param("salary") SysSalary salary); + + /** + * 通过薪资ID查询薪资信息 + * + * @param salaryId 薪资ID + * @return 薪资对象信息 + */ + public SysSalary selectSalaryById(Long salaryId); + + /** + * 删除薪资信息 + * + * @param salaryId 薪资ID + * @return 结果 + */ + public int deleteSalaryById(Long salaryId); + + /** + * 批量删除薪资信息 + * + * @param salaryIds 需要删除的薪资ID + * @return 结果 + */ + public int deleteSalaryByIds(Long[] salaryIds); + + /** + * 修改薪资信息 + * + * @param salary 薪资信息 + * @return 结果 + */ + public int updateSalary(SysSalary salary); + + /** + * 新增薪资信息 + * + * @param salary 薪资信息 + * @return 结果 + */ + public int insertSalary(SysSalary salary); + + /** + * 校验该用户在该月份是否存在薪资信息 + * + * @param userId 用户ID + * @param salaryMonth 薪资月份 + * @return 薪资信息 + */ + public SysSalary checkSalaryExist(@Param("userId") Long userId, @Param("salaryMonth") String salaryMonth); } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysModuleService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysModuleService.java index 04ef27c34a499d4039e85739fb26484d4a8c9d72..4fea6ed2b9aebaec22dfc0ad18ceadc30859709f 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysModuleService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysModuleService.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.common.core.domain.entity.SysModule; import java.util.List; @@ -9,11 +10,66 @@ import java.util.List; public interface ISysModuleService { /** * 根据表名查询功能模块(默认权限) + * @param tableName 表名 + * @return 功能模块 */ - SysModule getModuleByTableName(String tableName); + public SysModule getModuleByTableName(String tableName); /** * 根据表名和角色ID查询功能模块权限配置 + * @param tableName 表名 + * @param roleIds 角色ID列表 + * @return 功能模块列表 */ - List getModuleByTableNameAndRoleIds(String tableName, List roleIds); -} \ No newline at end of file + public List getModuleByTableNameAndRoleIds(String tableName, List roleIds); + + /** + * 分页查询功能模块配置 + * @param page 分页对象 + * @param module 功能模块 + * @return 分页结果 + */ + public IPage selectModuleList(IPage page, SysModule module); + + /** + * 根据模块ID查询模块详情 + * @param moduleId 模块ID + * @return 模块详情 + */ + public SysModule selectModuleById(Long moduleId); + + /** + * 新增功能模块配置 + * @param module 功能模块 + * @return 结果 + */ + public int insertModule(SysModule module); + + /** + * 修改功能模块配置 + * @param module 功能模块 + * @return 结果 + */ + public int updateModule(SysModule module); + + /** + * 删除功能模块配置 + * @param moduleIds 模块ID列表 + * @return 结果 + */ + public int deleteModuleByIds(Long[] moduleIds); + + /** + * 检查模块名称是否唯一 + * @param module 功能模块 + * @return true:唯一 false:已存在 + */ + public boolean checkModuleNameUnique(SysModule module); + + /** + * 检查关联表名是否唯一 + * @param module 功能模块 + * @return true:唯一 false:已存在 + */ + public boolean checkTableNameUnique(SysModule module); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOrderService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOrderService.java index a7276ac1c01341347996431dd1ccb48c39e6f566..c815255bf181fa88adef6048387db49492bd7b82 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOrderService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOrderService.java @@ -8,4 +8,45 @@ import java.util.List; */ public interface ISysOrderService { -} \ No newline at end of file + /** + * 查询订单列表 + * @param order 条件查询 + * @return 订单列表 + */ + public List selectOrderList(SysOrder order); + + /** + * 新增订单 + * @param order 订单 + * @return 结果 + */ + public int insertOrder(SysOrder order); + + /** + * 修改订单 + * @param order 订单 + * @return 结果 + */ + public int updateOrder(SysOrder order); + + /** + * 批量删除订单 + * @param orderIds 订单ID数组 + * @return 结果 + */ + public int deleteOrderByIds(Long[] orderIds); + + /** + * 根据订单号查询订单 + * @param orderNo 订单号 + * @return 订单 + */ + public SysOrder selectOrderByNo(String orderNo); + + /** + * 校验订单是否存在 + * @param order 订单 + * @return 结果 + */ + public boolean checkOrderExist(SysOrder order); +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysSalaryService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysSalaryService.java index efed9a05d014257947de402ef12d4dfc50b56a45..a30a14971f246de3c29435d624d52c2272a38c0c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysSalaryService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysSalaryService.java @@ -8,4 +8,45 @@ import java.util.List; */ public interface ISysSalaryService { -} \ No newline at end of file + /** + * 查看薪资列表 + * @param salary 条件查询 + * @return 薪资列表 + */ + public List selectSalaryList(SysSalary salary); + + /** + * 修改薪资信息 + * @param salary 薪资信息 + * @return 结果 + */ + public int updateSalary(SysSalary salary); + + /** + * 删除薪资信息 + * @param salaryIds 薪资ID数组 + * @return 结果 + */ + public int deleteSalaryByIds(Long[] salaryIds); + + /** + * 新增薪资信息 + * @param salary 薪资信息 + * @return 结果 + */ + public int insertSalary(SysSalary salary); + + /** + * 根据薪资ID查询薪资信息 + * @param salaryId 薪资ID + * @return 薪资信息 + */ + public SysSalary selectSalaryById(Long salaryId); + + /** + * 校验该用户在该月份是否存在薪资信息 + * @param salary 薪资信息 + * @return true:存在,false:不存在 + */ + public boolean checkSalaryExist(SysSalary salary); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysModuleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysModuleServiceImpl.java index e5121f159780390a41c691a5db82c4349956a68e..03f6bccf6a9dc7d03edd201016dae69edfa2ad03 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysModuleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysModuleServiceImpl.java @@ -1,6 +1,10 @@ package com.ruoyi.system.service.impl; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.entity.SysModule; +import com.ruoyi.common.core.domain.entity.SysSalary; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.mapper.SysModuleMapper; import com.ruoyi.system.service.ISysModuleService; import org.springframework.beans.factory.annotation.Autowired; @@ -9,16 +13,109 @@ import java.util.List; @Service public class SysModuleServiceImpl implements ISysModuleService { + @Autowired private SysModuleMapper sysModuleMapper; + /** + * 根据表名查询功能模块(默认权限) + * @param tableName 表名 + * @return 功能模块 + */ @Override public SysModule getModuleByTableName(String tableName) { return sysModuleMapper.selectModuleByTableName(tableName); } + /** + * 根据表名和角色ID查询功能模块权限配置 + * @param tableName 表名 + * @param roleIds 角色ID列表 + * @return 功能模块列表 + */ @Override public List getModuleByTableNameAndRoleIds(String tableName, List roleIds) { return sysModuleMapper.selectModuleByTableNameAndRoleIds(tableName, roleIds); } + + /** + * 分页查询功能模块列表 + * @param page 分页信息 + * @param module 功能模块查询条件 + * @return 功能模块列表 + */ + @Override + public IPage selectModuleList(IPage page, SysModule module) { + return sysModuleMapper.selectModuleList(page, module); + } + + /** + * 根据ID查询功能模块详情 + * @param moduleId 功能模块ID + * @return 功能模块详情 + */ + @Override + public SysModule selectModuleById(Long moduleId) { + return sysModuleMapper.selectModuleById(moduleId); + } + + /** + * 新增功能模块 + * @param module 功能模块 + * @return 新增结果 + */ + @Override + public int insertModule(SysModule module) { + return sysModuleMapper.insertModule(module); + } + + /** + * 修改功能模块 + * @param module 功能模块 + * @return 修改结果 + */ + @Override + public int updateModule(SysModule module) { + return sysModuleMapper.updateModule(module); + } + + /** + * 删除功能模块 + * @param moduleIds 功能模块ID数组 + * @return 删除结果 + */ + @Override + public int deleteModuleByIds(Long[] moduleIds) { + return sysModuleMapper.deleteModuleByIds(moduleIds); + } + + /** + * 检查模块名称是否唯一 + * @param module 功能模块 + * @return true:唯一 false:已存在 + */ + @Override + public boolean checkModuleNameUnique(SysModule module) { + Long moduleId = StringUtils.isNull(module.getModuleId()) ? -1L : module.getModuleId(); + SysModule info = sysModuleMapper.checkModuleNameExist(module.getModuleName()); + if (StringUtils.isNotNull(info) && info.getModuleId().longValue() != moduleId.longValue()) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 检查关联表名是否唯一 + * @param module 功能模块 + * @return true:唯一 false:已存在 + */ + @Override + public boolean checkTableNameUnique(SysModule module) { + Long moduleId = StringUtils.isNull(module.getModuleId()) ? -1L : module.getModuleId(); + SysModule info = sysModuleMapper.checkTableNameExist(module.getTableName()); + if (StringUtils.isNotNull(info) && info.getModuleId().longValue() != moduleId.longValue()) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } } \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOrderServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOrderServiceImpl.java index e30cf64af01bf915e72118bebf2c0570873f0b74..7fd245bdbf1c54bbc7e389b11fe33924e4e06e58 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOrderServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOrderServiceImpl.java @@ -1,13 +1,95 @@ package com.ruoyi.system.service.impl; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.mapper.SysOrderMapper; import com.ruoyi.system.service.ISysOrderService; +import com.ruoyi.common.core.domain.entity.SysOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +/** + * 订单信息服务层实现 + * + * @author Kelsey + */ @Service public class SysOrderServiceImpl implements ISysOrderService { + @Autowired private SysOrderMapper sysOrderMapper; -} \ No newline at end of file + /** + * 查询订单列表 + * @param order 条件查询 + * @return 订单列表 + */ + @Override + public List selectOrderList(SysOrder order) { + return sysOrderMapper.selectOrderList(order); + } + + /** + * 新增订单 + * @param order 订单 + * @return 结果 + */ + @Override + public int insertOrder(SysOrder order) { + return sysOrderMapper.insertOrder(order); + } + + /** + * 修改订单 + * @param order 订单 + * @return 结果 + */ + @Override + public int updateOrder(SysOrder order) { + return sysOrderMapper.updateOrder(order); + } + + /** + * 批量删除订单 + * @param orderIds 订单ID数组 + * @return 结果 + */ + @Override + public int deleteOrderByIds(Long[] orderIds) { + for (Long orderId : orderIds) { + SysOrder order = sysOrderMapper.selectOrderById(orderId); + if (StringUtils.isNotNull(order) && "2".equals(order.getDelFlag())) { + throw new ServiceException(String.format("订单ID %1$s 已删除,无法删除", orderId)); + } + } + return sysOrderMapper.deleteOrderByIds(orderIds); + } + + /** + * 根据订单号查询订单 + * @param orderNo 订单号 + * @return 订单 + */ + @Override + public SysOrder selectOrderByNo(String orderNo) { + return sysOrderMapper.selectOrderByNo(orderNo); + } + + /** + * 校验订单是否存在 + * @param order 订单 + * @return 结果 + */ + @Override + public boolean checkOrderExist(SysOrder order) { + Long orderId = StringUtils.isNull(order.getOrderId()) ? -1L : order.getOrderId(); + SysOrder info = sysOrderMapper.selectOrderByNo(order.getOrderNo()); + if (StringUtils.isNotNull(info) && info.getOrderId().longValue() != orderId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysSalaryServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysSalaryServiceImpl.java index 56f700e2c8a4d85757bc13167526adb443bc498e..3af5ceb790dc98731c072e7a9dcb51ce7e8d8827 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysSalaryServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysSalaryServiceImpl.java @@ -1,13 +1,111 @@ package com.ruoyi.system.service.impl; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysSalary; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.mapper.SysSalaryMapper; import com.ruoyi.system.service.ISysSalaryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + +/** + * 薪资信息 服务层处理 + * + * @author Kelsey + */ @Service public class SysSalaryServiceImpl implements ISysSalaryService { + @Autowired private SysSalaryMapper sysSalaryMapper; -} \ No newline at end of file + /** + * 查看薪资列表 + * + * @param salary 条件查询 + * @return 薪资列表 + */ + @Override + public List selectSalaryList(SysSalary salary) { + return sysSalaryMapper.selectSalaryList(salary); + } + + /** + * 修改薪资信息 + * + * @param salary 薪资信息 + * @return 结果 + */ + @Override + public int updateSalary(SysSalary salary) { + return sysSalaryMapper.updateSalary(salary); + } + + /** + * 批量删除薪资信息 + * + * @param salaryIds 需要删除的薪资ID + * @return 结果 + */ + @Override + public int deleteSalaryByIds(Long[] salaryIds) { + for (Long salaryId : salaryIds) { + SysSalary salary = selectSalaryById(salaryId); + if (StringUtils.isNull(salary)) { + throw new ServiceException(String.format("薪资ID %1$s 不存在,无法删除", salaryId)); + } + } + return sysSalaryMapper.deleteSalaryByIds(salaryIds); + } + + /** + * 新增保存薪资信息 + * + * @param salary 薪资信息 + * @return 结果 + */ + @Override + public int insertSalary(SysSalary salary) { + return sysSalaryMapper.insertSalary(salary); + } + + /** + * 通过薪资ID查询薪资信息 + * + * @param salaryId 薪资ID + * @return 薪资对象信息 + */ + @Override + public SysSalary selectSalaryById(Long salaryId) { + return sysSalaryMapper.selectSalaryById(salaryId); + } + + /** + * 校验该用户在该月份是否存在薪资信息 + * + * @param salary 薪资信息 + * @return 结果 + */ + @Override + public boolean checkSalaryExist(SysSalary salary) { + Long salaryId = StringUtils.isNull(salary.getSalaryId()) ? -1L : salary.getSalaryId(); + SysSalary info = sysSalaryMapper.checkSalaryExist(salaryId, salary.getSalaryMonth()); + if (StringUtils.isNotNull(info) && info.getSalaryId().longValue() != salaryId.longValue()) { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 删除薪资信息 + * + * @param salaryId 薪资ID + * @return 结果 + */ + public int deleteSalaryById(Long salaryId) { + return sysSalaryMapper.deleteSalaryById(salaryId); + } +} \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysModuleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysModuleMapper.xml index 74f849c6c74f7555fc1768021ab83a095a8bb042..74a945574b4ff23fe91d06f67d909e09674fec3c 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysModuleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysModuleMapper.xml @@ -2,18 +2,39 @@ + + + + + + + + + + + + + + + + + + SELECT module_id, module_name, table_name, role_id, data_scope, scope_expr, level, + create_by, create_time, update_by, update_time + FROM sys_module + + - SELECT * FROM sys_module - WHERE table_name = #{tableName} AND del_flag = '0' AND role_id IS NULL + WHERE table_name = #{tableName} AND role_id IS NULL LIMIT 1 - SELECT * FROM sys_module WHERE table_name = #{tableName} - AND del_flag = '0' AND role_id IN #{roleId} @@ -21,4 +42,98 @@ ORDER BY level DESC - \ No newline at end of file + + + + + + + + + INSERT INTO sys_module( + module_id, + module_name, + table_name, + role_id, + data_scope, + scope_expr, + level, + create_by, + create_time + ) VALUES ( + #{moduleId}, + #{moduleName}, + #{tableName}, + #{roleId}, + #{dataScope}, + #{scopeExpr}, + #{level}, + #{createBy}, + sysdate() + ) + + + + + UPDATE sys_module + + module_name = #{moduleName}, + table_name = #{tableName}, + role_id = #{roleId}, + data_scope = #{dataScope}, + scope_expr = #{scopeExpr}, + level = #{level}, + update_by = #{updateBy}, + update_time = sysdate() + + WHERE module_id = #{moduleId} + + + + + DELETE FROM sys_module + WHERE module_id IN + + #{id} + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysOrderMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysOrderMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..aefa7eec01660a21a025d8163c86b540809f3071 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/SysOrderMapper.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select order_id, order_no, order_type, user_id, user_name, dept_id, dept_name, + customer_name, order_amount, order_status, order_date, delivery_date, + remark, create_by, create_time, update_by, update_time, del_flag + from sys_order + + + + + + + + + + insert into sys_order( + order_id, + order_no, + order_type, + user_id, + user_name, + dept_id, + dept_name, + customer_name, + order_amount, + order_status, + order_date, + delivery_date, + remark, + create_by, + create_time + ) values ( + #{orderId}, + #{orderNo}, + #{orderType}, + #{userId}, + #{userName}, + #{deptId}, + #{deptName}, + #{customerName}, + #{orderAmount}, + #{orderStatus}, + #{orderDate}, + #{deliveryDate}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + update sys_order + + order_type = #{orderType}, + customer_name = #{customerName}, + order_amount = #{orderAmount}, + order_status = #{orderStatus}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where order_id = #{orderId} + + + + update sys_order + set del_flag = '2', + update_time = sysdate() + where order_id = #{orderId} + + + + update sys_order + set del_flag = '2', + update_time = sysdate() + where order_id in + + #{orderId} + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysSalaryMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysSalaryMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..36f991e894c9b4bfcfd34c26bf0c7d304a75c36e --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/SysSalaryMapper.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select salary_id, user_id, user_name, dept_id, dept_name, + salary_month, base_salary, bonus, allowance, deduction, tax, net_salary, + status, remark, create_by, create_time, update_by, update_time + from sys_salary + + + + + + + + + + update sys_salary + + user_id = #{userId}, + user_name = #{userName}, + dept_id = #{deptId}, + dept_name = #{deptName}, + salary_month = #{salaryMonth}, + base_salary = #{baseSalary}, + bonus = #{bonus}, + allowance = #{allowance}, + deduction = #{deduction}, + tax = #{tax}, + net_salary = #{netSalary}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where salary_id = #{salaryId} + + + + insert into sys_salary( + salary_id, + user_id, + user_name, + dept_id, + dept_name, + salary_month, + base_salary, + bonus, + allowance, + deduction, + tax, + net_salary, + status, + remark, + create_by, + create_time + ) values ( + #{salaryId}, + #{userId}, + #{userName}, + #{deptId}, + #{deptName}, + #{salaryMonth}, + #{baseSalary}, + #{bonus}, + #{allowance}, + #{deduction}, + #{tax}, + #{netSalary}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + + delete from sys_salary where salary_id = #{salaryId} + + + + delete from sys_salary where salary_id in + + #{salaryId} + + + + diff --git a/sql/ry_20240629.sql b/sql/ry_20240629.sql index 16f9640855d0debcd1e7619ea4967dba4010f4e1..8efc6f2a8610c0d650c3d7a165a234c821a93567 100644 --- a/sql/ry_20240629.sql +++ b/sql/ry_20240629.sql @@ -714,7 +714,6 @@ create table sys_module data_scope int default 0 comment '数据权限类型:仅本人(0)、本部门(1)、本部门及下级(2)、全部(3)、自定义(4)等', scope_expr varchar(255) default null comment '自定义数据权限表达式,data_scope=4时生效', level int default 0 comment '数据权限优先级,level越大优先级越高,默认0', - del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)', create_by varchar(64) default '' comment '创建者', create_time datetime comment '创建时间', update_by varchar(64) default '' comment '更新者', @@ -775,8 +774,6 @@ create table sys_salary user_name varchar(64) not null comment '员工姓名', dept_id bigint(20) not null comment '部门id', dept_name varchar(100) default null comment '部门名称', - post_id bigint(20) default null comment '岗位id', - post_name varchar(100) default null comment '岗位名称', salary_month varchar(7) not null comment '薪资月份,格式yyyy-MM', base_salary decimal(12, 2) not null comment '基本工资', bonus decimal(12, 2) default 0 comment '奖金', @@ -790,7 +787,6 @@ create table sys_salary create_time datetime comment '创建时间', update_by varchar(64) default '' comment '更新者', update_time datetime comment '更新时间', - del_flag char(1) default '0' comment '删除标志(0代表存在 2代表删除)', primary key (salary_id) ) engine = innodb auto_increment = 1 @@ -800,8 +796,8 @@ create table sys_salary -- 初始化-薪资信息表数据 -- ---------------------------- insert into sys_salary ( - salary_id, user_id, user_name, dept_id, dept_name, post_id, post_name, salary_month, base_salary, bonus, allowance, deduction, tax, net_salary, status, remark, create_by, create_time, update_by, update_time, del_flag + salary_id, user_id, user_name, dept_id, dept_name, salary_month, base_salary, bonus, allowance, deduction, tax, net_salary, status, remark, create_by, create_time, update_by, update_time ) values - (1, 1, 'admin', 103, '研发部门', 1, '董事长', '2024-06', 20000.00, 5000.00, 1000.00, 500.00, 3000.00, 22500.00, '0', '6月工资', 'admin', now(), '', null, '0'), - (2, 2, 'ry', 105, '测试部门', 2, '项目经理', '2024-06', 12000.00, 2000.00, 800.00, 300.00, 1500.00, 13300.00, '0', '6月工资', 'admin', now(), '', null, '0'), - (3, 2, 'ry', 105, '测试部门', 2, '项目经理', '2024-07', 12000.00, 1000.00, 500.00, 200.00, 1200.00, 12300.00, '0', '7月工资', 'admin', now(), '', null, '0'); \ No newline at end of file + (1, 1, 'admin', 103, '研发部门', '2024-06', 20000.00, 5000.00, 1000.00, 500.00, 3000.00, 22500.00, '0', '6月工资', 'admin', now(), '', null), + (2, 2, 'ry', 105, '测试部门', '2024-06', 12000.00, 2000.00, 800.00, 300.00, 1500.00, 13300.00, '0', '6月工资', 'admin', now(), '', null), + (3, 2, 'ry', 105, '测试部门', '2024-07', 12000.00, 1000.00, 500.00, 200.00, 1200.00, 12300.00, '0', '7月工资', 'admin', now(), '', null);