diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java index bb86b81..52778e0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/EnterpriseController.java @@ -68,6 +68,10 @@ public class EnterpriseController extends BaseController{ return success(enterprisesService.selectEnterprisesById(id)); } +// public AjaxResult getEnterprisesByUserId(Long userId) { +// +// } + /** * 新增企业 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/TaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/TaskController.java new file mode 100644 index 0000000..ecc62ad --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/TaskController.java @@ -0,0 +1,24 @@ +package com.ruoyi.web.controller.app; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.service.ITasksService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/app/task") +@Slf4j +public class TaskController { + + @Autowired + private ITasksService iTasksService; + + @RequestMapping("/list") + public AjaxResult getTask() { + iTasksService.getAppTaskList(); + return AjaxResult.success(); + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java index d6ca25d..8c3275f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java @@ -83,5 +83,4 @@ public class WeChatLoginController { ajax.put("permissions", permissions); return ajax; } - } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java index f78bce7..2ef0ef5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/EnterprisesController.java @@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse; import com.ruoyi.system.domain.EnterpriseUsers; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; +import com.ruoyi.system.domain.vo.LabelValueVo; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -49,6 +50,17 @@ public class EnterprisesController extends BaseController return getDataTable(list); } + /** + * 查询企业简易列表 + */ +// @PreAuthorize("@ss.hasPermi('system:enterprises:list')") + @GetMapping("/simpleList") + public AjaxResult simpleList(Enterprises enterprises) + { + List list = enterprisesService.simpleList(enterprises); + return success(list); + } + /** * 导出企业列表 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index 9a50ad3..6f83077 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system; import java.util.List; import java.util.Set; + +import com.ruoyi.framework.utils.WeChatUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.ruoyi.common.constant.Constants; @@ -37,13 +39,16 @@ public class SysLoginController @Autowired private TokenService tokenService; + @Autowired + private WeChatUtils weChatUtils; + /** * 登录方法 * * @param loginBody 登录信息 * @return 结果 */ - @PostMapping("/login") + @PostMapping("login") public AjaxResult login(@RequestBody LoginBody loginBody) { AjaxResult ajax = AjaxResult.success(); @@ -92,4 +97,24 @@ public class SysLoginController List menus = menuService.selectMenuTreeByUserId(userId); return AjaxResult.success(menuService.buildMenus(menus)); } + + /** + * 获取微信二维码 URL + */ + @GetMapping("/wechat/qrcode") + public AjaxResult getWeChatQRCode(@RequestParam String state) { + String url = weChatUtils.getQRCodeUrl(state); + return AjaxResult.success("成功获取二维码", url); + } + + @GetMapping("/login/callback") + public AjaxResult weChatCallback(@RequestParam String code, @RequestParam String state) { + // 校验 state 是否匹配(防止 CSRF 攻击) + if (!"veryGood".equals(state)) { + return AjaxResult.error("非法请求"); + } + // 使用 code 获取微信用户信息 + String token = loginService.weChatLogin(code, "00"); + return AjaxResult.success("登录成功", token); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TasksController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TasksController.java new file mode 100644 index 0000000..9a7dd92 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TasksController.java @@ -0,0 +1,106 @@ +package com.ruoyi.web.controller.system; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.system.domain.vo.TaskSaveVo; +import org.springframework.security.access.prepost.PreAuthorize; +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.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.Tasks; +import com.ruoyi.system.service.ITasksService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 任务,用于存储所有的任务信息,任务可由不同用户创建并管理。Controller + * + * @author ruoyi + * @date 2025-01-14 + */ +@RestController +@RequestMapping("/system/tasks") +public class TasksController extends BaseController +{ + @Autowired + private ITasksService tasksService; + + /** + * 查询任务,用于存储所有的任务信息,任务可由不同用户创建并管理。列表 + */ +// @PreAuthorize("@ss.hasPermi('system:tasks:list')") +// @GetMapping("/list") +// public TableDataInfo list(Tasks tasks) +// { +// startPage(); +// List list = tasksService.(tasks); +// return getDataTable(list); +// } +// +// /** +// * 导出任务,用于存储所有的任务信息,任务可由不同用户创建并管理。列表 +// */ +// @PreAuthorize("@ss.hasPermi('system:tasks:export')") +// @Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, Tasks tasks) +// { +// List list = tasksService.selectTasksList(tasks); +// ExcelUtil util = new ExcelUtil(Tasks.class); +// util.exportExcel(response, list, "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。数据"); +// } +// +// /** +// * 获取任务,用于存储所有的任务信息,任务可由不同用户创建并管理。详细信息 +// */ +// @PreAuthorize("@ss.hasPermi('system:tasks:query')") +// @GetMapping(value = "/{id}") +// public AjaxResult getInfo(@PathVariable("id") Long id) +// { +// return success(tasksService.selectTasksById(id)); +// } +// +// /** +// * 新增任务,用于存储所有的任务信息,任务可由不同用户创建并管理。 +// */ + @PreAuthorize("@ss.hasPermi('system:tasks:add')") + @Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody TaskSaveVo taskSaveVo) + { + return toAjax(tasksService.insertTasks(taskSaveVo)); + } +// +// /** +// * 修改任务,用于存储所有的任务信息,任务可由不同用户创建并管理。 +// */ +// @PreAuthorize("@ss.hasPermi('system:tasks:edit')") +// @Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@RequestBody Tasks tasks) +// { +// return toAjax(tasksService.updateTasks(tasks)); +// } +// +// /** +// * 删除任务,用于存储所有的任务信息,任务可由不同用户创建并管理。 +// */ +// @PreAuthorize("@ss.hasPermi('system:tasks:remove')") +// @Log(title = "任务,用于存储所有的任务信息,任务可由不同用户创建并管理。", businessType = BusinessType.DELETE) +// @DeleteMapping("/{ids}") +// public AjaxResult remove(@PathVariable Long[] ids) +// { +// return toAjax(tasksService.deleteTasksByIds(ids)); +// } +} diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index e275203..3b6d867 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -128,6 +128,14 @@ mybatis-plus-boot-starter + + org.springframework.boot + spring-boot-starter-validation + + + org.quartz-scheduler + quartz + diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/WeChatConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/WeChatConfig.java index 342b079..c941b9c 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/WeChatConfig.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/WeChatConfig.java @@ -1,28 +1,15 @@ package com.ruoyi.common.config; +import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component @ConfigurationProperties(prefix = "wx") +@Data public class WeChatConfig { private String appId; private String appSecret; - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getAppSecret() { - return appSecret; - } - - public void setAppSecret(String appSecret) { - this.appSecret = appSecret; - } + private String callBackUrl; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TaskDTO.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TaskDTO.java new file mode 100644 index 0000000..0f8fc35 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TaskDTO.java @@ -0,0 +1,24 @@ +package com.ruoyi.common.core.domain; + +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class TaskDTO { + //任务标题 + private String title; + //任务类型 + private Integer taskType; + //任务优先级 + private String priority; + //任务状态 + private String status; + //任务计划开始时间 + private LocalDate startDate; + //任务计划结束时间 + private LocalDate endDate; + //企业集合 + private List enterprisesList; +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ScheduleUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ScheduleUtils.java new file mode 100644 index 0000000..f33a5c2 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ScheduleUtils.java @@ -0,0 +1,41 @@ +package com.ruoyi.common.utils; + +import org.quartz.*; +import org.springframework.stereotype.Component; + +/** + * 定时任务工具类,支持创建和删除任务 + */ +@Component +public class ScheduleUtils { + + /** + * 创建定时任务 + * + * @param scheduler Quartz调度器 + * @param jobName 任务名称 + * @param groupName 任务分组 + * @param cronExpression Cron表达式 + * @param jobDetail 任务详情 + */ + public static void createJob(Scheduler scheduler, String jobName, String groupName, String cronExpression, JobDetail jobDetail) throws SchedulerException { + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression); + CronTrigger trigger = TriggerBuilder.newTrigger() + .withIdentity(jobName, groupName) + .withSchedule(cronScheduleBuilder) + .build(); + scheduler.scheduleJob(jobDetail, trigger); + } + + /** + * 删除定时任务 + * + * @param scheduler Quartz调度器 + * @param jobName 任务名称 + * @param groupName 任务分组 + */ + public static void deleteJob(Scheduler scheduler, String jobName, String groupName) throws SchedulerException { + JobKey jobKey = JobKey.jobKey(jobName, groupName); + scheduler.deleteJob(jobKey); + } +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 799bc52..ae251c5 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -111,7 +111,7 @@ public class SecurityConfig .authorizeHttpRequests((requests) -> { permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll()); // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - requests.antMatchers("/login", "/register","/app/login", "/captchaImage").permitAll() + requests.antMatchers("/admin/login", "/register","/app/login", "/captchaImage").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/utils/WeChatUtils.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/utils/WeChatUtils.java index 6d7327f..b4c425a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/utils/WeChatUtils.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/utils/WeChatUtils.java @@ -16,6 +16,7 @@ public class WeChatUtils { private final RestTemplate restTemplate = new RestTemplate(); + //获取openid public JSONObject getSession(String code) { String appId = weChatConfig.getAppId(); String appSecret = weChatConfig.getAppSecret(); @@ -61,5 +62,19 @@ public class WeChatUtils { } } + /** + * 构建微信扫码登录的二维码 URL + */ + public String getQRCodeUrl(String state) { + + String appId = weChatConfig.getAppId(); + String callBackUrl = weChatConfig.getCallBackUrl(); + return String.format( + "https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_login&state=%s", + appId, callBackUrl, state + ); + } + + // } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index dc4c94e..f3aa5fa 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -73,6 +73,9 @@ public class SysLoginService @Autowired private ISysConfigService configService; +// @Autowired +// private SysPermissionService permissionService; + @Autowired private SysUserMapper sysUserMapper; @Autowired @@ -231,23 +234,25 @@ public class SysLoginService @Transactional public void register(RegisterVo registerVo) { final Long userId = SecurityUtils.getUserId(); - final SysUser sysUser = userService.selectUserById(userId); if (sysUser == null) { - throw new ServiceException(); + throw new ServiceException("用户不存在"); } +// if (registerVo.getUserType() != null && "01".equals(registerVo.getUserType())) { +// } + BeanUtils.copyProperties(registerVo, sysUser); -// sysUserMapper.selectUserByWxOpenid() - -// BeanUtils.copyProperties(user, registerVo); -// -// sysUserMapper.updateUser(user); +// sysUser.setStatus("1"); + final int res = sysUserMapper.updateUser(sysUser); + if (res < 0) { + throw new ServiceException("添加失败"); + } } public String weChatLogin(String code, String type) { -// Map wxSession = this.getWxSession(code); + Map wxSession = this.getWxSession(code); // if (type == null || "".equals(type)) { // throw new ServiceException("缺少类型"); @@ -273,6 +278,7 @@ public class SysLoginService // user.setPhonenumber(""); // user.setSex(""); user.setStatus("1"); // 默认停用状态 + user.setUserType("03"); //初始用户类型 // 保存用户信息 int rows = sysUserMapper.insertUser(user); if (rows <= 0) { diff --git a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index bf88988..0eab21c 100644 --- a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -26,7 +26,7 @@ import com.ruoyi.common.core.page.TableDataInfo; /** * ${functionName}Controller - * + * * @author ${author} * @date ${datetime} */ diff --git a/ruoyi-generator/src/main/resources/vm/java/domain.java.vm b/ruoyi-generator/src/main/resources/vm/java/domain.java.vm index ef583da..26bcc98 100644 --- a/ruoyi-generator/src/main/resources/vm/java/domain.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/domain.java.vm @@ -9,11 +9,6 @@ import com.baomidou.mybatisplus.annotation.TableName; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.rchuing.sis.common.annotation.Excel; -import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; #if($table.crud || $table.sub) import com.rchuing.sis.common.core.domain.BaseEntity; #elseif($table.tree) @@ -27,48 +22,91 @@ import com.fenghuang.common.core.domain.TreeEntity; * @date ${datetime} */ #if($table.crud || $table.sub) - #set($Entity="BaseEntity") + #set($Entity="BaseEntity") #elseif($table.tree) - #set($Entity="TreeEntity") + #set($Entity="TreeEntity") #end -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@TableName("${tableName}") -public class ${ClassName} implements Serializable -{ - private static final long serialVersionUID = 1L; +@TableName(resultMap = "${packageName}.mapper.${ClassName}Mapper.${ClassName}Result") +public class ${ClassName} extends ${Entity} + { +private static final long serialVersionUID = 1L; - #foreach ($column in $columns) - #if(!$table.isSuperColumn($column.javaField)) - /** $column.columnComment */ - #if($column.list) - #set($parentheseIndex=$column.columnComment.indexOf("(")) - #if($parentheseIndex != -1) - #set($comment=$column.columnComment.substring(0, $parentheseIndex)) - #else - #set($comment=$column.columnComment) - #end - #if($parentheseIndex != -1) - @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") - @TableField("`$column.columnName`") - #elseif($column.javaType == 'Date') - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") - @TableField("`$column.columnName`") - #else - @Excel(name = "${comment}") - @TableField("`$column.columnName`") - #end - #end - #if($column.isPk == 1) - @TableId(type = IdType.AUTO) - #end + #foreach ($column in $columns) + #if(!$table.isSuperColumn($column.javaField)) + /** $column.columnComment */ + #if($column.list) + #set($parentheseIndex=$column.columnComment.indexOf("(")) + #if($parentheseIndex != -1) + #set($comment=$column.columnComment.substring(0, $parentheseIndex)) + #else + #set($comment=$column.columnComment) + #end + #if($parentheseIndex != -1) + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + #elseif($column.javaType == 'Date') + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") + #else + @Excel(name = "${comment}") + #end + #end + #if($column.isPk == 1) + @TableId(value = "$column.columnName",type = IdType.AUTO) + #end + private $column.javaType $column.javaField; - private $column.javaType $column.javaField; + #end + #end + #if($table.sub) + /** $table.subTable.functionName信息 */ + private List<${subClassName}> ${subclassName}List; - #end - #end + #end + #foreach ($column in $columns) + #if(!$table.isSuperColumn($column.javaField)) + #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) + #set($AttrName=$column.javaField) + #else + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #end + public void set${AttrName}($column.javaType $column.javaField) + { + this.$column.javaField = $column.javaField; + } + public $column.javaType get${AttrName}() + { + return $column.javaField; + } + #end + #end + #if($table.sub) + public List<${subClassName}> get${subClassName}List() + { + return ${subclassName}List; + } + + public void set${subClassName}List(List<${subClassName}> ${subclassName}List) + { + this.${subclassName}List = ${subclassName}List; + } + + #end +@Override +public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + #foreach ($column in $columns) + #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]")) + #set($AttrName=$column.javaField) + #else + #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) + #end + .append("${column.javaField}", get${AttrName}()) + #end + #if($table.sub) + .append("${subclassName}List", get${subClassName}List()) + #end + .toString(); +} + } diff --git a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm index 5c1df73..4e0a530 100644 --- a/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm @@ -14,5 +14,78 @@ import ${packageName}.domain.${subClassName}; * @date ${datetime} */ public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int insert${ClassName}(${ClassName} ${className}); + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + + /** + * 删除${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的数据主键集合 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + #if($table.sub) + + /** + * 批量删除${subTable.functionName} + * + * @param ${pkColumn.javaField}s 需要删除的数据主键集合 + * @return 结果 + */ + public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + + /** + * 批量新增${subTable.functionName} + * + * @param ${subclassName}List ${subTable.functionName}列表 + * @return 结果 + */ + public int batch${subClassName}(List<${subClassName}> ${subclassName}List); + + + /** + * 通过${functionName}主键删除${subTable.functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}ID + * @return 结果 + */ + public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField}); + #end } diff --git a/ruoyi-generator/src/main/resources/vm/java/service.java.vm b/ruoyi-generator/src/main/resources/vm/java/service.java.vm index 757f1e2..fca2d6c 100644 --- a/ruoyi-generator/src/main/resources/vm/java/service.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/service.java.vm @@ -11,5 +11,51 @@ import com.baomidou.mybatisplus.extension.service.IService; * @date ${datetime} */ public interface I${ClassName}Service extends IService<${ClassName}> { + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName}集合 + */ + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int insert${ClassName}(${ClassName} ${className}); + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + public int update${ClassName}(${ClassName} ${className}); + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); } diff --git a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm index aa130ef..3dda1d7 100644 --- a/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm @@ -28,5 +28,135 @@ import ${packageName}.service.I${ClassName}Service; */ @Service public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { + @Autowired + private ${ClassName}Mapper ${className}Mapper; + /** + * 查询${functionName} + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return ${functionName} + */ + @Override + public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) { + return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); + } + + /** + * 查询${functionName}列表 + * + * @param ${className} ${functionName} + * @return ${functionName} + */ + @Override + public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) { + return ${className}Mapper.select${ClassName}List(${className}); + } + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + #if($table.sub) + @Transactional + #end + @Override + public int insert${ClassName}(${ClassName} ${className}) { + #foreach ($column in $columns) + #if($column.javaField == 'createTime') + ${className}.setCreateTime(DateUtils.getNowDate()); + #end + #end + #if($table.sub) + int rows = ${className}Mapper.insert${ClassName}(${className}); + insert${subClassName}(${className}); + return rows; + #else + return ${className}Mapper.insert${ClassName}(${className}); + #end + } + + /** + * 修改${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ + #if($table.sub) + @Transactional + #end + @Override + public int update${ClassName}(${ClassName} ${className}) { + #foreach ($column in $columns) + #if($column.javaField == 'updateTime') + ${className}.setUpdateTime(DateUtils.getNowDate()); + #end + #end + #if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); + insert${subClassName}(${className}); + #end + return ${className}Mapper.update${ClassName}(${className}); + } + + /** + * 批量删除${functionName} + * + * @param ${pkColumn.javaField}s 需要删除的${functionName}主键 + * @return 结果 + */ + #if($table.sub) + @Transactional + #end + @Override + public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) { + #if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s); + #end + return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s); + } + + /** + * 删除${functionName}信息 + * + * @param ${pkColumn.javaField} ${functionName}主键 + * @return 结果 + */ + #if($table.sub) + @Transactional + #end + @Override + public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) { + #if($table.sub) + ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); + #end + return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); + } + #if($table.sub) + + /** + * 新增${subTable.functionName}信息 + * + * @param ${className} ${functionName}对象 + */ + public void insert${subClassName}(${ClassName} ${className}) { + List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); + ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); + if (StringUtils.isNotNull(${subclassName}List)) + { + List<${subClassName}> list = new ArrayList<${subClassName}>(); + for (${subClassName} ${subclassName} : ${subclassName}List) + { + ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); + list.add(${subclassName}); + } + if (list.size() > 0) + { + ${className}Mapper.batch${subClassName}(list); + } + } + } + #end } diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml index 0421087..416eda6 100644 --- a/ruoyi-quartz/pom.xml +++ b/ruoyi-quartz/pom.xml @@ -37,4 +37,4 @@ - \ No newline at end of file + diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/AutowiringSpringBeanJobFactory.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/AutowiringSpringBeanJobFactory.java new file mode 100644 index 0000000..0da433b --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/AutowiringSpringBeanJobFactory.java @@ -0,0 +1,22 @@ +package com.ruoyi.quartz.config; + +import org.quartz.spi.TriggerFiredBundle; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.context.ApplicationContext; +import org.springframework.scheduling.quartz.SpringBeanJobFactory; +import org.springframework.stereotype.Component; + +@Component +public class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory { + + @Autowired + private ApplicationContext applicationContext; + + @Override + protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { + Object jobInstance = super.createJobInstance(bundle); + applicationContext.getAutowireCapableBeanFactory().autowireBean(jobInstance); + return jobInstance; + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/QuartzConfig.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/QuartzConfig.java new file mode 100644 index 0000000..45e9915 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/QuartzConfig.java @@ -0,0 +1,30 @@ +package com.ruoyi.quartz.config; + +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +@Configuration +public class QuartzConfig { + + private final AutowiringSpringBeanJobFactory jobFactory; + + public QuartzConfig(AutowiringSpringBeanJobFactory jobFactory) { + this.jobFactory = jobFactory; + } + + @Bean + public SchedulerFactoryBean schedulerFactoryBean() { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setJobFactory(jobFactory); // 设置自定义 Job 工厂 + return factory; + } + + @Bean + public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) throws SchedulerException { + return schedulerFactoryBean.getScheduler(); + } +} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java index d4e065a..92d7685 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java @@ -8,7 +8,7 @@ // ///** // * 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效) -// * +// * // * @author ruoyi // */ //@Configuration diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AutoTaskJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AutoTaskJob.java new file mode 100644 index 0000000..5290823 --- /dev/null +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/AutoTaskJob.java @@ -0,0 +1,25 @@ +package com.ruoyi.quartz.task; + +import com.ruoyi.common.core.domain.TaskDTO; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component("autoTask") +public class AutoTaskJob implements Job { + + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + + // 获取任务信息 + TaskDTO task = (TaskDTO) jobExecutionContext.getJobDetail().getJobDataMap().get("task"); + System.out.println("AutoTaskJob execute"); + System.out.println("执行任务:" + task.getTitle()); + jobExecutionContext.getJobDetail().getKey().getName(); + } +// + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TaskEnterprises.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TaskEnterprises.java new file mode 100644 index 0000000..e6c031d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TaskEnterprises.java @@ -0,0 +1,32 @@ +package com.ruoyi.system.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 任务企业映射,用于关联任务与企业的对应关系。对象 task_enterprises + * + * @author ruoyi + * @date 2025-01-14 + */ +@TableName("tasks_enterprises") +@Data +public class TaskEnterprises extends BaseEntity + { + private static final long serialVersionUID = 1L; + + /** 映射记录ID,主键 */ + @TableId(value = "id",type = IdType.AUTO) + private Long id; + + /** 任务ID */ + private Long taskId; + + /** 企业ID */ + private Long enterpriseId; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Tasks.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Tasks.java new file mode 100644 index 0000000..bba0b0f --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Tasks.java @@ -0,0 +1,86 @@ +package com.ruoyi.system.domain; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import java.io.Serializable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 任务,用于存储所有的任务信息,任务可由不同用户创建并管理。对象 tasks + * + * @author ruoyi + * @date 2025-01-14 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("tasks") +public class Tasks extends BaseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 任务ID,主键 + */ + @TableId(type = IdType.AUTO) + private Long id; + + /** + * 任务标题 + */ + @TableField("`title`") + private String title; + + /** + * 任务描述 + */ + @TableField("`description`") + private String description; + + /** + * 任务类型,表示任务的类别,例如:1.发布任务、2.自动任务等 + */ + @TableField("`task_type`") + private Integer taskType; + + /** + * 任务优先级 + */ + @TableField("`priority`") + private String priority; + + /** + * 任务状态 + */ + @TableField("`status`") + private String status; + + /** + * 任务计划开始时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @TableField("`start_date`") + private LocalDate startDate; + + /** + * 任务计划结束时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @TableField("`end_date`") + private LocalDate endDate; + +} + + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/LabelValueVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/LabelValueVo.java new file mode 100644 index 0000000..d07c903 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/LabelValueVo.java @@ -0,0 +1,9 @@ +package com.ruoyi.system.domain.vo; + +import lombok.Data; + +@Data +public class LabelValueVo { + private String label; + private Long value; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RegisterVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RegisterVo.java index d57624d..9cd9765 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RegisterVo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RegisterVo.java @@ -2,11 +2,13 @@ package com.ruoyi.system.domain.vo; import lombok.Data; +import javax.validation.constraints.NotBlank; + @Data public class RegisterVo { private String nickName; private String sex; private String phonenumber; - private String deptId; - private String code; + private Long deptId; + private String userType; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TaskSaveVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TaskSaveVo.java new file mode 100644 index 0000000..1cb2aa9 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/TaskSaveVo.java @@ -0,0 +1,25 @@ +package com.ruoyi.system.domain.vo; + +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class TaskSaveVo { + //任务标题 + private String title; + //任务类型 + private Integer taskType; + //任务优先级 + private String priority; + //任务状态 + private String status; + //任务计划开始时间 + private LocalDate startDate; + //任务计划结束时间 + private LocalDate endDate; + //企业集合 + private List enterprisesList; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskEnterprisesMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskEnterprisesMapper.java new file mode 100644 index 0000000..6c8ae07 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TaskEnterprisesMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.domain.TaskEnterprises; +import com.ruoyi.system.domain.TaskEnterprises; +import org.apache.ibatis.annotations.Mapper; + +/** + * ${comments} Mapper 接口 + * + * @author ruoyi + * @date ${date} + */ +@Mapper +public interface TaskEnterprisesMapper extends BaseMapper { +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TasksMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TasksMapper.java new file mode 100644 index 0000000..83ff6ef --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TasksMapper.java @@ -0,0 +1,17 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.domain.Tasks; +import org.apache.ibatis.annotations.Mapper; + +/** + * 任务,用于存储所有的任务信息,任务可由不同用户创建并管理。Mapper接口 + * + * @author ruoyi + * @date 2025-01-14 + */ +@Mapper +public interface TasksMapper extends BaseMapper { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java index 9fb0a6b..f54dc2d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IEnterprisesService.java @@ -3,6 +3,7 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.Enterprises; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; +import com.ruoyi.system.domain.vo.LabelValueVo; /** * 企业Service接口 @@ -61,4 +62,6 @@ public interface IEnterprisesService public int deleteEnterprisesById(Long id); public void addEnterpriseUsers(EnterpriseUserInsertVo enterpriseUserInsertVo); + + public List simpleList(Enterprises enterprises); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITaskEnterprisesService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITaskEnterprisesService.java new file mode 100644 index 0000000..152b1ba --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITaskEnterprisesService.java @@ -0,0 +1,15 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.TaskEnterprises; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 任务企业映射,用于关联任务与企业的对应关系。Service接口 + * + * @author ruoyi + * @date 2025-01-14 + */ +public interface ITaskEnterprisesService extends IService { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITasksService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITasksService.java new file mode 100644 index 0000000..bf1d1c9 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITasksService.java @@ -0,0 +1,19 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.Tasks; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.system.domain.vo.TaskSaveVo; + +/** + * 任务,用于存储所有的任务信息,任务可由不同用户创建并管理。Service接口 + * + * @author ruoyi + * @date 2025-01-14 + */ +public interface ITasksService extends IService { + int insertTasks(TaskSaveVo taskSaveVo); + + List getAppTaskList(); + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java index 6b97dce..7972160 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EnterprisesServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service.impl; +import java.util.ArrayList; import java.util.List; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -7,7 +8,9 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.system.domain.EnterpriseUsers; import com.ruoyi.system.domain.vo.EnterpriseUserInsertVo; +import com.ruoyi.system.domain.vo.LabelValueVo; import com.ruoyi.system.mapper.EnterpriseUsersMapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.EnterprisesMapper; @@ -22,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional; * @date 2025-01-08 */ @Service +@Slf4j + public class EnterprisesServiceImpl implements IEnterprisesService { @Autowired @@ -123,4 +128,22 @@ public class EnterprisesServiceImpl implements IEnterprisesService enterpriseUsersMapper.insert(enterpriseUsers); }); } + + @Override + public List simpleList(Enterprises enterprises) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.select(Enterprises::getId, Enterprises::getEnterprisesName); + + final List enterprisesList = enterprisesMapper.selectList(wrapper); + + List labelValueVo = new ArrayList<>(); + enterprisesList.forEach(item->{ + LabelValueVo res = new LabelValueVo(); + res.setLabel(item.getEnterprisesName()); + res.setValue(item.getId()); + labelValueVo.add(res); + }); + + return labelValueVo; + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TaskEnterprisesServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TaskEnterprisesServiceImpl.java new file mode 100644 index 0000000..f279220 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TaskEnterprisesServiceImpl.java @@ -0,0 +1,19 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.TaskEnterprisesMapper; +import com.ruoyi.system.domain.TaskEnterprises; +import com.ruoyi.system.service.ITaskEnterprisesService; + +/** + * 任务企业映射,用于关联任务与企业的对应关系。Service业务层处理 + * + * @author ruoyi + * @date 2025-01-14 + */ +@Service +public class TaskEnterprisesServiceImpl extends ServiceImpl implements ITaskEnterprisesService { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TasksServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TasksServiceImpl.java new file mode 100644 index 0000000..bfc2b42 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TasksServiceImpl.java @@ -0,0 +1,74 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.system.domain.TaskEnterprises; +import com.ruoyi.system.domain.vo.TaskSaveVo; +import com.ruoyi.system.mapper.TaskEnterprisesMapper; +import com.ruoyi.system.service.ITaskEnterprisesService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.TasksMapper; +import com.ruoyi.system.domain.Tasks; +import com.ruoyi.system.service.ITasksService; +import com.ruoyi.system.mapper.TasksMapper; +import reactor.core.scheduler.Scheduler; + +import java.util.List; +//import org.quartz.Scheduler; + +/** + * 任务,用于存储所有的任务信息,任务可由不同用户创建并管理。Service业务层处理 + * + * @author ruoyi + * @date 2025-01-14 + */ +@Service +public class TasksServiceImpl extends ServiceImpl implements ITasksService { + + @Autowired + private TaskEnterprisesMapper taskEnterprisesMapper; + @Autowired + private TasksMapper tasksMapper; + + + @Override + public int insertTasks(TaskSaveVo taskSaveVo) { + //任务类型 + Tasks tasks = new Tasks(); + + BeanUtils.copyProperties(taskSaveVo, tasks); + + final int insert = tasksMapper.insert(tasks); + if (insert < 1) { + throw new ServiceException("插入失败"); + } + + if (taskSaveVo.getTaskType() == 2) { + //自动执行 + + + } else { + + } + + final List enterprisesList = taskSaveVo.getEnterprisesList(); + for (Long id : enterprisesList) { + TaskEnterprises enterprises = new TaskEnterprises(); + enterprises.setTaskId(tasks.getId()); + enterprises.setEnterpriseId(id); + taskEnterprisesMapper.insert(enterprises); + } + + return 0; + } + + @Override + public List getAppTaskList() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(Tasks::getTaskType, 1); + return tasksMapper.selectList(wrapper); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/TasksMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TasksMapper.xml new file mode 100644 index 0000000..c957354 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/TasksMapper.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + select id, creator, title, description, task_type, priority, status, start_date, end_date, create_time, update_time, updater, deleted from tasks + + + + + + + + insert into tasks + + creator, + title, + description, + task_type, + priority, + status, + start_date, + end_date, + create_time, + update_time, + updater, + deleted, + + + #{creator}, + #{title}, + #{description}, + #{taskType}, + #{priority}, + #{status}, + #{startDate}, + #{endDate}, + #{createTime}, + #{updateTime}, + #{updater}, + #{deleted}, + + + + + update tasks + + creator = #{creator}, + title = #{title}, + description = #{description}, + task_type = #{taskType}, + priority = #{priority}, + status = #{status}, + start_date = #{startDate}, + end_date = #{endDate}, + create_time = #{createTime}, + update_time = #{updateTime}, + updater = #{updater}, + deleted = #{deleted}, + + where id = #{id} + + + + delete from tasks where id = #{id} + + + + delete from tasks where id in + + #{id} + + +