From fcdb659453c0f269c5acea8994bd808da4be8124 Mon Sep 17 00:00:00 2001 From: zsy <2651995050@qq.com> Date: Tue, 17 Dec 2024 12:42:18 +0800 Subject: [PATCH 1/3] test --- .../com/hyc/wechat/controller/annotation/ControllerConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java b/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java index 5c2a19b..213c8b6 100644 --- a/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java +++ b/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java @@ -1,3 +1,4 @@ +// test /* * Copyright (c) 2019. 黄钰朝 * -- 2.34.1 From 0f2470694ffcc6d135e889317c9a56463a482e19 Mon Sep 17 00:00:00 2001 From: zsy <2651995050@qq.com> Date: Tue, 17 Dec 2024 16:18:13 +0800 Subject: [PATCH 2/3] test --- .../annotation/ControllerConfig.java | 22 +----- .../constant/ControllerMessage.java | 33 +++------ .../controller/constant/RequestMethod.java | 25 ------- .../wechat/controller/constant/WebPage.java | 28 +------- .../impl/filter/EncodingFilter.java | 30 ++------ .../controller/impl/filter/LoginFilter.java | 25 +------ .../impl/listener/ServletContextListener.java | 31 +++------ .../controller/impl/servlet/MyServlet.java | 25 +------ .../src/com/hyc/wechat/dao/BaseDao.java | 23 ------- .../src/com/hyc/wechat/dao/ChatDao.java | 25 ------- .../src/com/hyc/wechat/dao/DataSource.java | 27 -------- .../src/com/hyc/wechat/dao/FriendDao.java | 23 ------- .../src/com/hyc/wechat/dao/MemberDao.java | 23 ------- .../src/com/hyc/wechat/dao/MessageDao.java | 29 -------- .../src/com/hyc/wechat/dao/MomentDao.java | 12 ---- .../src/com/hyc/wechat/dao/NewsDao.java | 21 ------ .../src/com/hyc/wechat/dao/RecordDao.java | 21 ------ .../src/com/hyc/wechat/dao/RemarkDao.java | 21 ------ .../src/com/hyc/wechat/dao/ReplyDao.java | 17 ----- .../src/com/hyc/wechat/dao/ResultMapper.java | 19 ----- .../src/com/hyc/wechat/dao/SQLMapper.java | 21 +----- .../src/com/hyc/wechat/dao/SQLRunner.java | 63 +---------------- .../src/com/hyc/wechat/dao/UserDao.java | 29 +------- .../com/hyc/wechat/dao/annotation/Delete.java | 27 +++----- .../com/hyc/wechat/dao/annotation/Field.java | 23 ++----- .../com/hyc/wechat/dao/annotation/Insert.java | 24 ++----- .../com/hyc/wechat/dao/annotation/Param.java | 17 ----- .../com/hyc/wechat/dao/annotation/Query.java | 17 ----- .../com/hyc/wechat/dao/annotation/Result.java | 17 ----- .../hyc/wechat/dao/annotation/ResultType.java | 17 ----- .../com/hyc/wechat/dao/annotation/Table.java | 19 +---- .../com/hyc/wechat/dao/annotation/Update.java | 19 +---- .../hyc/wechat/dao/impl/DataSourceImpl.java | 30 -------- .../hyc/wechat/dao/impl/SQLRunnerImpl.java | 65 +---------------- .../hyc/wechat/exception/DaoException.java | 49 +++++++------ .../wechat/exception/ServiceException.java | 50 ++++++++------ .../hyc/wechat/factory/DaoProxyFactory.java | 42 +++++------ .../wechat/factory/ServiceProxyFactory.java | 45 ++++++------ .../wechat/factory/proxy/ConnectionProxy.java | 35 ++++------ .../model/builder/MessageVOBuilder.java | 69 +++++++++++++------ .../wechat/model/builder/MomentVOBuilder.java | 17 ----- .../hyc/wechat/model/dto/ServiceResult.java | 17 ----- .../src/com/hyc/wechat/model/po/Chat.java | 19 +---- .../src/com/hyc/wechat/model/po/Friend.java | 19 +---- .../src/com/hyc/wechat/model/po/Member.java | 19 +---- .../hyc/wechat/model/po/abs/BaseEntity.java | 19 ----- wechat-master/web/static/css/index.css | 21 +++++- wechat-master/web/static/js/bootstrap.min.js | 6 +- 48 files changed, 247 insertions(+), 1048 deletions(-) diff --git a/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java b/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java index 213c8b6..6f7da14 100644 --- a/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java +++ b/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java @@ -1,30 +1,10 @@ // test -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.annotation; import java.lang.annotation.*; -/** - * @author 黄钰朝 - * @description 用于注解ActionProvider的url路径 - * @date 2019-05-02 11:28 - */ -@Documented @Retention(value = RetentionPolicy.RUNTIME) @Target(value = ElementType.TYPE) public @interface ControllerConfig { diff --git a/wechat-master/src/com/hyc/wechat/controller/constant/ControllerMessage.java b/wechat-master/src/com/hyc/wechat/controller/constant/ControllerMessage.java index 845d3dd..b8d49f5 100644 --- a/wechat-master/src/com/hyc/wechat/controller/constant/ControllerMessage.java +++ b/wechat-master/src/com/hyc/wechat/controller/constant/ControllerMessage.java @@ -1,31 +1,11 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.constant; - -/** - * @author 黄钰朝 - * @description 用于枚举控制层的系统消息 - * @date 2019-05-03 13:11 - */ +// 定义一个名为ControllerMessage的枚举类,用于存储控制器相关的消息常量 public enum ControllerMessage { - /** * 游客身份 */ + //枚举常量,表示用户当前处于游客身份 YOU_ARE_VISITOR("您现在处于游客身份,该服务并未对游客开放,如需使用请先注册一个账号"), /* @@ -36,21 +16,24 @@ public enum ControllerMessage { /** * 系统故障 */ + // 枚举常量,用于分隔不同类型的消息常量,系统错误码部分 SYSTEM_EXECEPTION("服务器发生了严重异常,无法提供服务"), /** * 请求参数错误 */ + //// 枚举常量,表示请求参数错误 REQUEST_INVALID("您的请求参数不足或错误,系统无法处理您的请求"); + // 枚举成员变量,用于存储消息文本 public String message; - + // 枚举的构造方法,用于在创建枚举实例时初始化成员变量 ControllerMessage(String message) { this.message = message; } - + // 公共方法,用于获取枚举实例中存储的消息文本 public String getMessage() { return message; } - + // 私有方法,用于设置枚举实例中的消息文本 private void setMessage(String message) { this.message = message; } diff --git a/wechat-master/src/com/hyc/wechat/controller/constant/RequestMethod.java b/wechat-master/src/com/hyc/wechat/controller/constant/RequestMethod.java index bb3cb1c..459f548 100644 --- a/wechat-master/src/com/hyc/wechat/controller/constant/RequestMethod.java +++ b/wechat-master/src/com/hyc/wechat/controller/constant/RequestMethod.java @@ -1,30 +1,5 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.constant; -/** - * request中method的枚举常量 - * - * @author 黄钰朝 - * @program XHotel - * @description - * @date 2019-04-18 12:45 - */ - public enum RequestMethod { /** diff --git a/wechat-master/src/com/hyc/wechat/controller/constant/WebPage.java b/wechat-master/src/com/hyc/wechat/controller/constant/WebPage.java index 9327e9b..4af5035 100644 --- a/wechat-master/src/com/hyc/wechat/controller/constant/WebPage.java +++ b/wechat-master/src/com/hyc/wechat/controller/constant/WebPage.java @@ -1,32 +1,8 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.constant; - -/** - * 界面的地址常量 - * - * @author 黄钰朝 - * @program XHotel - * @description - * @date 2019-04-18 12:48 - */ +// 定义一个名为WebPage的枚举类,用于表示不同的网页路径 public enum WebPage { - /** * 注册界面 */ @@ -69,6 +45,8 @@ public enum WebPage { PICTRUES_JSP; @Override + // 重写toString方法,以提供枚举常量的字符串表示形式 + // 将枚举名称转换为小写,并用点号替换下划线,以符合网页文件的命名习惯 public String toString() { return "/"+super.toString().toLowerCase().replaceAll("_", "."); } diff --git a/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java b/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java index fdafd38..c5eac73 100644 --- a/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java +++ b/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.impl.filter; @@ -27,13 +12,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -/** - * @author 黄钰朝 - * @program wechat - * @description 负责设置编码格式 - * @date 2019-05-02 22:56 - */ - +// 使用@WebFilter注解定义一个过滤器,指定过滤器的名称、URL模式、初始化参数 @WebFilter( filterName = "EncodingFilter", urlPatterns = {"/*"}, servletNames = {"/*"}, @@ -63,23 +42,28 @@ public class EncodingFilter implements Filter { req.setCharacterEncoding(ENCODING); resp.setContentType("text/html;charset=utf-8"); resp.setCharacterEncoding(ENCODING); + // 添加CORS相关的响应头,允许跨域请求 resp.addHeader("Access-Control-Allow-Origin", "*"); resp.addHeader("Access-Control-Allow-Headers", "origin, content-type, accept, x-requested-with, sid, mycustom, smuser"); resp.addHeader("Access-Control-Allow-Methods", "*"); resp.addHeader("Access-Control-Max-Age", "100"); resp.addHeader("Access-Control-Allow-Credentials", "false"); - + // 继续执行过滤链中的下一个过滤器或Servlet filterChain.doFilter(servletRequest, servletResponse); } catch (IOException | ServletException e) { e.printStackTrace(); try { + // 设置请求属性,传递系统异常信息 req.setAttribute("message", ControllerMessage.SYSTEM_EXECEPTION.message); + // 转发请求到错误页面 req.getRequestDispatcher(WebPage.ERROR_JSP.toString()).forward(req, resp); } catch (ServletException | IOException ex) { + // 打印转发过程中可能出现的异常堆栈信息 ex.printStackTrace(); } } + // 获取日志记录器 Logger logger = Logger.getLogger(EncodingFilter.class); logger.info("[请求url] : " + req.getRequestURI() + " [请求参数] :" + req.getQueryString()); } diff --git a/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java b/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java index f519a74..74bf00f 100644 --- a/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java +++ b/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.impl.filter; import com.hyc.wechat.controller.constant.ControllerMessage; @@ -35,12 +20,7 @@ import java.io.IOException; import static com.hyc.wechat.util.ControllerUtils.returnJsonObject; -/** - * @author 黄钰朝 - * @program wechat - * @description 负责过滤需要登陆的页面的请求 - * @date 2019-05-09 15:41 - */ + @WebFilter( filterName = "LoginFilter", urlPatterns = {"/*"}, servletNames = {"/*"}, @@ -96,5 +76,4 @@ public class LoginFilter implements Filter { filterChain.doFilter(req, resp); } - } diff --git a/wechat-master/src/com/hyc/wechat/controller/impl/listener/ServletContextListener.java b/wechat-master/src/com/hyc/wechat/controller/impl/listener/ServletContextListener.java index 5d93cf2..d78dfbe 100644 --- a/wechat-master/src/com/hyc/wechat/controller/impl/listener/ServletContextListener.java +++ b/wechat-master/src/com/hyc/wechat/controller/impl/listener/ServletContextListener.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.impl.listener; @@ -25,18 +10,20 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; + /** - * @author 黄钰朝 - * @program wechat - * @description 负责监听servlet的初始化和销毁事件 - * @date 2019-05-01 08:44 + * Servlet上下文监听器,用于在Web应用启动时初始化一些资源,并在Web应用关闭时释放这些资源。 */ - @WebListener public class ServletContextListener implements javax.servlet.ServletContextListener { - + /** + * 使用ConcurrentHashMap来存储服务提供者,保证线程安全。 + */ private static final ConcurrentHashMap providerMap = new ConcurrentHashMap<>(); - + /** + * 当Servlet上下文被初始化时调用此方法。 + * @param sce Servlet上下文事件 + */ @Override public void contextInitialized(ServletContextEvent sce) { diff --git a/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java b/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java index e7d7609..438bc45 100644 --- a/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java +++ b/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.controller.impl.servlet; import com.hyc.wechat.controller.annotation.ControllerConfig; @@ -33,12 +18,6 @@ import java.util.Set; import static com.hyc.wechat.provider.Provider.toErrorPage; -/** - * @author 黄钰朝 - * @program wechat - * @description 接收客户端请求,将其转发到controller - * @date 2019-05-02 03:28 - */ @MultipartConfig(location = "/home/pan/tomcat/webapps/wechat/upload") //@MultipartConfig(location = "C:\\Users\\Misterchaos\\Documents\\Java Develop Workplaces\\IDEA workspace\\wechat\\out\\artifacts\\wechat_war_exploded\\upload") @WebServlet("/wechat/*") @@ -56,8 +35,6 @@ public class MyServlet extends HttpServlet { * @param resp 响应 * @name doPost * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { diff --git a/wechat-master/src/com/hyc/wechat/dao/BaseDao.java b/wechat-master/src/com/hyc/wechat/dao/BaseDao.java index 27cb1ed..d57f660 100644 --- a/wechat-master/src/com/hyc/wechat/dao/BaseDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/BaseDao.java @@ -1,28 +1,11 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; import com.hyc.wechat.dao.annotation.*; /** - * @author 黄钰朝 * @program wechat * @description 提供Dao的基础方法接口 - * @date 2019-05-01 17:11 */ public interface BaseDao { @@ -41,8 +24,6 @@ public interface BaseDao { * @param obj 要插入的对象 * @name insert * @notice none - * @author 黄钰朝 - * @date 2019/5/1 */ @Insert() int insert(Object obj); @@ -56,8 +37,6 @@ public interface BaseDao { * @name update * @notice 请注意此方法默认更新该对象中所有不为null的属性到数据库
* 如果不希望更新某些字段,请将其设置为null - * @author 黄钰朝 - * @date 2019/5/1 */ @Update() int update(Object obj); @@ -68,8 +47,6 @@ public interface BaseDao { * @param obj 要删除的对象 * @name delete * @notice none - * @author 黄钰朝 - * @date 2019/5/1 */ @Delete() int delete(Object obj); diff --git a/wechat-master/src/com/hyc/wechat/dao/ChatDao.java b/wechat-master/src/com/hyc/wechat/dao/ChatDao.java index 088642f..282a478 100644 --- a/wechat-master/src/com/hyc/wechat/dao/ChatDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/ChatDao.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -24,9 +9,7 @@ import com.hyc.wechat.model.po.Chat; import java.util.List; /** - * @author 黄钰朝 * @description 负责聊天表的CRUD - * @date 2019-05-03 02:18 */ public interface ChatDao extends BaseDao { @@ -40,8 +23,6 @@ public interface ChatDao extends BaseDao { * @return 聊天对象 * @name getChatById * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = Chat.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where id = ? ") @@ -54,8 +35,6 @@ public interface ChatDao extends BaseDao { * @return 该用户加入的聊天集合 * @name listByUserId * @notice none - * @author 黄钰朝 - * @date 2019/5/3 */ @Result(entity = Chat.class, returns = ResultType.LIST) @Query(value = "select c.id,c.number,c.owner_id,c.name,c.type,c.member,c.photo,c.status,c.gmt_create,c.gmt_modified " + @@ -72,8 +51,6 @@ public interface ChatDao extends BaseDao { * @return * @name toFriendChat * @notice none - * @author 黄钰朝 - * @date 2019/5/5 */ @Result(entity = Chat.class, returns = ResultType.OBJECT) @Query(value = "select c.id,c.number,c.owner_id,u.name as name,c.member,u.photo as photo,c.type,c.status,c.gmt_create,c.gmt_modified " + @@ -88,8 +65,6 @@ public interface ChatDao extends BaseDao { * @return * @name getByChatNumber * @notice none - * @author 黄钰朝 - * @date 2019/5/6 */ @Result(entity = Chat.class,returns = ResultType.OBJECT) @Query(value = "select "+ALL_FIELD+" from "+TABLE+" where number = ? ") diff --git a/wechat-master/src/com/hyc/wechat/dao/DataSource.java b/wechat-master/src/com/hyc/wechat/dao/DataSource.java index b151749..d6cde51 100644 --- a/wechat-master/src/com/hyc/wechat/dao/DataSource.java +++ b/wechat-master/src/com/hyc/wechat/dao/DataSource.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -21,10 +6,8 @@ import com.hyc.wechat.exception.DaoException; import java.sql.Connection; /** - * @author 黄钰朝 * @program wechat * @description 负责向Dao层提供数据库连接 - * @date 2019-05-01 16:33 */ public interface DataSource { /** @@ -34,8 +17,6 @@ public interface DataSource { * @throws DaoException 如果数据库连接已经达到最大值时仍然调用此方法,则抛出此异常 * @name getConnection * @notice 数据库连接的数量受到配置文件中最大值的限制 - * @author 黄钰朝 - * @date 2019/5/1 */ Connection getConnection() throws DaoException; @@ -45,8 +26,6 @@ public interface DataSource { * * @param conn 数据库连接 * @name freeConnection - * @author 黄钰朝 - * @date 2019/5/1 */ void freeConnection(Connection conn); @@ -56,8 +35,6 @@ public interface DataSource { * @param conn 数据库连接 * @return java.sql.Connection * @name createConnection - * @author 黄钰朝 - * @date 2019/5/1 */ void destroyConnection(Connection conn); @@ -67,8 +44,6 @@ public interface DataSource { * * @return int 当前已经创建的连接数 * @name getCurrentCount - * @author 黄钰朝 - * @date 2019/5/1 */ int getCurrentCount(); @@ -77,8 +52,6 @@ public interface DataSource { * * @return int 当前空闲连接数 * @name getfreeCount - * @author 黄钰朝 - * @date 2019/5/1 */ int getfreeCount(); } diff --git a/wechat-master/src/com/hyc/wechat/dao/FriendDao.java b/wechat-master/src/com/hyc/wechat/dao/FriendDao.java index 8b02e1e..2f9a9be 100644 --- a/wechat-master/src/com/hyc/wechat/dao/FriendDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/FriendDao.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -26,10 +11,8 @@ import java.math.BigInteger; import java.util.List; /** - * @author 黄钰朝 * @program wechat * @description 负责朋友表CRUD - * @date 2019-05-02 01:59 */ public interface FriendDao extends BaseDao { @@ -44,8 +27,6 @@ public interface FriendDao extends BaseDao { * @return * @name getFriendByUIDAndFriendId * @notice none - * @author 黄钰朝 - * @date 2019/5/6 */ @Result(entity = Friend.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where user_id = ? and friend_id = ? ") @@ -59,8 +40,6 @@ public interface FriendDao extends BaseDao { * @return * @name listByUserId * @notice none - * @author 黄钰朝 - * @date 2019/5/6 */ @Result(entity = Friend.class, returns = ResultType.LIST) @Query(value = "select f.id,f.user_id,f.friend_id,f.chat_id,f.group_id,f.alias,f.description,u.photo as photo,f.status,f.gmt_create,f.gmt_modified " + @@ -74,8 +53,6 @@ public interface FriendDao extends BaseDao { * @param id 朋友id * @name getFriendById * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Friend.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where id = ? ") diff --git a/wechat-master/src/com/hyc/wechat/dao/MemberDao.java b/wechat-master/src/com/hyc/wechat/dao/MemberDao.java index 42a2e60..df42079 100644 --- a/wechat-master/src/com/hyc/wechat/dao/MemberDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/MemberDao.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -25,9 +10,7 @@ import java.math.BigInteger; import java.util.List; /** - * @author 黄钰朝 * @description 用于user_chat表的CRUD - * @date 2019-05-03 13:05 */ public interface MemberDao extends BaseDao { String TABLE = "member"; @@ -40,8 +23,6 @@ public interface MemberDao extends BaseDao { * @return 成员对象 * @name getMemberById * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = Member.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where id = ? ") @@ -55,8 +36,6 @@ public interface MemberDao extends BaseDao { * @return 成员对象 * @name getMemberByUIdAndChatId * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = Member.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where user_id = ? and chat_id = ? ") @@ -69,8 +48,6 @@ public interface MemberDao extends BaseDao { * @param chatId 聊天id * @return * @notice none - * @author 黄钰朝 - * @date 2019/5/5 */ @Result(entity = Member.class, returns = ResultType.LIST) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where chat_id = ? ") diff --git a/wechat-master/src/com/hyc/wechat/dao/MessageDao.java b/wechat-master/src/com/hyc/wechat/dao/MessageDao.java index cb9a40f..e11df98 100644 --- a/wechat-master/src/com/hyc/wechat/dao/MessageDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/MessageDao.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -25,9 +10,7 @@ import java.math.BigInteger; import java.util.List; /** - * @author 黄钰朝 * @description 用于message表的CRUD - * @date 2019-05-03 13:06 */ public interface MessageDao extends BaseDao { @@ -43,8 +26,6 @@ public interface MessageDao extends BaseDao { * @param chatId 聊天id * @return 成员对象 * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = Message.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where sender_id = ? and chat_id = ? and time = ? ") @@ -60,8 +41,6 @@ public interface MessageDao extends BaseDao { * @param offset 起始记录数 * @name listMessageByUserIdAndChatId * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Message.class, returns = ResultType.LIST) @Query(value = "select m.id, m.sender_id, m.chat_id, m.content , m.type , m.time ,m.status , " + @@ -79,8 +58,6 @@ public interface MessageDao extends BaseDao { * @param offset 起始记录数 * @name listMessageByUserIdAndChatId * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Message.class, returns = ResultType.LIST) @Query(value = "select m.id, m.sender_id, m.chat_id, m.content , m.type , m.time ,m.status , " + @@ -96,8 +73,6 @@ public interface MessageDao extends BaseDao { * @param chatId 聊天id * @param fileName 导出文件名 * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Message.class, returns = ResultType.LIST) @Query(value = "select m.id, m.sender_id, m.chat_id, m.content , m.type , m.time ,m.status , " + @@ -114,8 +89,6 @@ public interface MessageDao extends BaseDao { * @param limit 每页查询记录数 * @param offset 起始记录数 * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Message.class, returns = ResultType.LIST) @Query(value = "select m.id, m.sender_id, m.chat_id, m.content , m.type , m.time ,m.status , " + @@ -131,8 +104,6 @@ public interface MessageDao extends BaseDao { * @param limit 每页查询记录数 * @param offset 起始记录数 * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Message.class, returns = ResultType.LIST) @Query(value = "select m.id, m.sender_id, m.chat_id, m.content , m.type , m.time ,m.status , " + diff --git a/wechat-master/src/com/hyc/wechat/dao/MomentDao.java b/wechat-master/src/com/hyc/wechat/dao/MomentDao.java index c9e1145..ab1369e 100644 --- a/wechat-master/src/com/hyc/wechat/dao/MomentDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/MomentDao.java @@ -25,9 +25,7 @@ import com.hyc.wechat.model.po.Moment; import java.util.List; /** - * @author 黄钰朝 * @description 负责朋友圈的CRUD - * @date 2019-05-07 11:55 */ public interface MomentDao extends BaseDao { String TABLE = "moment"; @@ -39,8 +37,6 @@ public interface MomentDao extends BaseDao { * @param id 朋友圈id * @name geMomentById * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = Moment.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where id = ? ") @@ -52,8 +48,6 @@ public interface MomentDao extends BaseDao { * @param ownerId 用户id * @param stauts 状态 * @notice none - * @author 黄钰朝 - * @date 2019/5/8 */ @Result(entity = Moment.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where owner_id = ? and status = ? ") @@ -68,8 +62,6 @@ public interface MomentDao extends BaseDao { * @param offset 起始记录数 * @name listMyMomentByOwnerIdDesc * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Moment.class, returns = ResultType.LIST) @Query("select " + ALL_FIELD + " from " + TABLE + " where owner_id = ? order by time desc limit ? offset ? ") @@ -83,8 +75,6 @@ public interface MomentDao extends BaseDao { * @param offset 起始记录数 * @name listMyMomentByOwnerId * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = Moment.class, returns = ResultType.LIST) @Query("select " + ALL_FIELD + " from " + TABLE + " where owner_id = ? order by time limit ? offset ? ") @@ -99,8 +89,6 @@ public interface MomentDao extends BaseDao { * @param offset 起始记录数 * @name loadPhoto * @notice none - * @author 黄钰朝 - * @date 2019/5/10 */ @Result(entity = Moment.class, returns = ResultType.LIST) @Query("select photo from " + TABLE + " where owner_id = ? order by time desc limit ? offset ? ") diff --git a/wechat-master/src/com/hyc/wechat/dao/NewsDao.java b/wechat-master/src/com/hyc/wechat/dao/NewsDao.java index 18c0760..0bd9b06 100644 --- a/wechat-master/src/com/hyc/wechat/dao/NewsDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/NewsDao.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -24,9 +9,7 @@ import com.hyc.wechat.model.po.News; import java.util.List; /** - * @author 黄钰朝 * @description 负责动态表的CRUD - * @date 2019-05-07 18:47 */ public interface NewsDao extends BaseDao { String TABLE = "news"; @@ -40,8 +23,6 @@ public interface NewsDao extends BaseDao { * @param offset 起始记录数 * @name listNewsByUserId * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = News.class, returns = ResultType.LIST) @Query("select " + ALL_FIELD + " from " + TABLE + " where user_id = ? order by gmt_create desc limit ? offset ? ") @@ -55,8 +36,6 @@ public interface NewsDao extends BaseDao { * @param userId 用户id * @name getNewsByMomentId * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Result(entity = News.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where moment_id = ? and user_id = ? ") diff --git a/wechat-master/src/com/hyc/wechat/dao/RecordDao.java b/wechat-master/src/com/hyc/wechat/dao/RecordDao.java index 83e9fb2..328a3e0 100644 --- a/wechat-master/src/com/hyc/wechat/dao/RecordDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/RecordDao.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -20,9 +5,7 @@ import com.hyc.wechat.dao.annotation.Delete; import com.hyc.wechat.dao.annotation.Update; /** - * @author 黄钰朝 * @description 负责消息记录CRUD - * @date 2019-05-06 21:41 */ public interface RecordDao extends BaseDao { String TABLE = "record"; @@ -37,8 +20,6 @@ public interface RecordDao extends BaseDao { * @param chatId 聊天id * @name updateStatusInChat * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Update("update " + TABLE + " as r inner join message as m set r.status = ? where r.user_id = ? and r.message_id = m.id and m.chat_id = ?") void updateStatusInChat(Object status, Object userId ,Object chatId); @@ -51,8 +32,6 @@ public interface RecordDao extends BaseDao { * @param chatId 聊天id * @name deleteAllRecordInChat * @notice none - * @author 黄钰朝 - * @date 2019/5/10 */ @Update("delete r from " + TABLE + " r inner join message m on r.message_id = m.id where r.user_id = ? and m.chat_id = ? " ) void deleteAllRecordInChat(Object userId , Object chatId); diff --git a/wechat-master/src/com/hyc/wechat/dao/RemarkDao.java b/wechat-master/src/com/hyc/wechat/dao/RemarkDao.java index 91c87d9..7dfc4e4 100644 --- a/wechat-master/src/com/hyc/wechat/dao/RemarkDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/RemarkDao.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -25,9 +10,7 @@ import com.hyc.wechat.model.po.Remark; import java.util.List; /** - * @author 黄钰朝 * @description - * @date 2019-05-14 01:12 */ public interface RemarkDao extends BaseDao{ String TABLE = "remark"; @@ -41,8 +24,6 @@ public interface RemarkDao extends BaseDao{ * @param offset 起始记录数 * @name listRemarkDesc * @notice none - * @author 黄钰朝 - * @date 2019/5/14 */ @Result(entity = Remark.class, returns = ResultType.LIST) @Query("select " + ALL_FIELD + " from " + TABLE + " where moment_id = ? order by time limit ? offset ? ") @@ -54,8 +35,6 @@ public interface RemarkDao extends BaseDao{ * @param id 评论id * @name geRemarkById * @notice none - * @author 黄钰朝 - * @date 2019/5/14 */ @Result(entity = Remark.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where id = ? ") diff --git a/wechat-master/src/com/hyc/wechat/dao/ReplyDao.java b/wechat-master/src/com/hyc/wechat/dao/ReplyDao.java index 98c2b34..6d20246 100644 --- a/wechat-master/src/com/hyc/wechat/dao/ReplyDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/ReplyDao.java @@ -1,25 +1,8 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; /** - * @author 黄钰朝 * @description - * @date 2019-05-14 01:12 */ public interface ReplyDao extends BaseDao { } diff --git a/wechat-master/src/com/hyc/wechat/dao/ResultMapper.java b/wechat-master/src/com/hyc/wechat/dao/ResultMapper.java index 02767c1..70158db 100644 --- a/wechat-master/src/com/hyc/wechat/dao/ResultMapper.java +++ b/wechat-master/src/com/hyc/wechat/dao/ResultMapper.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; @@ -20,10 +5,8 @@ package com.hyc.wechat.dao; import java.sql.ResultSet; /** - * @author 黄钰朝 * @program XHotel * @description 用于处理执行查询语句之后返回的结果集,将结果集映射为对象 - * @date 2019-04-09 15:06 */ public interface ResultMapper { /** @@ -32,8 +15,6 @@ public interface ResultMapper { * @param rs 需要映射的结果集 * @return java.lang.Object * @notice none - * @author 黄钰朝 - * @date 2019/4/10 */ Object doMap(ResultSet rs); } diff --git a/wechat-master/src/com/hyc/wechat/dao/SQLMapper.java b/wechat-master/src/com/hyc/wechat/dao/SQLMapper.java index 8e2afab..d81a449 100644 --- a/wechat-master/src/com/hyc/wechat/dao/SQLMapper.java +++ b/wechat-master/src/com/hyc/wechat/dao/SQLMapper.java @@ -1,26 +1,9 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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. - */ - +//t package com.hyc.wechat.dao; /** - * @author 黄钰朝 * @program XHotel * @description 用于将属性映射成sql预编译语句 - * @date 2019-04-11 17:55 */ public interface SQLMapper { @@ -32,8 +15,6 @@ public interface SQLMapper { * @return 返回映射之后的预编译sql语句 * @name doMap * @notice none - * @author 黄钰朝 - * @date 2019/4/12 */ String doMap(Object... params); diff --git a/wechat-master/src/com/hyc/wechat/dao/SQLRunner.java b/wechat-master/src/com/hyc/wechat/dao/SQLRunner.java index 722a9f6..2a5f5da 100644 --- a/wechat-master/src/com/hyc/wechat/dao/SQLRunner.java +++ b/wechat-master/src/com/hyc/wechat/dao/SQLRunner.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; import com.hyc.wechat.dao.annotation.Insert; @@ -21,10 +6,8 @@ import com.hyc.wechat.dao.annotation.Insert; import java.util.LinkedList; /** - * @author 黄钰朝 * @program wechat * @description 负责执行SQL语句 - * @date 2019-05-01 17:34 */ public interface SQLRunner { @@ -48,8 +31,6 @@ public interface SQLRunner { * @return java.lang.Object * @name executeUpdate * @notice none - * @author 黄钰朝 - * @date 2019/4/9 */ int executeUpdate(String sql, Object[] params); @@ -63,8 +44,6 @@ public interface SQLRunner { * @return int 执行sql语句后影响记录的行数 * @name executeUpdate * @notice 必须传入一个SqlMapper的实现类用于映射预编译语句 - * @author 黄钰朝 - * @date 2019/4/9 * @see SQLMapper */ int executeUpdate(Object obj, SQLMapper sqlMapper); @@ -76,8 +55,6 @@ public interface SQLRunner { * @return int 更新的数据库记录数 * @name insert * @notice none - * @author 黄钰朝 - * @date 2019/4/9 */ @Insert() int insert(Object obj, String table); @@ -90,8 +67,6 @@ public interface SQLRunner { * @name update * @notice 请注意此方法默认更新该对象中所有不为null的属性到数据库
* 如果不希望更新某些字段,请将其设置为null - * @author 黄钰朝 - * @date 2019/4/10 */ int update(Object obj, String table); @@ -102,8 +77,6 @@ public interface SQLRunner { * @return int * @name delete * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ int delete(Object id, String table); @@ -125,8 +98,6 @@ public interface SQLRunner { * @return java.lang.Object * @name executeQuery * @notice none - * @author 黄钰朝 - * @date 2019/4/9 */ Object executeQuery(String sql, Object[] params, ResultMapper mapper); @@ -145,8 +116,6 @@ public interface SQLRunner { * @return java.util.LinkedList * @name queryList * @notice none - * @author 黄钰朝 - * @date 2019/4/10 */ LinkedList queryList(String sql, Object[] params, Class clazz); @@ -160,8 +129,6 @@ public interface SQLRunner { * @return Object * @name queryList * @notice 如果查询结果为空,则返回null - * @author 黄钰朝 - * @date 2019/4/10 */ Object queryObject(String sql, Object[] params, Class clazz); @@ -173,8 +140,6 @@ public interface SQLRunner { * @return 查询的字段值 * @name queryValue * @notice 如果查询结果为空,则返回null - * @author 黄钰朝 - * @date 2019/4/11 */ Object queryValue(String sql, Object[] params); @@ -201,8 +166,6 @@ public interface SQLRunner { * @return java.util.LinkedList * @name queryOrderBy * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ LinkedList queryOrderBy(String[] selectFields, String orderBy, boolean isDesc, String tableName); @@ -234,8 +197,6 @@ public interface SQLRunner { * @return java.util.LinkedList * @name queryWhere * @notice 连接词不能为not - * @author 黄钰朝 - * @date 2019/4/13 */ LinkedList queryWhere(String[] selectFields, Object obj, String conj, String condition); @@ -251,8 +212,6 @@ public interface SQLRunner { * @return java.util.LinkedList * @name queryWhereAndEquals * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ LinkedList queryWhereAndEquals(String[] selectFields, Object obj); @@ -269,8 +228,6 @@ public interface SQLRunner { * @return java.util.LinkedList * @name queryWhereLikeAnd * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ LinkedList queryWhereLikeAnd(String[] selectFields, Object obj); @@ -286,8 +243,6 @@ public interface SQLRunner { * @return java.util.LinkedList * @name queryWhereLikeAnd * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ LinkedList queryWhereLikeOr(String[] selectFields, Object obj); @@ -307,8 +262,6 @@ public interface SQLRunner { * @return java.util.LinkedList * @name queryPages * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ LinkedList queryPages(String[] selectFields, String tableName, String limit, String offset); @@ -326,8 +279,6 @@ public interface SQLRunner { * @param fieldValues 将映射的属性值返回在这个集合中 * @name fieldMapper * @notice 只映射该对象中值不为null的属性 - * @author 黄钰朝 - * @date 2019/4/9 */ void fieldMapper(Object obj, LinkedList fieldNames, LinkedList fieldValues); @@ -339,8 +290,6 @@ public interface SQLRunner { * @return java.lang.String * @name selectMapper * @notice 请注意本方法产生的语句不带有预编译参数 - * @author 黄钰朝 - * @date 2019/4/13 */ String selectMapper(String tableName, Object[] selectFields); @@ -352,8 +301,6 @@ public interface SQLRunner { * @return java.lang.String 返回映射之后的预编译where语句,如where id = ? and user_name = ? * @name whereMapper * @notice 请注意此语句只用于追加where语句,不能单独用来查询 - * @author 黄钰朝 - * @date 2019/4/13 */ String whereMapper(Object[] whereFields, String conj, String condition); @@ -365,8 +312,6 @@ public interface SQLRunner { * @return java.lang.String 返回映射之后的预编译where语句,如where id like ? and user_name like ? * @name likeMapper * @notice 请注意此语句只用于追加where语句,不能单独用来查询 - * @author 黄钰朝 - * @date 2019/4/13 */ String likeMapper(Object[] likeFields, String conj); @@ -378,8 +323,6 @@ public interface SQLRunner { * @return java.lang.String * @name orderByMapper * @notice 请注意此语句只用于追加where语句,不能单独用来查询 - * @author 黄钰朝 - * @date 2019/4/13 */ String orderByMapper(String orderBy, boolean isDesc); @@ -391,8 +334,6 @@ public interface SQLRunner { * @return java.lang.String * @name pageMapper * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ String pageMapper(String limit, String offset); @@ -405,8 +346,6 @@ public interface SQLRunner { * @return java.lang.String * @name pageMapper * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ String pageOffsetMapper(String offset); diff --git a/wechat-master/src/com/hyc/wechat/dao/UserDao.java b/wechat-master/src/com/hyc/wechat/dao/UserDao.java index 7cb137d..79ac649 100644 --- a/wechat-master/src/com/hyc/wechat/dao/UserDao.java +++ b/wechat-master/src/com/hyc/wechat/dao/UserDao.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao; import com.hyc.wechat.dao.annotation.Query; @@ -24,10 +9,8 @@ import com.hyc.wechat.model.po.User; import java.util.List; /** - * @author 黄钰朝 * @program wechat * @description 负责User类CRUD - * @date 2019-05-01 23:39 */ public interface UserDao extends BaseDao { String TABLE = "user"; @@ -42,8 +25,6 @@ public interface UserDao extends BaseDao { * @return 用户对象 * @name getUserById * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = User.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where id = ? ") @@ -57,8 +38,6 @@ public interface UserDao extends BaseDao { * @return 用户对象 * @name getUserByEmail * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = User.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where email = ? ") @@ -72,8 +51,6 @@ public interface UserDao extends BaseDao { * @return 用户对象 * @name getUserByWechatId * @notice none - * @author 黄钰朝 - * @date 2019/5/2 */ @Result(entity = User.class, returns = ResultType.OBJECT) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where wechat_id = ? ") @@ -84,8 +61,6 @@ public interface UserDao extends BaseDao { * @return * @name listByName * @notice none - * @author 黄钰朝 - * @date 2019/5/5 */ @Result(entity = User.class, returns = ResultType.LIST) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where name = ?") @@ -99,8 +74,6 @@ public interface UserDao extends BaseDao { * @return * @name listLike * @notice 注意本方法本身不带有模糊查询功能,必须在传入参数中带有模糊条件 - * @author 黄钰朝 - * @date 2019/5/6 */ @Result(entity = User.class, returns = ResultType.LIST) @Query(value = "select " + ALL_FIELD + " from " + TABLE + " where name like ? ") diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Delete.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Delete.java index 1737077..5ef3c56 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Delete.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Delete.java @@ -1,32 +1,25 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; import java.lang.annotation.*; /** - * @author 黄钰朝 * @program wechat * @description 用于注解删除语句 - * @date 2019-05-01 13:32 */ @Documented + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface Delete { + /** + * 定义一个value属性,默认值为空字符串。 + * 该属性用于指定删除操作的SQL语句或标识符。 + * 当注解被应用于方法上时,可以通过这个属性来传递具体的删除逻辑。 + * @return 返回删除操作的SQL语句或标识符。 + */ String value()default ""; } diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Field.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Field.java index 7a8a4f1..805f2d0 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Field.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Field.java @@ -1,32 +1,19 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; import java.lang.annotation.*; /** - * @author 黄钰朝 * @description 用于注解SQL语句的返回结果类型 * @program wechat - * @date 2019-05-01 13:32 */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) public @interface Field { + /* 定义一个name属性,用于指定实体类字段对应的数据库表的列名。 + * 当注解被应用于字段上时,可以通过这个属性来指定映射关系。 + * @return 返回数据库表的列名。 + */ String name (); } diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Insert.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Insert.java index 9390c38..8e606e0 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Insert.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Insert.java @@ -1,32 +1,22 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; import java.lang.annotation.*; /** - * @author 黄钰朝 * @program wechat * @description 用于注解插入语句 - * @date 2019-05-01 13:32 */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) + public @interface Insert { + /** + * 定义一个value属性,默认值为空字符串。 + * 该属性用于指定插入操作的SQL语句或标识符。 + * 当注解被应用于方法上时,可以通过这个属性来传递具体的插入逻辑。 + * @return 返回插入操作的SQL语句或标识符。 + */ String value()default ""; } diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Param.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Param.java index 8fae49c..8c3d6b0 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Param.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Param.java @@ -1,28 +1,11 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; import java.lang.annotation.*; /** - * @author 黄钰朝 * @description 用于注解SQL语句的返回结果类型 * @program wechat - * @date 2019-05-01 13:32 */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Query.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Query.java index 4fb40d2..cc73c17 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Query.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Query.java @@ -1,28 +1,11 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; import java.lang.annotation.*; /** - * @author 黄钰朝 * @program wechat * @description 用于注解查询语句 - * @date 2019-05-01 13:32 */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Result.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Result.java index c251659..f5a6b74 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Result.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Result.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; @@ -21,10 +6,8 @@ import com.hyc.wechat.model.po.abs.BaseEntity; import java.lang.annotation.*; /** - * @author 黄钰朝 * @description 用于注解SQL语句的返回结果类型 * @program wechat - * @date 2019-05-01 13:32 */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/ResultType.java b/wechat-master/src/com/hyc/wechat/dao/annotation/ResultType.java index c10cfc8..7f79cfd 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/ResultType.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/ResultType.java @@ -1,26 +1,9 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; /** - * @author 黄钰朝 * @program wechat * @description 用于枚举SQL语句返回值类型 - * @date 2019-05-01 21:21 */ public enum ResultType{ /** diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Table.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Table.java index 5ae7ebf..f3695eb 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Table.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Table.java @@ -1,29 +1,12 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; import java.lang.annotation.*; /** - * @author 黄钰朝 * @program wechat * @description 用于注解表名 - * @date 2019-05-01 00:19 */ @Documented @Retention(value = RetentionPolicy.RUNTIME) diff --git a/wechat-master/src/com/hyc/wechat/dao/annotation/Update.java b/wechat-master/src/com/hyc/wechat/dao/annotation/Update.java index 5a60d40..71bf04f 100644 --- a/wechat-master/src/com/hyc/wechat/dao/annotation/Update.java +++ b/wechat-master/src/com/hyc/wechat/dao/annotation/Update.java @@ -1,28 +1,11 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.annotation; import java.lang.annotation.*; /** - * @author 黄钰朝 * @description 用于注解更新语句 * @program wechat - * @date 2019-05-01 13:32 */ @Documented @Retention(RetentionPolicy.RUNTIME) diff --git a/wechat-master/src/com/hyc/wechat/dao/impl/DataSourceImpl.java b/wechat-master/src/com/hyc/wechat/dao/impl/DataSourceImpl.java index 3ac9143..0a74d04 100644 --- a/wechat-master/src/com/hyc/wechat/dao/impl/DataSourceImpl.java +++ b/wechat-master/src/com/hyc/wechat/dao/impl/DataSourceImpl.java @@ -1,19 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.impl; import com.hyc.wechat.dao.DataSource; @@ -30,10 +14,8 @@ import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; /** - * @author 黄钰朝 * @program wechat * @description 负责向Dao层提供数据库连接 - * @date 2019-05-01 16:40 */ public class DataSourceImpl implements DataSource { /* @@ -151,8 +133,6 @@ public class DataSourceImpl implements DataSource { * @throws DaoException 如果数据库连接已经达到最大值时仍然调用此方法,则抛出此异常 * @name getConnection * @notice 数据库连接的数量受到配置文件中最大值的限制 - * @author 黄钰朝 - * @date 2019/5/1 */ @Override public Connection getConnection() throws DaoException { @@ -189,8 +169,6 @@ public class DataSourceImpl implements DataSource { * * @param conn 数据库连接 * @name freeConnection - * @author 黄钰朝 - * @date 2019/5/1 */ @Override public void freeConnection(Connection conn) { @@ -202,8 +180,6 @@ public class DataSourceImpl implements DataSource { * * @return java.sql.Connection * @name createConnection - * @author 黄钰朝 - * @date 2019/5/1 */ @Override public void destroyConnection(Connection conn) { @@ -221,8 +197,6 @@ public class DataSourceImpl implements DataSource { * * @return int 当前已经创建的连接数 * @name getCurrentCount - * @author 黄钰朝 - * @date 2019/5/1 */ @Override public int getCurrentCount() { @@ -234,8 +208,6 @@ public class DataSourceImpl implements DataSource { * * @return int 当前空闲连接数 * @name getfreeCount - * @author 黄钰朝 - * @date 2019/5/1 */ @Override public int getfreeCount() { @@ -254,8 +226,6 @@ public class DataSourceImpl implements DataSource { * * @return java.sql.Connection * @name createConnection - * @author 黄钰朝 - * @date 2019/5/1 */ private Connection createConnection() throws DaoException { currentCount++; diff --git a/wechat-master/src/com/hyc/wechat/dao/impl/SQLRunnerImpl.java b/wechat-master/src/com/hyc/wechat/dao/impl/SQLRunnerImpl.java index c615749..c791e36 100644 --- a/wechat-master/src/com/hyc/wechat/dao/impl/SQLRunnerImpl.java +++ b/wechat-master/src/com/hyc/wechat/dao/impl/SQLRunnerImpl.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.dao.impl; @@ -34,10 +19,8 @@ import static com.hyc.wechat.util.ReflectUtils.getMethods; import static com.hyc.wechat.util.StringUtils.field2SqlField; /** - * @author 黄钰朝 * @program wechat * @description 负责执行sql语句 - * @date 2019-05-01 17:34 */ public class SQLRunnerImpl implements SQLRunner { @@ -56,8 +39,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.Object * @name executeUpdate * @notice none - * @author 黄钰朝 - * @date 2019/4/9 */ @Override public int executeUpdate(String sql, Object[] params) { @@ -92,8 +73,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return int 执行sql语句后影响记录的行数 * @name executeUpdate * @notice 必须传入一个SqlMapper的实现类用于映射预编译语句 - * @author 黄钰朝 - * @date 2019/4/9 * @see SQLMapper */ @Override @@ -149,8 +128,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return int 更新的数据库记录数 * @name insert * @notice none - * @author 黄钰朝 - * @date 2019/4/9 */ @Override public int insert(Object obj, String table) { @@ -185,8 +162,6 @@ public class SQLRunnerImpl implements SQLRunner { * @name update * @notice 请注意此方法默认更新该对象中所有不为null的属性到数据库
* 如果不希望更新某些字段,请将其设置为null - * @author 黄钰朝 - * @date 2019/4/10 */ @Override public int update(Object obj, String table) { @@ -230,8 +205,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return int * @name delete * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public int delete(Object obj, String table) { @@ -265,8 +238,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.Object * @name executeQuery * @notice none - * @author 黄钰朝 - * @date 2019/4/9 */ @Override public Object executeQuery(String sql, Object[] params, ResultMapper mapper) { @@ -320,9 +291,7 @@ public class SQLRunnerImpl implements SQLRunner { * @param clazz 用于映射结果集的实体类 * @return java.util.LinkedList * @name queryList - * @notice none - * @author 黄钰朝 - * @date 2019/4/10 + * @notice non */ @Override public LinkedList queryList(String sql, Object[] params, Class clazz) { @@ -333,10 +302,8 @@ public class SQLRunnerImpl implements SQLRunner { * ResultMapper的一个实现类,提供将结果集映射为一个List的方法
* 此类的对象在使用前必须设置一个用于映射结果的实体类 * - * @author 黄钰朝 * @name ListMapper * @notice 如果查询结果为空,则返回一个空集合 - * @date 2019/4/10 * @see com.hyc.www.dao.inter.ResultMapper */ LinkedList list = new LinkedList<>(); @@ -399,8 +366,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return Object * @name queryList * @notice 如果查询结果为空,则返回null - * @author 黄钰朝 - * @date 2019/4/10 */ @Override public Object queryObject(String sql, Object[] params, Class clazz) { @@ -416,8 +381,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return 查询的字段值 * @name queryValue * @notice 如果查询结果为空,则返回null - * @author 黄钰朝 - * @date 2019/4/11 */ @Override public Object queryValue(String sql, Object[] params) { @@ -461,8 +424,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.util.LinkedList * @name queryOrderBy * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public LinkedList queryOrderBy(String[] selectFields, String orderBy, boolean isDesc, String tableName) { @@ -504,8 +465,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.util.LinkedList * @name queryWhere * @notice 连接词不能为not - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public LinkedList queryWhere(String[] selectFields, Object obj, String conj, String condition) { @@ -548,8 +507,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.util.LinkedList * @name queryWhereAndEquals * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public LinkedList queryWhereAndEquals(String[] selectFields, Object obj) { @@ -569,8 +526,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.util.LinkedList * @name queryWhereLikeAnd * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public LinkedList queryWhereLikeAnd(String[] selectFields, Object obj) { @@ -589,8 +544,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.util.LinkedList * @name queryWhereLikeAnd * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public LinkedList queryWhereLikeOr(String[] selectFields, Object obj) { @@ -613,8 +566,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.util.LinkedList * @name queryPages * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public LinkedList queryPages(String[] selectFields, String tableName, String limit, String offset) { @@ -637,8 +588,6 @@ public class SQLRunnerImpl implements SQLRunner { * @param fieldValues 将映射的属性值返回在这个集合中 * @name fieldMapper * @notice 只映射该对象中值不为null的属性 - * @author 黄钰朝 - * @date 2019/4/9 */ @Override public void fieldMapper(Object obj, LinkedList fieldNames, LinkedList fieldValues) { @@ -688,8 +637,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.String * @name selectMapper * @notice 请注意本方法产生的语句不带有预编译参数 - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public String selectMapper(String tableName, Object[] selectFields) { @@ -710,8 +657,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.String 返回映射之后的预编译where语句,如where id = ? and user_name = ? * @name whereMapper * @notice 请注意此语句只用于追加where语句,不能单独用来查询 - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public String whereMapper(Object[] whereFields, String conj, String condition) { @@ -737,8 +682,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.String 返回映射之后的预编译where语句,如where id like ? and user_name like ? * @name likeMapper * @notice 请注意此语句只用于追加where语句,不能单独用来查询 - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public String likeMapper(Object[] likeFields, String conj) { @@ -763,8 +706,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.String * @name orderByMapper * @notice 请注意此语句只用于追加where语句,不能单独用来查询 - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public String orderByMapper(String orderBy, boolean isDesc) { @@ -792,8 +733,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.String * @name pageMapper * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public String pageMapper(String limit, String offset) { @@ -809,8 +748,6 @@ public class SQLRunnerImpl implements SQLRunner { * @return java.lang.String * @name pageMapper * @notice none - * @author 黄钰朝 - * @date 2019/4/13 */ @Override public String pageOffsetMapper(String offset) { diff --git a/wechat-master/src/com/hyc/wechat/exception/DaoException.java b/wechat-master/src/com/hyc/wechat/exception/DaoException.java index 8adfb85..d3d5e06 100644 --- a/wechat-master/src/com/hyc/wechat/exception/DaoException.java +++ b/wechat-master/src/com/hyc/wechat/exception/DaoException.java @@ -1,44 +1,51 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.exception; /** - * @author 黄钰朝 * @program wechat * @description 用于包装Dao层的异常 - * @date 2019-05-01 16:36 */ public class DaoException extends RuntimeException{ + /** + * 无参构造方法,调用父类的无参构造方法。 + * 创建一个没有详细消息的DaoException。 + */ public DaoException() { super(); } - + /** + * 带有详细消息的构造方法,调用父类的带消息的构造方法。 + * 创建一个带有详细消息的DaoException。 + * @param message 异常的详细描述信息 + */ public DaoException(String message) { super(message); } - + /** + * 带有详细消息和原因的构造方法,调用父类的带消息和原因的构造方法。 + * 创建一个带有详细消息和原因的DaoException。 + * @param message 异常的详细描述信息 + * @param cause 异常的原因,通常是另一个异常 + */ public DaoException(String message, Throwable cause) { super(message, cause); } - + /** + * 带有原因的构造方法,调用父类的带原因的构造方法。 + * 创建一个带有原因的DaoException。 + * @param cause 异常的原因,通常是另一个异常 + */ public DaoException(Throwable cause) { super(cause); } - + /** + * 带有详细消息、原因、抑制状态和可写堆栈跟踪的构造方法,调用父类的对应构造方法。 + * 创建一个带有详细消息、原因、抑制状态和可写堆栈跟踪的DaoException。 + * @param message 异常的详细描述信息 + * @param cause 异常的原因,通常是另一个异常 + * @param enableSuppression 是否启用抑制功能 + * @param writableStackTrace 是否生成堆栈跟踪信息 + */ protected DaoException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } diff --git a/wechat-master/src/com/hyc/wechat/exception/ServiceException.java b/wechat-master/src/com/hyc/wechat/exception/ServiceException.java index cb5a74d..79df3f2 100644 --- a/wechat-master/src/com/hyc/wechat/exception/ServiceException.java +++ b/wechat-master/src/com/hyc/wechat/exception/ServiceException.java @@ -1,44 +1,52 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.exception; /** - * @author 黄钰朝 * @program wechat * @description service层异常类 - * @date 2019-05-01 17:41 */ public class ServiceException extends RuntimeException{ + /** + * 无参构造方法,调用父类的无参构造方法。 + * 创建一个没有详细消息的ServiceException。 + */ public ServiceException() { super(); } - + /** + * 带有详细消息的构造方法,调用父类的带消息的构造方法。 + * 创建一个带有详细消息的ServiceException。 + * @param message 异常的详细描述信息 + */ public ServiceException(String message) { super(message); } - + /** + * 带有详细消息和原因的构造方法,调用父类的带消息和原因的构造方法。 + * 创建一个带有详细消息和原因的ServiceException。 + * @param message 异常的详细描述信息 + * @param cause 异常的原因,通常是另一个异常 + */ public ServiceException(String message, Throwable cause) { super(message, cause); } - + /** + * 带有原因的构造方法,调用父类的带原因的构造方法。 + * 创建一个带有原因的ServiceException。 + * @param cause 异常的原因,通常是另一个异常 + */ public ServiceException(Throwable cause) { super(cause); } - + /** + * 带有详细消息、原因、抑制状态和可写堆栈跟踪的构造方法,调用父类的对应构造方法。 + * 创建一个带有详细消息、原因、抑制状态和可写堆栈跟踪的ServiceException。 + * 这个构造方法是受保护的,通常用于异常类的子类化。 + * @param message 异常的详细描述信息 + * @param cause 异常的原因,通常是另一个异常 + * @param enableSuppression 是否启用抑制功能 + * @param writableStackTrace 是否生成堆栈跟踪信息 + */ protected ServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } diff --git a/wechat-master/src/com/hyc/wechat/factory/DaoProxyFactory.java b/wechat-master/src/com/hyc/wechat/factory/DaoProxyFactory.java index 326455f..713348a 100644 --- a/wechat-master/src/com/hyc/wechat/factory/DaoProxyFactory.java +++ b/wechat-master/src/com/hyc/wechat/factory/DaoProxyFactory.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.factory; @@ -25,16 +10,18 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; /** - * @author 黄钰朝 * @program wechat * @description 用于解析Dao接口中的sql语句,并执行 - * @date 2019-05-01 11:01 */ public class DaoProxyFactory implements InvocationHandler { private static SQLRunner executor = new SQLRunnerImpl(); private static DaoProxyFactory instance= new DaoProxyFactory(); - + /** + * 获取代理实例的方法,使用Java Proxy API创建一个代理对象。 + * @param interfaces DAO接口的Class对象 + * @return 返回一个实现了指定接口的代理对象 + */ public Object getProxyInstance(Class interfaces) { return Proxy.newProxyInstance(interfaces.getClassLoader(), new Class[]{interfaces}, this); } @@ -42,11 +29,21 @@ public class DaoProxyFactory implements InvocationHandler { private DaoProxyFactory() { } - + /** + * 获取DaoProxyFactory的单例实例。 + * @return 返回DaoProxyFactory的单例实例 + */ public static DaoProxyFactory getInstance(){ return instance; } - + /** + * 实现InvocationHandler接口的invoke方法,用于处理代理对象的方法调用。 + * @param proxy 代理对象 + * @param method 被调用的方法 + * @param args 调用方法时的参数 + * @return 返回方法调用的结果 + * @throws Throwable 如果执行过程中发生异常,则抛出 + */ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getAnnotation(Insert.class) != null) { @@ -77,17 +74,22 @@ public class DaoProxyFactory implements InvocationHandler { } } if (method.getAnnotation(Query.class) != null) { + // 获取@Result注解指定的返回类型 ResultType type = method.getAnnotation(Result.class).returns(); switch (type) { case OBJECT: + // 执行查询并返回单个对象 return executor.queryObject(method.getAnnotation(Query.class).value(), args, method.getAnnotation(Result.class).entity()); case LIST: + // 执行查询并返回对象列表 return executor.queryList(method.getAnnotation(Query.class).value(), args, method.getAnnotation(Result.class).entity()); case VALUE: + // 执行查询并返回单个值 return executor.queryValue(method.getAnnotation(Query.class).value(), args); default: } } + // 如果方法没有注解,则直接调用原始方法 return method.invoke(proxy, args); } diff --git a/wechat-master/src/com/hyc/wechat/factory/ServiceProxyFactory.java b/wechat-master/src/com/hyc/wechat/factory/ServiceProxyFactory.java index 454bf4a..d062e6a 100644 --- a/wechat-master/src/com/hyc/wechat/factory/ServiceProxyFactory.java +++ b/wechat-master/src/com/hyc/wechat/factory/ServiceProxyFactory.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.factory; import java.lang.reflect.InvocationHandler; @@ -21,31 +6,47 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; /** - * @author 黄钰朝 * @program wechat * @description 用于解析Dao接口中的sql语句,并执行 - * @date 2019-05-01 11:01 */ public class ServiceProxyFactory implements InvocationHandler { private Object target; - + /** + * 获取代理实例的方法,使用Java Proxy API创建一个代理对象。 + * @param target 被代理的目标对象 + * @return 返回一个实现了目标对象接口的代理对象 + */ public Object getProxyInstance(Object target) { this.target =target; + // 创建代理对象,该代理对象实现了目标对象的所有接口 return Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), this); } - + /** + * 实现InvocationHandler接口的invoke方法,用于处理代理对象的方法调用。 + * @param proxy 代理对象 + * @param method 被调用的方法 + * @param args 调用方法时的参数 + * @return 返回方法调用的结果 + * @throws Throwable 如果执行过程中发生异常,则抛出 + */ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return method.invoke(target, args); } - + /** + * 获取被代理的目标对象。 + * @return 返回被代理的目标对象 + */ public Object getTarget() { return target; } - + /** + * 设置被代理的目标对象。 + * @param target 被代理的目标对象 + */ public void setTarget(Object target) { this.target = target; } diff --git a/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java b/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java index 16511a5..007dc6c 100644 --- a/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java +++ b/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.factory.proxy; import com.hyc.wechat.dao.DataSource; @@ -26,16 +11,18 @@ import java.lang.reflect.Proxy; import java.sql.Connection; /** - * @author 黄钰朝 * @program wechat * @description 用于代理数据库连接对象 - * @date 2019-05-01 17:52 */ public class ConnectionProxy implements InvocationHandler { private Connection target; private DataSource dataSource; - + /** + * 获取代理实例的方法。 + * @param target 被代理的Connection对象 + * @return 返回一个Connection类型的代理实例 + */ public Connection getProxyInstance(Connection target){ this.target= target; return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),new Class[]{Connection.class},this); @@ -44,7 +31,13 @@ public class ConnectionProxy implements InvocationHandler { public ConnectionProxy(DataSource dataSource) { this.dataSource = dataSource; } - + /** + * 实现InvocationHandler接口的invoke方法,用于处理代理实例上的方法调用。 + * @param proxy 代理实例 + * @param method 被调用的方法 + * @param args 调用方法时传入的参数 + * @return 返回方法调用的结果 + */ @Override public Object invoke(Object proxy, Method method, Object[] args) { if ("close".equals(method.getName())) { @@ -58,7 +51,7 @@ public class ConnectionProxy implements InvocationHandler { throw new DaoException("无法调用目标对象的方法", e); } } - + // 以下是getter和setter方法,用于访问和修改target和dataSource属性 public Connection getTarget() { return target; } diff --git a/wechat-master/src/com/hyc/wechat/model/builder/MessageVOBuilder.java b/wechat-master/src/com/hyc/wechat/model/builder/MessageVOBuilder.java index 575fb5d..d58cd5c 100644 --- a/wechat-master/src/com/hyc/wechat/model/builder/MessageVOBuilder.java +++ b/wechat-master/src/com/hyc/wechat/model/builder/MessageVOBuilder.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.model.builder; import com.hyc.wechat.model.vo.MessageVO; @@ -22,49 +7,91 @@ import java.math.BigInteger; import java.sql.Timestamp; /** - * @author 黄钰朝 * @description 负责MessageVO的建造 - * @date 2019-05-07 14:58 */ public class MessageVOBuilder { private MessageVO messageVo; - + /** + * 构造函数,初始化MessageVO对象。 + */ public MessageVOBuilder() { this.messageVo = new MessageVO(); } - + /** + * 构建并返回MessageVO对象。 + * @return 构建好的MessageVO对象。 + */ public MessageVO build(){ return this.messageVo; } - + /** + * 设置消息发送者的名称。 + * @param senderName 发送者的名称。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setSenderName(String senderName) { this.messageVo.setSenderName(senderName); return this; } + /** + * 设置消息发送者的ID。 + * @param senderId 发送者的ID。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setSenderId(BigInteger senderId){ this.messageVo.setSenderId(senderId); return this; } + /** + * 设置消息发送者的头像URL。 + * @param senderPhoto 发送者头像的URL。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setSenderPhoto(String senderPhoto){ this.messageVo.setSenderPhoto(senderPhoto); return this; } + /** + * 设置消息所属的聊天ID。 + * @param chatId 聊天ID。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setChatId(BigInteger chatId){ this.messageVo.setChatId(chatId); return this; } + /** + * 设置消息内容。 + * @param content 消息内容。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setContent(String content){ this.messageVo.setContent(content); return this; } + /** + * 设置消息发送的时间。 + * @param time 发送时间。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setTime(Timestamp time){ this.messageVo.setTime(time); return this; } + /** + * 设置消息的类型。 + * @param type 消息类型。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setType(String type){ this.messageVo.setType(type); return this; } + /** + * 设置消息的ID。 + * @param id 消息ID。 + * @return 当前MessageVOBuilder对象,便于链式调用。 + */ public MessageVOBuilder setId(BigInteger id){ this.messageVo.setId(id); return this; diff --git a/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java b/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java index d8c6b7a..b205be0 100644 --- a/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java +++ b/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.model.builder; @@ -22,9 +7,7 @@ import java.math.BigInteger; import java.sql.Timestamp; /** - * @author 黄钰朝 * @description 负责朋友圈视图层对象的建造 - * @date 2019-05-07 20:32 */ public class MomentVOBuilder { private MomentVO momentVO; diff --git a/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java b/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java index a3092ac..22fe7e5 100644 --- a/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java +++ b/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java @@ -1,28 +1,11 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.model.dto; import com.hyc.wechat.service.constants.Status; /** - * @author 黄钰朝 * @program wechat * @description 用于service层返回处理结果 - * @date 2019-05-02 03:01 */ public class ServiceResult { /** diff --git a/wechat-master/src/com/hyc/wechat/model/po/Chat.java b/wechat-master/src/com/hyc/wechat/model/po/Chat.java index b483b75..2983521 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/Chat.java +++ b/wechat-master/src/com/hyc/wechat/model/po/Chat.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.model.po; import com.alibaba.fastjson.annotation.JSONField; @@ -23,9 +8,7 @@ import com.hyc.wechat.model.po.abs.BaseEntity; import java.math.BigInteger; /** - * @author 黄钰朝 * @description 对应数据库chat表 - * @date 2019-05-03 01:38 */ @Table(name = "chat") public class Chat extends BaseEntity { diff --git a/wechat-master/src/com/hyc/wechat/model/po/Friend.java b/wechat-master/src/com/hyc/wechat/model/po/Friend.java index 827f728..54a16a1 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/Friend.java +++ b/wechat-master/src/com/hyc/wechat/model/po/Friend.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.model.po; import com.alibaba.fastjson.annotation.JSONField; @@ -23,10 +8,8 @@ import com.hyc.wechat.model.po.abs.BaseEntity; import java.math.BigInteger; /** - * @author 黄钰朝 * @program wechat * @description 朋友表 - * @date 2019-05-02 01:56 */ @Table(name = "friend") public class Friend extends BaseEntity { diff --git a/wechat-master/src/com/hyc/wechat/model/po/Member.java b/wechat-master/src/com/hyc/wechat/model/po/Member.java index c96ca03..26321ae 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/Member.java +++ b/wechat-master/src/com/hyc/wechat/model/po/Member.java @@ -1,19 +1,4 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.model.po; import com.alibaba.fastjson.annotation.JSONField; @@ -23,9 +8,7 @@ import com.hyc.wechat.model.po.abs.BaseEntity; import java.math.BigInteger; /** - * @author 黄钰朝 * @description 用户和群聊的中间表 - * @date 2019-05-03 12:58 */ @Table(name = "member") public class Member extends BaseEntity { diff --git a/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java b/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java index 86aa318..28ee233 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java +++ b/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2019. 黄钰朝 - * - * 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 - * - * http://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.hyc.wechat.model.po.abs; @@ -23,10 +8,8 @@ import java.math.BigInteger; import java.util.Date; /** - * @author 黄钰朝 * @program wechat * @description 所有数据库记录的父类 - * @date 2019-05-01 23:19 */ public abstract class BaseEntity { @@ -77,8 +60,6 @@ public abstract class BaseEntity { * @return * @name toString * @notice none - * @author 黄钰朝 - * @date 2019/5/7 */ @Override public String toString() { diff --git a/wechat-master/web/static/css/index.css b/wechat-master/web/static/css/index.css index d2b43eb..97a13a5 100644 --- a/wechat-master/web/static/css/index.css +++ b/wechat-master/web/static/css/index.css @@ -1,4 +1,23 @@ - +/* +.page-body: +设置页面的最小宽度、高度、边距、边框圆角和溢出行为。 +.menu: +定义左侧菜单栏的宽度、位置、高度、浮动方向、背景色和显示类型。 +.menu-head, .menu-head-photo, .menu-head-img, .menu-head-info, .menu-head-nickname: +这些类用于设置菜单头部区域的布局、内边距、图片样式和昵称样式。 +.menu-search, .menu-search-icon, .menu-search-bar: +提供搜索框的样式,包括位置、宽度、高度、边框、背景色、字体颜色和内边距。 +.menu-option, .menu-option-item, .menu-option-chat: +定义菜单选项的布局和样式。 +.chat-box, .chat-box-head, .chat-box-title, .chat-box-title-box, .chat-box-title-text: +这些类用于设置聊天框的整体布局、标题样式和文本样式。 +.chat-input-box, .text-area: +定义聊天输入框的固定位置、高度、边框、背景色、字体大小和其他相关样式。 +.chat-output-box, .chat-output-head-photo-right, .chat-output-head-photo-left, .chat-output-content-right, .chat-output-content-left, .chat-output-meta-left, .chat-output-bubble-right, .chat-output-bubble-left, .chat-output-bubble-inner, .chat-output-bubble-pre-right, .chat-output-bubble-pre-left: +这些类用于设置聊天输出框的布局、头像位置、消息气泡的样式、文本的对齐方式、最大宽度和背景色。 +.user-photo, .my-photo, .user-list-block-href, .user-list-block, .user-info, .user-box, .my-name, .my-message: +这些类用于定义用户列表的样式,包括头像、用户名、消息预览的布局和样式。 +*/ .page-body { min-width: 800px; height: 100%; diff --git a/wechat-master/web/static/js/bootstrap.min.js b/wechat-master/web/static/js/bootstrap.min.js index c4c0d1f..a1f2a91 100644 --- a/wechat-master/web/static/js/bootstrap.min.js +++ b/wechat-master/web/static/js/bootstrap.min.js @@ -1,7 +1,3 @@ -/*! - * Bootstrap v4.3.1 (https://getbootstrap.com/) - * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - */ + !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jquery"),require("popper.js")):"function"==typeof define&&define.amd?define(["exports","jquery","popper.js"],e):e((t=t||self).bootstrap={},t.jQuery,t.Popper)}(this,function(t,g,u){"use strict";function i(t,e){for(var n=0;nthis._items.length-1||t<0))if(this._isSliding)g(this._element).one(Q.SLID,function(){return e.to(t)});else{if(n===t)return this.pause(),void this.cycle();var i=ndocument.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},t._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},t._checkScrollbar=function(){var t=document.body.getBoundingClientRect();this._isBodyOverflowing=t.left+t.right
',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:0,container:!1,fallbackPlacement:"flip",boundary:"scrollParent",sanitize:!0,sanitizeFn:null,whiteList:Ee},je="show",He="out",Re={HIDE:"hide"+De,HIDDEN:"hidden"+De,SHOW:"show"+De,SHOWN:"shown"+De,INSERTED:"inserted"+De,CLICK:"click"+De,FOCUSIN:"focusin"+De,FOCUSOUT:"focusout"+De,MOUSEENTER:"mouseenter"+De,MOUSELEAVE:"mouseleave"+De},xe="fade",Fe="show",Ue=".tooltip-inner",We=".arrow",qe="hover",Me="focus",Ke="click",Qe="manual",Be=function(){function i(t,e){if("undefined"==typeof u)throw new TypeError("Bootstrap's tooltips require Popper.js (https://popper.js.org/)");this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}var t=i.prototype;return t.enable=function(){this._isEnabled=!0},t.disable=function(){this._isEnabled=!1},t.toggleEnabled=function(){this._isEnabled=!this._isEnabled},t.toggle=function(t){if(this._isEnabled)if(t){var e=this.constructor.DATA_KEY,n=g(t.currentTarget).data(e);n||(n=new this.constructor(t.currentTarget,this._getDelegateConfig()),g(t.currentTarget).data(e,n)),n._activeTrigger.click=!n._activeTrigger.click,n._isWithActiveTrigger()?n._enter(null,n):n._leave(null,n)}else{if(g(this.getTipElement()).hasClass(Fe))return void this._leave(null,this);this._enter(null,this)}},t.dispose=function(){clearTimeout(this._timeout),g.removeData(this.element,this.constructor.DATA_KEY),g(this.element).off(this.constructor.EVENT_KEY),g(this.element).closest(".modal").off("hide.bs.modal"),this.tip&&g(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,(this._activeTrigger=null)!==this._popper&&this._popper.destroy(),this._popper=null,this.element=null,this.config=null,this.tip=null},t.show=function(){var e=this;if("none"===g(this.element).css("display"))throw new Error("Please use show on visible elements");var t=g.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){g(this.element).trigger(t);var n=_.findShadowRoot(this.element),i=g.contains(null!==n?n:this.element.ownerDocument.documentElement,this.element);if(t.isDefaultPrevented()||!i)return;var o=this.getTipElement(),r=_.getUID(this.constructor.NAME);o.setAttribute("id",r),this.element.setAttribute("aria-describedby",r),this.setContent(),this.config.animation&&g(o).addClass(xe);var s="function"==typeof this.config.placement?this.config.placement.call(this,o,this.element):this.config.placement,a=this._getAttachment(s);this.addAttachmentClass(a);var l=this._getContainer();g(o).data(this.constructor.DATA_KEY,this),g.contains(this.element.ownerDocument.documentElement,this.tip)||g(o).appendTo(l),g(this.element).trigger(this.constructor.Event.INSERTED),this._popper=new u(this.element,o,{placement:a,modifiers:{offset:this._getOffset(),flip:{behavior:this.config.fallbackPlacement},arrow:{element:We},preventOverflow:{boundariesElement:this.config.boundary}},onCreate:function(t){t.originalPlacement!==t.placement&&e._handlePopperPlacementChange(t)},onUpdate:function(t){return e._handlePopperPlacementChange(t)}}),g(o).addClass(Fe),"ontouchstart"in document.documentElement&&g(document.body).children().on("mouseover",null,g.noop);var c=function(){e.config.animation&&e._fixTransition();var t=e._hoverState;e._hoverState=null,g(e.element).trigger(e.constructor.Event.SHOWN),t===He&&e._leave(null,e)};if(g(this.tip).hasClass(xe)){var h=_.getTransitionDurationFromElement(this.tip);g(this.tip).one(_.TRANSITION_END,c).emulateTransitionEnd(h)}else c()}},t.hide=function(t){var e=this,n=this.getTipElement(),i=g.Event(this.constructor.Event.HIDE),o=function(){e._hoverState!==je&&n.parentNode&&n.parentNode.removeChild(n),e._cleanTipClass(),e.element.removeAttribute("aria-describedby"),g(e.element).trigger(e.constructor.Event.HIDDEN),null!==e._popper&&e._popper.destroy(),t&&t()};if(g(this.element).trigger(i),!i.isDefaultPrevented()){if(g(n).removeClass(Fe),"ontouchstart"in document.documentElement&&g(document.body).children().off("mouseover",null,g.noop),this._activeTrigger[Ke]=!1,this._activeTrigger[Me]=!1,this._activeTrigger[qe]=!1,g(this.tip).hasClass(xe)){var r=_.getTransitionDurationFromElement(n);g(n).one(_.TRANSITION_END,o).emulateTransitionEnd(r)}else o();this._hoverState=""}},t.update=function(){null!==this._popper&&this._popper.scheduleUpdate()},t.isWithContent=function(){return Boolean(this.getTitle())},t.addAttachmentClass=function(t){g(this.getTipElement()).addClass(Ae+"-"+t)},t.getTipElement=function(){return this.tip=this.tip||g(this.config.template)[0],this.tip},t.setContent=function(){var t=this.getTipElement();this.setElementContent(g(t.querySelectorAll(Ue)),this.getTitle()),g(t).removeClass(xe+" "+Fe)},t.setElementContent=function(t,e){"object"!=typeof e||!e.nodeType&&!e.jquery?this.config.html?(this.config.sanitize&&(e=Se(e,this.config.whiteList,this.config.sanitizeFn)),t.html(e)):t.text(e):this.config.html?g(e).parent().is(t)||t.empty().append(e):t.text(g(e).text())},t.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},t._getOffset=function(){var e=this,t={};return"function"==typeof this.config.offset?t.fn=function(t){return t.offsets=l({},t.offsets,e.config.offset(t.offsets,e.element)||{}),t}:t.offset=this.config.offset,t},t._getContainer=function(){return!1===this.config.container?document.body:_.isElement(this.config.container)?g(this.config.container):g(document).find(this.config.container)},t._getAttachment=function(t){return Pe[t.toUpperCase()]},t._setListeners=function(){var i=this;this.config.trigger.split(" ").forEach(function(t){if("click"===t)g(i.element).on(i.constructor.Event.CLICK,i.config.selector,function(t){return i.toggle(t)});else if(t!==Qe){var e=t===qe?i.constructor.Event.MOUSEENTER:i.constructor.Event.FOCUSIN,n=t===qe?i.constructor.Event.MOUSELEAVE:i.constructor.Event.FOCUSOUT;g(i.element).on(e,i.config.selector,function(t){return i._enter(t)}).on(n,i.config.selector,function(t){return i._leave(t)})}}),g(this.element).closest(".modal").on("hide.bs.modal",function(){i.element&&i.hide()}),this.config.selector?this.config=l({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},t._fixTitle=function(){var t=typeof this.element.getAttribute("data-original-title");(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},t._enter=function(t,e){var n=this.constructor.DATA_KEY;(e=e||g(t.currentTarget).data(n))||(e=new this.constructor(t.currentTarget,this._getDelegateConfig()),g(t.currentTarget).data(n,e)),t&&(e._activeTrigger["focusin"===t.type?Me:qe]=!0),g(e.getTipElement()).hasClass(Fe)||e._hoverState===je?e._hoverState=je:(clearTimeout(e._timeout),e._hoverState=je,e.config.delay&&e.config.delay.show?e._timeout=setTimeout(function(){e._hoverState===je&&e.show()},e.config.delay.show):e.show())},t._leave=function(t,e){var n=this.constructor.DATA_KEY;(e=e||g(t.currentTarget).data(n))||(e=new this.constructor(t.currentTarget,this._getDelegateConfig()),g(t.currentTarget).data(n,e)),t&&(e._activeTrigger["focusout"===t.type?Me:qe]=!1),e._isWithActiveTrigger()||(clearTimeout(e._timeout),e._hoverState=He,e.config.delay&&e.config.delay.hide?e._timeout=setTimeout(function(){e._hoverState===He&&e.hide()},e.config.delay.hide):e.hide())},t._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},t._getConfig=function(t){var e=g(this.element).data();return Object.keys(e).forEach(function(t){-1!==Oe.indexOf(t)&&delete e[t]}),"number"==typeof(t=l({},this.constructor.Default,e,"object"==typeof t&&t?t:{})).delay&&(t.delay={show:t.delay,hide:t.delay}),"number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),_.typeCheckConfig(be,t,this.constructor.DefaultType),t.sanitize&&(t.template=Se(t.template,t.whiteList,t.sanitizeFn)),t},t._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},t._cleanTipClass=function(){var t=g(this.getTipElement()),e=t.attr("class").match(Ne);null!==e&&e.length&&t.removeClass(e.join(""))},t._handlePopperPlacementChange=function(t){var e=t.instance;this.tip=e.popper,this._cleanTipClass(),this.addAttachmentClass(this._getAttachment(t.placement))},t._fixTransition=function(){var t=this.getTipElement(),e=this.config.animation;null===t.getAttribute("x-placement")&&(g(t).removeClass(xe),this.config.animation=!1,this.hide(),this.show(),this.config.animation=e)},i._jQueryInterface=function(n){return this.each(function(){var t=g(this).data(Ie),e="object"==typeof n&&n;if((t||!/dispose|hide/.test(n))&&(t||(t=new i(this,e),g(this).data(Ie,t)),"string"==typeof n)){if("undefined"==typeof t[n])throw new TypeError('No method named "'+n+'"');t[n]()}})},s(i,null,[{key:"VERSION",get:function(){return"4.3.1"}},{key:"Default",get:function(){return Le}},{key:"NAME",get:function(){return be}},{key:"DATA_KEY",get:function(){return Ie}},{key:"Event",get:function(){return Re}},{key:"EVENT_KEY",get:function(){return De}},{key:"DefaultType",get:function(){return ke}}]),i}();g.fn[be]=Be._jQueryInterface,g.fn[be].Constructor=Be,g.fn[be].noConflict=function(){return g.fn[be]=we,Be._jQueryInterface};var Ve="popover",Ye="bs.popover",ze="."+Ye,Xe=g.fn[Ve],$e="bs-popover",Ge=new RegExp("(^|\\s)"+$e+"\\S+","g"),Je=l({},Be.Default,{placement:"right",trigger:"click",content:"",template:''}),Ze=l({},Be.DefaultType,{content:"(string|element|function)"}),tn="fade",en="show",nn=".popover-header",on=".popover-body",rn={HIDE:"hide"+ze,HIDDEN:"hidden"+ze,SHOW:"show"+ze,SHOWN:"shown"+ze,INSERTED:"inserted"+ze,CLICK:"click"+ze,FOCUSIN:"focusin"+ze,FOCUSOUT:"focusout"+ze,MOUSEENTER:"mouseenter"+ze,MOUSELEAVE:"mouseleave"+ze},sn=function(t){var e,n;function i(){return t.apply(this,arguments)||this}n=t,(e=i).prototype=Object.create(n.prototype),(e.prototype.constructor=e).__proto__=n;var o=i.prototype;return o.isWithContent=function(){return this.getTitle()||this._getContent()},o.addAttachmentClass=function(t){g(this.getTipElement()).addClass($e+"-"+t)},o.getTipElement=function(){return this.tip=this.tip||g(this.config.template)[0],this.tip},o.setContent=function(){var t=g(this.getTipElement());this.setElementContent(t.find(nn),this.getTitle());var e=this._getContent();"function"==typeof e&&(e=e.call(this.element)),this.setElementContent(t.find(on),e),t.removeClass(tn+" "+en)},o._getContent=function(){return this.element.getAttribute("data-content")||this.config.content},o._cleanTipClass=function(){var t=g(this.getTipElement()),e=t.attr("class").match(Ge);null!==e&&0=this._offsets[o]&&("undefined"==typeof this._offsets[o+1]||t Date: Wed, 18 Dec 2024 18:55:07 +0800 Subject: [PATCH 3/3] test --- .../annotation/ControllerConfig.java | 14 ++- .../impl/filter/EncodingFilter.java | 50 ++++----- .../controller/impl/filter/LoginFilter.java | 95 ++++++++-------- .../controller/impl/servlet/MyServlet.java | 78 +++++++------- .../wechat/factory/proxy/ConnectionProxy.java | 54 ++++++++-- .../wechat/model/builder/MomentVOBuilder.java | 102 ++++++++++++++++-- .../hyc/wechat/model/dto/ServiceResult.java | 51 ++++++++- .../src/com/hyc/wechat/model/po/Chat.java | 78 +++++++++++++- .../src/com/hyc/wechat/model/po/Friend.java | 95 ++++++++++++++-- .../src/com/hyc/wechat/model/po/Member.java | 81 +++++++++++++- .../hyc/wechat/model/po/abs/BaseEntity.java | 63 ++++++++++- 11 files changed, 604 insertions(+), 157 deletions(-) diff --git a/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java b/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java index 6f7da14..b48749b 100644 --- a/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java +++ b/wechat-master/src/com/hyc/wechat/controller/annotation/ControllerConfig.java @@ -1,12 +1,16 @@ // test -package com.hyc.wechat.controller.annotation; +package com.hyc.wechat.controller.annotation; // 定义注解所在的包名 -import java.lang.annotation.*; +import java.lang.annotation.*; // 导入Java标准注解库 -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = ElementType.TYPE) -public @interface ControllerConfig { +// 定义一个名为ControllerConfig的注解 +@Retention(value = RetentionPolicy.RUNTIME) // 指定注解的生命周期,RUNTIME表示注解将被保留到运行时,可以通过反射读取 +@Target(value = ElementType.TYPE) // 指定注解可以应用的目标类型,TYPE表示注解可以用于类、接口或枚举声明 +public @interface ControllerConfig { // 使用@interface关键字定义注解 + + // 定义一个名为path的属性方法,默认值为空字符串 + // 该属性用于配置控制器类的路径 String path() default ""; } diff --git a/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java b/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java index c5eac73..91591c4 100644 --- a/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java +++ b/wechat-master/src/com/hyc/wechat/controller/impl/filter/EncodingFilter.java @@ -1,48 +1,52 @@ +package com.hyc.wechat.controller.impl.filter; // 定义过滤器所在的包名 -package com.hyc.wechat.controller.impl.filter; +import com.hyc.wechat.controller.constant.ControllerMessage; // 导入控制器消息常量类 +import com.hyc.wechat.controller.constant.WebPage; // 导入网页常量类 +import org.apache.log4j.Logger; // 导入log4j日志记录器 -import com.hyc.wechat.controller.constant.ControllerMessage; -import com.hyc.wechat.controller.constant.WebPage; -import org.apache.log4j.Logger; +import javax.servlet.*; // 导入Servlet API +import javax.servlet.annotation.WebFilter; // 导入WebFilter注解 +import javax.servlet.annotation.WebInitParam; // 导入WebInitParam注解 +import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest类 +import javax.servlet.http.HttpServletResponse; // 导入HttpServletResponse类 +import java.io.IOException; // 导入IOException类 -import javax.servlet.*; -import javax.servlet.annotation.WebFilter; -import javax.servlet.annotation.WebInitParam; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -// 使用@WebFilter注解定义一个过滤器,指定过滤器的名称、URL模式、初始化参数 +// 使用@WebFilter注解定义一个名为"EncodingFilter"的过滤器 +// 过滤器将作用于所有的URL模式("/*") +// 并且具有一个初始化参数"ENCODING",其值为"UTF-8" @WebFilter( filterName = "EncodingFilter", - urlPatterns = {"/*"}, servletNames = {"/*"}, + urlPatterns = {"/*"}, initParams = { @WebInitParam(name = "ENCODING", value = "UTF-8") } ) -public class EncodingFilter implements Filter { +public class EncodingFilter implements Filter { // 实现Filter接口 - private String ENCODING = null; + private String ENCODING = null; // 用于存储字符编码的成员变量 @Override - public void init(FilterConfig config) { + public void init(FilterConfig config) { // 过滤器初始化方法 + // 从FilterConfig获取初始化参数"ENCODING" this.ENCODING = config.getInitParameter("ENCODING"); } @Override - public void destroy() { - + public void destroy() { // 过滤器销毁方法 + // 在此可以释放资源,但本例中无需实现 } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) { + // 类型转换,以便使用HttpServletRequest和HttpServletResponse的方法 HttpServletRequest req = (HttpServletRequest) servletRequest; HttpServletResponse resp = (HttpServletResponse) servletResponse; try { + // 设置请求和响应的字符编码 req.setCharacterEncoding(ENCODING); resp.setContentType("text/html;charset=utf-8"); resp.setCharacterEncoding(ENCODING); - // 添加CORS相关的响应头,允许跨域请求 + // 设置CORS相关响应头,允许跨域请求 resp.addHeader("Access-Control-Allow-Origin", "*"); resp.addHeader("Access-Control-Allow-Headers", "origin, content-type, accept, x-requested-with, sid, mycustom, smuser"); @@ -52,20 +56,18 @@ public class EncodingFilter implements Filter { // 继续执行过滤链中的下一个过滤器或Servlet filterChain.doFilter(servletRequest, servletResponse); } catch (IOException | ServletException e) { - e.printStackTrace(); + e.printStackTrace(); // 打印异常堆栈信息 try { // 设置请求属性,传递系统异常信息 req.setAttribute("message", ControllerMessage.SYSTEM_EXECEPTION.message); // 转发请求到错误页面 req.getRequestDispatcher(WebPage.ERROR_JSP.toString()).forward(req, resp); } catch (ServletException | IOException ex) { - // 打印转发过程中可能出现的异常堆栈信息 - ex.printStackTrace(); + ex.printStackTrace(); // 打印转发过程中可能出现的异常堆栈信息 } } - // 获取日志记录器 + // 获取日志记录器并记录请求信息 Logger logger = Logger.getLogger(EncodingFilter.class); logger.info("[请求url] : " + req.getRequestURI() + " [请求参数] :" + req.getQueryString()); } } - diff --git a/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java b/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java index 74bf00f..b608e76 100644 --- a/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java +++ b/wechat-master/src/com/hyc/wechat/controller/impl/filter/LoginFilter.java @@ -1,79 +1,80 @@ -//导入必要库 +// 导入必要的库 package com.hyc.wechat.controller.impl.filter; -import com.hyc.wechat.controller.constant.ControllerMessage; -import com.hyc.wechat.controller.constant.RequestMethod; -import com.hyc.wechat.controller.constant.WebPage; -import com.hyc.wechat.model.dto.ServiceResult; -import com.hyc.wechat.model.po.User; -import com.hyc.wechat.provider.UserProvider; -import com.hyc.wechat.service.constants.Status; -import com.hyc.wechat.service.impl.UserServiceImpl; +import com.hyc.wechat.controller.constant.ControllerMessage; // 导入控制器消息常量类 +import com.hyc.wechat.controller.constant.RequestMethod; // 导入请求方法常量类 +import com.hyc.wechat.controller.constant.WebPage; // 导入网页常量类 +import com.hyc.wechat.model.dto.ServiceResult; // 导入服务结果数据传输对象 +import com.hyc.wechat.model.po.User; // 导入用户持久化对象 +import com.hyc.wechat.provider.UserProvider; // 导入用户提供者类 +import com.hyc.wechat.service.constants.Status; // 导入状态常量类 +import com.hyc.wechat.service.impl.UserServiceImpl; // 导入用户服务实现类 -import javax.servlet.*; -import javax.servlet.annotation.WebFilter; -import javax.servlet.annotation.WebInitParam; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.io.IOException; - -import static com.hyc.wechat.util.ControllerUtils.returnJsonObject; +import javax.servlet.*; // 导入Servlet API +import javax.servlet.annotation.WebFilter; // 导入WebFilter注解 +import javax.servlet.annotation.WebInitParam; // 导入WebInitParam注解 +import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest类 +import javax.servlet.http.HttpServletResponse; // 导入HttpServletResponse类 +import javax.servlet.http.HttpSession; // 导入HttpSession类 +import java.io.IOException; // 导入IOException类 +import static com.hyc.wechat.util.ControllerUtils.returnJsonObject; // 导入返回JSON对象的工具方法 +// 使用@WebFilter注解定义一个名为"LoginFilter"的过滤器 +// 过滤器将作用于所有的URL模式("/*") @WebFilter( filterName = "LoginFilter", - urlPatterns = {"/*"}, servletNames = {"/*"}, + urlPatterns = {"/*"}, initParams = { @WebInitParam(name = "ENCODING", value = "UTF-8") }) -public class LoginFilter implements Filter { +public class LoginFilter implements Filter { // 实现Filter接口 - private final UserProvider userProvider = new UserProvider(); + private final UserProvider userProvider = new UserProvider(); // 创建用户提供者实例 @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { - HttpServletRequest req = (HttpServletRequest) servletRequest; - HttpServletResponse resp = (HttpServletResponse) servletResponse; - String method = req.getParameter("method"); - String uri = req.getRequestURI(); - String contextPath = req.getContextPath(); - String path = uri.substring(contextPath.length()); - HttpSession sess = req.getSession(false); + HttpServletRequest req = (HttpServletRequest) servletRequest; // 类型转换 + HttpServletResponse resp = (HttpServletResponse) servletResponse; // 类型转换 + String method = req.getParameter("method"); // 获取请求方法参数 + String uri = req.getRequestURI(); // 获取请求URI + String contextPath = req.getContextPath(); // 获取上下文路径 + String path = uri.substring(contextPath.length()); // 获取请求路径 + HttpSession sess = req.getSession(false); // 获取当前会话,如果不存在则返回null - //尝试自动登陆 + // 尝试自动登录 userProvider.autoLogin(req); - sess=req.getSession(); - //放行登陆注册 + sess = req.getSession(); // 获取或创建会话 + + // 放行登录和注册相关请求 if (sess == null || sess.getAttribute("login") == null) { - if (WebPage.LOGIN_JSP.toString().equalsIgnoreCase(path) || - (WebPage.REGISTER_JSP.toString()).equalsIgnoreCase(path) || - (RequestMethod.LOGIN_DO.toString()).equalsIgnoreCase(method) || - (RequestMethod.REGISTER_DO.toString()).equalsIgnoreCase(method) || - path.endsWith("logo.png") || path.endsWith(".js") || path.endsWith("agreement.html")) { - filterChain.doFilter(req, resp); + if (WebPage.LOGIN_JSP.toString().equalsIgnoreCase(path) || // 登录页面 + WebPage.REGISTER_JSP.toString().equalsIgnoreCase(path) || // 注册页面 + RequestMethod.LOGIN_DO.toString().equalsIgnoreCase(method) || // 登录操作 + RequestMethod.REGISTER_DO.toString().equalsIgnoreCase(method) || // 注册操作 + path.endsWith("logo.png") || path.endsWith(".js") || path.endsWith("agreement.html")) { // 资源文件 + filterChain.doFilter(req, resp); // 继续执行过滤链 return; } else { - //检查session是否有'login'属性,没有则重定向到登陆界面 + // 检查会话是否有'login'属性,没有则重定向到登录界面 if (sess == null || sess.getAttribute("login") == null) { - req.getRequestDispatcher(WebPage.LOGIN_JSP.toString()).forward(req, resp); + req.getRequestDispatcher(WebPage.LOGIN_JSP.toString()).forward(req, resp); // 转发到登录页面 return; } } - }else { - //已登陆用户检查登陆身份 + } else { + // 已登录用户检查登录身份 if (path.startsWith("/wechat/moment") || path.startsWith("/wechat/friend")) { - //检查登陆身份 - User user = (User) sess.getAttribute("login"); + // 检查登录身份 + User user = (User) sess.getAttribute("login"); // 获取登录用户信息 if (user != null && UserServiceImpl.VISITOR_EMAIL.equals(user.getEmail())) { - //游客不可使用 - returnJsonObject(resp, new ServiceResult(Status.ERROR, ControllerMessage.YOU_ARE_VISITOR.message, null)); + // 游客不可使用 + returnJsonObject(resp, new ServiceResult(Status.ERROR, ControllerMessage.YOU_ARE_VISITOR.message, null)); // 返回错误信息 return; } } } - filterChain.doFilter(req, resp); + filterChain.doFilter(req, resp); // 继续执行过滤链 } - } diff --git a/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java b/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java index 438bc45..2799439 100644 --- a/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java +++ b/wechat-master/src/com/hyc/wechat/controller/impl/servlet/MyServlet.java @@ -1,67 +1,65 @@ -//导入必要库 +// 导入必要的库 package com.hyc.wechat.controller.impl.servlet; -import com.hyc.wechat.controller.annotation.ControllerConfig; -import com.hyc.wechat.controller.constant.ControllerMessage; -import com.hyc.wechat.provider.Provider; -import com.hyc.wechat.util.ControllerUtils; -import org.apache.log4j.Logger; +import com.hyc.wechat.controller.annotation.ControllerConfig; // 导入自定义的ControllerConfig注解 +import com.hyc.wechat.controller.constant.ControllerMessage; // 导入控制器消息常量类 +import com.hyc.wechat.provider.Provider; // 导入Provider接口 +import com.hyc.wechat.util.ControllerUtils; // 导入控制器工具类 +import org.apache.log4j.Logger; // 导入log4j日志记录器 -import javax.servlet.annotation.MultipartConfig; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Map; -import java.util.Set; +import javax.servlet.annotation.MultipartConfig; // 导入MultipartConfig注解 +import javax.servlet.annotation.WebServlet; // 导入WebServlet注解 +import javax.servlet.http.HttpServlet; // 导入HttpServlet类 +import javax.servlet.http.HttpServletRequest; // 导入HttpServletRequest类 +import javax.servlet.http.HttpServletResponse; // 导入HttpServletResponse类 +import java.io.IOException; // 导入IOException类 +import java.util.Map; // 导入Map接口 +import java.util.Set; // 导入Set接口 -import static com.hyc.wechat.provider.Provider.toErrorPage; +import static com.hyc.wechat.provider.Provider.toErrorPage; // 导入Provider类的静态方法toErrorPage +// 使用@MultipartConfig注解配置文件上传的临时存储位置 @MultipartConfig(location = "/home/pan/tomcat/webapps/wechat/upload") //@MultipartConfig(location = "C:\\Users\\Misterchaos\\Documents\\Java Develop Workplaces\\IDEA workspace\\wechat\\out\\artifacts\\wechat_war_exploded\\upload") -@WebServlet("/wechat/*") +@WebServlet("/wechat/*") // 使用@WebServlet注解映射@WebServlet到/wechat/*路径 public class MyServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { - this.doPost(req, resp); + this.doPost(req, resp); // 将GET请求转发到doPost方法处理 } /** * 负责将请求转发到url对应的Provider * - * @param req 请求 - * @param resp 响应 + * @param req 请求对象 + * @param resp 响应对象 * @name doPost * @notice none */ @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { - MapproviderMap = (Map) getServletContext().getAttribute("providerMap"); - String url = req.getRequestURI(); - Set keys = providerMap.keySet(); - Logger logger = Logger.getLogger(MyServlet.class); - logger.info("[请求url:]"+url+"[匹配provider]:"+url.substring(14)); - boolean isMatch=false; - for (String key : keys) { - //解析注解中的path信息,匹配ActionProvider - String path =providerMap.get(key).getPath(); - if (url.substring(14).equalsIgnoreCase(path)) { - providerMap.get(key).doAction(req, resp); - logger.info("provider 分发完毕"); - isMatch=true; + Map providerMap = (Map) getServletContext().getAttribute("providerMap"); // 从ServletContext获取Provider映射 + String url = req.getRequestURI(); // 获取请求的URI + Set keys = providerMap.keySet(); // 获取Provider映射的键集合 + Logger logger = Logger.getLogger(MyServlet.class); // 获取日志记录器 + logger.info("[请求url:] " + url + " [匹配provider]: " + url.substring(14)); // 记录请求的URL和尝试匹配的Provider + boolean isMatch = false; // 标记是否找到匹配的Provider + for (String key : keys) { // 遍历Provider映射的键集合 + // 解析注解中的path信息,匹配ActionProvider + String path = providerMap.get(key).getPath(); // 获取Provider的路径 + if (url.substring(14).equalsIgnoreCase(path)) { // 检查请求的路径是否与Provider的路径匹配 + providerMap.get(key).doAction(req, resp); // 执行匹配的Provider的doAction方法 + logger.info("provider 分发完毕"); // 记录Provider分发完成 + isMatch = true; // 设置匹配标志为true } } - if(!isMatch){ - toErrorPage(ControllerMessage.REQUEST_INVALID.message,req,resp); - logger.info("该请求没有匹配provider :"+url.substring(14)); - return; + if (!isMatch) { // 如果没有找到匹配的Provider + toErrorPage(ControllerMessage.REQUEST_INVALID.message, req, resp); // 转发到错误页面 + logger.info("该请求没有匹配provider: " + url.substring(14)); // 记录没有匹配的Provider + return; // 结束方法执行 } -// logger.info("响应结果 "+resp.getOutputStream()); + // logger.info("响应结果 "+resp.getOutputStream()); // 这行代码被注释掉了,可能是为了调试目的 } - - } - diff --git a/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java b/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java index 007dc6c..6325d5c 100644 --- a/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java +++ b/wechat-master/src/com/hyc/wechat/factory/proxy/ConnectionProxy.java @@ -1,4 +1,3 @@ -//导入必要库 package com.hyc.wechat.factory.proxy; import com.hyc.wechat.dao.DataSource; @@ -12,25 +11,38 @@ import java.sql.Connection; /** * @program wechat - * @description 用于代理数据库连接对象 + * @description 这个类用于创建数据库连接对象的代理。代理模式允许我们在不修改原始连接对象的情况下, + * 对其进行增强,例如管理连接的生命周期、实现自动关闭连接等。 */ public class ConnectionProxy implements InvocationHandler { + // 被代理的Connection对象 private Connection target; + // 数据源对象,用于管理数据库连接 private DataSource dataSource; + + /** + * 构造方法,接收一个数据源对象作为参数。 + * @param dataSource 用于管理数据库连接的数据源对象 + */ + public ConnectionProxy(DataSource dataSource) { + this.dataSource = dataSource; + } + /** * 获取代理实例的方法。 * @param target 被代理的Connection对象 * @return 返回一个Connection类型的代理实例 */ - public Connection getProxyInstance(Connection target){ - this.target= target; - return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),new Class[]{Connection.class},this); + public Connection getProxyInstance(Connection target) { + this.target = target; // 设置被代理的目标对象 + // 使用Proxy类创建一个Connection代理实例,并将当前对象作为调用处理器 + return (Connection) Proxy.newProxyInstance( + Connection.class.getClassLoader(), // 类加载器 + new Class[]{Connection.class}, // 代理实现的接口数组 + this); // 调用处理器 } - public ConnectionProxy(DataSource dataSource) { - this.dataSource = dataSource; - } /** * 实现InvocationHandler接口的invoke方法,用于处理代理实例上的方法调用。 * @param proxy 代理实例 @@ -40,30 +52,50 @@ public class ConnectionProxy implements InvocationHandler { */ @Override public Object invoke(Object proxy, Method method, Object[] args) { + // 如果调用的是close方法,则将连接放回数据源,而不是真正关闭连接 if ("close".equals(method.getName())) { - //调用代理对象的close方法时,将目标对象放回数据库连接池 - dataSource.freeConnection(target); - return null; + dataSource.freeConnection(target); // 将连接放回数据源 + return null; // close方法没有返回值 } try { + // 对于其他方法调用,直接转发给被代理的目标对象 return method.invoke(target, args); } catch (IllegalAccessException | InvocationTargetException e) { + // 如果方法调用过程中发生异常,则抛出DaoException throw new DaoException("无法调用目标对象的方法", e); } } + // 以下是getter和setter方法,用于访问和修改target和dataSource属性 + + /** + * 获取被代理的Connection对象。 + * @return 被代理的Connection对象 + */ public Connection getTarget() { return target; } + /** + * 设置被代理的Connection对象。 + * @param target 被代理的Connection对象 + */ public void setTarget(Connection target) { this.target = target; } + /** + * 获取数据源对象。 + * @return 数据源对象 + */ public DataSource getDataSource() { return dataSource; } + /** + * 设置数据源对象。 + * @param dataSource 数据源对象 + */ public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } diff --git a/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java b/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java index b205be0..49ca18e 100644 --- a/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java +++ b/wechat-master/src/com/hyc/wechat/model/builder/MomentVOBuilder.java @@ -7,98 +7,186 @@ import java.math.BigInteger; import java.sql.Timestamp; /** - * @description 负责朋友圈视图层对象的建造 + * @description 这个类是一个建造者模式的具体实现,用于构建朋友圈视图层对象(MomentVO)。 */ public class MomentVOBuilder { + // MomentVO对象,用于存储构建过程中的数据 private MomentVO momentVO; + /** + * 构造方法,初始化MomentVO对象。 + */ public MomentVOBuilder() { this.momentVO = new MomentVO(); } + /** + * 构建并返回MomentVO对象。 + * @return 返回构建完成的MomentVO对象 + */ public MomentVO build() { return this.momentVO; } + // 以下方法用于设置MomentVO对象的属性,并返回当前Builder对象,以便链式调用 + /** + * 设置朋友圈动态的时间戳。 + * @param time 时间戳 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setTime(Timestamp time){ this.momentVO.setTime(time); return this; } + /** + * 设置用户头像的URL。 + * @param userPhoto 用户头像URL + * @return 返回当前Builder对象 + */ public MomentVOBuilder setUserPhoto(String userPhoto){ this.momentVO.setUserPhoto(userPhoto); return this; } - + /** + * 设置朋友圈动态的照片URL。 + * @param photo 照片URL + * @return 返回当前Builder对象 + */ public MomentVOBuilder setPhoto(String photo){ this.momentVO.setPhoto(photo); return this; } + /** + * 设置用户名。 + * @param userName 用户名 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setUserName(String userName){ this.momentVO.setUserName(userName); return this; } + /** + * 设置朋友圈动态的ID。 + * @param id 动态ID + * @return 返回当前Builder对象 + */ public MomentVOBuilder setId(BigInteger id) { this.momentVO.setId(id); return this; } + /** + * 设置发布动态的用户的ID。 + * @param userId 用户ID + * @return 返回当前Builder对象 + */ public MomentVOBuilder setUserId(BigInteger userId) { this.momentVO.setOwnerId(userId); return this; } + /** + * 设置朋友圈动态的内容。 + * @param content 动态内容 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setContent(String content) { this.momentVO.setContent(content); return this; } + /** + * 设置朋友圈动态的分享次数。 + * @param share 分享次数 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setShare(Long share) { this.momentVO.setShare(share); return this; } + /** + * 设置朋友圈动态的点赞次数。 + * @param love 点赞次数 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setLove(Long love) { this.momentVO.setLove(love); return this; } + + /** + * 设置朋友圈动态的评论次数。 + * @param remark 评论次数 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setRemark(Long remark) { this.momentVO.setRemark(remark); return this; } + /** + * 设置朋友圈动态的浏览次数。 + * @param view 浏览次数 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setView(Long view) { this.momentVO.setView(view); return this; } + /** + * 设置朋友圈动态的收藏次数。 + * @param collect 收藏次数 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setCollect(Long collect) { this.momentVO.setCollect(collect); return this; } + /** + * 设置当前用户是否点赞了该动态。 + * @param loved 是否点赞 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setLoved(Boolean loved) { this.momentVO.setLoved(loved); return this; } + /** + * 设置当前用户是否分享了该动态。 + * @param shared 是否分享 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setShared(Boolean shared) { this.momentVO.setShared(shared); return this; } - public MomentVOBuilder setViewed(Boolean viewed) { - this.momentVO.setViewed(viewed); - return this; +/** + * 设置当前用户是否浏览了该动态。 + * @param viewed 是否浏览 + * @return 返回当前Builder对象 + */ +public MomentVOBuilder setViewed(Boolean viewed) { + this.momentVO.setViewed(viewed); + return this; +} - } + /** + * 设置当前用户是否收藏了该动态。 + * @param collected 是否收藏 + * @return 返回当前Builder对象 + */ public MomentVOBuilder setCollected(Boolean collected) { this.momentVO.setCollected(collected); return this; - } } diff --git a/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java b/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java index 22fe7e5..e001356 100644 --- a/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java +++ b/wechat-master/src/com/hyc/wechat/model/dto/ServiceResult.java @@ -5,52 +5,95 @@ import com.hyc.wechat.service.constants.Status; /** * @program wechat - * @description 用于service层返回处理结果 + * @description 用于service层返回处理结果的数据传输对象(DTO) */ public class ServiceResult { /** - * 状态码 + * 状态码,用于表示处理结果的状态 */ private Status status; + /** - * 响应消息 + * 响应消息,用于提供处理结果的详细信息 */ private String message; + /** - * 响应数据 + * 响应数据,用于返回处理结果相关的数据 */ private Object data; + /** + * 默认构造函数,用于创建一个空的ServiceResult对象 + */ public ServiceResult() { } + /** + * 带参数的构造函数,用于创建一个具有初始状态的ServiceResult对象 + * + * @param status 处理结果的状态码 + * @param message 处理结果的详细信息 + * @param data 处理结果相关的数据 + */ public ServiceResult(Status status, String message, Object data) { this.status = status; this.message = message; this.data = data; } + /** + * 获取状态码 + * + * @return 返回处理结果的状态码 + */ public Status getStatus() { return status; } + /** + * 设置状态码 + * + * @param status 处理结果的状态码 + */ public void setStatus(Status status) { this.status = status; } + /** + * 获取响应消息 + * + * @return 返回处理结果的详细信息 + */ public String getMessage() { return message; } + /** + * 设置响应消息 + * + * @param message 处理结果的详细信息 + */ public void setMessage(String message) { this.message = message; } + /** + * 获取响应数据 + * + * @return 返回处理结果相关的数据 + */ public Object getData() { return data; } + /** + * 设置响应数据 + * + * @param data 处理结果相关的数据 + */ public void setData(Object data) { this.data = data; } } + diff --git a/wechat-master/src/com/hyc/wechat/model/po/Chat.java b/wechat-master/src/com/hyc/wechat/model/po/Chat.java index 2983521..71f8e3e 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/Chat.java +++ b/wechat-master/src/com/hyc/wechat/model/po/Chat.java @@ -8,63 +8,135 @@ import com.hyc.wechat.model.po.abs.BaseEntity; import java.math.BigInteger; /** - * @description 对应数据库chat表 + * @description 该类是对应数据库中chat表的实体类,用于表示聊天信息 */ -@Table(name = "chat") +@Table(name = "chat") // 指定该实体类对应的数据库表名为chat public class Chat extends BaseEntity { + // 聊天室的编号 private String number; - @JSONField(name = "owner_id") + + // 聊天室所有者的ID + @JSONField(name = "owner_id") // 指定在JSON序列化时的字段名为owner_id private BigInteger ownerId; + + // 聊天室的类型(如群聊、私聊等) private String type; + + // 聊天室的名称 private String name; + + // 聊天室的成员数量 private Integer member; + + // 聊天室的封面照片URL private String photo; + /** + * 获取聊天室的类型 + * + * @return 聊天室的类型 + */ public String getType() { return type; } + /** + * 设置聊天室的类型 + * + * @param type 聊天室的类型 + */ public void setType(String type) { this.type = type; } + /** + * 获取聊天室的编号 + * + * @return 聊天室的编号 + */ public String getNumber() { return number; } + /** + * 设置聊天室的编号 + * + * @param number 聊天室的编号 + */ public void setNumber(String number) { this.number = number; } + /** + * 获取聊天室的封面照片URL + * + * @return 聊天室的封面照片URL + */ public String getPhoto() { return photo; } + /** + * 设置聊天室的封面照片URL + * + * @param photo 聊天室的封面照片URL + */ public void setPhoto(String photo) { this.photo = photo; } + /** + * 获取聊天室所有者的ID + * + * @return 聊天室所有者的ID + */ public BigInteger getOwnerId() { return ownerId; } + /** + * 设置聊天室所有者的ID + * + * @param ownerId 聊天室所有者的ID + */ public void setOwnerId(BigInteger ownerId) { this.ownerId = ownerId; } + /** + * 获取聊天室的名称 + * + * @return 聊天室的名称 + */ public String getName() { return name; } + /** + * 设置聊天室的名称 + * + * @param name 聊天室的名称 + */ public void setName(String name) { this.name = name; } + /** + * 获取聊天室的成员数量 + * + * @return 聊天室的成员数量 + */ public Integer getMember() { return member; } + /** + * 设置聊天室的成员数量 + * + * @param member 聊天室的成员数量 + */ public void setMember(Integer member) { this.member = member; } } + diff --git a/wechat-master/src/com/hyc/wechat/model/po/Friend.java b/wechat-master/src/com/hyc/wechat/model/po/Friend.java index 54a16a1..1f8fbc3 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/Friend.java +++ b/wechat-master/src/com/hyc/wechat/model/po/Friend.java @@ -9,74 +9,157 @@ import java.math.BigInteger; /** * @program wechat - * @description 朋友表 + * @description 该类是对应数据库中friend表的实体类,用于表示朋友关系信息 */ -@Table(name = "friend") +@Table(name = "friend") // 指定该实体类对应的数据库表名为friend public class Friend extends BaseEntity { - @JSONField(name = "user_id") + // 用户ID,表示朋友的用户标识 + @JSONField(name = "user_id") // 指定在JSON序列化时的字段名为user_id private BigInteger userId; - @JSONField(name = "friend_id") + + // 朋友ID,表示朋友的用户标识 + @JSONField(name = "friend_id") // 指定在JSON序列化时的字段名为friend_id private BigInteger friendId; - @JSONField(name = "chat_id") + + // 聊天室ID,表示与朋友关联的聊天室标识 + @JSONField(name = "chat_id") // 指定在JSON序列化时的字段名为chat_id private BigInteger chatId; + + // 朋友的头像照片URL private String photo; - @JSONField(name = "group_id") + + // 分组ID,表示朋友所属的分组标识 + @JSONField(name = "group_id") // 指定在JSON序列化时的字段名为group_id private BigInteger groupId; + + // 朋友的别名,用于在好友列表中显示的名称 private String alias; + + // 朋友的描述信息 private String description; + /** + * 获取与朋友关联的聊天室ID + * + * @return 聊天室ID + */ public BigInteger getChatId() { return chatId; } + /** + * 设置与朋友关联的聊天室ID + * + * @param chatId 聊天室ID + */ public void setChatId(BigInteger chatId) { this.chatId = chatId; } + /** + * 获取朋友的头像照片URL + * + * @return 头像照片URL + */ public String getPhoto() { return photo; } + /** + * 设置朋友的头像照片URL + * + * @param photo 头像照片URL + */ public void setPhoto(String photo) { this.photo = photo; } + /** + * 获取用户ID + * + * @return 用户ID + */ public BigInteger getUserId() { return userId; } + /** + * 设置用户ID + * + * @param userId 用户ID + */ public void setUserId(BigInteger userId) { this.userId = userId; } + /** + * 获取朋友ID + * + * @return 朋友ID + */ public BigInteger getFriendId() { return friendId; } + /** + * 设置朋友ID + * + * @param friendId 朋友ID + */ public void setFriendId(BigInteger friendId) { this.friendId = friendId; } + /** + * 获取分组ID + * + * @return 分组ID + */ public BigInteger getGroupId() { return groupId; } + /** + * 设置分组ID + * + * @param groupId 分组ID + */ public void setGroupId(BigInteger groupId) { this.groupId = groupId; } + /** + * 获取朋友的别名 + * + * @return 朋友的别名 + */ public String getAlias() { return alias; } + /** + * 设置朋友的别名 + * + * @param alias 朋友的别名 + */ public void setAlias(String alias) { this.alias = alias; } + /** + * 获取朋友的描述信息 + * + * @return 朋友的描述信息 + */ public String getDescription() { return description; } + /** + * 设置朋友的描述信息 + * + * @param description 朋友的描述信息 + */ public void setDescription(String description) { this.description = description; } diff --git a/wechat-master/src/com/hyc/wechat/model/po/Member.java b/wechat-master/src/com/hyc/wechat/model/po/Member.java index 26321ae..6095d92 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/Member.java +++ b/wechat-master/src/com/hyc/wechat/model/po/Member.java @@ -8,64 +8,135 @@ import com.hyc.wechat.model.po.abs.BaseEntity; import java.math.BigInteger; /** - * @description 用户和群聊的中间表 + * @description 该类是对应数据库中member表的实体类,用于表示用户和群聊的中间关系 */ -@Table(name = "member") +@Table(name = "member") // 指定该实体类对应的数据库表名为member public class Member extends BaseEntity { - @JSONField(name = "user_id") + // 用户ID,表示成员的用户标识 + @JSONField(name = "user_id") // 指定在JSON序列化时的字段名为user_id private BigInteger userId; - @JSONField(name = "chat_id") + + // 聊天室ID,表示成员所属的群聊标识 + @JSONField(name = "chat_id") // 指定在JSON序列化时的字段名为chat_id private BigInteger chatId; - @JSONField(name = "group_alias") + + // 群聊别名,表示成员在群聊中的别名 + @JSONField(name = "group_alias") // 指定在JSON序列化时的字段名为group_alias private String groupAlias; + + // 申请状态,表示成员的申请状态(如:待审批、已通过等) private String apply; + + // 背景图片,表示成员在群聊中的背景图片 private String background; + + // 等级,表示成员在群聊中的等级或权限级别 private Integer level; + /** + * 获取成员的申请状态 + * + * @return 申请状态 + */ public String getApply() { return apply; } + /** + * 设置成员的申请状态 + * + * @param apply 申请状态 + */ public void setApply(String apply) { this.apply = apply; } + /** + * 获取成员的等级 + * + * @return 等级 + */ public Integer getLevel() { return level; } + /** + * 设置成员的等级 + * + * @param level 等级 + */ public void setLevel(Integer level) { this.level = level; } + /** + * 获取成员的用户ID + * + * @return 用户ID + */ public BigInteger getUserId() { return userId; } + /** + * 设置成员的用户ID + * + * @param userId 用户ID + */ public void setUserId(BigInteger userId) { this.userId = userId; } + /** + * 获取成员所属的群聊ID + * + * @return 群聊ID + */ public BigInteger getChatId() { return chatId; } + /** + * 设置成员所属的群聊ID + * + * @param chatId 群聊ID + */ public void setChatId(BigInteger chatId) { this.chatId = chatId; } + /** + * 获取成员在群聊中的别名 + * + * @return 群聊别名 + */ public String getGroupAlias() { return groupAlias; } + /** + * 设置成员在群聊中的别名 + * + * @param groupAlias 群聊别名 + */ public void setGroupAlias(String groupAlias) { this.groupAlias = groupAlias; } + /** + * 获取成员在群聊中的背景图片 + * + * @return 背景图片 + */ public String getBackground() { return background; } + /** + * 设置成员在群聊中的背景图片 + * + * @param background 背景图片 + */ public void setBackground(String background) { this.background = background; } diff --git a/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java b/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java index 28ee233..214cda3 100644 --- a/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java +++ b/wechat-master/src/com/hyc/wechat/model/po/abs/BaseEntity.java @@ -9,57 +9,110 @@ import java.util.Date; /** * @program wechat - * @description 所有数据库记录的父类 + * @description 所有数据库记录的父类,定义了通用的字段和方法 */ public abstract class BaseEntity { + /** + * 记录的唯一标识符 + */ @Field(name = "id") private BigInteger id; + + /** + * 记录的状态,通常用于表示记录的启用、禁用等状态 + */ @Field(name = "status") private Integer status; + + /** + * 记录的创建时间 + */ @Field(name = "gmt_create") private Date gmtCreate; + + /** + * 记录的最后修改时间 + */ @Field(name = "gmt_modified") private Date gmtModified; + /** + * 获取记录的唯一标识符 + * + * @return 记录的唯一标识符 + */ public BigInteger getId() { return id; } + /** + * 设置记录的唯一标识符 + * + * @param id 记录的唯一标识符 + */ public void setId(BigInteger id) { this.id = id; } + /** + * 获取记录的状态 + * + * @return 记录的状态 + */ public Integer getStatus() { return status; } + /** + * 设置记录的状态 + * + * @param status 记录的状态 + */ public void setStatus(Integer status) { this.status = status; } + /** + * 获取记录的创建时间 + * + * @return 记录的创建时间 + */ public Date getGmtCreate() { return gmtCreate; } + /** + * 设置记录的创建时间 + * + * @param gmtCreate 记录的创建时间 + */ public void setGmtCreate(Date gmtCreate) { this.gmtCreate = gmtCreate; } + /** + * 获取记录的最后修改时间 + * + * @return 记录的最后修改时间 + */ public Date getGmtModified() { return gmtModified; } + /** + * 设置记录的最后修改时间 + * + * @param gmtModified 记录的最后修改时间 + */ public void setGmtModified(Date gmtModified) { this.gmtModified = gmtModified; } /** - * 所有的po层实体类都继承此类,在这里一次性重写toString方法,使用json格式输出 + * 重写toString方法,使用JSON格式输出实体类的信息 * - * @return - * @name toString - * @notice none + * @return 实体类的JSON字符串表示 */ @Override public String toString() { -- 2.34.1