From b34a44931559d9e0f4f360126a8a9f25e364f6bb Mon Sep 17 00:00:00 2001
From: kouse <274295865@qq.com>
Date: Thu, 3 Dec 2020 10:32:01 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E5=AE=8C=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/share/controller/UserController.java | 50 +++++++++++
.../java/com/share/domain/CompanyUser.java | 48 ++++++++++
.../java/com/share/domain/PersonalUser.java | 57 ++++++++++++
.../src/main/java/com/share/domain/User.java | 89 +++++++++++++++++++
.../com/share/mapper/CompanyUserMapper.java | 32 +++++++
.../com/share/mapper/PersonalUserMapper.java | 30 +++++++
.../java/com/share/mapper/UserMapper.java | 36 ++++++++
.../java/com/share/service/UserService.java | 37 ++++++++
.../share/service/impl/UserServiceImpl.java | 77 ++++++++++++++++
.../resources/mapper/CompanyUserMapper.xml | 24 +++++
.../resources/mapper/PersonalUserMapper.xml | 25 ++++++
.../main/resources/mapper/UserInfoMapper.xml | 1 +
.../src/main/resources/mapper/UserMapper.xml | 21 +++++
13 files changed, 527 insertions(+)
create mode 100644 share_project/src/main/java/com/share/controller/UserController.java
create mode 100644 share_project/src/main/java/com/share/domain/CompanyUser.java
create mode 100644 share_project/src/main/java/com/share/domain/PersonalUser.java
create mode 100644 share_project/src/main/java/com/share/domain/User.java
create mode 100644 share_project/src/main/java/com/share/mapper/CompanyUserMapper.java
create mode 100644 share_project/src/main/java/com/share/mapper/PersonalUserMapper.java
create mode 100644 share_project/src/main/java/com/share/mapper/UserMapper.java
create mode 100644 share_project/src/main/java/com/share/service/UserService.java
create mode 100644 share_project/src/main/java/com/share/service/impl/UserServiceImpl.java
create mode 100644 share_project/src/main/resources/mapper/CompanyUserMapper.xml
create mode 100644 share_project/src/main/resources/mapper/PersonalUserMapper.xml
create mode 100644 share_project/src/main/resources/mapper/UserMapper.xml
diff --git a/share_project/src/main/java/com/share/controller/UserController.java b/share_project/src/main/java/com/share/controller/UserController.java
new file mode 100644
index 00000000..93c2513f
--- /dev/null
+++ b/share_project/src/main/java/com/share/controller/UserController.java
@@ -0,0 +1,50 @@
+package com.share.controller;
+
+import com.share.domain.CompanyUser;
+import com.share.domain.PersonalUser;
+import com.share.domain.ResultInfo;
+import com.share.domain.User;
+import com.share.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-12-02 23:00
+ **/
+@Controller
+@RequestMapping("/user")
+public class UserController {
+
+ private UserService userService;
+
+ @Autowired
+ public void setUserService(UserService userService) {
+ this.userService = userService;
+ }
+
+ /**
+ * 注册用户
+ * @param user 用户数据
+ * @return 注册状态
+ */
+ @RequestMapping("/registration")
+ public ResultInfo registration(User user){
+ return userService.registration(user);
+ }
+
+
+ @RequestMapping("/supplyCompany")
+ public ResultInfo supplyPersonalInfo(PersonalUser user){
+ return userService.supplyPersonalUser(user);
+ }
+
+ @RequestMapping("supplyCompany")
+ public ResultInfo supplyCompanyInfo(CompanyUser user){
+ return userService.supplyCompanyUser(user);
+ }
+
+}
diff --git a/share_project/src/main/java/com/share/domain/CompanyUser.java b/share_project/src/main/java/com/share/domain/CompanyUser.java
new file mode 100644
index 00000000..1264127a
--- /dev/null
+++ b/share_project/src/main/java/com/share/domain/CompanyUser.java
@@ -0,0 +1,48 @@
+package com.share.domain;
+
+import java.io.Serializable;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-12-02 09:16
+ **/
+public class CompanyUser implements Serializable {
+
+ /**
+ * 用户名
+ */
+ private String username;
+
+ /**
+ * 电话
+ */
+ private String telephone;
+
+ /**
+ * 营业执照编号
+ */
+ private String licenseCode;
+
+ /**
+ * 法人姓名
+ */
+ private String legalName;
+
+ /**
+ * 公司类型
+ */
+ private String companyType;
+
+ /**
+ * 公司地址
+ */
+ private String address;
+
+ /**
+ * 公司简介
+ */
+ private String profile;
+
+}
diff --git a/share_project/src/main/java/com/share/domain/PersonalUser.java b/share_project/src/main/java/com/share/domain/PersonalUser.java
new file mode 100644
index 00000000..86c6d8e4
--- /dev/null
+++ b/share_project/src/main/java/com/share/domain/PersonalUser.java
@@ -0,0 +1,57 @@
+package com.share.domain;
+
+import java.io.Serializable;
+
+/**
+ * Demo Class
+ * 个人用户信息表映射类
+ * @author 古市
+ * @date 2020-12-01 21:52
+ **/
+public class PersonalUser implements Serializable {
+
+ /**
+ * 用户名
+ */
+ private String username;
+
+ /**
+ * 电话
+ */
+ private String telephone;
+
+ /**
+ * 真实姓名
+ */
+ private String realName;
+
+ /**
+ * 身份证
+ */
+ private String identityCard;
+
+ /**
+ * 学历
+ */
+ private String qualification;
+
+ /**
+ * 个人证书
+ */
+ private String certificate;
+
+ /**
+ * 技能
+ */
+ private String skill;
+
+ /**
+ * 个人简介
+ */
+ private String profile;
+
+
+
+
+
+}
diff --git a/share_project/src/main/java/com/share/domain/User.java b/share_project/src/main/java/com/share/domain/User.java
new file mode 100644
index 00000000..e213c45d
--- /dev/null
+++ b/share_project/src/main/java/com/share/domain/User.java
@@ -0,0 +1,89 @@
+package com.share.domain;
+
+import java.io.Serializable;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-11-29 20:51
+ **/
+public class User implements Serializable {
+
+ /**
+ * 账号
+ */
+ private String username;
+
+ /**
+ * 电话号码
+ */
+ private String telephone;
+
+ /**
+ * 电子邮箱
+ */
+ private String email;
+
+ /**
+ * 密码
+ */
+ private String password;
+
+ /**
+ * 用户类型 个人用户--0;公司用户--1
+ */
+ private String role;
+
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getTelephone() {
+ return telephone;
+ }
+
+ public void setTelephone(String telephone) {
+ this.telephone = telephone;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "username='" + username + '\'' +
+ ", telephone='" + telephone + '\'' +
+ ", email='" + email + '\'' +
+ ", password='" + password + '\'' +
+ ", role='" + role + '\'' +
+ '}';
+ }
+}
diff --git a/share_project/src/main/java/com/share/mapper/CompanyUserMapper.java b/share_project/src/main/java/com/share/mapper/CompanyUserMapper.java
new file mode 100644
index 00000000..b4f9c279
--- /dev/null
+++ b/share_project/src/main/java/com/share/mapper/CompanyUserMapper.java
@@ -0,0 +1,32 @@
+package com.share.mapper;
+
+import com.share.domain.CompanyUser;
+import com.share.domain.PersonalUser;
+import com.share.domain.User;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-12-02 22:13
+ **/
+@Repository
+public interface CompanyUserMapper {
+
+ /**
+ * 在公司用户表中提前新增一条记录
+ * @param user
+ * @return
+ */
+ int insertUser(User user);
+
+ /**
+ * 完善用户的数据
+ * @param user
+ * @return
+ */
+ int supplyInfo(CompanyUser user);
+
+
+}
diff --git a/share_project/src/main/java/com/share/mapper/PersonalUserMapper.java b/share_project/src/main/java/com/share/mapper/PersonalUserMapper.java
new file mode 100644
index 00000000..ab557c7d
--- /dev/null
+++ b/share_project/src/main/java/com/share/mapper/PersonalUserMapper.java
@@ -0,0 +1,30 @@
+package com.share.mapper;
+
+import com.share.domain.PersonalUser;
+import com.share.domain.User;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-12-02 09:23
+ **/
+@Repository
+public interface PersonalUserMapper {
+
+ /**
+ * 在个人用户表中提前新增一条记录
+ * @param user
+ * @return
+ */
+ int insertUser(User user);
+
+ /**
+ * 完善用户的数据
+ * @param user
+ * @return
+ */
+ int supplyInfo(PersonalUser user);
+
+}
diff --git a/share_project/src/main/java/com/share/mapper/UserMapper.java b/share_project/src/main/java/com/share/mapper/UserMapper.java
new file mode 100644
index 00000000..160fc4c5
--- /dev/null
+++ b/share_project/src/main/java/com/share/mapper/UserMapper.java
@@ -0,0 +1,36 @@
+package com.share.mapper;
+
+import com.share.domain.User;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-11-29 20:58
+ **/
+@Repository
+public interface UserMapper {
+
+ /**
+ * 往数据库中新增一条user信息
+ * @param user 新添加的用户
+ */
+ void insertUser(User user);
+
+ /**
+ * 对用户名进行查重
+ * @param username
+ * @return
+ */
+ int selectUsername(String username);
+
+ /**
+ * 对手机号进行查重
+ * @param telephone
+ * @return
+ */
+ int selectTelephone(String telephone);
+
+
+}
diff --git a/share_project/src/main/java/com/share/service/UserService.java b/share_project/src/main/java/com/share/service/UserService.java
new file mode 100644
index 00000000..a8e67011
--- /dev/null
+++ b/share_project/src/main/java/com/share/service/UserService.java
@@ -0,0 +1,37 @@
+package com.share.service;
+
+import com.share.domain.CompanyUser;
+import com.share.domain.PersonalUser;
+import com.share.domain.ResultInfo;
+import com.share.domain.User;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-12-02 22:26
+ **/
+public interface UserService {
+
+ /**
+ * 注册用户
+ * @param user
+ * @return
+ */
+ ResultInfo registration(User user);
+
+ /**
+ * 补充个人用户的信息
+ * @param personalUser
+ * @return
+ */
+ ResultInfo supplyPersonalUser(PersonalUser personalUser);
+
+ /**
+ * 补充公司用户的信息
+ * @param companyUser
+ * @return
+ */
+ ResultInfo supplyCompanyUser(CompanyUser companyUser);
+
+}
diff --git a/share_project/src/main/java/com/share/service/impl/UserServiceImpl.java b/share_project/src/main/java/com/share/service/impl/UserServiceImpl.java
new file mode 100644
index 00000000..09787b26
--- /dev/null
+++ b/share_project/src/main/java/com/share/service/impl/UserServiceImpl.java
@@ -0,0 +1,77 @@
+package com.share.service.impl;
+
+import com.share.domain.CompanyUser;
+import com.share.domain.PersonalUser;
+import com.share.domain.ResultInfo;
+import com.share.domain.User;
+import com.share.mapper.CompanyUserMapper;
+import com.share.mapper.PersonalUserMapper;
+import com.share.mapper.UserMapper;
+import com.share.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Demo Class
+ *
+ * @author 古市
+ * @date 2020-12-02 22:26
+ **/
+@Service
+public class UserServiceImpl implements UserService {
+
+
+ private UserMapper userMapper;
+
+ private PersonalUserMapper personalUserMapper;
+
+ private CompanyUserMapper companyUserMapper;
+
+ @Autowired
+ public void setPersonalUserMapper(PersonalUserMapper personalUserMapper) {
+ this.personalUserMapper = personalUserMapper;
+ }
+
+ @Autowired
+ public void setCompanyUserMapper(CompanyUserMapper companyUserMapper) {
+ this.companyUserMapper = companyUserMapper;
+ }
+
+ @Autowired
+ public void setUserMapper(UserMapper userMapper) {
+ this.userMapper = userMapper;
+ }
+
+ final String roleFlag = "1";
+
+ @Override
+ public ResultInfo registration(User user) {
+ //在用户表中添加信息
+ userMapper.insertUser(user);
+ //判断用户类型
+ if (roleFlag.equals(user.getRole())){
+ //公司用户
+ companyUserMapper.insertUser(user);
+ }else {
+ personalUserMapper.insertUser(user);
+ }
+
+ return ResultInfo.successInfo("注册成功");
+ }
+
+ @Override
+ public ResultInfo supplyPersonalUser(PersonalUser personalUser){
+ if (personalUserMapper.supplyInfo(personalUser) == 1){
+ return ResultInfo.successInfo("成功录入");
+ };
+ return ResultInfo.failInfo();
+ }
+
+ @Override
+ public ResultInfo supplyCompanyUser(CompanyUser companyUser){
+ if (companyUserMapper.supplyInfo(companyUser) == 1){
+ return ResultInfo.successInfo("成功录入");
+ };
+ return ResultInfo.failInfo();
+ }
+}
diff --git a/share_project/src/main/resources/mapper/CompanyUserMapper.xml b/share_project/src/main/resources/mapper/CompanyUserMapper.xml
new file mode 100644
index 00000000..4ac78ac8
--- /dev/null
+++ b/share_project/src/main/resources/mapper/CompanyUserMapper.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+ insert into company_user (username, telephone)
+ values (#{username}, #{telephone})
+
+
+
+ update company_user set license_code = #{licenseCode}, legal_name = #{legalName},
+ company_type = #{companyType}, address = #{address}, profile = #{profile}
+ where username = #{username}
+
+
+
+ insert into company_user (username, telephone, license_code, legal_name, company_type, address, profile)
+ VALUES (#{username}, #{telephone}, #{licenseCode}, #{legalName}, #{companyType}, #{address}, #{profile})
+
+
+
+
\ No newline at end of file
diff --git a/share_project/src/main/resources/mapper/PersonalUserMapper.xml b/share_project/src/main/resources/mapper/PersonalUserMapper.xml
new file mode 100644
index 00000000..4f87e1da
--- /dev/null
+++ b/share_project/src/main/resources/mapper/PersonalUserMapper.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ insert into personal_user (username, telephone)
+ values (#{username}, #{telephone})
+
+
+
+ update personal_user set real_name = #{realName}, identity_card = #{identityCard},
+ qualification = #{qualification}, certificate = #{certificate},
+ skill = #{skill}, profile = #{profile}
+ where username = #{username}
+
+
+
+ insert into personal_user (username, telephone, real_name, identity_card, qualification, certificate, skill, profile)
+ VALUES (#{username}, #{telephone}, #{realName}, #{identityCard}, #{qualification}, #{certificate}, #{skill}, #{profile})
+
+
+
+
\ No newline at end of file
diff --git a/share_project/src/main/resources/mapper/UserInfoMapper.xml b/share_project/src/main/resources/mapper/UserInfoMapper.xml
index 6ae71f0f..6ff9aa21 100644
--- a/share_project/src/main/resources/mapper/UserInfoMapper.xml
+++ b/share_project/src/main/resources/mapper/UserInfoMapper.xml
@@ -14,4 +14,5 @@
select telephone from user where username = #{username};
+
\ No newline at end of file
diff --git a/share_project/src/main/resources/mapper/UserMapper.xml b/share_project/src/main/resources/mapper/UserMapper.xml
new file mode 100644
index 00000000..9c54acbf
--- /dev/null
+++ b/share_project/src/main/resources/mapper/UserMapper.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+ insert into user (username, telephone, email, password, role) VALUES (#{username}, #{telephone}, #{email}, #{password}, #{role})
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
Gitee
From 84187b30468ba737807b1cf220c2c862d11db61f Mon Sep 17 00:00:00 2001
From: kouse <274295865@qq.com>
Date: Fri, 4 Dec 2020 19:35:57 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=B3=A8=E5=86=8C?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/share/controller/UserController.java | 29 +++++++-
.../controller/UserProjectController.java | 1 +
.../java/com/share/domain/CompanyUser.java | 68 +++++++++++++++++
.../java/com/share/domain/PersonalUser.java | 74 +++++++++++++++++++
.../java/com/share/mapper/UserMapper.java | 9 ++-
.../java/com/share/service/UserService.java | 21 ++++++
.../share/service/impl/UserServiceImpl.java | 59 ++++++++++++++-
.../src/main/resources/mapper/UserMapper.xml | 20 ++++-
8 files changed, 271 insertions(+), 10 deletions(-)
diff --git a/share_project/src/main/java/com/share/controller/UserController.java b/share_project/src/main/java/com/share/controller/UserController.java
index 93c2513f..19f3f59e 100644
--- a/share_project/src/main/java/com/share/controller/UserController.java
+++ b/share_project/src/main/java/com/share/controller/UserController.java
@@ -7,7 +7,9 @@ import com.share.domain.User;
import com.share.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpSession;
/**
* Demo Class
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
**/
@Controller
@RequestMapping("/user")
+@ResponseBody
public class UserController {
private UserService userService;
@@ -37,14 +40,34 @@ public class UserController {
}
- @RequestMapping("/supplyCompany")
+ @PostMapping("/supplyPerson")
public ResultInfo supplyPersonalInfo(PersonalUser user){
return userService.supplyPersonalUser(user);
}
- @RequestMapping("supplyCompany")
+ @PostMapping("/supplyCompany")
public ResultInfo supplyCompanyInfo(CompanyUser user){
return userService.supplyCompanyUser(user);
}
+ @GetMapping("/repeatUsername/{username}")
+ public ResultInfo repeatUsername(@PathVariable String username){
+ return userService.repeatUsername(username);
+ }
+
+ @GetMapping("/repeatTelephone/{telephone}")
+ public ResultInfo repeatTelephone(@PathVariable String telephone){
+ return userService.repeatTelephone(telephone);
+ }
+
+ @PostMapping("/login")
+ public ResultInfo login(String account, String password, HttpSession session){
+ User user = userService.login(account, password);
+ if (user != null && user.getUsername() != null){
+ session.setAttribute("user", user);
+ return ResultInfo.successInfo("登录成功");
+ }
+ return ResultInfo.failInfo("请检查用户名和密码");
+ }
+
}
diff --git a/share_project/src/main/java/com/share/controller/UserProjectController.java b/share_project/src/main/java/com/share/controller/UserProjectController.java
index 2d02d678..18f04bf0 100644
--- a/share_project/src/main/java/com/share/controller/UserProjectController.java
+++ b/share_project/src/main/java/com/share/controller/UserProjectController.java
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
*/
@Controller
@ResponseBody
+@RequestMapping("/user")
public class UserProjectController {
private DemandProjectService demandProjectService;
diff --git a/share_project/src/main/java/com/share/domain/CompanyUser.java b/share_project/src/main/java/com/share/domain/CompanyUser.java
index 1264127a..b742cfb4 100644
--- a/share_project/src/main/java/com/share/domain/CompanyUser.java
+++ b/share_project/src/main/java/com/share/domain/CompanyUser.java
@@ -45,4 +45,72 @@ public class CompanyUser implements Serializable {
*/
private String profile;
+ @Override
+ public String toString() {
+ return "CompanyUser{" +
+ "username='" + username + '\'' +
+ ", telephone='" + telephone + '\'' +
+ ", licenseCode='" + licenseCode + '\'' +
+ ", legalName='" + legalName + '\'' +
+ ", companyType='" + companyType + '\'' +
+ ", address='" + address + '\'' +
+ ", profile='" + profile + '\'' +
+ '}';
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getTelephone() {
+ return telephone;
+ }
+
+ public void setTelephone(String telephone) {
+ this.telephone = telephone;
+ }
+
+ public String getLicenseCode() {
+ return licenseCode;
+ }
+
+ public void setLicenseCode(String licenseCode) {
+ this.licenseCode = licenseCode;
+ }
+
+ public String getLegalName() {
+ return legalName;
+ }
+
+ public void setLegalName(String legalName) {
+ this.legalName = legalName;
+ }
+
+ public String getCompanyType() {
+ return companyType;
+ }
+
+ public void setCompanyType(String companyType) {
+ this.companyType = companyType;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getProfile() {
+ return profile;
+ }
+
+ public void setProfile(String profile) {
+ this.profile = profile;
+ }
}
diff --git a/share_project/src/main/java/com/share/domain/PersonalUser.java b/share_project/src/main/java/com/share/domain/PersonalUser.java
index 86c6d8e4..2b048a05 100644
--- a/share_project/src/main/java/com/share/domain/PersonalUser.java
+++ b/share_project/src/main/java/com/share/domain/PersonalUser.java
@@ -51,7 +51,81 @@ public class PersonalUser implements Serializable {
private String profile;
+ public String getUsername() {
+ return username;
+ }
+ public void setUsername(String username) {
+ this.username = username;
+ }
+ public String getTelephone() {
+ return telephone;
+ }
+ public void setTelephone(String telephone) {
+ this.telephone = telephone;
+ }
+
+ public String getRealName() {
+ return realName;
+ }
+
+ public void setRealName(String realName) {
+ this.realName = realName;
+ }
+
+ public String getIdentityCard() {
+ return identityCard;
+ }
+
+ public void setIdentityCard(String identityCard) {
+ this.identityCard = identityCard;
+ }
+
+ public String getQualification() {
+ return qualification;
+ }
+
+ public void setQualification(String qualification) {
+ this.qualification = qualification;
+ }
+
+ public String getCertificate() {
+ return certificate;
+ }
+
+ public void setCertificate(String certificate) {
+ this.certificate = certificate;
+ }
+
+ public String getSkill() {
+ return skill;
+ }
+
+ public void setSkill(String skill) {
+ this.skill = skill;
+ }
+
+ public String getProfile() {
+ return profile;
+ }
+
+ public void setProfile(String profile) {
+ this.profile = profile;
+ }
+
+ @Override
+ public String toString() {
+ return "PersonalUser{" +
+ "username='" + username + '\'' +
+ ", telephone='" + telephone + '\'' +
+ ", realName='" + realName + '\'' +
+ ", identityCard='" + identityCard + '\'' +
+ ", qualification='" + qualification + '\'' +
+ ", certificate='" + certificate + '\'' +
+ ", skill='" + skill + '\'' +
+ ", profile='" + profile + '\'' +
+ '}';
+ }
}
diff --git a/share_project/src/main/java/com/share/mapper/UserMapper.java b/share_project/src/main/java/com/share/mapper/UserMapper.java
index 160fc4c5..9aff00a4 100644
--- a/share_project/src/main/java/com/share/mapper/UserMapper.java
+++ b/share_project/src/main/java/com/share/mapper/UserMapper.java
@@ -3,6 +3,8 @@ package com.share.mapper;
import com.share.domain.User;
import org.springframework.stereotype.Repository;
+import java.util.Map;
+
/**
* Demo Class
*
@@ -32,5 +34,10 @@ public interface UserMapper {
*/
int selectTelephone(String telephone);
-
+ /**
+ * 用户登录接口
+ * @param map 参数表,包括两个参数 password,account 有三种数据(邮箱、手机号、用户名)
+ * @return
+ */
+ User login(Map map);
}
diff --git a/share_project/src/main/java/com/share/service/UserService.java b/share_project/src/main/java/com/share/service/UserService.java
index a8e67011..fa11ecf3 100644
--- a/share_project/src/main/java/com/share/service/UserService.java
+++ b/share_project/src/main/java/com/share/service/UserService.java
@@ -34,4 +34,25 @@ public interface UserService {
*/
ResultInfo supplyCompanyUser(CompanyUser companyUser);
+ /**
+ * 查询是否有重复的手机号
+ * @param telephone
+ * @return
+ */
+ ResultInfo repeatTelephone(String telephone);
+
+ /**
+ * 查询是否有重复的用户名
+ * @param username
+ * @return
+ */
+ ResultInfo repeatUsername(String username);
+
+ /**
+ * 用户登录的业务逻辑
+ * @param account 用户名、手机号、邮箱
+ * @param password 密码
+ * @return
+ */
+ User login(String account, String password);
}
diff --git a/share_project/src/main/java/com/share/service/impl/UserServiceImpl.java b/share_project/src/main/java/com/share/service/impl/UserServiceImpl.java
index 09787b26..2ce819f7 100644
--- a/share_project/src/main/java/com/share/service/impl/UserServiceImpl.java
+++ b/share_project/src/main/java/com/share/service/impl/UserServiceImpl.java
@@ -10,6 +10,10 @@ import com.share.mapper.UserMapper;
import com.share.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.GetMapping;
+
+import java.util.HashMap;
+import java.util.Map;
/**
* Demo Class
@@ -46,6 +50,14 @@ public class UserServiceImpl implements UserService {
@Override
public ResultInfo registration(User user) {
+ //判断是否有重复的电话,或用户名
+ if (userMapper.selectUsername(user.getUsername().strip()) > 0){
+ return ResultInfo.failInfo("有重复的用户名");
+ }
+ if (userMapper.selectTelephone(user.getTelephone().strip()) > 0){
+ //查询出有重复的手机号
+ return ResultInfo.failInfo("有重复的手机号");
+ }
//在用户表中添加信息
userMapper.insertUser(user);
//判断用户类型
@@ -63,15 +75,54 @@ public class UserServiceImpl implements UserService {
public ResultInfo supplyPersonalUser(PersonalUser personalUser){
if (personalUserMapper.supplyInfo(personalUser) == 1){
return ResultInfo.successInfo("成功录入");
- };
- return ResultInfo.failInfo();
+ }
+ return ResultInfo.failInfo("写入失败");
}
@Override
public ResultInfo supplyCompanyUser(CompanyUser companyUser){
if (companyUserMapper.supplyInfo(companyUser) == 1){
return ResultInfo.successInfo("成功录入");
- };
- return ResultInfo.failInfo();
+ }
+ return ResultInfo.failInfo("写入失败");
+ }
+
+ @Override
+ public ResultInfo repeatTelephone(String telephone) {
+ if (userMapper.selectTelephone(telephone.strip()) > 0){
+ //查询出有重复的手机号
+ return ResultInfo.failInfo("有重复的手机号");
+ }
+ return ResultInfo.successInfo();
+ }
+
+ @Override
+ public ResultInfo repeatUsername(String username) {
+ if (userMapper.selectUsername(username.strip()) > 0){
+ return ResultInfo.failInfo("有重复的用户名");
+ }
+ return ResultInfo.successInfo();
}
+
+
+ @Override
+ public User login(String account, String password){
+ //对account进行类型的判断
+ //判断是邮箱还是手机号的正则表达式
+ String em = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
+ String ph = "^((13[0-9])|(15[^4,\\D])|(17[0-9])|(18[0,5-9]))\\d{8}$";
+
+ Mapparam = new HashMap<>();
+ if(account.matches(ph)) {
+ param.put("telephone", account);
+ }else if(account.matches(em)) {
+ param.put("email", account);
+ }else {
+ param.put("username", account);
+ }
+ param.put("password", password);
+ return userMapper.login(param);
+ }
+
+
}
diff --git a/share_project/src/main/resources/mapper/UserMapper.xml b/share_project/src/main/resources/mapper/UserMapper.xml
index 9c54acbf..8e4e3c3f 100644
--- a/share_project/src/main/resources/mapper/UserMapper.xml
+++ b/share_project/src/main/resources/mapper/UserMapper.xml
@@ -8,14 +8,30 @@
insert into user (username, telephone, email, password, role) VALUES (#{username}, #{telephone}, #{email}, #{password}, #{role})
-