Переглянути джерело

新增选择用户种类user or worker
新增新增志愿者信息模块

LiRong 5 місяців тому
батько
коміт
b6f33c6bd0

+ 6 - 0
leromro-admin/pom.xml

@@ -66,6 +66,12 @@
             <artifactId>leromro-core</artifactId>
         </dependency>
 
+        <!-- 乐融融 系统-->
+        <dependency>
+            <groupId>com.leromro</groupId>
+            <artifactId>leromro_service</artifactId>
+            <version>3.8.9</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 2 - 1
leromro-admin/src/main/java/com/leromro/LeromroApplication.java

@@ -14,7 +14,8 @@ public class LeromroApplication
 {
     public static void main(String[] args)
     {
-        // System.setProperty("spring.devtools.restart.enabled", "false");
+        System.setProperty("spring.devtools.restart.enabled", "false");
+
         SpringApplication.run(LeromroApplication.class, args);
         System.out.println("(♥◠‿◠)ノ゙  若依启动成功   ლ(´ڡ`ლ)゙  \n" +
                 " .-------.       ____     __        \n" +

+ 14 - 4
leromro-admin/src/main/java/com/leromro/web/controller/system/SysLoginController.java

@@ -3,12 +3,10 @@ package com.leromro.web.controller.system;
 import java.util.List;
 import java.util.Set;
 
+import com.leromro.system.service.ISysUserService;
 import lombok.extern.slf4j.Slf4j;
 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.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.leromro.common.constant.Constants;
 import com.leromro.common.core.domain.AjaxResult;
 import com.leromro.common.core.domain.entity.SysMenu;
@@ -41,6 +39,8 @@ public class SysLoginController
 
     @Autowired
     private TokenService tokenService;
+    @Autowired
+    private ISysUserService userService;
 
     /**
      * 登录方法
@@ -107,4 +107,14 @@ public class SysLoginController
         List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
         return AjaxResult.success(menuService.buildMenus(menus));
     }
+
+    @PutMapping("setUserOrWorker/{userOrWorker}")
+    public AjaxResult setUserOrWorker(@PathVariable Integer userOrWorker){
+        Long userId = SecurityUtils.getUserId();
+        SysUser user = new SysUser();
+        user.setUserId(userId);
+        user.setUserOrWorker(userOrWorker);
+        userService.updateUserProfile(user);
+        return AjaxResult.success();
+    }
 }

+ 7 - 5
leromro-admin/src/main/resources/application.yml

@@ -64,7 +64,7 @@ spring:
   devtools:
     restart:
       # 热部署开关
-      enabled: true
+      enabled: false
   # redis 配置
   redis:
     # 地址
@@ -74,7 +74,7 @@ spring:
     # 数据库索引
     database: 0
     # 密码
-    password: 123456
+    # password: 123456
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -104,7 +104,7 @@ mybatis-plus:
   typeAliasesPackage: com.leromro.**.domain
 
 # PageHelper分页插件
-pagehelper:
+pagehelper: 
   helperDialect: mysql
   supportMethodsArguments: true
   params: count=countSql
@@ -125,5 +125,7 @@ xss:
   urlPatterns: /system/*,/monitor/*,/tool/*
 wx:
   url: https://api.weixin.qq.com
-  app-id: wxd757c9902b8d10d9
-  secret: 8743a3bc9611c8d145d2679141e58dd4
+  app-id: wxf8cc1f7fffc41354
+  secret: 36a6c5c2148e1c16a33a59279fed0378
+#  app-id: wx0173594f259dadc6
+#  secret: 4fd3e8dbc1a3fdc73b45baf1c095d5e8

+ 30 - 1
leromro-common/src/main/java/com/leromro/common/core/domain/entity/SysUser.java

@@ -16,7 +16,7 @@ import com.leromro.common.xss.Xss;
 
 /**
  * 用户对象 sys_user
- * 
+ *
  * @author ruoyi
  */
 public class SysUser extends BaseEntity
@@ -100,6 +100,33 @@ public class SysUser extends BaseEntity
     @TableField(exist = false)
     private Long roleId;
 
+    public Integer getUserPlatform() {
+        return userPlatform;
+    }
+
+    public void setUserPlatform(Integer userPlatform) {
+        this.userPlatform = userPlatform;
+    }
+
+    /** 平台 web:0 小程序:1 **/
+
+    private Integer userPlatform ;
+
+    public SysUser(Integer userOrWorker) {
+        this.userOrWorker = userOrWorker;
+    }
+
+    public Integer getUserOrWorker() {
+        return userOrWorker;
+    }
+
+    public void setUserOrWorker(Integer userOrWorker) {
+        this.userOrWorker = userOrWorker;
+    }
+
+    /** 1 用户  2 志愿者 **/
+    private Integer userOrWorker;
+
     public SysUser()
     {
 
@@ -338,6 +365,8 @@ public class SysUser extends BaseEntity
             .append("updateTime", getUpdateTime())
             .append("remark", getRemark())
             .append("dept", getDept())
+            .append("userPlatform",getUserPlatform())
+            .append("userOrWorker",getUserOrWorker())
             .toString();
     }
 }

+ 2 - 0
leromro-framework/src/main/java/com/leromro/framework/web/service/SysLoginService.java

@@ -107,6 +107,8 @@ public class SysLoginService
             user.setNickName("微信用户");
             user.setUserName(IdUtil.getSnowflakeNextIdStr());
             user.setPassword(SecurityUtils.encryptPassword("123456"));
+            //注册新微信用户:平台默认是0(小程序)
+            user.setUserPlatform(0);
             this.userService.save(user);
             result.put("isNew", true);
         } else {

+ 2 - 0
leromro-framework/src/main/java/com/leromro/framework/web/service/SysRegisterService.java

@@ -77,6 +77,8 @@ public class SysRegisterService
         {
             sysUser.setNickName(username);
             sysUser.setPassword(SecurityUtils.encryptPassword(password));
+            //用户平台默认是web端 :1
+            sysUser.setUserPlatform(1);
             boolean regFlag = userService.registerUser(sysUser);
             if (!regFlag)
             {

+ 1 - 0
leromro-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -189,6 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="loginDate != null">login_date = #{loginDate},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  			<if test="remark != null">remark = #{remark},</if>
+ 		    <if test="userOrWorker != null">user_or_worker = #{userOrWorker},</if>
  			update_time = sysdate()
  		</set>
  		where user_id = #{userId}

+ 40 - 0
leromro_service/pom.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.leromro</groupId>
+        <artifactId>leromro</artifactId>
+        <version>3.8.9</version>
+    </parent>
+
+    <artifactId>leromro_service</artifactId>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <!-- 核心模块-->
+        <dependency>
+            <groupId>com.leromro</groupId>
+            <artifactId>leromro-framework</artifactId>
+        </dependency>
+
+        <!-- swagger3-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
+
+
+    </dependencies>
+
+</project>

+ 35 - 0
leromro_service/src/main/java/com/leromro/serve/controller/VolunteerInfoController.java

@@ -0,0 +1,35 @@
+package com.leromro.serve.controller;
+
+
+import com.leromro.common.core.domain.R;
+import com.leromro.common.utils.SecurityUtils;
+import com.leromro.common.utils.uuid.IdUtils;
+import com.leromro.serve.domain.vos.VolunteerInfoVO;
+import com.leromro.serve.service.IVolunteerInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * <p>
+ * 志愿者信息表 前端控制器
+ * </p>
+ *
+ * @author lr
+ * @since 2025-04-07
+ */
+@RestController
+@RequestMapping("/serve/l-volunteer-info")
+public class VolunteerInfoController {
+    @Autowired
+    private IVolunteerInfoService volunteerInfoService;
+    /**
+     * 新增志愿者信息
+     * **/
+    @PutMapping("/insertNewVolunteerInfo/{serviceCategory}")
+    public R newVolunteerInfoByuserId(@RequestBody VolunteerInfoVO volunteerInfoVO, @PathVariable Long serviceCategory){
+        Long userId = SecurityUtils.getUserId();
+        volunteerInfoService.newVolunteerInfoByuserId(volunteerInfoVO,userId,serviceCategory);
+        return R.ok();
+    }
+
+}

+ 99 - 0
leromro_service/src/main/java/com/leromro/serve/domain/VolunteerInfo.java

@@ -0,0 +1,99 @@
+package com.leromro.serve.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 志愿者信息表
+ * </p>
+ *
+ * @author lr
+ * @since 2025-04-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("l_volunteer_info")
+@ApiModel(value="LVolunteerInfo对象", description="志愿者信息表")
+public class VolunteerInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键id")
+    @TableId(value = "volunteer_id", type = IdType.AUTO)
+    private Long volunteerId;
+
+    @ApiModelProperty(value = "用户id")
+    private Long userId;
+
+    @ApiModelProperty(value = "志愿者姓名")
+    private String name;
+
+    @ApiModelProperty(value = "身份证号")
+    private String idCard;
+
+    @ApiModelProperty(value = "照片")
+    private String picture;
+
+    @ApiModelProperty(value = "评分")
+    private Double score;
+
+    @ApiModelProperty(value = "大类别")
+    private Long serviceCategory;
+
+    @ApiModelProperty(value = "小类别")
+    private Long serviceType;
+
+    @ApiModelProperty(value = "学科科目")
+    private Long serviceSubject;
+
+    @ApiModelProperty(value = "技能描述")
+    private String skillDescribe;
+
+    @ApiModelProperty(value = "联系电话")
+    private String phonenumber;
+
+    @ApiModelProperty(value = "性别 0女 1男")
+    private Integer sex;
+
+    @ApiModelProperty(value = "状态 0 不接单  1 正在接单")
+    private Integer status;
+
+    @ApiModelProperty(value = "证书图片")
+    private String certificate;
+
+    @ApiModelProperty(value = "之前工作过的单位")
+    private String workedCompany;
+
+    @ApiModelProperty(value = "职称")
+    private String level;
+
+    @ApiModelProperty(value = "是否在职 0 否 1是")
+    private Integer isOnJob;
+
+    @ApiModelProperty(value = "地区")
+    private String city;
+
+    @ApiModelProperty(value = "详细地址")
+    private String address;
+
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "更新时间")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+
+}

+ 7 - 0
leromro_service/src/main/java/com/leromro/serve/domain/vos/VolunteerInfoVO.java

@@ -0,0 +1,7 @@
+package com.leromro.serve.domain.vos;
+
+import com.leromro.serve.domain.VolunteerInfo;
+
+public class VolunteerInfoVO extends VolunteerInfo {
+
+}

+ 19 - 0
leromro_service/src/main/java/com/leromro/serve/mapper/VolunteerInfoMapper.java

@@ -0,0 +1,19 @@
+package com.leromro.serve.mapper;
+
+import com.leromro.serve.domain.VolunteerInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.leromro.serve.domain.vos.VolunteerInfoVO;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 志愿者信息表 Mapper 接口
+ * </p>
+ *
+ * @author lr
+ * @since 2025-04-07
+ */
+public interface VolunteerInfoMapper extends BaseMapper<VolunteerInfo> {
+
+    void newVolunteerByUserId(@Param("info") VolunteerInfoVO volunteerInfoVO, Long userId);
+}

+ 18 - 0
leromro_service/src/main/java/com/leromro/serve/service/IVolunteerInfoService.java

@@ -0,0 +1,18 @@
+package com.leromro.serve.service;
+
+import com.leromro.serve.domain.VolunteerInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.leromro.serve.domain.vos.VolunteerInfoVO;
+
+/**
+ * <p>
+ * 志愿者信息表 服务类
+ * </p>
+ *
+ * @author lr
+ * @since 2025-04-07
+ */
+public interface IVolunteerInfoService extends IService<VolunteerInfo> {
+
+    void newVolunteerInfoByuserId(VolunteerInfoVO volunteerInfoVO, Long userId,Long serviceCategory);
+}

+ 44 - 0
leromro_service/src/main/java/com/leromro/serve/service/impl/VolunteerInfoServiceImpl.java

@@ -0,0 +1,44 @@
+package com.leromro.serve.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.leromro.serve.domain.VolunteerInfo;
+import com.leromro.serve.domain.vos.VolunteerInfoVO;
+import com.leromro.serve.mapper.VolunteerInfoMapper;
+import com.leromro.serve.service.IVolunteerInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 志愿者信息表 服务实现类
+ * </p>
+ *
+ * @author lr
+ * @since 2025-04-07
+ */
+@Service
+public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, VolunteerInfo> implements IVolunteerInfoService {
+
+    @Autowired
+    private VolunteerInfoMapper volunteerInfoMapper;
+
+    /**
+     * @param volunteerInfoVO
+     * @param userId
+     * @param serviceCategory
+     */
+    @Override
+    public void newVolunteerInfoByuserId(VolunteerInfoVO volunteerInfoVO, Long userId, Long serviceCategory) {
+        LambdaQueryWrapper<VolunteerInfo> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(VolunteerInfo::getVolunteerId, userId).eq(VolunteerInfo::getServiceCategory, serviceCategory);
+        Integer i = volunteerInfoMapper.selectCount(wrapper);
+
+        if(i>0){
+            throw new RuntimeException("此用户已有志愿者信息,不可重复创建,请前往修改");
+        }else {volunteerInfoMapper.newVolunteerByUserId(volunteerInfoVO,userId);}
+    }
+}

+ 57 - 0
leromro_service/src/main/resources/mapper/serve/VolunteerInfoMapper.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.leromro.serve.mapper.VolunteerInfoMapper">
+    <insert id="newVolunteerByUserId">
+        INSERT INTO l_volunteer_info (
+        <if test="info.userId != null">user_id,</if>
+        <if test="info.name != null">name,</if>
+        <if test="info.idCard != null">id_card,</if>
+        <if test="info.picture != null">picture,</if>
+        <if test="info.serviceCategory != null">service_category,</if>
+        <if test="info.serviceType != null">service_type,</if>
+        <if test="info.serviceSubject != null">service_subject,</if>
+        <if test="info.skillDescribe != null">skill_describe,</if>
+        <if test="info.phonenumber != null">phonenumber,</if>
+        <if test="info.sex != null">sex,</if>
+        <if test="volunteerInfoVO.status != null">status,</if>
+        <if test="volunteerInfoVO.certificate != null">certificate,</if>
+        <if test="volunteerInfoVO.workedCompany != null">worked_company,</if>
+        <if test="volunteerInfoVO.level != null">level,</if>
+        <if test="volunteerInfoVO.isOnJob != null">is_on_job,</if>
+        <if test="volunteerInfoVO.city != null">city,</if>
+        <if test="volunteerInfoVO.address != null">address,</if>
+        <if test="volunteerInfoVO.createTime != null">create_time,</if>
+        <if test="volunteerInfoVO.updateTime != null">update_time,</if>
+        <if test="volunteerInfoVO.remark != null">remark</if>
+        )
+        VALUES (
+        <if test="volunteerInfoVO.userId != null">#{volunteerInfoVO.userId},</if>
+        <if test="volunteerInfoVO.name != null">#{volunteerInfoVO.name},</if>
+        <if test="volunteerInfoVO.idCard != null">#{volunteerInfoVO.idCard},</if>
+        <if test="volunteerInfoVO.picture != null">#{volunteerInfoVO.picture},</if>
+        <if test="volunteerInfoVO.serviceCategory != null">#{volunteerInfoVO.serviceCategory},</if>
+        <if test="volunteerInfoVO.serviceType != null">#{volunteerInfoVO.serviceType},</if>
+        <if test="volunteerInfoVO.serviceSubject != null">#{volunteerInfoVO.serviceSubject},</if>
+        <if test="volunteerInfoVO.skillDescribe != null">#{volunteerInfoVO.skillDescribe},</if>
+        <if test="volunteerInfoVO.phonenumber != null">#{volunteerInfoVO.phonenumber},</if>
+        <if test="volunteerInfoVO.sex != null">#{volunteerInfoVO.sex},</if>
+        <if test="volunteerInfoVO.status != null">#{volunteerInfoVO.status},</if>
+        <if test="volunteerInfoVO.certificate != null">#{volunteerInfoVO.certificate},</if>
+        <if test="volunteerInfoVO.workedCompany != null">#{volunteerInfoVO.workedCompany},</if>
+        <if test="volunteerInfoVO.level != null">#{volunteerInfoVO.level},</if>
+        <if test="volunteerInfoVO.isOnJob != null">#{volunteerInfoVO.isOnJob},</if>
+        <if test="volunteerInfoVO.city != null">#{volunteerInfoVO.city},</if>
+        <if test="volunteerInfoVO.address != null">#{volunteerInfoVO.address},</if>
+        <if test="volunteerInfoVO.createTime != null">#{volunteerInfoVO.createTime},</if>
+        <if test="volunteerInfoVO.updateTime != null">#{volunteerInfoVO.updateTime},</if>
+        <if test="volunteerInfoVO.remark != null">#{volunteerInfoVO.remark}</if>
+        )
+
+
+
+    </insert>
+
+
+</mapper>

+ 1 - 0
pom.xml

@@ -263,6 +263,7 @@
         <module>leromro-generator</module>
         <module>leromro-common</module>
         <module>leromro-core</module>
+        <module>leromro_service</module>
     </modules>
     <packaging>pom</packaging>