Jelajahi Sumber

dev_guolina

36052 1 Minggu lalu
induk
melakukan
6b85add243

+ 28 - 0
pom.xml

@@ -15,6 +15,34 @@
     </properties>
     <dependencies>
         <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.4</version>
+        </dependency>
+        <!-- JJWT 依赖 -->
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.9.1</version>
+        </dependency>
+        <!-- Redisson 依赖 -->
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson</artifactId>
+            <version>3.16.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+            <version>3.1.5</version>
+        </dependency>
+
+
+        <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>

+ 10 - 0
src/main/java/com/zhentao/Cangliang.java

@@ -0,0 +1,10 @@
+package com.zhentao;
+
+/**
+ * @Date 2025/5/10 10:17
+ * @Author gln
+ **/
+//常量类
+public class Cangliang {
+    
+}

+ 2 - 0
src/main/java/com/zhentao/GlnSaleApplication.java

@@ -1,9 +1,11 @@
 package com.zhentao;
 
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 @SpringBootApplication
+@MapperScan("com.zhentao.mapper")
 public class GlnSaleApplication {
 
     public static void main(String[] args) {

+ 28 - 0
src/main/java/com/zhentao/config/RedisConfig.java

@@ -0,0 +1,28 @@
+package com.zhentao.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * @Date 2025/4/21 18:44
+ * @Author gln
+ **/
+@Configuration
+public class RedisConfig {
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+        RedisTemplate<String, Object> template = new RedisTemplate<>();
+        template.setConnectionFactory(redisConnectionFactory);
+        template.setKeySerializer(new StringRedisSerializer());
+        template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
+        template.setHashKeySerializer(new StringRedisSerializer());
+        template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
+        template.afterPropertiesSet();
+        return template;
+    }
+}

+ 44 - 0
src/main/java/com/zhentao/config/RedissionConfig.java

@@ -0,0 +1,44 @@
+package com.zhentao.config;
+
+import org.redisson.Redisson;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @Date 2025/4/10 13:36
+ * @Author gln
+ **/
+@Configuration
+public class RedissionConfig {
+
+//    @Value("${spring.redis.host}")
+//    private String host;
+//
+//    @Value("${spring.redis.port}")
+//    private int port;
+//
+//    @Value("${spring.redis.database}")
+//    private int database;
+//
+//    @Value("${spring.redis.password}")
+//    private String password;
+
+
+    @Bean
+    public RedissonClient getRedisson() {
+        Config config = new Config();
+        config.useSingleServer().setAddress("redis://localhost:6379");
+//                .setDatabase(database);
+//        if (StringUtils.isNotEmpty(password)) {
+//            config.useSingleServer().setAddress("redis://" + host + ":" + port).setDatabase(database)
+//                    .setPassword(password);
+//        } else {
+//            config.useSingleServer().setAddress("redis://" + host + ":" + port).setDatabase(database);
+//        }
+        //设置全局默认看门狗机续期时间,如果在使用时不设置,则使用全局的,如果全局不设置,则使用默认的30000,单位毫秒
+        config.setLockWatchdogTimeout(2000);
+        return Redisson.create(config);
+    }
+}

+ 78 - 0
src/main/java/com/zhentao/config/SnowflakeUtil.java

@@ -0,0 +1,78 @@
+package com.zhentao.config;
+
+/**
+ * @Date 2025/4/21 19:25
+ * @Author gln
+ **/
+
+public class SnowflakeUtil {
+    // 起始时间戳,可自定义,这里以 2020-01-01 00:00:00 为例
+    private static final long START_TIMESTAMP = 1577836800000L;
+
+    // 数据中心 ID 所占位数
+    private static final long DATA_CENTER_ID_BITS = 5L;
+    // 机器 ID 所占位数
+    private static final long WORKER_ID_BITS = 5L;
+    // 序列号所占位数
+    private static final long SEQUENCE_BITS = 12L;
+
+    // 数据中心 ID 最大值
+    private static final long MAX_DATA_CENTER_ID = -1L ^ (-1L << DATA_CENTER_ID_BITS);
+    // 机器 ID 最大值
+    private static final long MAX_WORKER_ID = -1L ^ (-1L << WORKER_ID_BITS);
+    // 序列号最大值
+    private static final long SEQUENCE_MASK = -1L ^ (-1L << SEQUENCE_BITS);
+
+    // 机器 ID 向左移位数
+    private static final long WORKER_ID_SHIFT = SEQUENCE_BITS;
+    // 数据中心 ID 向左移位数
+    private static final long DATA_CENTER_ID_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS;
+    // 时间戳向左移位数
+    private static final long TIMESTAMP_LEFT_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS + DATA_CENTER_ID_BITS;
+
+    // 固定数据中心 ID 和机器 ID
+    private static final long DATA_CENTER_ID = 1;
+    private static final long WORKER_ID = 1;
+
+    private static long sequence = 0L;
+    private static long lastTimestamp = -1L;
+
+    public static synchronized long nextId() {
+        long timestamp = System.currentTimeMillis();
+
+        if (timestamp < lastTimestamp) {
+            throw new RuntimeException("Clock moved backwards. Refusing to generate id for " + (lastTimestamp - timestamp) + " milliseconds");
+        }
+
+        if (timestamp == lastTimestamp) {
+            sequence = (sequence + 1) & SEQUENCE_MASK;
+            if (sequence == 0) {
+                timestamp = waitForNextMillis(lastTimestamp);
+            }
+        } else {
+            sequence = 0L;
+        }
+
+        lastTimestamp = timestamp;
+
+        return ((timestamp - START_TIMESTAMP) << TIMESTAMP_LEFT_SHIFT) |
+                (DATA_CENTER_ID << DATA_CENTER_ID_SHIFT) |
+                (WORKER_ID << WORKER_ID_SHIFT) |
+                sequence;
+    }
+
+    private static long waitForNextMillis(long lastTimestamp) {
+        long timestamp = System.currentTimeMillis();
+        while (timestamp <= lastTimestamp) {
+            timestamp = System.currentTimeMillis();
+        }
+        return timestamp;
+    }
+
+    public static void main(String[] args) {
+        for (int i = 0; i < 10; i++) {
+            System.out.println(nextId());
+        }
+    }
+}
+

+ 55 - 0
src/main/java/com/zhentao/config/enums/ApiServiceExceptionEnum.java

@@ -0,0 +1,55 @@
+package com.zhentao.config.enums;
+
+public enum ApiServiceExceptionEnum implements BaseExceptionEnum {
+	SUCCESS(1, "成功"),
+	ERROR(2, "失败"),
+//	RESULT_SUCCES(1,"成功"),
+//   RESULT_ERROR(0,"失败"),
+   Login_SUCCESS(3,"登录成功"),
+   Login_ERROR(4,"登录失败"),
+    REG_ERROR(5,"注册失败"),
+    REG_SUCCESS(6,"注册成功"),
+   ISEXISTS_NOT_ERROR(7,"不存在"),
+   ISEXISTS_ERROR(8,"已存在"),
+    NOT_NULL(9,"不能为空"),
+   SHOP_AUDIT_ERROR(0,"审核失败"),
+    //   ISADD_ERROR(0,"已创建过"),
+//   APPLY_ERROR(0,"已报过名"),
+//   APPLY_TIME_ERROR(0,"已超时"),
+//   APPLY_NUM_ERROR(0,"报名已满"),
+    //   SHOP_NOEXISTS_ERROR(0,"店铺不存在"),
+    SHOP_AUDIT_STATUS(0,"审核中"),
+    USER_PASSWORD_NOT_NULL(402,"用户名或密码不能为空"),
+    PASSWORD_ERROR(9,"密码错误"),
+    PARAM_ERROR(10,"参数错误"),
+    USER_ISEXISTS_ERROR(8,"用户名已存在"),
+    ART_ERROR(400,"没有待发布文章"),
+   USER_NOT_EXISTS(401,"用户不存在");
+
+
+
+
+
+
+     ApiServiceExceptionEnum(Integer code , String message) {
+
+    	 this.code=code;
+    	 this.message=message;
+    }
+     private Integer code;
+
+     private String message;
+
+    @Override
+	public Integer getCode() {
+		// TODO Auto-generated method stub
+		return code;
+	}
+
+	@Override
+	public String getMessage() {
+		// TODO Auto-generated method stub
+		return message;
+	}
+
+}

+ 18 - 0
src/main/java/com/zhentao/config/enums/BaseExceptionEnum.java

@@ -0,0 +1,18 @@
+package com.zhentao.config.enums;
+
+/**
+ * 抽象接口
+ *
+ */
+public interface BaseExceptionEnum {
+
+    /**
+     * 获取异常编码
+     */
+    Integer getCode();
+
+    /**
+     * 获取异常信息
+     */
+    String getMessage();
+}

+ 23 - 0
src/main/java/com/zhentao/config/exceptions/ApiException.java

@@ -0,0 +1,23 @@
+package com.zhentao.config.exceptions;
+
+
+import com.zhentao.config.enums.BaseExceptionEnum;
+import lombok.Data;
+
+@Data
+public class ApiException extends RuntimeException{
+
+	public Integer code;
+	public String msg;
+	public ApiException(BaseExceptionEnum baseExceptionEnum) {
+		super(baseExceptionEnum.getMessage());
+		this.code = baseExceptionEnum.getCode();
+		this.msg = baseExceptionEnum.getMessage();
+	}
+	public ApiException(Integer code, String message) {
+		super(message);
+		this.code=code;
+		this.msg=message;
+	}
+
+}

+ 66 - 0
src/main/java/com/zhentao/config/exceptions/GlobalExceptionHandler.java

@@ -0,0 +1,66 @@
+package com.zhentao.config.exceptions;//package com.zhentao.config.exceptions;
+//
+//
+//import com.zhentao.config.vo.ResultVo;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.web.bind.MethodArgumentNotValidException;
+//import org.springframework.web.bind.annotation.ControllerAdvice;
+//import org.springframework.web.bind.annotation.ExceptionHandler;
+//import org.springframework.web.bind.annotation.ResponseBody;
+//import org.springframework.web.bind.annotation.RestControllerAdvice;
+//import org.springframework.web.multipart.MultipartException;
+//
+//import javax.servlet.http.HttpServletRequest;
+//
+//@ControllerAdvice
+//@RestControllerAdvice
+//@Slf4j
+//public class GlobalExceptionHandler {
+//    // private Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
+//
+//    /**
+//     * 系统异常处理,比如:404,500
+//     *
+//     * @param req
+//     * @param e
+//     * @return
+//     * @throws Exception
+//     */
+//    @ExceptionHandler(value = Exception.class)
+//    @ResponseBody
+//    public ResultVo defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
+//        // log.error("", e);
+//        log.error(e.getMessage());
+//        //判断是否属于自定义异常
+//
+//
+//        if (e instanceof org.springframework.web.servlet.NoHandlerFoundException) {
+//        	return ResultVo.error(404,"不存在页面请求");
+//       }
+//
+//        if (e instanceof ApiException) {
+//
+//            ApiException customException = (ApiException) e;
+//
+//            return ResultVo.error(customException.getCode(), customException.getMessage());
+//        } else if (e instanceof MultipartException){
+//            log.error("系统异常{}", e);
+//            return ResultVo.error(1000, "上传文件异常");
+//        } else if(e instanceof MethodArgumentNotValidException) {
+//            MethodArgumentNotValidException methodArgumentNotValidException=(MethodArgumentNotValidException)e;
+//            return ResultVo.error(1002,methodArgumentNotValidException.getBindingResult().getFieldError().getDefaultMessage());
+//        }else{
+//            log.error("系统异常{}", e);
+//            return ResultVo.error(1001, "系统参数异常");
+//        }
+//    }
+//
+//
+//
+////    @ExceptionHandler(value = InsufficientAuthenticationException.class)
+////    @ResponseBody
+////    public ResultVo jsonErrorHandle(HttpServletRequest req, InsufficientAuthenticationException e) {
+////        return ResultVo.error(0, e.getMessage());
+////    }
+//
+//}

+ 114 - 0
src/main/java/com/zhentao/config/token/TokenUtils.java

@@ -0,0 +1,114 @@
+package com.zhentao.config.token;
+
+
+import com.zhentao.config.enums.ApiServiceExceptionEnum;
+import com.zhentao.config.exceptions.ApiException;
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.JwtBuilder;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.bind.DatatypeConverter;
+import java.security.Key;
+import java.util.Date;
+
+/**
+ * 生成Token工具类
+ */
+public class TokenUtils {
+
+    /**
+     * 签名秘钥
+     */
+    public static final String SECRET = "cjyfutu1688";
+
+    /**
+     * 生成token
+     * @param id 一般传入userName
+     * @return
+     */
+    public static String createJwtToken(String id){
+        String issuer = "www.futureading.com";
+        String subject = "65532781@qq.com";
+        long ttlMillis = System.currentTimeMillis();
+        return createJwtToken(id, issuer, subject, ttlMillis);
+    }
+
+    /**
+     * 生成Token
+     *
+     * @param id
+     *            编号
+     * @param issuer
+     *            该JWT的签发者,是否使用是可选的
+     * @param subject
+     *            该JWT所面向的用户,是否使用是可选的;
+     * @param ttlMillis
+     *            签发时间
+     * @return token String
+     */
+    public static String createJwtToken(String id, String issuer, String subject, long ttlMillis) {
+
+        // 签名算法 ,将对token进行签名
+        SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
+
+        // 生成签发时间
+        long nowMillis = System.currentTimeMillis();
+        Date now = new Date(nowMillis);
+
+        // 通过秘钥签名JWT
+        byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(SECRET);
+        Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
+
+        // Let's set the JWT Claims
+        JwtBuilder builder = Jwts.builder().setId(id)
+                .setIssuedAt(now)
+                .setSubject(subject)
+                .setIssuer(issuer)
+                .signWith(signatureAlgorithm, signingKey);
+
+        // if it has been specified, let's add the expiration
+        if (ttlMillis >= 0) {
+            long expMillis = nowMillis + ttlMillis;
+            Date exp = new Date(expMillis);
+            builder.setExpiration(exp);
+        }
+
+        // Builds the JWT and serializes it to a compact, URL-safe string
+        return builder.compact();
+
+    }
+
+    // Sample method to validate and read the JWT
+    public static Claims parseJWT(String jwt) {
+        // This line will throw an exception if it is not a signed JWS (as expected)
+        Claims claims = Jwts.parser()
+                .setSigningKey(DatatypeConverter.parseBase64Binary(SECRET))
+                .parseClaimsJws(jwt).getBody();
+        return claims;
+    }
+
+    public static Long getUserId(String token){
+        Claims claims = null;
+        try {
+            claims = TokenUtils.parseJWT(token);
+        } catch (Exception e) {
+            throw new ApiException(ApiServiceExceptionEnum.Login_ERROR);
+        }
+
+        if(null==claims) {
+            throw new ApiException(ApiServiceExceptionEnum.Login_ERROR);
+        }
+        String id = claims.getId();
+        Long userId=Long.valueOf(id);
+
+        return userId;
+
+
+    }
+
+    public static void main(String[] args) {
+        System.out.println(TokenUtils.createJwtToken("admin"));
+    }
+}

+ 96 - 0
src/main/java/com/zhentao/config/vo/ResultVo.java

@@ -0,0 +1,96 @@
+package com.zhentao.config.vo;
+
+import com.zhentao.config.enums.ApiServiceExceptionEnum;
+import lombok.Data;
+
+@Data
+public class ResultVo<T> {
+    private Integer code;
+    private String msg;
+    private  T obj;
+
+    public ResultVo() {}
+
+    public ResultVo(int code, String msg, T obj) {
+        this.code = code;
+        this.msg = msg;
+        this.obj = obj;
+
+    }
+
+    public ResultVo(ApiServiceExceptionEnum apiServiceExceptionEnum, T object) {
+        this.code = apiServiceExceptionEnum.getCode();
+        this.msg = apiServiceExceptionEnum.getMessage();
+        this.obj = object;
+    }
+    public ResultVo(ApiServiceExceptionEnum apiServiceExceptionEnum) {
+        this.code = apiServiceExceptionEnum.getCode();
+        this.msg = apiServiceExceptionEnum.getMessage();
+        this.obj = null;
+    }
+
+    public static ResultVo success(Object object) {
+        ResultVo resultVO = new ResultVo();
+        resultVO.setMsg("成功");
+        resultVO.setObj(object);
+        return resultVO;
+    }
+
+    public static ResultVo success() {
+        return success(null);
+    }
+    public static ResultVo error(Integer code, String msg) {
+        ResultVo resultVO = new ResultVo();
+        resultVO.setCode(code);
+        resultVO.setMsg(msg);
+        return resultVO;
+    }
+    public static ResultVo error(){
+        ResultVo resultVO=new ResultVo();
+        resultVO.setCode(0);
+        resultVO.setMsg("失败");
+        return resultVO;
+    }
+    public static ResultVo error(Integer code,String msg,Object obj){
+        ResultVo resultVO=new ResultVo();
+        resultVO.setCode(0);
+        resultVO.setMsg(msg);
+        resultVO.setObj(obj);
+        return resultVO;
+    }
+
+    public static ResultVo error(ApiServiceExceptionEnum apiServiceExceptionEnum) {
+        ResultVo resultVO=new ResultVo();
+        resultVO.setCode(apiServiceExceptionEnum.getCode());
+        resultVO.setMsg(apiServiceExceptionEnum.getMessage());
+        return resultVO;
+    }
+    public static ResultVo success(Integer code,String msg,Object obj){
+        ResultVo resultVO=new ResultVo();
+        resultVO.setCode(0);
+        resultVO.setMsg(msg);
+        resultVO.setObj(obj);
+        return resultVO;
+    }
+
+    public static ResultVo success(ApiServiceExceptionEnum apiServiceExceptionEnum) {
+        ResultVo resultVO=new ResultVo();
+        resultVO.setCode(apiServiceExceptionEnum.getCode());
+        resultVO.setMsg(apiServiceExceptionEnum.getMessage());
+        return resultVO;
+    }
+    public static ResultVo success(ApiServiceExceptionEnum apiServiceExceptionEnum,Object object) {
+        ResultVo resultVO=new ResultVo();
+        resultVO.setCode(apiServiceExceptionEnum.getCode());
+        resultVO.setMsg(apiServiceExceptionEnum.getMessage());
+        resultVO.setObj(object);
+        return resultVO;
+    }
+    public static ResultVo error(ApiServiceExceptionEnum apiServiceExceptionEnum,Object object) {
+        ResultVo resultVO=new ResultVo();
+        resultVO.setCode(apiServiceExceptionEnum.getCode());
+        resultVO.setMsg(apiServiceExceptionEnum.getMessage());
+        resultVO.setObj(object);
+        return resultVO;
+    }
+}

+ 21 - 0
src/main/java/com/zhentao/controller/UserController.java

@@ -0,0 +1,21 @@
+package com.zhentao.controller;
+
+import com.zhentao.service.UserLoginService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Date 2025/5/10 10:14
+ * @Author gln
+ **/
+@RestController
+@RequestMapping("user")
+public class UserController {
+    @Autowired
+    private UserLoginService userLoginService;
+    @RequestMapping("test")
+    public String test(){
+        return "dddd";
+    }
+}

+ 0 - 67
src/main/java/com/zhentao/demos/web/BasicController.java

@@ -1,67 +0,0 @@
-/*
- * Copyright 2013-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.zhentao.demos.web;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
- */
-@Controller
-public class BasicController {
-
-    // http://127.0.0.1:8080/hello?name=lisi
-    @RequestMapping("/hello")
-    @ResponseBody
-    public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) {
-        return "Hello " + name;
-    }
-
-    // http://127.0.0.1:8080/user
-    @RequestMapping("/user")
-    @ResponseBody
-    public User user() {
-        User user = new User();
-        user.setName("theonefx");
-        user.setAge(666);
-        return user;
-    }
-
-    // http://127.0.0.1:8080/save_user?name=newName&age=11
-    @RequestMapping("/save_user")
-    @ResponseBody
-    public String saveUser(User u) {
-        return "user will save: name=" + u.getName() + ", age=" + u.getAge();
-    }
-
-    // http://127.0.0.1:8080/html
-    @RequestMapping("/html")
-    public String html() {
-        return "index.html";
-    }
-
-    @ModelAttribute
-    public void parseUser(@RequestParam(name = "name", defaultValue = "unknown user") String name
-            , @RequestParam(name = "age", defaultValue = "12") Integer age, User user) {
-        user.setName("zhangsan");
-        user.setAge(18);
-    }
-}

+ 0 - 44
src/main/java/com/zhentao/demos/web/PathVariableController.java

@@ -1,44 +0,0 @@
-/*
- * Copyright 2013-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.zhentao.demos.web;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
- */
-@Controller
-public class PathVariableController {
-
-    // http://127.0.0.1:8080/user/123/roles/222
-    @RequestMapping(value = "/user/{userId}/roles/{roleId}", method = RequestMethod.GET)
-    @ResponseBody
-    public String getLogin(@PathVariable("userId") String userId, @PathVariable("roleId") String roleId) {
-        return "User Id : " + userId + " Role Id : " + roleId;
-    }
-
-    // http://127.0.0.1:8080/javabeat/somewords
-    @RequestMapping(value = "/javabeat/{regexp1:[a-z-]+}", method = RequestMethod.GET)
-    @ResponseBody
-    public String getRegExp(@PathVariable("regexp1") String regexp1) {
-        return "URI Part : " + regexp1;
-    }
-}

+ 0 - 43
src/main/java/com/zhentao/demos/web/User.java

@@ -1,43 +0,0 @@
-/*
- * Copyright 2013-2018 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.zhentao.demos.web;
-
-/**
- * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
- */
-public class User {
-
-    private String name;
-
-    private Integer age;
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public Integer getAge() {
-        return age;
-    }
-
-    public void setAge(Integer age) {
-        this.age = age;
-    }
-}

+ 0 - 3
src/main/resources/application.properties

@@ -1,3 +0,0 @@
-# 应用服务 WEB 访问端口
-server.port=8080
-

+ 75 - 0
src/main/resources/application.yml

@@ -0,0 +1,75 @@
+#端口号
+server:
+  port: 7001
+  #  redis
+#  redis:
+#    host: 127.0.0.1
+#    port: 6379
+spring:
+#  application:
+#    name: producer  #服务的名字 -注册到注册中心上面的时候名字就是这个 -服务发现的时候根据名字去发现
+#  cloud:
+#    nacos:
+#      #      注册
+#      discovery:
+#        server-addr: localhost:8848  #ncaos的地址
+#        username: nacos #账号
+#        password: nacos #密码
+#        namespace: 5a45197a-dccb-4c50-a3ac-583319d85777
+#        group: ican_parent
+#      #        扫描
+#      config:
+#        server-addr: 59.110.123.177:8848
+#        username: nacos
+#        password: nacos
+#        namespace: 5a45197a-dccb-4c50-a3ac-583319d85777
+#        group: ican_parent
+#        file-extension: yml
+#    #        sentinel
+#    sentinel:
+#      transport:
+#        dashboard: localhost:9999
+#    #        gateway
+#    gateway:
+#      routes:
+#        - id: ican-mobile
+#          uri: lb://ican-mobile
+#          predicates:
+#            - Path=/mobile/**
+#          filters:
+#            - StripPrefix=1
+#            - Log=true
+#        - id: ican-backend
+#          uri: lb://ican-backend
+#          predicates:
+#            - Path=/backend/**
+#          filters:
+#            - StripPrefix=1
+#            - Log=true
+  #数据库参数
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://localhost:3306/1aa?characterEncoding=utf8&serverTimezone=GMT%2B8
+    username: root
+    password: 212579974
+
+#  web:
+#    resources:
+#      static-locations: file:///C:\Users\36052\Desktop\专五项目\imgs  #作用是将 http://localhost:8080/ 和 当前的文件夹 对应起来  路径相当于此文件夹   此文件夹相当于这个路径
+
+#mybatis:
+#  type-aliases-package: com.zhentao.pojo
+#  mapper-locations: classpath:mapper/*.xml
+#  configuration:
+#    map-underscore-to-camel-case: true
+
+#mybatis-plus
+mybatis-plus:
+  mapper-locations: classpath:/mapper/*.xml
+  type-aliases-package: com.zhentao.pojo
+
+#日志
+logging:
+  level:
+    com:
+      zhentao: debug

+ 0 - 6
src/main/resources/static/index.html

@@ -1,6 +0,0 @@
-<html>
-<body>
-<h1>hello word!!!</h1>
-<p>this is a html page</p>
-</body>
-</html>