瀏覽代碼

律所模块

qxy 4 周之前
父節點
當前提交
d6e3f6dc49

+ 5 - 1
alien-entity/src/main/java/shop/alien/entity/store/LifeSys.java

@@ -16,13 +16,17 @@ import java.util.Date;
 @TableName("life_sys")
 public class LifeSys {
 
+    @ApiModelProperty(value = "主键")
     @TableId(value = "id", type = IdType.AUTO)
-    private String id;
+    private Integer id;
 
+    @ApiModelProperty(value = "用户名")
     private String userName;
 
+    @ApiModelProperty(value = "密码")
     private String userPassword;
 
+    @ApiModelProperty(value = "角色id")
     private String roleId;
 
     @ApiModelProperty(value = "删除标记, 0:未删除, 1:已删除")

+ 1 - 0
alien-entity/src/main/java/shop/alien/mapper/LawFirmMapper.java

@@ -17,3 +17,4 @@ public interface LawFirmMapper extends BaseMapper<LawFirm> {
 
 }
 
+

+ 1 - 0
alien-entity/src/main/resources/mapper/LawFirmMapper.xml

@@ -58,3 +58,4 @@
 
 </mapper>
 
+

+ 16 - 1
alien-gateway/src/main/java/shop/alien/gateway/controller/SystemController.java

@@ -5,8 +5,10 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.LifeSys;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.dto.SystemLoginDto;
+import shop.alien.entity.store.dto.SystemRegisterDto;
 import shop.alien.entity.store.vo.SystemLoginVo;
 import shop.alien.gateway.service.SystemService;
 import shop.alien.util.common.TokenInfo;
@@ -41,7 +43,7 @@ public class SystemController {
     }
 
     @ApiOperation("web中台退出登录")
-    @ApiOperationSupport(order = 1)
+    @ApiOperationSupport(order = 2)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "query"),
@@ -51,4 +53,17 @@ public class SystemController {
         return R.success("退出成功");
     }
 
+    @ApiOperation("系统用户注册")
+    @ApiOperationSupport(order = 3)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String", paramType = "body", required = true),
+            @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "body", required = true),
+            @ApiImplicitParam(name = "roleId", value = "角色id", dataType = "String", paramType = "body", required = false),
+    })
+    @PostMapping(value = "/register")
+    public R<LifeSys> register(@RequestBody SystemRegisterDto registerDto) {
+        log.info("SystemController.register?userName={},roleId={}", registerDto.getUserName(), registerDto.getRoleId());
+        return systemService.register(registerDto.getUserName(), registerDto.getPassword(), registerDto.getRoleId());
+    }
+
 }

+ 12 - 0
alien-gateway/src/main/java/shop/alien/gateway/service/SystemService.java

@@ -1,5 +1,7 @@
 package shop.alien.gateway.service;
 
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.LifeSys;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.vo.SystemLoginVo;
 
@@ -15,4 +17,14 @@ public interface SystemService {
 
     public SystemLoginVo logout(UserLoginInfo userLoginInfo);
 
+    /**
+     * 系统用户注册
+     *
+     * @param userName 用户名
+     * @param password 密码
+     * @param roleId   角色id
+     * @return R<LifeSys>
+     */
+    R<LifeSys> register(String userName, String password, String roleId);
+
 }

+ 40 - 2
alien-gateway/src/main/java/shop/alien/gateway/service/impl/SystemServiceImpl.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.LifeSys;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.vo.SystemLoginVo;
@@ -66,11 +68,11 @@ public class SystemServiceImpl implements SystemService {
                 new LambdaQueryWrapper<LifeSys>()
                         .eq(LifeSys::getUserName, username)
         );
-        if (lifeSys != null && encryptToMD5(lifeSys.getUserPassword()).equals(password)) {
+        if (lifeSys != null && lifeSys.getUserPassword().equals(encryptToMD5(password))) {
             Map<String, String> tokenMap = new HashMap<>();
             tokenMap.put("phone", "123456");
             tokenMap.put("userName", lifeSys.getUserName());
-            tokenMap.put("userId", lifeSys.getId());
+            tokenMap.put("userId", String.valueOf(lifeSys.getId()));
             tokenMap.put("userType", "web");
             //存入token
             result.setToken(JwtUtil.createJWT("web_" + lifeSys.getId(), lifeSys.getUserName(), JSONObject.toJSONString(tokenMap), effectiveTimeIntLong));
@@ -92,6 +94,42 @@ public class SystemServiceImpl implements SystemService {
         return null;
     }
 
+    @Override
+    public R<LifeSys> register(String userName, String password, String roleId) {
+        // 校验必填字段
+        if (!StringUtils.hasText(userName)) {
+            return R.fail("用户名不能为空");
+        }
+        if (!StringUtils.hasText(password)) {
+            return R.fail("密码不能为空");
+        }
+
+        // 校验用户名是否已存在
+        LambdaQueryWrapper<LifeSys> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(LifeSys::getUserName, userName);
+        LifeSys existingUser = lifeSysMapper.selectOne(queryWrapper);
+        if (existingUser != null) {
+            return R.fail("该用户名已存在,请更换其他用户名");
+        }
+
+        // 创建新用户
+        LifeSys lifeSys = new LifeSys();
+        lifeSys.setUserName(userName);
+        // 密码使用MD5加密后存储
+        lifeSys.setUserPassword(encryptToMD5(password));
+        if (StringUtils.hasText(roleId)) {
+            lifeSys.setRoleId(roleId);
+        }
+        lifeSys.setDeleteFlag(0); // 未删除
+
+        // 保存用户
+        int result = lifeSysMapper.insert(lifeSys);
+        if (result > 0) {
+            return R.data(lifeSys, "注册成功");
+        }
+        return R.fail("注册失败,请稍后重试");
+    }
+
     public static String encryptToMD5(String input) {
         try {
             // 获取 MD5 算法的 MessageDigest 实例

+ 9 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/controller/LawFirmController.java

@@ -118,5 +118,14 @@ public class LawFirmController {
                 .page(lawFirmService);
         return R.data(pageResult);
     }
+
+    @ApiOperation("律所注册")
+    @ApiOperationSupport(order = 7)
+    @PostMapping("/register")
+    public R<LawFirm> register(@RequestBody LawFirm lawFirm) {
+        log.info("LawFirmController.register?lawFirm={}", lawFirm);
+        return lawFirmService.register(lawFirm);
+    }
 }
 
+

+ 9 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/LawFirmService.java

@@ -47,5 +47,14 @@ public interface LawFirmService extends IService<LawFirm> {
      * @return R<Boolean>
      */
     R<Boolean> deleteLawFirm(Integer id);
+
+    /**
+     * 律所注册
+     *
+     * @param lawFirm 律所信息
+     * @return R<LawFirm>
+     */
+    R<LawFirm> register(LawFirm lawFirm);
 }
 
+

+ 84 - 0
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawFirmServiceImpl.java

@@ -74,5 +74,89 @@ public class LawFirmServiceImpl extends ServiceImpl<LawFirmMapper, LawFirm> impl
         }
         return R.fail("删除失败");
     }
+
+    @Override
+    public R<LawFirm> register(LawFirm lawFirm) {
+        log.info("LawFirmServiceImpl.register?lawFirm={}", lawFirm);
+        
+        // 校验必填字段
+        if (!StringUtils.hasText(lawFirm.getFirmName())) {
+            return R.fail("律所名称不能为空");
+        }
+        if (!StringUtils.hasText(lawFirm.getCreditCode())) {
+            return R.fail("统一社会信用代码不能为空");
+        }
+        if (!StringUtils.hasText(lawFirm.getPhone())) {
+            return R.fail("联系电话不能为空");
+        }
+        if (!StringUtils.hasText(lawFirm.getDirectorName())) {
+            return R.fail("负责人姓名不能为空");
+        }
+        if (!StringUtils.hasText(lawFirm.getDirectorPhone())) {
+            return R.fail("负责人电话不能为空");
+        }
+        
+        // 校验统一社会信用代码是否已存在
+        LambdaQueryWrapper<LawFirm> creditCodeWrapper = new LambdaQueryWrapper<>();
+        creditCodeWrapper.eq(LawFirm::getCreditCode, lawFirm.getCreditCode());
+        creditCodeWrapper.eq(LawFirm::getDeleteFlag, 0);
+        long creditCodeCount = this.count(creditCodeWrapper);
+        if (creditCodeCount > 0) {
+            return R.fail("该统一社会信用代码已注册,请勿重复注册");
+        }
+        
+        // 校验联系电话是否已存在
+        if (StringUtils.hasText(lawFirm.getPhone())) {
+            LambdaQueryWrapper<LawFirm> phoneWrapper = new LambdaQueryWrapper<>();
+            phoneWrapper.eq(LawFirm::getPhone, lawFirm.getPhone());
+            phoneWrapper.eq(LawFirm::getDeleteFlag, 0);
+            long phoneCount = this.count(phoneWrapper);
+            if (phoneCount > 0) {
+                return R.fail("该联系电话已被使用,请更换其他号码");
+            }
+        }
+        
+        // 校验负责人电话是否已存在
+        if (StringUtils.hasText(lawFirm.getDirectorPhone())) {
+            LambdaQueryWrapper<LawFirm> directorPhoneWrapper = new LambdaQueryWrapper<>();
+            directorPhoneWrapper.eq(LawFirm::getDirectorPhone, lawFirm.getDirectorPhone());
+            directorPhoneWrapper.eq(LawFirm::getDeleteFlag, 0);
+            long directorPhoneCount = this.count(directorPhoneWrapper);
+            if (directorPhoneCount > 0) {
+                return R.fail("该负责人电话已被使用,请更换其他号码");
+            }
+        }
+        
+        // 校验邮箱是否已存在
+        if (StringUtils.hasText(lawFirm.getEmail())) {
+            LambdaQueryWrapper<LawFirm> emailWrapper = new LambdaQueryWrapper<>();
+            emailWrapper.eq(LawFirm::getEmail, lawFirm.getEmail());
+            emailWrapper.eq(LawFirm::getDeleteFlag, 0);
+            long emailCount = this.count(emailWrapper);
+            if (emailCount > 0) {
+                return R.fail("该邮箱已被使用,请更换其他邮箱");
+            }
+        }
+        
+        // 设置注册时的初始状态
+        lawFirm.setStatus(1); // 启用状态
+        lawFirm.setCertificationStatus(0); // 未认证状态
+        lawFirm.setDeleteFlag(0); // 未删除
+        lawFirm.setIsRecommended(0); // 默认不推荐
+        if (lawFirm.getLawyerCount() == null) {
+            lawFirm.setLawyerCount(0);
+        }
+        if (lawFirm.getPartnerCount() == null) {
+            lawFirm.setPartnerCount(0);
+        }
+        
+        // 保存律所信息
+        boolean result = this.save(lawFirm);
+        if (result) {
+            return R.data(lawFirm, "注册成功,请等待审核");
+        }
+        return R.fail("注册失败,请稍后重试");
+    }
 }
 
+

+ 16 - 1
alien-store/src/main/java/shop/alien/store/controller/SystemController.java

@@ -5,8 +5,10 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.LifeSys;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.dto.SystemLoginDto;
+import shop.alien.entity.store.dto.SystemRegisterDto;
 import shop.alien.entity.store.vo.SystemLoginVo;
 import shop.alien.store.service.SystemService;
 import shop.alien.util.common.TokenInfo;
@@ -41,7 +43,7 @@ public class SystemController {
     }
 
     @ApiOperation("web中台退出登录")
-    @ApiOperationSupport(order = 1)
+    @ApiOperationSupport(order = 2)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "query"),
@@ -51,4 +53,17 @@ public class SystemController {
         return R.success("退出成功");
     }
 
+    @ApiOperation("系统用户注册")
+    @ApiOperationSupport(order = 3)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String", paramType = "body", required = true),
+            @ApiImplicitParam(name = "password", value = "密码", dataType = "String", paramType = "body", required = true),
+            @ApiImplicitParam(name = "roleId", value = "角色id", dataType = "String", paramType = "body", required = false),
+    })
+    @PostMapping(value = "/register")
+    public R<LifeSys> register(@RequestBody SystemRegisterDto registerDto) {
+        log.info("SystemController.register?userName={},roleId={}", registerDto.getUserName(), registerDto.getRoleId());
+        return systemService.register(registerDto.getUserName(), registerDto.getPassword(), registerDto.getRoleId());
+    }
+
 }

+ 12 - 0
alien-store/src/main/java/shop/alien/store/service/SystemService.java

@@ -1,5 +1,7 @@
 package shop.alien.store.service;
 
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.LifeSys;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.vo.SystemLoginVo;
 
@@ -15,4 +17,14 @@ public interface SystemService {
 
     public SystemLoginVo logout(UserLoginInfo userLoginInfo);
 
+    /**
+     * 系统用户注册
+     *
+     * @param userName 用户名
+     * @param password 密码
+     * @param roleId   角色id
+     * @return R<LifeSys>
+     */
+    R<LifeSys> register(String userName, String password, String roleId);
+
 }

+ 40 - 2
alien-store/src/main/java/shop/alien/store/service/impl/SystemServiceImpl.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.LifeSys;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.entity.store.vo.SystemLoginVo;
@@ -66,11 +68,11 @@ public class SystemServiceImpl implements SystemService {
                 new LambdaQueryWrapper<LifeSys>()
                         .eq(LifeSys::getUserName, username)
         );
-        if (lifeSys != null && encryptToMD5(lifeSys.getUserPassword()).equals(password)) {
+        if (lifeSys != null && lifeSys.getUserPassword().equals(encryptToMD5(password))) {
             Map<String, String> tokenMap = new HashMap<>();
             tokenMap.put("phone", "123456");
             tokenMap.put("userName", lifeSys.getUserName());
-            tokenMap.put("userId", lifeSys.getId());
+            tokenMap.put("userId", String.valueOf(lifeSys.getId()));
             tokenMap.put("userType", "web");
             //存入token
             result.setToken(JwtUtil.createJWT("web_" + lifeSys.getId(), lifeSys.getUserName(), JSONObject.toJSONString(tokenMap), effectiveTimeIntLong));
@@ -92,6 +94,42 @@ public class SystemServiceImpl implements SystemService {
         return null;
     }
 
+    @Override
+    public R<LifeSys> register(String userName, String password, String roleId) {
+        // 校验必填字段
+        if (!StringUtils.hasText(userName)) {
+            return R.fail("用户名不能为空");
+        }
+        if (!StringUtils.hasText(password)) {
+            return R.fail("密码不能为空");
+        }
+
+        // 校验用户名是否已存在
+        LambdaQueryWrapper<LifeSys> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(LifeSys::getUserName, userName);
+        LifeSys existingUser = lifeSysMapper.selectOne(queryWrapper);
+        if (existingUser != null) {
+            return R.fail("该用户名已存在,请更换其他用户名");
+        }
+
+        // 创建新用户
+        LifeSys lifeSys = new LifeSys();
+        lifeSys.setUserName(userName);
+        // 密码使用MD5加密后存储
+        lifeSys.setUserPassword(encryptToMD5(password));
+        if (StringUtils.hasText(roleId)) {
+            lifeSys.setRoleId(roleId);
+        }
+        lifeSys.setDeleteFlag(0); // 未删除
+
+        // 保存用户
+        int result = lifeSysMapper.insert(lifeSys);
+        if (result > 0) {
+            return R.data(lifeSys, "注册成功");
+        }
+        return R.fail("注册失败,请稍后重试");
+    }
+
     public static String encryptToMD5(String input) {
         try {
             // 获取 MD5 算法的 MessageDigest 实例