HINOTOR 2 years ago
parent a26e102088
commit a31e7c2cf5

@ -1,11 +0,0 @@
CREATE TABLE `dianpingdb`.`user` (
`id` int NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`telephone` varchar(40) NOT NULL DEFAULT '',
`password` varchar(200) NOT NULL DEFAULT '',
`nick_name` varchar(40) NOT NULL DEFAULT '',
`gender` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE INDEX `telephone_unique_index`(`telephone`) USING BTREE
);

@ -8,11 +8,11 @@
<version>2.7.16</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.imooc</groupId>
<artifactId>dianping</artifactId>
<groupId>com.example</groupId>
<artifactId>recommend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>dianping</name>
<description>dianping</description>
<name>recommend</name>
<description>recommend</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -73,7 +73,7 @@
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (maybe moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>

@ -1,17 +1,17 @@
package com.imooc.dianping;
package com.example.recommend;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@SpringBootApplication(scanBasePackages = {"com.imooc.dianping"})
@MapperScan("com.imooc.dianping.dal")
@SpringBootApplication(scanBasePackages = {"com.example.recommend"})
@MapperScan("com.example.recommend.dal")
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class DianpingApplication {
public class RecommendApplication {
public static void main(String[] args) {
SpringApplication.run(DianpingApplication.class, args);
SpringApplication.run(RecommendApplication.class, args);
}
}

@ -1,4 +1,4 @@
package com.imooc.dianping.common;
package com.example.recommend.common;
public class BusinessException extends Exception {
private CommonError commonError;

@ -1,4 +1,4 @@
package com.imooc.dianping.common;
package com.example.recommend.common;
public class CommonError {
//错误码

@ -1,4 +1,4 @@
package com.imooc.dianping.common;
package com.example.recommend.common;
public class CommonRes {
//表明读经请求的返回处理结果,"success"或"fail"

@ -1,4 +1,4 @@
package com.imooc.dianping.common;
package com.example.recommend.common;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

@ -1,4 +1,4 @@
package com.imooc.dianping.common;
package com.example.recommend.common;
public enum EmBusinessError {
//通用的错误类型10000开头

@ -1,4 +1,4 @@
package com.imooc.dianping.common;
package com.example.recommend.common;
import org.springframework.web.bind.ServletRequestBindingException;
import org.springframework.web.bind.annotation.ControllerAdvice;

@ -1,12 +1,12 @@
package com.imooc.dianping.controller;
package com.example.recommend.controller;
import com.imooc.dianping.common.BusinessException;
import com.imooc.dianping.common.CommonRes;
import com.imooc.dianping.common.CommonUtil;
import com.imooc.dianping.common.EmBusinessError;
import com.imooc.dianping.model.UserModel;
import com.imooc.dianping.request.RegisterReq;
import com.imooc.dianping.service.UserService;
import com.example.recommend.common.BusinessException;
import com.example.recommend.common.CommonRes;
import com.example.recommend.common.CommonUtil;
import com.example.recommend.common.EmBusinessError;
import com.example.recommend.request.RegisterReq;
import com.example.recommend.service.UserService;
import com.example.recommend.model.UserModel;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@ -1,13 +1,13 @@
package com.imooc.dianping.dal;
package com.example.recommend.dal;
import com.imooc.dianping.model.UserModel;
import com.example.recommend.model.UserModel;
public interface UserModelMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
int deleteByPrimaryKey(Integer id);
@ -15,7 +15,7 @@ public interface UserModelMapper {
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
int insert(UserModel record);
@ -23,7 +23,7 @@ public interface UserModelMapper {
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
int insertSelective(UserModel record);
@ -31,7 +31,7 @@ public interface UserModelMapper {
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
UserModel selectByPrimaryKey(Integer id);
@ -39,7 +39,7 @@ public interface UserModelMapper {
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
int updateByPrimaryKeySelective(UserModel record);
@ -47,7 +47,7 @@ public interface UserModelMapper {
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
int updateByPrimaryKey(UserModel record);
}

@ -1,4 +1,4 @@
package com.imooc.dianping.model;
package com.example.recommend.model;
import java.util.Date;
@ -8,7 +8,7 @@ public class UserModel {
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user.id
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
private Integer id;
@ -17,7 +17,7 @@ public class UserModel {
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user.created_at
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
private Date createdAt;
@ -26,7 +26,7 @@ public class UserModel {
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user.updated_at
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
private Date updatedAt;
@ -35,7 +35,7 @@ public class UserModel {
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user.telephone
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
private String telephone;
@ -44,7 +44,7 @@ public class UserModel {
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user.password
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
private String password;
@ -53,7 +53,7 @@ public class UserModel {
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user.nick_name
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
private String nickName;
@ -62,7 +62,7 @@ public class UserModel {
* This field was generated by MyBatis Generator.
* This field corresponds to the database column user.gender
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
private Integer gender;
@ -72,7 +72,7 @@ public class UserModel {
*
* @return the value of user.id
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public Integer getId() {
return id;
@ -84,7 +84,7 @@ public class UserModel {
*
* @param id the value for user.id
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public void setId(Integer id) {
this.id = id;
@ -96,7 +96,7 @@ public class UserModel {
*
* @return the value of user.created_at
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public Date getCreatedAt() {
return createdAt;
@ -108,7 +108,7 @@ public class UserModel {
*
* @param createdAt the value for user.created_at
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
@ -120,7 +120,7 @@ public class UserModel {
*
* @return the value of user.updated_at
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public Date getUpdatedAt() {
return updatedAt;
@ -132,7 +132,7 @@ public class UserModel {
*
* @param updatedAt the value for user.updated_at
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
@ -144,7 +144,7 @@ public class UserModel {
*
* @return the value of user.telephone
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public String getTelephone() {
return telephone;
@ -156,7 +156,7 @@ public class UserModel {
*
* @param telephone the value for user.telephone
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public void setTelephone(String telephone) {
this.telephone = telephone == null ? null : telephone.trim();
@ -168,7 +168,7 @@ public class UserModel {
*
* @return the value of user.password
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public String getPassword() {
return password;
@ -180,7 +180,7 @@ public class UserModel {
*
* @param password the value for user.password
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
@ -192,7 +192,7 @@ public class UserModel {
*
* @return the value of user.nick_name
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public String getNickName() {
return nickName;
@ -204,7 +204,7 @@ public class UserModel {
*
* @param nickName the value for user.nick_name
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public void setNickName(String nickName) {
this.nickName = nickName == null ? null : nickName.trim();
@ -216,7 +216,7 @@ public class UserModel {
*
* @return the value of user.gender
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public Integer getGender() {
return gender;
@ -228,7 +228,7 @@ public class UserModel {
*
* @param gender the value for user.gender
*
* @mbg.generated Fri Oct 06 13:41:12 CST 2023
* @mbg.generated Mon Oct 09 13:50:54 CST 2023
*/
public void setGender(Integer gender) {
this.gender = gender;

@ -1,4 +1,4 @@
package com.imooc.dianping.request;
package com.example.recommend.request;
import jakarta.validation.constraints.NotBlank;

@ -1,7 +1,7 @@
package com.imooc.dianping.service;
package com.example.recommend.service;
import com.imooc.dianping.common.BusinessException;
import com.imooc.dianping.model.UserModel;
import com.example.recommend.common.BusinessException;
import com.example.recommend.model.UserModel;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
@ -11,7 +11,7 @@ public interface UserService {
UserModel register(UserModel registerUser) throws BusinessException, UnsupportedEncodingException, NoSuchAlgorithmException;
UserModel login(String telphone, String password) throws UnsupportedEncodingException, NoSuchAlgorithmException, BusinessException;
UserModel login(String telephone, String password) throws UnsupportedEncodingException, NoSuchAlgorithmException, BusinessException;
Integer countAllUser();
}

@ -1,10 +1,10 @@
package com.imooc.dianping.service.impl;
package com.example.recommend.service.impl;
import com.imooc.dianping.common.BusinessException;
import com.imooc.dianping.common.EmBusinessError;
import com.imooc.dianping.dal.UserModelMapper;
import com.imooc.dianping.model.UserModel;
import com.imooc.dianping.service.UserService;
import com.example.recommend.common.BusinessException;
import com.example.recommend.common.EmBusinessError;
import com.example.recommend.dal.UserModelMapper;
import com.example.recommend.model.UserModel;
import com.example.recommend.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
@ -43,7 +43,7 @@ public class UserServiceImpl implements UserService {
}
@Override
public UserModel login(String telphone, String password) throws UnsupportedEncodingException, NoSuchAlgorithmException, BusinessException {
public UserModel login(String telephone, String password) throws UnsupportedEncodingException, NoSuchAlgorithmException, BusinessException {
return null;
}

@ -1,8 +1,8 @@
server.port=8010
mybatis.mapperLocations=classpath:mapping/*.xml
#???????????
spring.datasource.name=dianpingdb
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dianpingdb?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.name=recommenddb
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/recommenddb?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
#??druid??????

@ -0,0 +1,12 @@
CREATE TABLE `recommenddb`.`user`
(
`id` int NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`telephone` varchar(40) NOT NULL DEFAULT '',
`password` varchar(200) NOT NULL DEFAULT '',
`nick_name` varchar(40) NOT NULL DEFAULT '',
`gender` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE INDEX `telephone_unique_index` (`telephone`) USING BTREE
);

@ -1,11 +1,11 @@
<?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.imooc.dianping.dal.UserModelMapper">
<resultMap id="BaseResultMap" type="com.imooc.dianping.model.UserModel">
<mapper namespace="com.example.recommend.dal.UserModelMapper">
<resultMap id="BaseResultMap" type="com.example.recommend.model.UserModel">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
@ -19,7 +19,7 @@
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
id, created_at, updated_at, telephone, password, nick_name, gender
</sql>
@ -27,7 +27,7 @@
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
select
<include refid="Base_Column_List" />
@ -38,16 +38,16 @@
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
delete from user
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.imooc.dianping.model.UserModel">
<insert id="insert" parameterType="com.example.recommend.model.UserModel">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
@ -59,11 +59,11 @@
#{password,jdbcType=VARCHAR}, #{nickName,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.imooc.dianping.model.UserModel">
<insert id="insertSelective" parameterType="com.example.recommend.model.UserModel">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
@ -110,11 +110,11 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.imooc.dianping.model.UserModel">
<update id="updateByPrimaryKeySelective" parameterType="com.example.recommend.model.UserModel">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
update user
<set>
@ -139,11 +139,11 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.imooc.dianping.model.UserModel">
<update id="updateByPrimaryKey" parameterType="com.example.recommend.model.UserModel">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Oct 06 13:41:12 CST 2023.
This element was generated on Mon Oct 09 13:50:54 CST 2023.
-->
update user
set created_at = #{createdAt,jdbcType=TIMESTAMP},

@ -6,10 +6,12 @@
<context id="DB2Tables" targetRuntime="MyBatis3">
<!--数据库链接地址账号密码-->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/dianpingdb?characterEncoding=utf8&amp;useSSL=false" userId="root" password="123456">
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/recommenddb?characterEncoding=utf8&amp;useSSL=false"
userId="root" password="123456">
</jdbcConnection>
<!--生成DataObject类存放位置-->
<javaModelGenerator targetPackage="com.imooc.dianping.model" targetProject="src/main/java">
<javaModelGenerator targetPackage="com.example.recommend.model" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
@ -23,7 +25,7 @@
type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象
type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口
-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.imooc.dianping.dal" targetProject="src/main/java">
<javaClientGenerator type="XMLMAPPER" targetPackage="com.example.recommend.dal" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
@ -39,7 +41,7 @@
<table tableName="user" domainObjectName="UserModel" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false">
<generatedKey column="id" sqlStatement="MySql" identity="true" />
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
</context>

@ -1,10 +1,10 @@
package com.imooc.dianping;
package com.example.recommend;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DianpingApplicationTests {
class RecommendApplicationTests {
@Test
void contextLoads() {
Loading…
Cancel
Save