diff --git a/esua-epdc/db/mysql.sql b/esua-epdc/doc/db/mysql.sql similarity index 100% rename from esua-epdc/db/mysql.sql rename to esua-epdc/doc/db/mysql.sql diff --git a/esua-epdc/db/newupdate.sql b/esua-epdc/doc/db/newupdate.sql similarity index 100% rename from esua-epdc/db/newupdate.sql rename to esua-epdc/doc/db/newupdate.sql diff --git a/esua-epdc/db/oracle.sql b/esua-epdc/doc/db/oracle.sql similarity index 100% rename from esua-epdc/db/oracle.sql rename to esua-epdc/doc/db/oracle.sql diff --git a/esua-epdc/db/postgresql.sql b/esua-epdc/doc/db/postgresql.sql similarity index 100% rename from esua-epdc/db/postgresql.sql rename to esua-epdc/doc/db/postgresql.sql diff --git a/esua-epdc/db/sqlserver.sql b/esua-epdc/doc/db/sqlserver.sql similarity index 100% rename from esua-epdc/db/sqlserver.sql rename to esua-epdc/doc/db/sqlserver.sql diff --git a/esua-epdc/doc/开发规范/命名规范.txt b/esua-epdc/doc/开发规范/命名规范.txt new file mode 100644 index 000000000..684d4b35e --- /dev/null +++ b/esua-epdc/doc/开发规范/命名规范.txt @@ -0,0 +1,19 @@ +dao层: +1、结果集是集合用selectListXXX +2、结果集为一个实例用selectOneXXX +3、更新:updateXXX +4、插入:insertXXX +5、删除:deleteXXX +6、获取统计值的方法用 selectCount +service层: +1、结果集是集合:listXXX +2、结果集是一个实例:getXXX +3、插入:saveXXX +5、修改:modifyXXX +4、删除:removeXXX +5、获取统计值的方法用 countXXX + + +数据传输对象:xxxDTO,xxx 为业务领域相关的名称 + +controller层根据接口定义来取名,接口定的什么就取什么 diff --git a/esua-epdc/doc/开发规范/阿里巴巴java开发规范1.4.pdf b/esua-epdc/doc/开发规范/阿里巴巴java开发规范1.4.pdf new file mode 100755 index 000000000..35865f059 Binary files /dev/null and b/esua-epdc/doc/开发规范/阿里巴巴java开发规范1.4.pdf differ diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java index b06fb2bf5..a44ec142c 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java @@ -98,4 +98,10 @@ public class SysDeptController { return new Result(); } + + @GetMapping("listGridId/{pid}") + @ApiOperation("获取所有下属网格ID集合") + public Result> listGridIdByPid(@PathVariable("pid") Long pid){ + return sysDeptService.listGridIdByPid(pid); + } } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java index 17a0c6e8d..5233ed93a 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java @@ -1,8 +1,8 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ @@ -50,4 +50,13 @@ public interface SysDeptDao extends BaseDao { */ List listSimpleDeptInfo(Map params); + /** + * 获取所有下属网格ID集合 + * + * @param pid + * @return java.util.List + * @author yujintao + * @date 2019/9/5 13:46 + */ + List listGridIdByPid(Long pid); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java index b8827fbe4..2b8bb9ed5 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java @@ -8,6 +8,7 @@ package com.elink.esua.epdc.service; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.SysSimpleDeptDTO; import com.elink.esua.epdc.entity.SysDeptEntity; import com.elink.esua.epdc.commons.mybatis.service.BaseService; @@ -51,4 +52,14 @@ public interface SysDeptService extends BaseService { * @param id 部门ID */ List getSubDeptIdList(Long id); + + /** + * 获取所有下属网格ID集合 + * + * @param pid 部门ID + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @author yujintao + * @date 2019/9/5 13:45 + */ + Result> listGridIdByPid(Long pid); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java index f7d4f545e..a36d74e5a 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java @@ -18,6 +18,7 @@ import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; import com.elink.esua.epdc.commons.tools.security.user.UserDetail; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.commons.tools.utils.TreeUtils; import com.elink.esua.epdc.dao.SysDeptDao; import com.elink.esua.epdc.dto.SysDeptDTO; @@ -174,4 +175,10 @@ public class SysDeptServiceImpl extends BaseServiceImpl> listGridIdByPid(Long pid) { + List deptIdList = this.baseDao.listGridIdByPid(pid); + return new Result().ok(deptIdList); + } } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml index 60b2345ec..35ad9f915 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml @@ -35,4 +35,15 @@ ( SELECT * FROM sys_dept d WHERE d.pid = #{deptId} ) temp + + diff --git a/esua-epdc/epdc-auth/pom.xml b/esua-epdc/epdc-auth/pom.xml index fbff0aacd..053491122 100644 --- a/esua-epdc/epdc-auth/pom.xml +++ b/esua-epdc/epdc-auth/pom.xml @@ -23,6 +23,13 @@ epdc-admin-client 1.0.0 + + + com.esua.epdc + epdc-common-clienttoken + 1.0.0 + + org.springframework.boot spring-boot-starter-web diff --git a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java index 806c6d7cd..a2bebca12 100644 --- a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java +++ b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/controller/AuthController.java @@ -1,16 +1,16 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.elink.esua.epdc.controller; +import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.commons.tools.constant.Constant; import com.elink.esua.epdc.commons.tools.exception.ErrorCode; -import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; import com.elink.esua.epdc.commons.tools.security.user.UserDetail; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.commons.tools.validator.AssertUtils; @@ -40,7 +40,7 @@ import java.io.IOException; * @since 1.0.0 */ @RestController -@Api(tags="授权管理") +@Api(tags = "授权管理") public class AuthController { @Autowired private AuthService authService; @@ -50,9 +50,9 @@ public class AuthController { private CaptchaService captchaService; @GetMapping("captcha") - @ApiOperation(value = "验证码", produces="application/octet-stream") - @ApiImplicitParam(paramType = "query", dataType="string", name = "uuid", required = true) - public void captcha(HttpServletResponse response, String uuid)throws IOException { + @ApiOperation(value = "验证码", produces = "application/octet-stream") + @ApiImplicitParam(paramType = "query", dataType = "string", name = "uuid", required = true) + public void captcha(HttpServletResponse response, String uuid) throws IOException { //uuid不能为空 AssertUtils.isBlank(uuid, ErrorCode.IDENTIFIER_NOT_NULL); @@ -68,13 +68,13 @@ public class AuthController { @PostMapping(value = "login") @ApiOperation(value = "登录") - public Result login(@RequestBody LoginDTO login){ + public Result login(@RequestBody LoginDTO login) { //效验数据 ValidatorUtils.validateEntity(login); //验证码是否正确 boolean flag = captchaService.validate(login.getUuid(), login.getCaptcha()); - if(!flag){ + if (!flag) { return new Result().error(ErrorCode.CAPTCHA_ERROR); } @@ -86,7 +86,7 @@ public class AuthController { @PostMapping(value = "logout") @ApiOperation(value = "退出") - public Result logout(HttpServletRequest request){ + public Result logout(HttpServletRequest request) { String userId = request.getHeader(Constant.USER_KEY); authService.logout(Long.parseLong(userId)); @@ -96,27 +96,27 @@ public class AuthController { /** * 是否有资源访问权限 - * @param token token - * @param url 资源URL - * @param method 请求方式 * + * @param token token + * @param url 资源URL + * @param method 请求方式 * @return 有访问权限,则返回用户信息 */ @PostMapping("resource") public Result resource(@RequestParam(value = "token", required = false) String token, - @RequestParam("url") String url, @RequestParam("method") String method){ + @RequestParam("url") String url, @RequestParam("method") String method) { UserDetail data = resourceService.resource(token, url, method); return new Result().ok(data); } @GetMapping(value = "getLoginUserInfo") - public Result getLoginUserInfo(String token) { + public Result getLoginUserInfo(String token) { - CpUserDetail cpUserDetail = authService.getLoginUserInfo(token); + TokenDto cpUserDetail = authService.getLoginUserInfo(token); if (cpUserDetail != null) { - return new Result().ok(cpUserDetail); + return new Result().ok(cpUserDetail); } - return new Result().error(); + return new Result().error(); } } diff --git a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java index 1f500829c..48c57434c 100644 --- a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java +++ b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/AuthService.java @@ -1,14 +1,14 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.elink.esua.epdc.service; -import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; +import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.dto.AuthorizationDTO; import com.elink.esua.epdc.dto.LoginDTO; @@ -30,5 +30,5 @@ public interface AuthService { */ void logout(Long userId); - CpUserDetail getLoginUserInfo(String token); + TokenDto getLoginUserInfo(String token); } diff --git a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java index cd792001d..fa2f63e88 100644 --- a/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java +++ b/esua-epdc/epdc-auth/src/main/java/com/elink/esua/epdc/service/impl/AuthServiceImpl.java @@ -1,16 +1,15 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.elink.esua.epdc.service.impl; -import com.elink.esua.epdc.commons.tools.redis.CpUserDetailRedis; -import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; -import com.elink.esua.epdc.enums.UserStatusEnum; +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.common.token.util.CpUserDetailRedis; import com.elink.esua.epdc.commons.tools.exception.ErrorCode; import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.log.SysLogLogin; @@ -27,6 +26,7 @@ import com.elink.esua.epdc.commons.tools.utils.IpUtils; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.AuthorizationDTO; import com.elink.esua.epdc.dto.LoginDTO; +import com.elink.esua.epdc.enums.UserStatusEnum; import com.elink.esua.epdc.feign.UserFeignClient; import com.elink.esua.epdc.jwt.JwtProperties; import com.elink.esua.epdc.jwt.JwtUtils; @@ -78,7 +78,7 @@ public class AuthServiceImpl implements AuthService { log.setIp(IpUtils.getIpAddr(request)); //账号不存在 - if(user == null){ + if (user == null) { log.setStatus(LoginStatusEnum.FAIL.value()); log.setCreatorName(login.getUsername()); logProducer.saveLog(log); @@ -87,7 +87,7 @@ public class AuthServiceImpl implements AuthService { } //密码错误 - if(!PasswordUtils.matches(login.getPassword(), user.getPassword())){ + if (!PasswordUtils.matches(login.getPassword(), user.getPassword())) { log.setStatus(LoginStatusEnum.FAIL.value()); log.setCreator(user.getId()); log.setCreatorName(user.getUsername()); @@ -97,7 +97,7 @@ public class AuthServiceImpl implements AuthService { } //账号停用 - if(user.getStatus() == UserStatusEnum.DISABLE.value()){ + if (user.getStatus() == UserStatusEnum.DISABLE.value()) { log.setStatus(LoginStatusEnum.LOCK.value()); log.setCreator(user.getId()); log.setCreatorName(user.getUsername()); @@ -149,7 +149,7 @@ public class AuthServiceImpl implements AuthService { } @Override - public CpUserDetail getLoginUserInfo(String token) { + public TokenDto getLoginUserInfo(String token) { //是否过期 Claims claims = jwtUtils.getClaimByToken(token); if (claims == null || jwtUtils.isTokenExpired(claims.getExpiration())) { @@ -160,7 +160,7 @@ public class AuthServiceImpl implements AuthService { String userId = claims.getSubject(); //查询Redis,如果没数据,则保持用户信息到Redis - CpUserDetail cpUserDetail = cpUserDetailRedis.get(userId); + TokenDto cpUserDetail = cpUserDetailRedis.get(userId); if (cpUserDetail != null) { //过期时间 long expire = (claims.getExpiration().getTime() - System.currentTimeMillis()) / 1000; diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/pom.xml b/esua-epdc/epdc-commons/epdc-common-clienttoken/pom.xml new file mode 100644 index 000000000..dd4f4e01c --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/pom.xml @@ -0,0 +1,126 @@ + + + + + epdc-commons + com.esua.epdc + 1.0.0 + + 4.0.0 + + epdc-common-clienttoken + jar + + epdc-common-clienttoken + http://www.example.com + 客户端token + + + + com.esua.epdc + epdc-commons-tools + ${project.version} + + + + org.springframework.boot + spring-boot-starter-web + provided + + + + org.springframework.boot + spring-boot-starter-aop + provided + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + com.vaadin.external.google + android-json + + + + + + org.springframework.boot + spring-boot-autoconfigure + compile + + + + org.springframework.boot + spring-boot-autoconfigure-processor + compile + true + + + + org.springframework.boot + spring-boot-starter-log4j2 + provided + + + + io.jsonwebtoken + jjwt + 0.7.0 + + + + + ${project.artifactId} + + + + maven-clean-plugin + + + + maven-resources-plugin + + + maven-compiler-plugin + + true + ${maven.compiler.source} + ${maven.compiler.target} + ${project.build.sourceEncoding} + + + + maven-surefire-plugin + + + maven-war-plugin + + + maven-install-plugin + + + maven-deploy-plugin + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + + + + + + + ${project.basedir}/src/main/java + + diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/Login.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/Login.java new file mode 100644 index 000000000..9b622b179 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/Login.java @@ -0,0 +1,31 @@ +/** + * Copyright 2018 人人开源 http://www.renren.io + *

+ * 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.elink.esua.epdc.common.token.annotation; + +import java.lang.annotation.*; + +/** + * 登录效验 + * @author chenshun + * @email sunlightcs@gmail.com + * @date 2017/9/23 14:30 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Login { +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/LoginUser.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/LoginUser.java new file mode 100644 index 000000000..e19370c0e --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/LoginUser.java @@ -0,0 +1,35 @@ +/** + * Copyright 2018 人人开源 http://www.renren.io + *

+ * 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.elink.esua.epdc.common.token.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 登录用户信息 + * + * @author chenshun + * @email sunlightcs@gmail.com + * @date 2017-03-23 20:39 + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface LoginUser { + +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/NeedClientToken.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/NeedClientToken.java new file mode 100644 index 000000000..897a0048e --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/annotation/NeedClientToken.java @@ -0,0 +1,13 @@ +package com.elink.esua.epdc.common.token.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS)//生命注释保留时长,这里无需反射使用,使用CLASS级别 +@Target(ElementType.METHOD)//生命可以使用此注解的元素级别类型(如类、方法变量等) +public @interface NeedClientToken { + + boolean value() default true; +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/dto/TokenDto.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/dto/TokenDto.java new file mode 100644 index 000000000..fc5b1b155 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/dto/TokenDto.java @@ -0,0 +1,48 @@ +package com.elink.esua.epdc.common.token.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 用户token + * + * @author rongchao + * @Date 18-10-31 + */ +@Data +public class TokenDto implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 用户ID + */ + private String userId; + + /** + * 昵称 + */ + private String nickName; + + /** + * 用户头像 + */ + private String faceImg; + + /** + * 手机号 + */ + private String mobile; + + /** + * 真是姓名 + */ + private String realName; + + /** + * 网格ID + */ + private String gridId; +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/enums/ErrorCode.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/enums/ErrorCode.java new file mode 100644 index 000000000..711187292 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/enums/ErrorCode.java @@ -0,0 +1,46 @@ +package com.elink.esua.epdc.common.token.enums; + +import com.elink.esua.epdc.common.token.error.IErrorCode; + +/** + * client token错误码 + * + * @author rongchao + * @Date 18-11-24 + */ +public enum ErrorCode implements IErrorCode { + + SUCCESS(0, "请求成功"), + + ERR10001(10001, "clientToken不合法或者已过期"), + ERR10002(10002, "无法获取当前用户的信息,无法生成clientToken。"), + ERR10003(10003, "clientToken生成失败,请重试。"), + ERR10004(10004, "返回的Object类型不是EsuaResponse,无法添加token!"), + ERR10005(10005, "clentToken不能为空"), + + ERR500(500, "Internal Server Error"), + ERR501(501, "参数绑定异常"), + + ERR(ErrorCode.COMMON_ERR_CODE, "其他异常"); + + private int code; + + private String msg; + + ErrorCode(final int code, final String msg) { + this.code = code; + this.msg = msg; + } + + public static final int COMMON_ERR_CODE = -1; + + @Override + public int getCode() { + return code; + } + + @Override + public String getMsg() { + return msg; + } +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/error/IErrorCode.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/error/IErrorCode.java new file mode 100644 index 000000000..3d83f9fd2 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/error/IErrorCode.java @@ -0,0 +1,11 @@ +package com.elink.esua.epdc.common.token.error; + +/** + * @author rongchao + * @Date 18-11-20 + */ +public interface IErrorCode { + int getCode(); + + String getMsg(); +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/property/TokenPropertise.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/property/TokenPropertise.java new file mode 100644 index 000000000..352c03eb4 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/property/TokenPropertise.java @@ -0,0 +1,23 @@ +package com.elink.esua.epdc.common.token.property; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @author rongchao + * @Date 18-12-3 + */ +@Component +@ConfigurationProperties(prefix = "token") +public class TokenPropertise { + + private long expire = 7200L; + + public long getExpire() { + return expire; + } + + public void setExpire(long expire) { + this.expire = expire; + } +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/CpUserDetailRedis.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/CpUserDetailRedis.java new file mode 100644 index 000000000..6101c8f1f --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/CpUserDetailRedis.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.elink.esua.epdc.common.token.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.map.MapUtil; +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.redis.RedisKeys; +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * CP用户Redis + * + * @author rongchao + * @since 1.0.0 + */ +@Component +public class CpUserDetailRedis { + + @Autowired + private RedisUtils redisUtils; + + public void set(TokenDto user, long expire) { + if (user == null) { + return; + } + String key = RedisKeys.getCpUserKey(user.getUserId()); + //bean to map + Map map = BeanUtil.beanToMap(user, false, true); + redisUtils.hMSet(key, map, expire); + } + + /** + * 获取token信息 + * + * @param userId + * @return + */ + public TokenDto get(String userId) { + String key = RedisKeys.getCpUserKey(userId); + + Map map = redisUtils.hGetAll(key); + if (MapUtil.isEmpty(map)) { + return null; + } + + //map to bean + TokenDto user = BeanUtil.mapToBean(map, TokenDto.class, true); + + return user; + } + + /** + * 删除用户信息 + * + * @param userId + */ + public void logout(String userId) { + redisUtils.delete(RedisKeys.getCpUserKey(userId)); + } + + /** + * 设置redis时间 + * + * @param userId + * @param expire + * @author rongchao + */ + public boolean expire(String userId, long expire) { + return redisUtils.expire(RedisKeys.getCpUserKey(userId), expire); + } +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/TokenUtil.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/TokenUtil.java new file mode 100644 index 000000000..ba8a32beb --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/TokenUtil.java @@ -0,0 +1,39 @@ +package com.elink.esua.epdc.common.token.util; + +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.common.token.property.TokenPropertise; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * token服务类 + * + * @author rongchao + * @Date 18-10-31 + */ +@Component +public class TokenUtil { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private TokenPropertise tokenPropertise; + + @Autowired + private CpUserDetailRedis redisUtils; + + public TokenDto getTokenInfo(String userId) { + TokenDto tokenDto = redisUtils.get(userId); + return tokenDto; + } + + public void expireToken(String userId) { + redisUtils.logout(userId); + } + + public boolean delayToken(String token) { + return redisUtils.expire(token, tokenPropertise.getExpire()); + } +} diff --git a/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/UserUtil.java b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/UserUtil.java new file mode 100644 index 000000000..2e09b381f --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/UserUtil.java @@ -0,0 +1,55 @@ +package com.elink.esua.epdc.common.token.util; + +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.commons.tools.constant.Constant; +import com.elink.esua.epdc.commons.tools.utils.WebUtil; + +/** + * 用户工具类 + * + * @author rongchao + * @Date 18-11-20 + */ +public class UserUtil { + + /** + * 获取当前用户信息 + * + * @return + */ + public static TokenDto getCurrentUser() { + return (TokenDto) WebUtil.getAttributesFromRequest(Constant.APP_USER_KEY); + } + + /** + * 获取当前用户信息 + * + * @return com.elink.esua.common.token.dto.UserTokenDto + * @author yujintao + * @date 2018/12/5 9:24 + */ + public static TokenDto getCurrentUserInfo() { + TokenDto tokenDto = getCurrentUser(); + if (tokenDto == null) { + return null; + } + return tokenDto; + } + + /** + * 获取当前用户ID + * + * @return + */ + public static String getCurrentUserId() { + TokenDto tokenDto = getCurrentUser(); + if (tokenDto == null) { + return null; + } + return tokenDto.getUserId(); + } + + public static void setCurrentUser(TokenDto user) { + WebUtil.setAttributesFromRequest(Constant.APP_USER_KEY, user); + } +} diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/YesOrNoEnum.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/YesOrNoEnum.java index 4135959dc..ca35dc490 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/YesOrNoEnum.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/YesOrNoEnum.java @@ -18,19 +18,19 @@ public enum YesOrNoEnum { /** * 是 */ - YES(1), + YES("1"), /** * 否 */ - NO(0); + NO("0"); - private int value; + private String value; - YesOrNoEnum(int value) { + YesOrNoEnum(String value) { this.value = value; } - public int value() { + public String value() { return this.value; } } diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/CpUserDetailRedis.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/CpUserDetailRedis.java deleted file mode 100644 index 6ba73d60b..000000000 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/CpUserDetailRedis.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - *

- * https://www.renren.io - *

- * 版权所有,侵权必究! - */ - -package com.elink.esua.epdc.commons.tools.redis; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.map.MapUtil; -import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * CP用户Redis - * - * @author rongchao - * @since 1.0.0 - */ -@Component -public class CpUserDetailRedis { - - @Autowired - private RedisUtils redisUtils; - - public void set(CpUserDetail user, long expire) { - if (user == null) { - return; - } - String key = RedisKeys.getCpUserKey(user.getId()); - //bean to map - Map map = BeanUtil.beanToMap(user, false, true); - redisUtils.hMSet(key, map, expire); - } - - public CpUserDetail get(String id) { - String key = RedisKeys.getCpUserKey(id); - - Map map = redisUtils.hGetAll(key); - if (MapUtil.isEmpty(map)) { - return null; - } - - //map to bean - CpUserDetail user = BeanUtil.mapToBean(map, CpUserDetail.class, true); - - return user; - } - - /** - * 用户退出 - * - * @param id - */ - public void logout(String id) { - redisUtils.delete(RedisKeys.getCpUserKey(id)); - } -} \ No newline at end of file diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java index 494c8c448..8e0b10c1d 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisKeys.java @@ -14,64 +14,69 @@ package com.elink.esua.epdc.commons.tools.redis; */ public class RedisKeys { + /** + * 党建redis前缀 + */ + private static String rootPrefix = "epdc:"; + /** * 系统参数Key */ public static String getSysParamsKey() { - return "sys:params"; + return rootPrefix.concat("sys:params"); } /** * 登录验证码Key */ public static String getLoginCaptchaKey(String uuid) { - return "sys:captcha:" + uuid; + return rootPrefix.concat("sys:captcha:").concat(uuid); } /** * 登录用户Key */ public static String getSecurityUserKey(Long id) { - return "sys:security:user:" + id; + return rootPrefix.concat("sys:security:user:").concat(String.valueOf(id)); } /** * 系统日志Key */ public static String getSysLogKey() { - return "sys:log"; + return rootPrefix.concat("sys:log"); } /** * 系统资源Key */ public static String getSysResourceKey() { - return "sys:resource"; + return rootPrefix.concat("sys:resource"); } /** * 用户菜单导航Key */ public static String getUserMenuNavKey(Long userId, String language) { - return "sys:user:nav:" + userId + "_" + language; + return rootPrefix.concat("sys:user:nav:").concat(String.valueOf(userId)).concat("_").concat(language); } /** * 用户菜单导航Key */ public static String getUserMenuNavKey(Long userId) { - return "sys:user:nav:" + userId + "_*"; + return rootPrefix.concat("sys:user:nav:").concat(String.valueOf(userId)).concat("_*"); } /** * 用户权限标识Key */ public static String getUserPermissionsKey(Long userId) { - return "sys:user:permissions:" + userId; + return rootPrefix.concat("sys:user:permissions:").concat(String.valueOf(userId)); } public static String getCpUserKey(String id) { - return "sys:security:cpuser:" + id; + return rootPrefix.concat("sys:security:cpuser:").concat(id); } /** @@ -83,7 +88,7 @@ public class RedisKeys { * @date 2019/9/3 16:28 */ public static String getSimpleAreaKey(String areaId) { - return "epdc:config:simple:area:" + areaId; + return rootPrefix.concat("config:simple:area:").concat(areaId); } /** @@ -95,6 +100,6 @@ public class RedisKeys { * @date 2019/9/3 16:28 */ public static String getSimpleDictKey(String dictType) { - return "epdc:config:simple:dict:" + dictType; + return rootPrefix.concat("config:simple:dict:").concat(dictType); } } diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisUtils.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisUtils.java index f0724efaa..e09629633 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisUtils.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/redis/RedisUtils.java @@ -1,8 +1,8 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ @@ -38,20 +38,20 @@ public class RedisUtils { /** 不设置过期时长 */ public final static long NOT_EXPIRE = -1L; - public void set(String key, Object value, long expire){ + public void set(String key, Object value, long expire) { redisTemplate.opsForValue().set(key, value); - if(expire != NOT_EXPIRE){ + if (expire != NOT_EXPIRE) { expire(key, expire); } } - public void set(String key, Object value){ + public void set(String key, Object value) { set(key, value, DEFAULT_EXPIRE); } public Object get(String key, long expire) { Object value = redisTemplate.opsForValue().get(key); - if(expire != NOT_EXPIRE){ + if (expire != NOT_EXPIRE) { expire(key, expire); } return value; @@ -61,7 +61,7 @@ public class RedisUtils { return get(key, NOT_EXPIRE); } - public Set keys(String pattern){ + public Set keys(String pattern) { return redisTemplate.keys(pattern); } @@ -81,19 +81,19 @@ public class RedisUtils { return redisTemplate.opsForHash().get(key, field); } - public Map hGetAll(String key){ + public Map hGetAll(String key) { HashOperations hashOperations = redisTemplate.opsForHash(); return hashOperations.entries(key); } - public void hMSet(String key, Map map){ + public void hMSet(String key, Map map) { hMSet(key, map, DEFAULT_EXPIRE); } - public void hMSet(String key, Map map, long expire){ + public void hMSet(String key, Map map, long expire) { redisTemplate.opsForHash().putAll(key, map); - if(expire != NOT_EXPIRE){ + if (expire != NOT_EXPIRE) { expire(key, expire); } } @@ -105,32 +105,32 @@ public class RedisUtils { public void hSet(String key, String field, Object value, long expire) { redisTemplate.opsForHash().put(key, field, value); - if(expire != NOT_EXPIRE){ + if (expire != NOT_EXPIRE) { expire(key, expire); } } - public void expire(String key, long expire){ - redisTemplate.expire(key, expire, TimeUnit.SECONDS); + public boolean expire(String key, long expire) { + return redisTemplate.expire(key, expire, TimeUnit.SECONDS); } - public void hDel(String key, Object... fields){ + public void hDel(String key, Object... fields) { redisTemplate.opsForHash().delete(key, fields); } - public void leftPush(String key, Object value){ + public void leftPush(String key, Object value) { leftPush(key, value, DEFAULT_EXPIRE); } - public void leftPush(String key, Object value, long expire){ + public void leftPush(String key, Object value, long expire) { redisTemplate.opsForList().leftPush(key, value); - if(expire != NOT_EXPIRE){ + if (expire != NOT_EXPIRE) { expire(key, expire); } } - public Object rightPop(String key){ + public Object rightPop(String key) { return redisTemplate.opsForList().rightPop(key); } } diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ModuleUtils.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ModuleUtils.java new file mode 100644 index 000000000..b47948dc7 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ModuleUtils.java @@ -0,0 +1,45 @@ +package com.elink.esua.epdc.commons.tools.utils; + +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; + +import java.util.UUID; + +/** + * 工具类 + * + * @author yujintao + * @email yujintao@elink-cn.com + * @date 2019/9/5 14:44 + */ +@Slf4j +public class ModuleUtils { + + /** + * feignclient降级处理错误返回 + * + * @param errorMsg 保存信息 + * @param methodName 方法名,打印到日志文件 + * @param params 参数,打印的日志文件 + * @return com.elink.esua.commons.tools.utils.Result + * @author yujintao + * @date 2019/9/5 14:44 + */ + public static Result feignConError(String errorMsg, String methodName, Object... params) { + String msg = errorMsg + "调用方法->{},参数->{}"; + log.error(msg, methodName, JSONObject.toJSONString(params)); + return new Result().error(errorMsg); + } + + /** + * 生成uuid + * + * @return java.lang.String + * @author yujintao + * @date 2019/9/5 14:44 + */ + public static String generateUUID() { + return UUID.randomUUID().toString().replace("-", ""); + } + +} diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/WebUtil.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/WebUtil.java new file mode 100644 index 000000000..5cf6c89cc --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/WebUtil.java @@ -0,0 +1,66 @@ +package com.elink.esua.epdc.commons.tools.utils; + +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * Web工具类 + * + * @author rongchao + * @Date 18-11-20 + */ +public class WebUtil { + + public static HttpServletRequest getHttpServletRequest() { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletRequest request = requestAttributes.getRequest(); + return request; + } + + public static Object getAttributesFromRequest(String paramName) { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + return requestAttributes.getAttribute(paramName, RequestAttributes.SCOPE_REQUEST); + } + + public static void setAttributesFromRequest(String paramName, Object obj) { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + requestAttributes.setAttribute(paramName, obj, RequestAttributes.SCOPE_REQUEST); + } + + /** + * 获取用户真实IP地址,不使用request.getRemoteAddr();的原因是有可能用户使用了代理软件方式避免真实IP地址, + *

+ * 可是,如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值,究竟哪个才是真正的用户端的真实IP呢? + * 答案是取X-Forwarded-For中第一个非unknown的有效IP字符串。 + *

+ * 如:X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, + * 192.168.1.100 + *

+ * 用户真实IP为: 192.168.1.110 + * + * @return + */ + public static String getIpAddress() { + HttpServletRequest request = getHttpServletRequest(); + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + return ip; + } +} diff --git a/esua-epdc/epdc-commons/epdc-wx/.editorconfig b/esua-epdc/epdc-commons/epdc-wx/.editorconfig new file mode 100644 index 000000000..775be5ba0 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/.editorconfig @@ -0,0 +1,14 @@ +# EditorConfig: http://editorconfig.org/ + +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/esua-epdc/epdc-commons/epdc-wx/.travis.yml b/esua-epdc/epdc-commons/epdc-wx/.travis.yml new file mode 100644 index 000000000..5d2a7698b --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/.travis.yml @@ -0,0 +1,13 @@ +language: java +jdk: + - openjdk8 + +script: "mvn clean package -Dmaven.test.skip=true" + +branches: + only: + - master + +notifications: + email: + - binarywang@vip.qq.com diff --git a/esua-epdc/epdc-commons/epdc-wx/README.md b/esua-epdc/epdc-commons/epdc-wx/README.md new file mode 100644 index 000000000..790d56ba1 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/README.md @@ -0,0 +1,58 @@ +[![码云Gitee](https://gitee.com/binary/weixin-java-mp-demo-springboot/badge/star.svg?theme=blue)](https://gitee.com/binary/weixin-java-mp-demo-springboot) +[![Github](http://github-svg-buttons.herokuapp.com/star.svg?user=binarywang&repo=weixin-java-mp-demo-springboot&style=flat&background=1081C1)](https://github.com/binarywang/weixin-java-mp-demo-springboot) +[![Build Status](https://travis-ci.org/binarywang/weixin-java-mp-demo-springboot.svg?branch=master)](https://travis-ci.org/binarywang/weixin-java-mp-demo-springboot) +----------------------- + +### 本Demo基于Spring Boot构建,实现微信公众号后端开发功能。 +### 本项目为WxJava的Demo演示程序,更多Demo请[查阅此处](https://github.com/Wechat-Group/WxJava/blob/master/demo.md)。 +#### 如有问题请[【在此提问】](https://github.com/binarywang/weixin-java-mp-demo-springboot/issues),谢谢配合。 + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +## 使用步骤: +1. 请注意,本demo为简化代码编译时加入了lombok支持,如果不了解lombok的话,请先学习下相关知识,比如可以阅读[此文章](https://mp.weixin.qq.com/s/cUc-bUcprycADfNepnSwZQ); +1. 另外,新手遇到问题,请务必先阅读[【开发文档首页】](https://github.com/Wechat-Group/WxJava/wiki)的常见问题部分,可以少走很多弯路,节省不少时间。 +1. 配置:复制 `/src/main/resources/application.yml.template` 或修改其扩展名生成 `application.yml` 文件,根据自己需要填写相关配置(需要注意的是:yml文件内的属性冒号后面的文字之前需要加空格,可参考已有配置,否则属性会设置不成功); +2. 主要配置说明如下: +``` +wx: + mp: + configs: + - appId: 1111 (一个公众号的appid) + secret: 1111(公众号的appsecret) + token: 111 (接口配置里的Token值) + aesKey: 111 (接口配置里的EncodingAESKey值) + - appId: 2222 (另一个公众号的appid,以下同上) + secret: 1111 + token: 111 + aesKey: 111 +``` +3. 运行Java程序:`WxMpDemoApplication`; +4. 配置微信公众号中的接口地址:http://公网可访问域名/wx/portal/xxxxx (注意,xxxxx为对应公众号的appid值); +5. 根据自己需要修改各个handler的实现,加入自己的业务逻辑。 + diff --git a/esua-epdc/epdc-commons/epdc-wx/pom.xml b/esua-epdc/epdc-commons/epdc-wx/pom.xml new file mode 100644 index 000000000..081d0e49c --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + + com.esua.epdc + epdc-commons + 1.0.0 + + + 1.0.0 + epdc-wx + jar + + Wechat mp demo with Spring Boot and WxJava + 基于 WxJava 和 Spring Boot 实现的微信公众号后端开发演示项目 + + + 3.5.0 + + 1.8 + 1.8 + UTF-8 + UTF-8 + zh_CN + wechat-mp-demo + + + + + com.github.binarywang + weixin-java-mp + ${weixin-java-mp.version} + + + + org.projectlombok + lombok + provided + + + + org.springframework.boot + spring-boot-autoconfigure + compile + + + org.springframework.boot + spring-boot-configuration-processor + compile + true + + + org.springframework.boot + spring-boot-autoconfigure-processor + compile + true + + + diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/AbstractBuilder.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/AbstractBuilder.java new file mode 100644 index 000000000..dc270da56 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/AbstractBuilder.java @@ -0,0 +1,17 @@ +package com.elink.esua.epdc.wx.mp.builder; + +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public abstract class AbstractBuilder { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + + public abstract WxMpXmlOutMessage build(String content, + WxMpXmlMessage wxMessage, WxMpService service); +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/ImageBuilder.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/ImageBuilder.java new file mode 100644 index 000000000..8daf22d2c --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/ImageBuilder.java @@ -0,0 +1,24 @@ +package com.elink.esua.epdc.wx.mp.builder; + +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutImageMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public class ImageBuilder extends AbstractBuilder { + + @Override + public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, + WxMpService service) { + + WxMpXmlOutImageMessage m = WxMpXmlOutMessage.IMAGE().mediaId(content) + .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) + .build(); + + return m; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/TextBuilder.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/TextBuilder.java new file mode 100644 index 000000000..93ea48018 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/builder/TextBuilder.java @@ -0,0 +1,22 @@ +package com.elink.esua.epdc.wx.mp.builder; + +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutTextMessage; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public class TextBuilder extends AbstractBuilder { + + @Override + public WxMpXmlOutMessage build(String content, WxMpXmlMessage wxMessage, + WxMpService service) { + WxMpXmlOutTextMessage m = WxMpXmlOutMessage.TEXT().content(content) + .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) + .build(); + return m; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/config/WxMpConfiguration.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/config/WxMpConfiguration.java new file mode 100644 index 000000000..59a027c9d --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/config/WxMpConfiguration.java @@ -0,0 +1,113 @@ +package com.elink.esua.epdc.wx.mp.config; + +import com.elink.esua.epdc.wx.mp.handler.*; +import lombok.AllArgsConstructor; +import me.chanjar.weixin.mp.api.WxMpMessageRouter; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; +import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.List; +import java.util.stream.Collectors; + +import static me.chanjar.weixin.common.api.WxConsts.EventType; +import static me.chanjar.weixin.common.api.WxConsts.EventType.SUBSCRIBE; +import static me.chanjar.weixin.common.api.WxConsts.EventType.UNSUBSCRIBE; +import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType.CLICK; +import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType.VIEW; +import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType; +import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType.EVENT; +import static me.chanjar.weixin.mp.constant.WxMpEventConstants.CustomerService.*; +import static me.chanjar.weixin.mp.constant.WxMpEventConstants.POI_CHECK_NOTIFY; + +/** + * wechat mp configuration + * + * @author Binary Wang(https://github.com/binarywang) + */ +@AllArgsConstructor +@Configuration +@EnableConfigurationProperties(WxMpProperties.class) +public class WxMpConfiguration { + private final LogHandler logHandler; + private final NullHandler nullHandler; + private final KfSessionHandler kfSessionHandler; + private final StoreCheckNotifyHandler storeCheckNotifyHandler; + private final LocationHandler locationHandler; + private final MenuHandler menuHandler; + private final MsgHandler msgHandler; + private final UnsubscribeHandler unsubscribeHandler; + private final SubscribeHandler subscribeHandler; + private final ScanHandler scanHandler; + private final WxMpProperties properties; + + @Bean + public WxMpService wxMpService() { + // 代码里 getConfigs()处报错的同学,请注意仔细阅读项目说明,你的IDE需要引入lombok插件!!!! + final List configs = this.properties.getConfigs(); + if (configs == null) { + throw new RuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!"); + } + + WxMpService service = new WxMpServiceImpl(); + service.setMultiConfigStorages(configs + .stream().map(a -> { + WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl(); + configStorage.setAppId(a.getAppId()); + configStorage.setSecret(a.getSecret()); + configStorage.setToken(a.getToken()); + configStorage.setAesKey(a.getAesKey()); + return configStorage; + }).collect(Collectors.toMap(WxMpDefaultConfigImpl::getAppId, a -> a, (o, n) -> o))); + return service; + } + + @Bean + public WxMpMessageRouter messageRouter(WxMpService wxMpService) { + final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService); + + // 记录所有事件的日志 (异步执行) + newRouter.rule().handler(this.logHandler).next(); + + // 接收客服会话管理事件 + newRouter.rule().async(false).msgType(EVENT).event(KF_CREATE_SESSION) + .handler(this.kfSessionHandler).end(); + newRouter.rule().async(false).msgType(EVENT).event(KF_CLOSE_SESSION) + .handler(this.kfSessionHandler).end(); + newRouter.rule().async(false).msgType(EVENT).event(KF_SWITCH_SESSION) + .handler(this.kfSessionHandler).end(); + + // 门店审核事件 + newRouter.rule().async(false).msgType(EVENT).event(POI_CHECK_NOTIFY).handler(this.storeCheckNotifyHandler).end(); + + // 自定义菜单事件 + newRouter.rule().async(false).msgType(EVENT).event(CLICK).handler(this.menuHandler).end(); + + // 点击菜单连接事件 + newRouter.rule().async(false).msgType(EVENT).event(VIEW).handler(this.nullHandler).end(); + + // 关注事件 + newRouter.rule().async(false).msgType(EVENT).event(SUBSCRIBE).handler(this.subscribeHandler).end(); + + // 取消关注事件 + newRouter.rule().async(false).msgType(EVENT).event(UNSUBSCRIBE).handler(this.unsubscribeHandler).end(); + + // 上报地理位置事件 + newRouter.rule().async(false).msgType(EVENT).event(EventType.LOCATION).handler(this.locationHandler).end(); + + // 接收地理位置消息 + newRouter.rule().async(false).msgType(XmlMsgType.LOCATION).handler(this.locationHandler).end(); + + // 扫码事件 + newRouter.rule().async(false).msgType(EVENT).event(EventType.SCAN).handler(this.scanHandler).end(); + + // 默认 + newRouter.rule().async(false).handler(this.msgHandler).end(); + + return newRouter; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/config/WxMpProperties.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/config/WxMpProperties.java new file mode 100644 index 000000000..6a1aa5947 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/config/WxMpProperties.java @@ -0,0 +1,46 @@ +package com.elink.esua.epdc.wx.mp.config; + +import com.elink.esua.epdc.wx.mp.utils.JsonUtils; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.List; + +/** + * wechat mp properties + * + * @author Binary Wang(https://github.com/binarywang) + */ +@Data +@ConfigurationProperties(prefix = "wx.mp") +public class WxMpProperties { + private List configs; + + @Data + public static class MpConfig { + /** + * 设置微信公众号的appid + */ + private String appId; + + /** + * 设置微信公众号的app secret + */ + private String secret; + + /** + * 设置微信公众号的token + */ + private String token; + + /** + * 设置微信公众号的EncodingAESKey + */ + private String aesKey; + } + + @Override + public String toString() { + return JsonUtils.toJson(this); + } +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/AbstractHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/AbstractHandler.java new file mode 100644 index 000000000..b3a89e72b --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/AbstractHandler.java @@ -0,0 +1,12 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import me.chanjar.weixin.mp.api.WxMpMessageHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public abstract class AbstractHandler implements WxMpMessageHandler { + protected Logger logger = LoggerFactory.getLogger(getClass()); +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/KfSessionHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/KfSessionHandler.java new file mode 100644 index 000000000..46df4a7a2 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/KfSessionHandler.java @@ -0,0 +1,25 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class KfSessionHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService wxMpService, + WxSessionManager sessionManager) { + //TODO 对会话做处理 + return null; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/LocationHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/LocationHandler.java new file mode 100644 index 000000000..9089a15a2 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/LocationHandler.java @@ -0,0 +1,44 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import com.elink.esua.epdc.wx.mp.builder.TextBuilder; +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.stereotype.Component; + +import java.util.Map; + +import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class LocationHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService wxMpService, + WxSessionManager sessionManager) { + if (wxMessage.getMsgType().equals(XmlMsgType.LOCATION)) { + //TODO 接收处理用户发送的地理位置消息 + try { + String content = "感谢反馈,您的的地理位置已收到!"; + return new TextBuilder().build(content, wxMessage, null); + } catch (Exception e) { + this.logger.error("位置消息接收处理失败", e); + return null; + } + } + + //上报地理位置事件 + this.logger.info("上报地理位置,纬度 : {},经度 : {},精度 : {}", + wxMessage.getLatitude(), wxMessage.getLongitude(), String.valueOf(wxMessage.getPrecision())); + + //TODO 可以将用户地理位置信息保存到本地数据库,以便以后使用 + + return null; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/LogHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/LogHandler.java new file mode 100644 index 000000000..1ff3ec3de --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/LogHandler.java @@ -0,0 +1,25 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import com.elink.esua.epdc.wx.mp.utils.JsonUtils; +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class LogHandler extends AbstractHandler { + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService wxMpService, + WxSessionManager sessionManager) { + this.logger.info("\n接收到请求消息,内容:{}", JsonUtils.toJson(wxMessage)); + return null; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/MenuHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/MenuHandler.java new file mode 100644 index 000000000..249d87e3c --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/MenuHandler.java @@ -0,0 +1,36 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.stereotype.Component; + +import java.util.Map; + +import static me.chanjar.weixin.common.api.WxConsts.MenuButtonType; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class MenuHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService weixinService, + WxSessionManager sessionManager) { + + String msg = String.format("type:%s, event:%s, key:%s", + wxMessage.getMsgType(), wxMessage.getEvent(), + wxMessage.getEventKey()); + if (MenuButtonType.VIEW.equals(wxMessage.getEvent())) { + return null; + } + + return WxMpXmlOutMessage.TEXT().content(msg) + .fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()) + .build(); + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/MsgHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/MsgHandler.java new file mode 100644 index 000000000..21f8b48b2 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/MsgHandler.java @@ -0,0 +1,52 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import com.elink.esua.epdc.wx.mp.builder.TextBuilder; +import com.elink.esua.epdc.wx.mp.utils.JsonUtils; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.Map; + +import static me.chanjar.weixin.common.api.WxConsts.XmlMsgType; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class MsgHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService weixinService, + WxSessionManager sessionManager) { + + if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) { + //TODO 可以选择将消息保存到本地 + } + + //当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服 + try { + if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服") + && weixinService.getKefuService().kfOnlineList() + .getKfOnlineList().size() > 0) { + return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE() + .fromUser(wxMessage.getToUser()) + .toUser(wxMessage.getFromUser()).build(); + } + } catch (WxErrorException e) { + e.printStackTrace(); + } + + //TODO 组装回复消息 + String content = "收到信息内容:" + JsonUtils.toJson(wxMessage); + + return new TextBuilder().build(content, wxMessage, weixinService); + + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/NullHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/NullHandler.java new file mode 100644 index 000000000..f76290842 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/NullHandler.java @@ -0,0 +1,24 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class NullHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService wxMpService, + WxSessionManager sessionManager) { + return null; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/ScanHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/ScanHandler.java new file mode 100644 index 000000000..407f94676 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/ScanHandler.java @@ -0,0 +1,25 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import java.util.Map; + +import org.springframework.stereotype.Component; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class ScanHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map map, + WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException { + // 扫码事件处理 + return null; + } +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/StoreCheckNotifyHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/StoreCheckNotifyHandler.java new file mode 100644 index 000000000..cd1cd25ed --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/StoreCheckNotifyHandler.java @@ -0,0 +1,27 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * 门店审核事件处理 + * + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class StoreCheckNotifyHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService wxMpService, + WxSessionManager sessionManager) { + // TODO 处理门店审核事件 + return null; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/SubscribeHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/SubscribeHandler.java new file mode 100644 index 000000000..88aac68bd --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/SubscribeHandler.java @@ -0,0 +1,71 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import java.util.Map; + +import com.elink.esua.epdc.wx.mp.builder.TextBuilder; +import org.springframework.stereotype.Component; + +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import me.chanjar.weixin.mp.bean.result.WxMpUser; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class SubscribeHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService weixinService, + WxSessionManager sessionManager) throws WxErrorException { + + this.logger.info("新关注用户 OPENID: " + wxMessage.getFromUser()); + + // 获取微信用户基本信息 + try { + WxMpUser userWxInfo = weixinService.getUserService() + .userInfo(wxMessage.getFromUser(), null); + if (userWxInfo != null) { + // TODO 可以添加关注用户到本地数据库 + } + } catch (WxErrorException e) { + if (e.getError().getErrorCode() == 48001) { + this.logger.info("该公众号没有获取用户信息权限!"); + } + } + + + WxMpXmlOutMessage responseResult = null; + try { + responseResult = this.handleSpecial(wxMessage); + } catch (Exception e) { + this.logger.error(e.getMessage(), e); + } + + if (responseResult != null) { + return responseResult; + } + + try { + return new TextBuilder().build("感谢关注", wxMessage, weixinService); + } catch (Exception e) { + this.logger.error(e.getMessage(), e); + } + + return null; + } + + /** + * 处理特殊请求,比如如果是扫码进来的,可以做相应处理 + */ + private WxMpXmlOutMessage handleSpecial(WxMpXmlMessage wxMessage) + throws Exception { + //TODO + return null; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/UnsubscribeHandler.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/UnsubscribeHandler.java new file mode 100644 index 000000000..4a4723d45 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/handler/UnsubscribeHandler.java @@ -0,0 +1,27 @@ +package com.elink.esua.epdc.wx.mp.handler; + +import me.chanjar.weixin.common.session.WxSessionManager; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; +import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +@Component +public class UnsubscribeHandler extends AbstractHandler { + + @Override + public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, + Map context, WxMpService wxMpService, + WxSessionManager sessionManager) { + String openId = wxMessage.getFromUser(); + this.logger.info("取消关注用户 OPENID: " + openId); + // TODO 可以更新本地数据库为取消关注状态 + return null; + } + +} diff --git a/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/utils/JsonUtils.java b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/utils/JsonUtils.java new file mode 100644 index 000000000..0c88b1568 --- /dev/null +++ b/esua-epdc/epdc-commons/epdc-wx/src/main/java/com/elink/esua/epdc/wx/mp/utils/JsonUtils.java @@ -0,0 +1,16 @@ +package com.elink.esua.epdc.wx.mp.utils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * @author Binary Wang(https://github.com/binarywang) + */ +public class JsonUtils { + public static String toJson(Object obj) { + Gson gson = new GsonBuilder() + .setPrettyPrinting() + .create(); + return gson.toJson(obj); + } +} diff --git a/esua-epdc/epdc-commons/pom.xml b/esua-epdc/epdc-commons/pom.xml index 9709e2771..3eb744925 100644 --- a/esua-epdc/epdc-commons/pom.xml +++ b/esua-epdc/epdc-commons/pom.xml @@ -9,7 +9,6 @@ 1.0.0 - com.esua.epdc epdc-commons pom @@ -19,5 +18,7 @@ epdc-commons-dynamic-datasource epdc-commons-api-version-control epdc-commons-tools-phone + epdc-wx + epdc-common-clienttoken diff --git a/esua-epdc/epdc-gateway/pom.xml b/esua-epdc/epdc-gateway/pom.xml index b75f10e3b..b1f5a18f7 100644 --- a/esua-epdc/epdc-gateway/pom.xml +++ b/esua-epdc/epdc-gateway/pom.xml @@ -40,6 +40,18 @@ org.springframework.cloud spring-cloud-starter-zipkin + + com.esua.epdc + epdc-common-clienttoken + 1.0.0 + compile + + + + com.esua.epdc + epdc-common-clienttoken + 1.0.0 + @@ -81,25 +93,29 @@ lb://epdc-auth-server lb://epdc-admin-server - - lb://epdc-activiti-server + + lb://epdc-activiti-server + lb://epdc-api-server lb://epdc-app-server - + lb://epdc-heart-server - + lb://epdc-job-server - - lb://epdc-message-server - lb://epdc-neighbor-server - + + lb://epdc-message-server + + lb://epdc-neighbor-server + + http://127.0.0.1:9064 lb://epdc-oss-server lb://epdc-events-server - - lb://epdc-services-server - + + lb://epdc-services-server + + http://127.0.0.1:9068 lb://epdc-demo-server @@ -124,17 +140,21 @@ lb://epdc-auth-server lb://epdc-admin-server - lb://epdc-activiti-server + lb://epdc-activiti-server + lb://epdc-api-server lb://epdc-app-server lb://epdc-heart-server lb://epdc-job-server - lb://epdc-message-server - lb://epdc-neighbor-server + lb://epdc-message-server + + lb://epdc-neighbor-server + lb://epdc-news-server lb://epdc-oss-server lb://epdc-events-server - lb://epdc-services-server + lb://epdc-services-server + lb://epdc-user-server lb://epdc-demo-server @@ -159,17 +179,21 @@ lb://epdc-auth-server lb://epdc-admin-server - lb://epdc-activiti-server + lb://epdc-activiti-server + lb://epdc-api-server lb://epdc-app-server lb://epdc-heart-server lb://epdc-job-server - lb://epdc-message-server - lb://epdc-neighbor-server + lb://epdc-message-server + + lb://epdc-neighbor-server + lb://epdc-news-server lb://epdc-oss-server lb://epdc-events-server - lb://epdc-services-server + lb://epdc-services-server + lb://epdc-user-server lb://epdc-demo-server diff --git a/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/ResourceFeignClient.java b/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/ResourceFeignClient.java index 68f229806..b52b556f8 100644 --- a/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/ResourceFeignClient.java +++ b/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/ResourceFeignClient.java @@ -8,7 +8,7 @@ package com.elink.esua.epdc.feign; -import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; +import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.feign.fallback.ResourceFeignClientFallback; import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; import com.elink.esua.epdc.commons.tools.security.user.UserDetail; @@ -50,5 +50,5 @@ public interface ResourceFeignClient { * @date 2019/8/19 17:19 */ @GetMapping("auth/getLoginUserInfo") - Result getLoginUserInfo(@RequestParam("token") String token); + Result getLoginUserInfo(@RequestParam("token") String token); } diff --git a/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/fallback/ResourceFeignClientFallback.java b/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/fallback/ResourceFeignClientFallback.java index da14350a3..987d2ff79 100644 --- a/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/fallback/ResourceFeignClientFallback.java +++ b/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/feign/fallback/ResourceFeignClientFallback.java @@ -1,14 +1,14 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.elink.esua.epdc.feign.fallback; -import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; +import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.commons.tools.security.user.UserDetail; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.feign.ResourceFeignClient; @@ -29,7 +29,7 @@ public class ResourceFeignClientFallback implements ResourceFeignClient { } @Override - public Result getLoginUserInfo(String token) { - return new Result().error(); + public Result getLoginUserInfo(String token) { + return new Result().error(); } } diff --git a/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/filter/CpAuthGatewayFilterFactory.java b/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/filter/CpAuthGatewayFilterFactory.java index babf5a4ce..b264baa24 100644 --- a/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/filter/CpAuthGatewayFilterFactory.java +++ b/esua-epdc/epdc-gateway/src/main/java/com/elink/esua/epdc/filter/CpAuthGatewayFilterFactory.java @@ -2,8 +2,8 @@ package com.elink.esua.epdc.filter; import com.alibaba.fastjson.JSON; +import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.commons.tools.constant.Constant; -import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.feign.ResourceFeignClient; import org.springframework.beans.factory.annotation.Autowired; @@ -70,14 +70,14 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory result = resourceFeignClient.getLoginUserInfo(token); + Result result = resourceFeignClient.getLoginUserInfo(token); if (!result.success()) { return response(exchange, result); } - CpUserDetail user = result.getData(); + TokenDto user = result.getData(); //当前登录用户userId,添加到header中 if (user != null) { - ServerHttpRequest build = exchange.getRequest().mutate().header(Constant.APP_USER_KEY, user.getId()).build(); + ServerHttpRequest build = exchange.getRequest().mutate().header(Constant.APP_USER_KEY, user.getUserId()).build(); return chain.filter(exchange.mutate().request(build).build()); } return chain.filter(exchange); @@ -119,4 +119,4 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactoryepdc-commons-tools 1.0.0 + + com.esua.epdc + epdc-heart-client + 1.0.0 + + + com.esua.epdc + epdc-neighbor-client + 1.0.0 + + + com.esua.epdc + epdc-news-client + 1.0.0 + + + com.esua.epdc + epdc-events-client + 1.0.0 + + + com.esua.epdc + epdc-services-client + 1.0.0 + + + com.esua.epdc + epdc-user-client + 1.0.0 + diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml b/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml index 1762d3b84..69598c800 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/pom.xml @@ -12,6 +12,10 @@ epdc-api-server jar + + 3.5.0 + + com.esua.epdc @@ -53,6 +57,20 @@ epdc-commons-api-version-control ${project.version} + + + + com.esua.epdc + epdc-wx + ${project.version} + + + + + com.esua.epdc + epdc-common-clienttoken + ${project.version} + @@ -76,4 +94,93 @@ + + + dev + + true + + + dev + + 9040 + + 2 + 47.104.224.45 + 6379 + elink@888 + + + + + epdc + elink833066 + + true + 47.104.224.45:8848 + + wx6ff4e50840cf7dfc + caf82e454ae4e2cb9697651194c37784 + 111 + 111 + + + + + test + + test + + 9040 + + 2 + 47.104.224.45 + 6379 + elink@888 + + + + + epdc + elink833066 + + true + 47.104.224.45:8848 + + wx6ff4e50840cf7dfc + caf82e454ae4e2cb9697651194c37784 + 111 + 111 + + + + + prod + + prod + + 9040 + + 2 + 47.104.224.45 + 6379 + elink@888 + + + + + epdc + elink888 + + false + 47.104.224.45:8848 + + wx62aba559696345af + a93c3dd28ce34fb96228830141e51549 + 111 + 111 + + + + diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/ApiApplication.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/ApiApplication.java index 6e75e8720..96d647692 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/ApiApplication.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/ApiApplication.java @@ -1,8 +1,8 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/annotation/Login.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/annotation/Login.java deleted file mode 100644 index 041820a0d..000000000 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/annotation/Login.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.elink.esua.epdc.annotation; - -import java.lang.annotation.*; - -/** - * 登录效验 - * @author Mark sunlightcs@gmail.com - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface Login { -} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/annotation/LoginUser.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/annotation/LoginUser.java deleted file mode 100644 index 2c6ce717a..000000000 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/annotation/LoginUser.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! - */ - -package com.elink.esua.epdc.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 登录用户信息 - * - * @author Mark sunlightcs@gmail.com - */ -@Target(ElementType.PARAMETER) -@Retention(RetentionPolicy.RUNTIME) -public @interface LoginUser { - -} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/config/WebConfig.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/config/WebConfig.java index 89458d299..21ddc3bd4 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/config/WebConfig.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/config/WebConfig.java @@ -1,15 +1,15 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ package com.elink.esua.epdc.config; -import com.elink.esua.epdc.commons.tools.resolver.LoginUserHandlerMethodArgumentResolver; import com.elink.esua.epdc.interceptor.AuthorizationInterceptor; +import com.elink.esua.epdc.resolver.LoginUserHandlerMethodArgumentResolver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.support.HandlerMethodArgumentResolver; @@ -25,8 +25,10 @@ import java.util.List; */ @Configuration public class WebConfig implements WebMvcConfigurer { + @Autowired private AuthorizationInterceptor authorizationInterceptor; + @Autowired private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver; diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiLoginController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiLoginController.java index 8f4033c4f..26cce4c81 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiLoginController.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiLoginController.java @@ -9,7 +9,7 @@ package com.elink.esua.epdc.controller; -import com.elink.esua.epdc.annotation.Login; +import com.elink.esua.epdc.common.token.annotation.Login; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; import com.elink.esua.epdc.dto.LoginDTO; diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTestController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTestController.java deleted file mode 100644 index 85a08fc37..000000000 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTestController.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - *

- * https://www.renren.io - *

- * 版权所有,侵权必究! - */ - -package com.elink.esua.epdc.controller; - -import com.elink.esua.epdc.annotation.Login; -import com.elink.esua.epdc.annotation.LoginUser; -import com.elink.esua.epdc.commons.tools.utils.Result; -import com.elink.esua.epdc.entity.UserEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 测试接口 - * - * @author Mark sunlightcs@gmail.com - */ -@RestController -@RequestMapping("test") -public class ApiTestController { - - /** - * 获取用户信息 - * - * @param user - * @return - */ - @Login - @GetMapping("userInfo") - public Result userInfo(@LoginUser UserEntity user) { - return new Result().ok(user); - } - - /** - * 获取用户ID - * - * @param userId - * @return - */ - @Login - @GetMapping("userId") - public Result userInfo(@RequestAttribute("userId") Long userId) { - return new Result().ok(userId); - } - - /** - * 忽略Token验证测试 - * - * @return - */ - @GetMapping("notToken") - public Result notToken() { - return new Result().ok("无需token也能访问。。。"); - } - -} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/interceptor/AuthorizationInterceptor.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/interceptor/AuthorizationInterceptor.java index a378ad2a1..de7aecf63 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/interceptor/AuthorizationInterceptor.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/interceptor/AuthorizationInterceptor.java @@ -1,23 +1,33 @@ /** - * Copyright (c) 2018 人人开源 All rights reserved. - * - * https://www.renren.io - * - * 版权所有,侵权必究! + * Copyright 2018 人人开源 http://www.renren.io + *

+ * 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.elink.esua.epdc.interceptor; -import com.elink.esua.epdc.annotation.Login; -import com.elink.esua.epdc.exception.ModuleErrorCode; -import com.elink.esua.epdc.annotation.Login; + +import com.elink.esua.epdc.common.token.annotation.Login; +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.common.token.enums.ErrorCode; +import com.elink.esua.epdc.common.token.util.TokenUtil; +import com.elink.esua.epdc.commons.tools.constant.Constant; import com.elink.esua.epdc.commons.tools.exception.RenException; -import com.elink.esua.epdc.entity.TokenEntity; -import com.elink.esua.epdc.exception.ModuleErrorCode; -import com.elink.esua.epdc.service.TokenService; -import org.apache.commons.lang3.StringUtils; +import com.elink.esua.epdc.jwt.JwtTokenUtils; +import io.jsonwebtoken.Claims; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; @@ -25,50 +35,60 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * 权限(Token)验证 - * - * @author Mark sunlightcs@gmail.com + * @author rongchao + * @Date 18-11-20 */ @Component public class AuthorizationInterceptor extends HandlerInterceptorAdapter { + @Autowired - private TokenService tokenService; + private TokenUtil tokenUtil; - public static final String USER_KEY = "userId"; + @Autowired + private JwtTokenUtils jwtUtils; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Login annotation; - if(handler instanceof HandlerMethod) { + if (handler instanceof HandlerMethod) { annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class); - }else{ + } else { return true; } - if(annotation == null){ + if (annotation == null) { return true; } //从header中获取token - String token = request.getHeader("token"); + String token = request.getHeader("Authorization"); //如果header中不存在token,则从参数中获取token - if(StringUtils.isBlank(token)){ + if (StringUtils.isEmpty(token)) { token = request.getParameter("token"); } //token为空 - if(StringUtils.isBlank(token)){ - throw new RenException(ModuleErrorCode.TOKEN_NOT_EMPTY); + if (StringUtils.isEmpty(token)) { + // 表示请求信息中没有携带token,前端需要修改上送数据 + throw new RenException(ErrorCode.ERR10005.getCode(), ErrorCode.ERR10005.getMsg()); + } + + Claims claims = jwtUtils.getClaimByToken(token); + + if (claims == null || jwtUtils.isTokenExpired(claims.getExpiration())) { + throw new RenException(ErrorCode.ERR10001.getCode(), ErrorCode.ERR10001.getMsg()); } + //获取用户ID + String userId = claims.getSubject(); //查询token信息 - TokenEntity tokenEntity = tokenService.getByToken(token); - if(tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){ - throw new RenException(ModuleErrorCode.TOKEN_INVALID); + TokenDto tokenDto = tokenUtil.getTokenInfo(userId); + if (tokenDto == null) { + throw new RenException(ErrorCode.ERR10001.getCode(), ErrorCode.ERR10001.getMsg()); } //设置userId到request里,后续根据userId,获取用户信息 - request.setAttribute(USER_KEY, tokenEntity.getUserId()); + request.setAttribute(Constant.APP_USER_KEY, tokenDto); return true; } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/jwt/JwtTokenProperties.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/jwt/JwtTokenProperties.java new file mode 100644 index 000000000..3e938f90d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/jwt/JwtTokenProperties.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.elink.esua.epdc.jwt; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * Jwt + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Configuration +@ConfigurationProperties(prefix = "jwt.token") +public class JwtTokenProperties { + private String secret; + private int expire; + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } + + public int getExpire() { + return expire; + } + + public void setExpire(int expire) { + this.expire = expire; + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/jwt/JwtTokenUtils.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/jwt/JwtTokenUtils.java new file mode 100644 index 000000000..736be6d35 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/jwt/JwtTokenUtils.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.elink.esua.epdc.jwt; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.joda.time.DateTime; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * Jwt工具类 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Component +public class JwtTokenUtils { + private static final Logger logger = LoggerFactory.getLogger(JwtTokenUtils.class); + + @Autowired + private JwtTokenProperties jwtProperties; + + /** + * 生成jwt token + */ + public String generateToken(String userId) { + return Jwts.builder() + .setHeaderParam("typ", "JWT") + .setSubject(userId) + .setIssuedAt(new Date()) + .setExpiration(DateTime.now().plusSeconds(jwtProperties.getExpire()).toDate()) + .signWith(SignatureAlgorithm.HS512, jwtProperties.getSecret()) + .compact(); + } + + public Claims getClaimByToken(String token) { + try { + return Jwts.parser() + .setSigningKey(jwtProperties.getSecret()) + .parseClaimsJws(token) + .getBody(); + } catch (Exception e) { + logger.debug("validate is token error, token = " + token, e); + return null; + } + } + + /** + * token是否过期 + * + * @return true:过期 + */ + public boolean isTokenExpired(Date expiration) { + return expiration.before(new Date()); + } +} diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/resolver/LoginUserHandlerMethodArgumentResolver.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/resolver/LoginUserHandlerMethodArgumentResolver.java similarity index 89% rename from esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/resolver/LoginUserHandlerMethodArgumentResolver.java rename to esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/resolver/LoginUserHandlerMethodArgumentResolver.java index 4d12e9e46..6e999b148 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/resolver/LoginUserHandlerMethodArgumentResolver.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/resolver/LoginUserHandlerMethodArgumentResolver.java @@ -6,11 +6,12 @@ * 版权所有,侵权必究! */ -package com.elink.esua.epdc.commons.tools.resolver; +package com.elink.esua.epdc.resolver; +import com.elink.esua.epdc.common.token.dto.TokenDto; +import com.elink.esua.epdc.common.token.util.CpUserDetailRedis; import com.elink.esua.epdc.commons.tools.annotation.LoginUser; import com.elink.esua.epdc.commons.tools.constant.Constant; -import com.elink.esua.epdc.commons.tools.redis.CpUserDetailRedis; import com.elink.esua.epdc.commons.tools.security.user.CpUserDetail; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -46,7 +47,7 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu if (StringUtils.isEmpty(userId)) { return null; } - CpUserDetail user = cpUserDetailRedis.get(userId); + TokenDto user = cpUserDetailRedis.get(userId); return user; } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java new file mode 100644 index 000000000..9a1aa7df1 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java @@ -0,0 +1,24 @@ +package com.elink.esua.epdc.service; + +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.NoticeDTO; + +/** + * 新闻通知模块 + * + * @author yujintao + * @email yujintao@elink-cn.com + * @date 2019/6/5 14:10 + */ +public interface NewsService { + + /** + * 通知保存 + * + * @param notice + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author yujintao + * @date 2019/9/5 14:17 + */ + Result saveNotice(NoticeDTO notice); +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java new file mode 100644 index 000000000..81223fb02 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java @@ -0,0 +1,23 @@ +package com.elink.esua.epdc.service.impl; + +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.NoticeDTO; +import com.elink.esua.epdc.service.NewsService; +import org.springframework.stereotype.Service; + +/** + * 新闻通知模块 + * + * @author yujintao + * @email yujintao@elink-cn.com + * @date 2019/9/5 14:10 + */ +@Service +public class NewsServiceImpl implements NewsService { + + + @Override + public Result saveNotice(NoticeDTO notice) { + return null; + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/controller/WxController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/controller/WxController.java new file mode 100644 index 000000000..0357ff904 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/controller/WxController.java @@ -0,0 +1,33 @@ +package com.elink.esua.epdc.wx.controller; + +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.wx.service.WxService; +import me.chanjar.weixin.common.bean.WxJsapiSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 微信Controller + * + * @author rongchao + * @Date 19-9-4 + */ +@RestController +@RequestMapping("wx") +public class WxController { + + @Autowired + private WxService wxService; + + /** + * 获取用户信息 + * + * @return + */ + @GetMapping("getWxConfig") + public Result getWxConfig(String url) { + return wxService.getWxConfig(url); + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/WxService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/WxService.java new file mode 100644 index 000000000..17ae1c39a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/WxService.java @@ -0,0 +1,20 @@ +package com.elink.esua.epdc.wx.service; + +import com.elink.esua.epdc.commons.tools.utils.Result; +import me.chanjar.weixin.common.bean.WxJsapiSignature; + +/** + * 微信接口类 + * + * @author rongchao + * @Date 19-9-4 + */ +public interface WxService { + + /** + * 获取微信jssdk配置信息 + * + * @return + */ + Result getWxConfig(String url); +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/impl/WxServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/impl/WxServiceImpl.java new file mode 100644 index 000000000..803e1c31e --- /dev/null +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/wx/service/impl/WxServiceImpl.java @@ -0,0 +1,38 @@ +package com.elink.esua.epdc.wx.service.impl; + +import com.elink.esua.epdc.commons.tools.exception.RenException; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.wx.service.WxService; +import me.chanjar.weixin.common.bean.WxJsapiSignature; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 微信相关服务实现类 + * + * @author rongchao + * @Date 19-9-4 + */ +@Service +public class WxServiceImpl implements WxService { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Autowired + private WxMpService wxMpService; + + @Override + public Result getWxConfig(String url) { + try { + WxJsapiSignature wxJsapiSignature = wxMpService.createJsapiSignature(url); + return new Result().ok(wxJsapiSignature); + } catch (WxErrorException e) { + log.error("获取微信Jssdk相关配置失败"); + throw new RenException("获取微信Jssdk相关配置失败"); + } + } +} diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml index a3a7d17a5..94809a5be 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8087 + port: @server.port@ servlet: context-path: /api @@ -16,22 +16,22 @@ spring: time-zone: GMT+8 date-format: yyyy-MM-dd HH:mm:ss redis: - database: 0 - host: 47.104.224.45 + database: @spring.redis.index@ + host: @spring.redis.host@ timeout: 30s - port: 6379 - password: elink@888 + port: @spring.redis.port@ + password: @spring.redis.password@ datasource: druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://47.104.224.45:3308/epdc_api?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC - username: root - password: shibei@888 + url: @spring.datasource.druid.url@ + username: @spring.datasource.druid.username@ + password: @spring.datasource.druid.password@ cloud: nacos: discovery: - server-addr: 47.104.224.45:8848 - register-enabled: true + server-addr: @nacos.server-addr@ + register-enabled: @nacos.register-enabled@ alibaba: seata: tx-service-group: epdc-api-server-fescar-service-group @@ -65,3 +65,14 @@ mybatis-plus: cache-enabled: false call-setters-on-nulls: true jdbc-type-for-null: 'null' + +wx: + mp: + configs: + - appId: @wx.mp.configs.appId@ + secret: @wx.mp.configs.secret@ + token: @wx.mp.configs.token@ + aesKey: @wx.mp.configs.aesKey@ + +token: + expire: 21600L diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-client/pom.xml b/esua-epdc/epdc-module/epdc-app/epdc-app-client/pom.xml deleted file mode 100644 index 2b9c90eb5..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-client/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - epdc-app - com.esua.epdc - 1.0.0 - - 4.0.0 - - epdc-app-client - jar - - - - com.esua.epdc - epdc-commons-tools - 1.0.0 - - - com.esua.epdc - epdc-heart-client - 1.0.0 - - - com.esua.epdc - epdc-neighbor-client - 1.0.0 - - - com.esua.epdc - epdc-news-client - 1.0.0 - - - com.esua.epdc - epdc-events-client - 1.0.0 - - - com.esua.epdc - epdc-services-client - 1.0.0 - - - com.esua.epdc - epdc-user-client - 1.0.0 - - - - diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-client/src/main/java/com/elink/esua/epdc/epdc.gitkeep b/esua-epdc/epdc-module/epdc-app/epdc-app-client/src/main/java/com/elink/esua/epdc/epdc.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/pom.xml b/esua-epdc/epdc-module/epdc-app/epdc-app-server/pom.xml deleted file mode 100644 index 42ce442e0..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-server/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - epdc-app - com.esua.epdc - 1.0.0 - - 4.0.0 - - epdc-app-server - jar - - - - com.esua.epdc - epdc-app-client - 1.0.0 - - - com.esua.epdc - epdc-commons-tools - 1.0.0 - - - com.esua.epdc - epdc-commons-mybatis - 1.0.0 - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-context-support - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - de.codecentric - spring-boot-admin-starter-client - ${spring.boot.admin.version} - - - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - com.spotify - docker-maven-plugin - - - - - - - - dev - - true - - - dev - - 9058 - - 2 - 47.104.224.45 - 6379 - elink@888 - - - - - epdc - elink888 - - false - 47.104.224.45:8848 - - - - - test - - test - - 9058 - - 2 - 47.104.224.45 - 6379 - elink@888 - - - - - epdc - elink888 - - false - 47.104.224.45:8848 - - - - - prod - - prod - - 9058 - - 2 - 47.104.224.45 - 6379 - elink@888 - - - - - epdc - elink888 - - false - 47.104.224.45:8848 - - - - - \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/AppApplication.java b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/AppApplication.java deleted file mode 100644 index 5fa453d6b..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/AppApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - *

- * https://www.renren.io - *

- * 版权所有,侵权必究! - */ - -package com.elink.esua.epdc; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.cloud.openfeign.EnableFeignClients; - -/** - * 移动端接口模块 - * - * @author Mark sunlightcs@gmail.com - * @since 1.1.0 - */ -@SpringBootApplication -@EnableDiscoveryClient -@EnableFeignClients -public class AppApplication { - - public static void main(String[] args) { - SpringApplication.run(AppApplication.class, args); - } - -} diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/config/ModuleConfigImpl.java b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/config/ModuleConfigImpl.java deleted file mode 100644 index 0a6891524..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/config/ModuleConfigImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - *

- * https://www.renren.io - *

- * 版权所有,侵权必究! - */ - -package com.elink.esua.epdc.config; - -import com.elink.esua.epdc.commons.tools.config.ModuleConfig; -import org.springframework.stereotype.Service; - -/** - * 模块配置信息-移动端接口模块 - * - * @author Mark sunlightcs@gmail.com - * @since 1.0.0 - */ -@Service -public class ModuleConfigImpl implements ModuleConfig { - @Override - public String getName() { - return "app"; - } -} diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/config/WebConfig.java b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/config/WebConfig.java deleted file mode 100644 index 1ca742ce7..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/java/com/elink/esua/epdc/config/WebConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2018 人人开源 All rights reserved. - *

- * https://www.renren.io - *

- * 版权所有,侵权必究! - */ - -package com.elink.esua.epdc.config; - -import com.elink.esua.epdc.commons.tools.resolver.LoginUserHandlerMethodArgumentResolver; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.util.List; - -/** - * MVC配置 - * - * @author Mark sunlightcs@gmail.com - */ -@Configuration -public class WebConfig implements WebMvcConfigurer { - - @Autowired - private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver; - - @Override - public void addArgumentResolvers(List argumentResolvers) { - argumentResolvers.add(loginUserHandlerMethodArgumentResolver); - } -} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/application.yml b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/application.yml deleted file mode 100644 index 6d75d4801..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/application.yml +++ /dev/null @@ -1,68 +0,0 @@ -server: - port: @server.port@ - servlet: - context-path: /epdc-app - -spring: - application: - name: epdc-app-server - # 环境 dev|test|prod - profiles: - active: @spring.profiles.active@ - messages: - encoding: UTF-8 - basename: i18n/messages,i18n/messages_common - jackson: - time-zone: GMT+8 - date-format: yyyy-MM-dd HH:mm:ss - redis: - database: @spring.redis.index@ - host: @spring.redis.host@ - timeout: 30s - port: @spring.redis.port@ - password: @spring.redis.password@ - cloud: - nacos: - discovery: - server-addr: @nacos.server-addr@ - register-enabled: @nacos.register-enabled@ - alibaba: - seata: - tx-service-group: epdc-app-server-fescar-service-group - datasource: - druid: - driver-class-name: com.mysql.jdbc.Driver - url: @spring.datasource.druid.url@ - username: @spring.datasource.druid.username@ - password: @spring.datasource.druid.password@ - - -management: - endpoints: - web: - exposure: - include: "*" - endpoint: - health: - show-details: ALWAYS - -mybatis-plus: - mapper-locations: classpath:/mapper/**/*.xml - #实体扫描,多个package用逗号或者分号分隔 - typeAliasesPackage: io.renren.entity;com.elink.esua.epdc.entity - global-config: - #数据库相关配置 - db-config: - #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; - id-type: ID_WORKER - #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" - field-strategy: NOT_NULL - #驼峰下划线转换 - column-underline: true - banner: false - #原生配置 - configuration: - map-underscore-to-camel-case: true - cache-enabled: false - call-setters-on-nulls: true - jdbc-type-for-null: 'null' diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages_en_US.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages_en_US.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages_zh_CN.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages_zh_CN.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages_zh_TW.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/messages_zh_TW.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation_en_US.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation_en_US.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation_zh_CN.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation_zh_CN.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation_zh_TW.properties b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/i18n/validation_zh_TW.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/logback-spring.xml b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/logback-spring.xml deleted file mode 100644 index dd5aa1d15..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - - - - - - debug - - - ${CONSOLE_LOG_PATTERN} - - UTF-8 - - - - - - - - ${log.path}/debug.log - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - - ${log.path}/debug-%d{yyyy-MM-dd}.%i.log - - 100MB - - - 15 - - - - debug - ACCEPT - DENY - - - - - - - ${log.path}/info.log - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - - ${log.path}/info-%d{yyyy-MM-dd}.%i.log - - 100MB - - - 15 - - - - info - ACCEPT - DENY - - - - - - - ${log.path}/warn.log - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - ${log.path}/warn-%d{yyyy-MM-dd}.%i.log - - 100MB - - - 15 - - - - warn - ACCEPT - DENY - - - - - - - ${log.path}/error.log - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - UTF-8 - - - - ${log.path}/error-%d{yyyy-MM-dd}.%i.log - - 100MB - - - 15 - - - - ERROR - ACCEPT - DENY - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/registry.conf b/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/registry.conf deleted file mode 100644 index 9cfedf9cc..000000000 --- a/esua-epdc/epdc-module/epdc-app/epdc-app-server/src/main/resources/registry.conf +++ /dev/null @@ -1,21 +0,0 @@ -registry { - # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa - type = "nacos" - - nacos { - serverAddr = "47.104.224.45" - namespace = "public" - cluster = "default" - } -} - -config { - # file、nacos 、apollo、zk、consul、etcd3 - type = "nacos" - - nacos { - serverAddr = "47.104.224.45" - namespace = "public" - cluster = "default" - } -} diff --git a/esua-epdc/epdc-module/epdc-app/pom.xml b/esua-epdc/epdc-module/epdc-app/pom.xml deleted file mode 100644 index cc01eb83b..000000000 --- a/esua-epdc/epdc-module/epdc-app/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - epdc-module - com.esua.epdc - 1.0.0 - - 4.0.0 - - epdc-app - pom - - epdc-app-client - epdc-app-server - - - - \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java index 9db5f4821..bb9dd80be 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsDetailDTO.java @@ -33,5 +33,9 @@ public class EpdcEventsDetailDTO implements Serializable { /** * 图片 */ - private List images; + private String images; + /** + * 图片数据 + */ + private String[] imageArray; } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java index 7145edf79..8bc5e9666 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/events/controller/EpdcEventsController.java @@ -61,7 +61,7 @@ public class EpdcEventsController { @GetMapping("{id}") public Result get(@PathVariable("id") String id){ EpdcEventsDetailDTO data = epdcEventsService.get(id); - + data.setImageArray(data.getImages().split(",")); return new Result().ok(data); } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml index 69b013b2b..5981d7ca3 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml @@ -3,20 +3,22 @@ diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDTO.java index e3e21626a..2ef174998 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDTO.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDTO.java @@ -49,17 +49,17 @@ public class NoticeDTO implements Serializable { private String noticeContent; /** - * 发布通知者姓名 + * 发布人姓名 */ private String creatorName; /** - * 发布通知部门 + * 发布人部门 */ - private String dept; + private String deptName; /** - * 发布通知部门ID + * 发布人部门ID */ private Long deptId; @@ -98,4 +98,39 @@ public class NoticeDTO implements Serializable { */ private String delFlag; + /** + * 是否已发布0否;1是 + */ + private String isPublish; + + /** + * 通知所属街道 + */ + private String street; + + /** + * 通知所属街道ID + */ + private Long streetId; + + /** + * 通知所属社区 + */ + private String community; + + /** + * 通知所属社区ID + */ + private Long communityId; + + /** + * 通知所属网格 + */ + private String grid; + + /** + * 通知所属网格ID + */ + private Long gridId; + } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDepartmentDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDepartmentDTO.java new file mode 100644 index 000000000..4475acffa --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeDepartmentDTO.java @@ -0,0 +1,81 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Data +public class NoticeDepartmentDTO implements Serializable { + + private static final long serialVersionUID = 3994084299547740579L; + + /** + * 主键 + */ + private String id; + + /** + * 通知ID + */ + private String noticeId; + + /** + * 部门ID + */ + private Long deptId; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 删除标记 + */ + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeController.java index e3c4f9955..d27d1aad9 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeController.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeController.java @@ -45,24 +45,24 @@ import java.util.Map; @RestController @RequestMapping("/notice") public class NoticeController { - + @Autowired private NoticeService noticeService; @GetMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = noticeService.page(params); return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ + public Result get(@PathVariable("id") String id) { NoticeDTO data = noticeService.get(id); return new Result().ok(data); } @PostMapping - public Result save(@RequestBody NoticeDTO dto){ + public Result save(@RequestBody NoticeDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); noticeService.save(dto); @@ -70,7 +70,7 @@ public class NoticeController { } @PutMapping - public Result update(@RequestBody NoticeDTO dto){ + public Result update(@RequestBody NoticeDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); noticeService.update(dto); @@ -78,7 +78,7 @@ public class NoticeController { } @DeleteMapping - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); noticeService.delete(ids); @@ -91,4 +91,18 @@ public class NoticeController { ExcelUtils.exportExcelToTarget(response, null, list, NoticeExcel.class); } + /** + * 通知发布 + * + * @param noticeId + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author yujintao + * @date 2019/9/5 17:05 + */ + @PostMapping("publish/{noticeId}") + public Result publish(@PathVariable String noticeId) { + noticeService.updatePublish(noticeId); + return new Result(); + } + } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeDepartmentController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeDepartmentController.java new file mode 100644 index 000000000..8269dea12 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeDepartmentController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.dto.NoticeDepartmentDTO; +import com.elink.esua.epdc.excel.NoticeDepartmentExcel; +import com.elink.esua.epdc.service.NoticeDepartmentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@RestController +@RequestMapping("noticedepartment") +public class NoticeDepartmentController { + + @Autowired + private NoticeDepartmentService noticeDepartmentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = noticeDepartmentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NoticeDepartmentDTO data = noticeDepartmentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NoticeDepartmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + noticeDepartmentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NoticeDepartmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + noticeDepartmentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + noticeDepartmentService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = noticeDepartmentService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, NoticeDepartmentExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDepartmentDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDepartmentDao.java new file mode 100644 index 000000000..708832ba7 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDepartmentDao.java @@ -0,0 +1,42 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.entity.NoticeDepartmentEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Mapper +public interface NoticeDepartmentDao extends BaseDao { + + /** + * 根据noticeId删除 + * + * @param noticeId + * @return int + * @author yujintao + * @date 2019/9/5 16:37 + */ + int deleteByNoticeId(String noticeId); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeDepartmentEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeDepartmentEntity.java new file mode 100644 index 000000000..40509bf1d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeDepartmentEntity.java @@ -0,0 +1,53 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("epdc_notice_department") +public class NoticeDepartmentEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = -5644283742322487661L; + + /** + * 通知ID + */ + private String noticeId; + + /** + * 部门ID + */ + @TableField(fill = FieldFill.DEFAULT) + private Long deptId; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeEntity.java index f7c6ae639..699c18284 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeEntity.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeEntity.java @@ -55,12 +55,12 @@ public class NoticeEntity extends BaseEpdcEntity { private String creatorName; /** - * 发布通知部门 + * 发布人部门 */ - private String dept; + private String deptName; /** - * 发布通知部门ID + * 发布人部门ID */ @TableField(fill = FieldFill.DEFAULT) private Long deptId; @@ -70,4 +70,42 @@ public class NoticeEntity extends BaseEpdcEntity { */ private Integer readingAmount; + /** + * 是否已发布0否;1是 + */ + private String isPublish; + + /** + * 通知所属街道 + */ + private String street; + + /** + * 通知所属街道ID + */ + private Long streetId; + + /** + * 通知所属社区 + */ + private String community; + + /** + * 通知所属社区ID + */ + private Long communityId; + + /** + * 通知所属网格 + */ + private String grid; + + /** + * 通知所属网格ID + */ + private Long gridId; + + + + } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NoticeDepartmentExcel.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NoticeDepartmentExcel.java new file mode 100644 index 000000000..22ad1812b --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/excel/NoticeDepartmentExcel.java @@ -0,0 +1,62 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Data +public class NoticeDepartmentExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "通知ID") + private String noticeId; + + @Excel(name = "部门ID") + private String deptId; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + @Excel(name = "删除标记") + private String delFlag; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java new file mode 100644 index 000000000..6f24d0f5c --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java @@ -0,0 +1,30 @@ +package com.elink.esua.epdc.feign; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.feign.fallback.AdminFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +import java.util.List; + +/** + * @author yujintao + * @email yujintao@elink-cn.com + * @date 2019/9/5 14:44 + */ +@FeignClient(name = ServiceConstant.EPDC_ADMIN_SERVER, fallback = AdminFeignClientFallback.class) +public interface AdminFeignClient { + + /** + * 根据部门ID,获取下属所有网格ID + * + * @param pid + * @return com.elink.esua.epdc.commons.tools.utils.Result> + * @author yujintao + * @date 2019/9/5 14:49 + */ + @GetMapping("/sys/dept/listGridId/{pid}") + Result> listGridIdByDeptPid(@PathVariable("pid") Long pid); +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java new file mode 100644 index 000000000..b1bf54ece --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java @@ -0,0 +1,24 @@ +package com.elink.esua.epdc.feign.fallback; + +import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.feign.AdminFeignClient; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author yujintao + * @email yujintao@elink-cn.com + * @date 2019/9/5 14:44 + */ +@Component +public class AdminFeignClientFallback implements AdminFeignClient { + + private final static String ERROR = "news调用admin失败"; + + @Override + public Result> listGridIdByDeptPid(Long pid) { + return ModuleUtils.feignConError(ERROR, "listGridIdByDeptPid", pid); + } +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NoticeDepartmentRedis.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NoticeDepartmentRedis.java new file mode 100644 index 000000000..dc3ab8f62 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/redis/NoticeDepartmentRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.redis; + +import com.elink.esua.epdc.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Component +public class NoticeDepartmentRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeDepartmentService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeDepartmentService.java new file mode 100644 index 000000000..ad6a3cf13 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeDepartmentService.java @@ -0,0 +1,116 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.NoticeDepartmentDTO; +import com.elink.esua.epdc.entity.NoticeDepartmentEntity; + +import java.util.List; +import java.util.Map; + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +public interface NoticeDepartmentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author + * @date + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author + * @date + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return NoticeDepartmentDTO + * @author + * @date + */ + NoticeDepartmentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author + * @date + */ + void save(NoticeDepartmentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author + * @date + */ + void update(NoticeDepartmentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author + * @date + */ + void delete(String[] ids); + + /** + * 保存通知和网格关系 + * + * @param id + * @param noticeGridList + * @return void + * @author yujintao + * @date 2019/9/5 15:08 + */ + void save(String id, List noticeGridList); + + /** + * 根据通知ID删除条目 + * + * @param id + * @return void + * @author yujintao + * @date 2019/9/5 15:52 + */ + void deleteByNoticeId(String id); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java index decc5ed48..f3d8c804e 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java @@ -92,4 +92,14 @@ public interface NoticeService extends BaseService { * @date */ void delete(String[] ids); + + /** + * 通知发布 + * + * @param noticeId + * @return void + * @author yujintao + * @date 2019/9/5 16:59 + */ + void updatePublish(String noticeId); } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeDepartmentServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeDepartmentServiceImpl.java new file mode 100644 index 000000000..9191614fc --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeDepartmentServiceImpl.java @@ -0,0 +1,128 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.NumConstant; +import com.elink.esua.epdc.commons.tools.exception.RenException; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.dao.NoticeDepartmentDao; +import com.elink.esua.epdc.dto.NoticeDepartmentDTO; +import com.elink.esua.epdc.entity.NoticeDepartmentEntity; +import com.elink.esua.epdc.redis.NoticeDepartmentRedis; +import com.elink.esua.epdc.service.NoticeDepartmentService; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 通知部门关系表 + * + * @author yujintao yujintao@elink-cn.com + * @since v1.0.0 2019-09-05 + */ +@Service +public class NoticeDepartmentServiceImpl extends BaseServiceImpl implements NoticeDepartmentService { + + @Autowired + private NoticeDepartmentRedis noticeDepartmentRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NoticeDepartmentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NoticeDepartmentDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public NoticeDepartmentDTO get(String id) { + NoticeDepartmentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NoticeDepartmentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NoticeDepartmentDTO dto) { + NoticeDepartmentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeDepartmentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NoticeDepartmentDTO dto) { + NoticeDepartmentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeDepartmentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void save(String id, List noticeGridList) { + if (StringUtils.isBlank(id) || CollUtil.isEmpty(noticeGridList)) { + throw new RenException("保存通知网格信息失败"); + } + List list = Lists.newArrayList(); + NoticeDepartmentEntity entity; + for (Long gridId : noticeGridList) { + entity = new NoticeDepartmentEntity(); + entity.setNoticeId(id); + entity.setDeptId(gridId); + list.add(entity); + } + this.insertBatch(list, NumConstant.TWENTY); + } + + @Override + public void deleteByNoticeId(String id) { + this.baseDao.deleteByNoticeId(id); + } +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java index dbe840fc4..61fc6b774 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java @@ -17,20 +17,26 @@ package com.elink.esua.epdc.service.impl; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; import com.elink.esua.epdc.commons.tools.security.user.UserDetail; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dao.NoticeDao; import com.elink.esua.epdc.dto.NoticeDTO; import com.elink.esua.epdc.entity.NoticeEntity; +import com.elink.esua.epdc.feign.AdminFeignClient; import com.elink.esua.epdc.redis.NoticeRedis; +import com.elink.esua.epdc.service.NoticeDepartmentService; import com.elink.esua.epdc.service.NoticeService; +import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,6 +58,12 @@ public class NoticeServiceImpl extends BaseServiceImpl @Autowired private NoticeRedis noticeRedis; + @Autowired + private AdminFeignClient adminFeignClient; + + @Autowired + private NoticeDepartmentService noticeDepartmentService; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -70,9 +82,11 @@ public class NoticeServiceImpl extends BaseServiceImpl private QueryWrapper getWrapper(Map params) { String id = (String) params.get(FieldConstant.ID_HUMP); + String noticeTitle = (String) params.get("noticeTitle"); QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id) + .like(StringUtils.isNotBlank(noticeTitle), "NOTICE_TITLE", noticeTitle); return wrapper; } @@ -86,25 +100,65 @@ public class NoticeServiceImpl extends BaseServiceImpl @Override @Transactional(rollbackFor = Exception.class) public void save(NoticeDTO dto) { - - UserDetail user = SecurityUser.getUser(); - if (!user.getDeptIdList().contains(dto.getDeptId())) { - throw new RenException("您没有操作此部门的数据权限"); - } - dto.setCreatorName(user.getRealName()); - NoticeEntity entity = ConvertUtils.sourceToTarget(dto, NoticeEntity.class); - insert(entity); + this.saveOrUpdate(dto); } @Override @Transactional(rollbackFor = Exception.class) public void update(NoticeDTO dto) { + this.saveOrUpdate(dto); + } + + /** + * 通知保存或更新 + * + * @param dto + * @return void + * @author yujintao + * @date 2019/9/5 16:02 + */ + private void saveOrUpdate(NoticeDTO dto) { UserDetail user = SecurityUser.getUser(); - if (!user.getDeptIdList().contains(dto.getDeptId())) { + dto.setCreatorName(user.getRealName()); + dto.setDeptId(user.getDeptId()); + dto.setDeptName(user.getDeptName()); + NoticeEntity entity = ConvertUtils.sourceToTarget(dto, NoticeEntity.class); + + // 通知所属部门id + Long noticeDeptId = entity.getStreetId(); + // 能接收通知的所有网格的ID + List noticeGridList = Lists.newArrayList(); + if (null != entity.getCommunityId()) { + noticeDeptId = entity.getCommunityId(); + } + if (null != entity.getGridId()) { + noticeDeptId = entity.getGridId(); + noticeGridList.add(noticeDeptId); + } + + if (!user.getDeptIdList().contains(noticeDeptId)) { throw new RenException("您没有操作此部门的数据权限"); } - NoticeEntity entity = ConvertUtils.sourceToTarget(dto, NoticeEntity.class); - updateById(entity); + boolean isSave = true; + if (StringUtils.isNotBlank(dto.getId())) { + isSave = false; + } + + if (isSave) { + insert(entity); + } else { + updateById(entity); + noticeDepartmentService.deleteByNoticeId(entity.getId()); + } + + if (CollUtil.isEmpty(noticeGridList)) { + Result> adminResult = adminFeignClient.listGridIdByDeptPid(noticeDeptId); + if (!adminResult.success() || CollUtil.isEmpty(adminResult.getData())) { + throw new RenException("获取部门信息失败"); + } + noticeGridList = adminResult.getData(); + } + this.noticeDepartmentService.save(entity.getId(), noticeGridList); } @Override @@ -112,6 +166,16 @@ public class NoticeServiceImpl extends BaseServiceImpl public void delete(String[] ids) { //物理删除 baseDao.deleteBatchIds(Arrays.asList(ids)); + for (String noticeId : ids) { + this.noticeDepartmentService.deleteByNoticeId(noticeId); + } } + @Override + public void updatePublish(String noticeId) { + NoticeEntity entity = new NoticeEntity(); + entity.setId(noticeId); + entity.setIsPublish(YesOrNoEnum.YES.value()); + this.updateById(entity); + } } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDao.xml new file mode 100644 index 000000000..b6c61a605 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDao.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDepartmentDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDepartmentDao.xml new file mode 100644 index 000000000..9bb1b8985 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDepartmentDao.xml @@ -0,0 +1,10 @@ + + + + + + + + DELETE FROM epdc_notice_department WHERE NOTICE_ID = #{noticeId} + + \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PartyMembersDao.xml b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PartyMembersDao.xml index 8ddc60bba..4cf0f16d2 100755 --- a/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PartyMembersDao.xml +++ b/esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PartyMembersDao.xml @@ -103,6 +103,7 @@ and pm.ID = #{id} and pm.DEL_FLAG = '0' and partytag.DEL_FLAG = '0' + GROUP BY pm.ID diff --git a/esua-epdc/epdc-module/pom.xml b/esua-epdc/epdc-module/pom.xml index 68c359200..4abd74cfe 100644 --- a/esua-epdc/epdc-module/pom.xml +++ b/esua-epdc/epdc-module/pom.xml @@ -24,7 +24,6 @@ epdc-events epdc-neighbor epdc-services - epdc-app epdc-user epdc-demo