Merge remote-tracking branch 'origin/1.0.1' into 1.0.1
| | |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.dao.system.dto.LoginPhoneDTO; |
| | | import com.doumee.dao.system.dto.UpdatePwdDto; |
| | | import com.doumee.dao.system.dto.WebLoginDTO; |
| | | import com.doumee.dao.system.dto.*; |
| | | import com.doumee.service.system.SystemLoginService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @ApiOperation("ç»å½ - å端") |
| | | @PostMapping("/login") |
| | | public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ONE, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ONE, true, request)); |
| | | } |
| | | |
| | | @PreventRepeat(limit = 10, lockTime = 10000) |
| | | @ApiOperation("çä¿¡éªè¯ç ç»å½") |
| | | @PostMapping("/loginByPhone") |
| | | public ApiResponse<String> loginByPhone (@Validated @RequestBody LoginPhoneDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ZERO, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ONE, true, request)); |
| | | } |
| | | |
| | | @PreventRepeat(limit = 10, lockTime = 10000) |
| | | @ApiOperation("微信å°ç¨åºç»å½") |
| | | @PostMapping("/loginByWxMini") |
| | | public ApiResponse<String> loginByWxMini (@Validated @RequestBody WxMiniLoginDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByWxMini(dto, request)); |
| | | } |
| | | |
| | | @ApiOperation("éåºç»å½") |
| | | @PostMapping("/logout") |
| | | public ApiResponse logout () { |
| | | systemLoginService.cleaOpenid(); |
| | | Subject subject = SecurityUtils.getSubject(); |
| | | subject.logout(); |
| | | return ApiResponse.success(null); |
| | |
| | | @ApiOperation("ç»å½") |
| | | @PostMapping("/login") |
| | | public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ZERO, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.ZERO,true, request)); |
| | | } |
| | | @PreventRepeat(limit = 10, lockTime = 10000) |
| | | @ApiOperation("çä¿¡éªè¯ç ç»å½") |
| | | @PostMapping("/loginByPhone") |
| | | public ApiResponse<String> loginByPhone (@Validated @RequestBody LoginPhoneDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ZERO, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.ZERO, true,request)); |
| | | } |
| | | |
| | | @ApiOperation("éåºç»å½") |
| | |
| | | <oshi.version>5.7.0</oshi.version> |
| | | <jna.version>5.7.0</jna.version> |
| | | <poi.version>5.0.0</poi.version> |
| | | <!-- 微信å°ç¨åº --> |
| | | <weixin-java-miniapp.version>4.1.0</weixin-java-miniapp.version> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | |
| | | <version>2.5.1</version> |
| | | </dependency> |
| | | |
| | | |
| | | <!-- WeChat å°ç¨åº --> |
| | | <dependency> |
| | | <groupId>com.github.binarywang</groupId> |
| | | <artifactId>weixin-java-miniapp</artifactId> |
| | | <version>${weixin-java-miniapp.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>net.sourceforge.jexcelapi</groupId> |
| | | <artifactId>jxl</artifactId> |
| | |
| | | // è·¯å¾æ¦æªé
ç½® |
| | | map.put("/system/login", "anon"); |
| | | map.put("/system/loginByPhone", "anon"); |
| | | map.put("/system/loginByWxMini", "anon"); |
| | | map.put("/system/logout", "anon"); |
| | | map.put("/common/captcha", "anon"); |
| | | map.put("/business/smsEmail/sendSms", "anon"); |
| | |
| | | public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { |
| | | ShiroToken usernamePasswordToken = (ShiroToken) token; |
| | | SystemUser queryUserDto = new SystemUser(); |
| | | queryUserDto.setUsername(usernamePasswordToken.getUsername()); |
| | | queryUserDto.setDeleted(Boolean.FALSE); |
| | | if(!usernamePasswordToken.isNeedPassword()){ |
| | | queryUserDto.setMobile(usernamePasswordToken.getUsername()); |
| | | SystemUser systemUser = systemUserService.findOne(queryUserDto); |
| | | if (systemUser == null) { |
| | | return Boolean.FALSE; |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | queryUserDto.setUsername(usernamePasswordToken.getUsername()); |
| | | SystemUser systemUser = systemUserService.findOne(queryUserDto); |
| | | if (systemUser == null) { |
| | | return Boolean.FALSE; |
| | | } |
| | | if(!usernamePasswordToken.isNeedPassword()){ |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | // å å¯å¯ç |
| | | String pwd = Utils.Secure.encryptPassword(new String(usernamePasswordToken.getPassword()), systemUser.getSalt()); |
| | | // æ¯è¾å¯ç |
| | |
| | | private String sex; |
| | | private String mobile; |
| | | |
| | | private String openid; |
| | | private Integer companyId; |
| | | private Integer areaId; |
| | | private Integer cityId; |
| | |
| | | public static final String RANGE_SIZE = "RANGE_SIZE"; |
| | | public static final String CATE_PARAM_OPEN = "_CATE_PARAM_OPEN"; |
| | | public static final String OPEN_SYNC_SWITCH = "OPEN_SYNC_SWITCH"; |
| | | |
| | | public static final String WX_MIN_PROGRAM = "WX_MIN_PROGRAM"; |
| | | public static final String WX_MIN_APPID = "WX_MIN_APPID"; |
| | | public static final String WX_MIN_SECRET = "WX_MIN_SECRET"; |
| | | |
| | | public static final String SYSTEM ="SYSTEM"; |
| | | public static final String GOODS_IMG_DIR ="GOODS_IMG_DIR"; |
| | |
| | | |
| | | SYSTEM(0, "ç³»ç»ç¨æ·", "管çå",Arrays.asList(0,1,2,3,4,5,6,7,8,9,10,11)), |
| | | COMPANY(1, "ä¼ä¸ç¨æ·", "ä¼ä¸",Arrays.asList(-1)), |
| | | ZHUBO(2, "主æ", "主æ",Arrays.asList(-1)), |
| | | ZHUBO(2, "åæ·", "åæ·",Arrays.asList(-1)), |
| | | ; |
| | | // æååé |
| | | private String name; |
| | |
| | | } |
| | | } |
| | | |
| | | public enum UnionApplyStatus { |
| | | UPLOAD(1, "å¾
ä¸ä¼ æä¿å","",0), |
| | | ; |
| | | // æååé |
| | | private String name; |
| | | private String info; |
| | | private int key; |
| | | private int collectStatus; |
| | | |
| | | |
| | | // æé æ¹æ³ |
| | | UnionApplyStatus(int key, String name,String info,int collectStatus) { |
| | | this.name = name; |
| | | this.key = key; |
| | | this.info = info; |
| | | this.collectStatus = collectStatus; |
| | | } |
| | | |
| | | // æ®éæ¹æ³ |
| | | public static String getName(int index) { |
| | | for (UnionApplyStatus c : UnionApplyStatus.values()) { |
| | | if (c.getKey() == index) { |
| | | return c.name; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | public static List<Integer> getKesByStatus(Integer collectStatus) { |
| | | List<Integer> list = new ArrayList<>(); |
| | | if(collectStatus!=null){ |
| | | for (UnionApplyStatus c : UnionApplyStatus.values()) { |
| | | if (Constants.equalsInteger(c.getCollectStatus() ,collectStatus)) { |
| | | list.add(c.getKey()); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | public static Integer getCollectStatus(Integer index) { |
| | | for (UnionApplyStatus c : UnionApplyStatus.values()) { |
| | | if (Constants.equalsInteger(c.getKey() , index)) { |
| | | return c.collectStatus; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | public static String getInfo(int index) { |
| | | for (UnionApplyStatus c : UnionApplyStatus.values()) { |
| | | if (c.getKey() == index) { |
| | | return c.info; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | // get set æ¹æ³ |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public int getKey() { |
| | | return key; |
| | | } |
| | | |
| | | public void setKey(int key) { |
| | | this.key = key; |
| | | } |
| | | |
| | | public String getInfo() { |
| | | return info; |
| | | } |
| | | |
| | | public void setInfo(String info) { |
| | | this.info = info; |
| | | } |
| | | |
| | | public int getCollectStatus() { |
| | | return collectStatus; |
| | | } |
| | | |
| | | public void setCollectStatus(int collectStatus) { |
| | | this.collectStatus = collectStatus; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public enum InsuranceApplyStatus { |
| | | UPLOAD(0, "æäº¤æä¿","",0), |
| | | PLATFORM_RETURN(1, "å®¡æ ¸ä¸éè¿","æäº¤æè§ï¼${param}",4), |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2022/12/7 17:26 |
| | | */ |
| | | @Data |
| | | public class AccessToken { |
| | | |
| | | private String accessToken; |
| | | //è¿ææ¶é´ å½åç³»ç»æ¶é´+å¾®ä¿¡ä¼ æ¥çè¿ææ¶é´ |
| | | private Long expiresTime; |
| | | |
| | | public AccessToken(String accessToken, String expiresIn) { |
| | | this.accessToken = accessToken; |
| | | this.expiresTime = System.currentTimeMillis()+Integer.parseInt(expiresIn)*1000; |
| | | } |
| | | |
| | | /** |
| | | * 夿tokenæ¯å¦è¿æ |
| | | * @return |
| | | */ |
| | | public boolean isExpired(){ |
| | | return System.currentTimeMillis()>expiresTime; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2022/12/7 17:27 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class SendWxMessage { |
| | | |
| | | private static String programUrl = "packagesMine/meetingDetails/meetingDetails?id="; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | // /** |
| | | // * ä¼è®®å¼å§éç¥ |
| | | // * @param systemUser ç¨æ· |
| | | // * @param bookings ä¼è®®ä¿¡æ¯ |
| | | // * @param rooms ä¼è®®å®¤ä¿¡æ¯ |
| | | // */ |
| | | // public void bookingsStart(SystemUser systemUser, Bookings bookings, Rooms rooms){ |
| | | // RestTemplate restTemplate = new RestTemplate(); |
| | | // String accessToken = systemDictDataBiz.queryCodeById(106); |
| | | // log.info("微信å°ç¨åº ä¼è®®å¼å§è®¢é
æ¶æ¯åéæ¥å¿ -> accessTokenï¼{}",accessToken); |
| | | // //è¿éç®åèµ·è§æä»¬æ¯æ¬¡é½è·åææ°çaccess_tokenï¼æ¶é´å¼åä¸ï¼åºè¯¥å¨access_tokenå¿«è¿ææ¶åéæ°è·åï¼ |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken; |
| | | // //æ¼æ¥æ¨éçæ¨¡ç |
| | | // WxMsgVO wxMsgVo = new WxMsgVO(); |
| | | // //ç¨æ·çopenidï¼è¦åéç»é£ä¸ªç¨æ·ï¼ |
| | | // wxMsgVo.setTouser(systemUser.getOpenid()); |
| | | // //订é
æ¶æ¯æ¨¡æ¿id |
| | | // wxMsgVo.setTemplate_id("di_lWUtlqvWAo7aWKZCH8Kzs1Cv2z3H6fOkKI4RwJzg"); |
| | | // Map<String, TemplateData> m = new HashMap<>(4); |
| | | // //ä¼è®®ä¸»é¢ |
| | | // m.put("thing1", new TemplateData(bookings.getName())); |
| | | // //ä¼è®®å°ç¹ |
| | | // m.put("thing2", new TemplateData(rooms.getName())); |
| | | // //æ¶é´ |
| | | // m.put("thing3", new TemplateData(DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd"))); |
| | | // //主æäºº |
| | | // m.put("name4", new TemplateData(systemUser.getRealname())); |
| | | // wxMsgVo.setPage(programUrl +bookings.getId()); |
| | | // wxMsgVo.setData(m); |
| | | // ResponseEntity<String> responseEntity = |
| | | // restTemplate.postForEntity(url, wxMsgVo, String.class); |
| | | // log.info("微信å°ç¨åº-> åæ¶éç¥è®¢é
æ¶æ¯å鿥å¿ï¼{}",JSONObject.toJSONString(responseEntity)); |
| | | // } |
| | | // |
| | | // /** |
| | | // * ä¼è®®åæ¶éç¥ |
| | | // * @param systemUser ç¨æ· |
| | | // * @param bookings ä¼è®®ä¿¡æ¯ |
| | | // * @param rooms ä¼è®®å®¤ä¿¡æ¯ |
| | | // */ |
| | | // public void bookingsCancel(SystemUser systemUser, Bookings bookings, Rooms rooms){ |
| | | // RestTemplate restTemplate = new RestTemplate(); |
| | | // String accessToken = systemDictDataBiz.queryCodeById(106); |
| | | // log.info("微信å°ç¨åº ä¼è®®å¼å§è®¢é
æ¶æ¯åéæ¥å¿ -> accessTokenï¼{}",accessToken); |
| | | // //è¿éç®åèµ·è§æä»¬æ¯æ¬¡é½è·åææ°çaccess_tokenï¼æ¶é´å¼åä¸ï¼åºè¯¥å¨access_tokenå¿«è¿ææ¶åéæ°è·åï¼ |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken; |
| | | // //æ¼æ¥æ¨éçæ¨¡ç |
| | | // WxMsgVO wxMsgVo = new WxMsgVO(); |
| | | // //ç¨æ·çopenidï¼è¦åéç»é£ä¸ªç¨æ·ï¼ |
| | | // wxMsgVo.setTouser(systemUser.getOpenid()); |
| | | // //订é
æ¶æ¯æ¨¡æ¿id |
| | | // wxMsgVo.setTemplate_id("6A79DG8Fd9CjUDHhxJVv8dWcqww0v9_wwQLr7_ZuNqU"); |
| | | // Map<String, TemplateData> m = new HashMap<>(4); |
| | | // //ä¼è®®åç§° |
| | | // m.put("thing4", new TemplateData(bookings.getName())); |
| | | // //ä¼è®®æ¶é´ |
| | | // m.put("time2", new TemplateData(DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd"))); |
| | | //// m.put("time4", new TemplateData( |
| | | //// DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd")+ |
| | | //// " " + DateUtil.getDate(bookings.getStartTime(),"HH:mm")+ |
| | | //// " è³ " + DateUtil.getDate(bookings.getEndTime(),"HH:mm") ) ); |
| | | // //ä¼è®®å®¤ |
| | | // m.put("thing1", new TemplateData(rooms.getName())); |
| | | // //夿³¨ |
| | | // m.put("thing3", new TemplateData(bookings.getRemark())); |
| | | // wxMsgVo.setPage(programUrl +bookings.getId()); |
| | | // wxMsgVo.setData(m); |
| | | // ResponseEntity<String> responseEntity = |
| | | // restTemplate.postForEntity(url, wxMsgVo, String.class); |
| | | // log.info("微信å°ç¨åº->åæ¶éç¥è®¢é
æ¶æ¯å鿥å¿ï¼{}",JSONObject.toJSONString(responseEntity)); |
| | | // } |
| | | // |
| | | // |
| | | // /** |
| | | // * ä¼è®®é¢çº¦æåéç¥ |
| | | // * @param systemUser ç¨æ· |
| | | // * @param bookings ä¼è®®ä¿¡æ¯ |
| | | // * @param rooms ä¼è®®å®¤ä¿¡æ¯ |
| | | // */ |
| | | // public void bookingsReservation(SystemUser systemUser, Bookings bookings, Rooms rooms){ |
| | | // RestTemplate restTemplate = new RestTemplate(); |
| | | // String accessToken = systemDictDataBiz.queryCodeById(106); |
| | | // log.info("微信å°ç¨åº ä¼è®®å¼å§è®¢é
æ¶æ¯åéæ¥å¿ -> accessTokenï¼{}",accessToken); |
| | | // |
| | | // //è¿éç®åèµ·è§æä»¬æ¯æ¬¡é½è·åææ°çaccess_tokenï¼æ¶é´å¼åä¸ï¼åºè¯¥å¨access_tokenå¿«è¿ææ¶åéæ°è·åï¼ |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="+accessToken; |
| | | // //æ¼æ¥æ¨éçæ¨¡ç |
| | | // WxMsgVO wxMsgVo = new WxMsgVO(); |
| | | // //ç¨æ·çopenidï¼è¦åéç»é£ä¸ªç¨æ·ï¼ |
| | | // wxMsgVo.setTouser(systemUser.getOpenid()); |
| | | // //订é
æ¶æ¯æ¨¡æ¿id |
| | | // wxMsgVo.setTemplate_id("usZxJqJ2AYPg24ViPMuY2lI-YRjdSD2JvFY3gY5kqh4"); |
| | | // Map<String, TemplateData> m = new HashMap<>(4); |
| | | // //ä¼è®®ä¸»é¢ |
| | | // m.put("thing3", new TemplateData(bookings.getName())); |
| | | // //ä¼è®®æ¶é´ |
| | | // m.put("time1", new TemplateData( |
| | | // DateUtil.getDate(bookings.getStartTime(),"yyyy-MM-dd") |
| | | //// + |
| | | //// " " + DateUtil.getDate(bookings.getStartTime(),"HH:mm")+ |
| | | //// " è³ " + DateUtil.getDate(bookings.getEndTime(),"HH:mm") |
| | | // ) ); |
| | | // //ä¼è®®å°ç¹ |
| | | // m.put("thing2", new TemplateData(rooms.getName())); |
| | | // //å起人 |
| | | // m.put("thing4", new TemplateData(systemUser.getRealname())); |
| | | // wxMsgVo.setPage(programUrl +bookings.getId()); |
| | | // wxMsgVo.setData(m); |
| | | // ResponseEntity<String> responseEntity = |
| | | // restTemplate.postForEntity(url, wxMsgVo, String.class); |
| | | // log.info("微信å°ç¨åº-> ä¼è®®é¢çº¦æå订é
æ¶æ¯å鿥å¿ï¼{}",JSONObject.toJSONString(responseEntity)); |
| | | // } |
| | | |
| | | |
| | | |
| | | // /** |
| | | // * è·åtoken |
| | | // */ |
| | | // private static String getAccessToken() { |
| | | // //åé请æ±è·åtoken |
| | | // JSONObject token = null; |
| | | // try { |
| | | // token = JSONObject.parseObject(HttpsUtil.get(APP_ACCESS_TOKEN_URL,false)); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // JSONObject jsonObject = token; |
| | | // String accessToken = (String) jsonObject.get("access_token"); |
| | | // Integer expiresIn = (Integer) jsonObject.get("expires_in"); |
| | | // //å建token对象ï¼å¹¶åå¨ |
| | | // return new AccessToken(accessToken,String.valueOf(expiresIn)).getAccessToken(); |
| | | // } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.beans.factory.config.BeanDefinition; |
| | | import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
| | | import org.springframework.beans.factory.support.BeanDefinitionRegistry; |
| | | import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * NOTICE: NEVER USE IT WHEN REGISTERING A SPRING BEAN. |
| | | * |
| | | * @author Guang YANG |
| | | */ |
| | | @Component |
| | | public class SpringUtils implements ApplicationContextAware { |
| | | |
| | | private static ApplicationContext CTX; |
| | | |
| | | public static ApplicationContext get() { |
| | | return CTX; |
| | | } |
| | | |
| | | @Override |
| | | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
| | | CTX = applicationContext; |
| | | } |
| | | |
| | | /** |
| | | * å容å¨ä¸å¨ææ·»å Bean |
| | | * |
| | | * @param ctx |
| | | * @param beanName |
| | | * @param beanClass |
| | | */ |
| | | public static void addBean(ApplicationContext ctx, String beanName, Class beanClass) { |
| | | BeanDefinitionRegistry beanDefReg = (DefaultListableBeanFactory)ctx.getAutowireCapableBeanFactory(); |
| | | BeanDefinitionBuilder beanDefBuilder = BeanDefinitionBuilder.genericBeanDefinition(beanClass); |
| | | BeanDefinition beanDef = beanDefBuilder.getBeanDefinition(); |
| | | if (!beanDefReg.containsBeanDefinition(beanName)) { |
| | | beanDefReg.registerBeanDefinition(beanName, beanDef); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä»å®¹å¨ä¸ç§»é¤Bean |
| | | * |
| | | * @param ctx |
| | | * @param beanName |
| | | */ |
| | | public static void removeBean(ApplicationContext ctx, String beanName) { |
| | | BeanDefinitionRegistry beanDefReg = (DefaultListableBeanFactory) ctx.getAutowireCapableBeanFactory(); |
| | | beanDefReg.getBeanDefinition(beanName); |
| | | beanDefReg.removeBeanDefinition(beanName); |
| | | } |
| | | |
| | | /** |
| | | * éåè¾åºææBeançä¿¡æ¯ |
| | | */ |
| | | static void showAllBeans(ApplicationContext ctx) { |
| | | //éå |
| | | for (String name : ctx.getBeanDefinitionNames()) { |
| | | System.out.println("name:" + name + ",class:" + ctx.getBean(name).getClass()); |
| | | } |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2022/12/7 17:28 |
| | | */ |
| | | @Data |
| | | public class TemplateData { |
| | | private String value; |
| | | |
| | | public TemplateData(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import cn.binarywang.wx.miniapp.api.WxMaService; |
| | | import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; |
| | | import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.utils.Constants; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | |
| | | /** |
| | | * 微信å°ç¨åºç»ä»¶ |
| | | */ |
| | | @Configuration |
| | | public class WxMiniConfig { |
| | | /********微信å°ç¨åºæå¡**********/ |
| | | public static WxMaService wxMaService; |
| | | /********微信å°ç¨åºæ¯ä»**********/ |
| | | // public static WxPayService wxPayService; |
| | | // /********微信APPæ¯ä»**********/ |
| | | // public static WxPayService wxAppPayService; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | public static WxMiniConfig me() { |
| | | return SpringUtils.get().getBean(WxMiniConfig.class); |
| | | } |
| | | |
| | | @PostConstruct |
| | | void init() { |
| | | this.load_WxMaService(); |
| | | // this.load_wxPayService(); |
| | | // this.load_wxAppPayService(); |
| | | } |
| | | /** |
| | | * åå§å微信å°ç¨åº |
| | | */ |
| | | public void load_WxMaService() { |
| | | WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); |
| | | config.setAppid(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MIN_PROGRAM,Constants.WX_MIN_APPID).getCode())); |
| | | config.setSecret(StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.WX_MIN_PROGRAM,Constants.WX_MIN_SECRET).getCode())); |
| | | config.setMsgDataFormat("JSON"); |
| | | //config.setToken(""); |
| | | //config.setAesKey(""); |
| | | WxMaService wxMaService = new WxMaServiceImpl(); |
| | | wxMaService.setWxMaConfig(config); |
| | | this.wxMaService = wxMaService; |
| | | } |
| | | |
| | | /** |
| | | * åå§å微信å°ç¨åºæ¯ä» |
| | | */ |
| | | // public void load_wxPayService() { |
| | | // WxPayConfig payConfig = new WxPayConfig(); |
| | | // payConfig.setTradeType(WxPayConstants.TradeType.JSAPI); |
| | | // payConfig.setSignType(WxPayConstants.SignType.MD5); |
| | | // payConfig.setAppId(StringUtils.trimToNull(wxPayProperties.getAppId())); |
| | | // payConfig.setMchId(StringUtils.trimToNull(wxPayProperties.getMchId())); |
| | | // payConfig.setMchKey(StringUtils.trimToNull(wxPayProperties.getMchKey())); |
| | | // payConfig.setKeyPath(StringUtils.trimToNull(wxPayProperties.getKeyPath())); |
| | | // payConfig.setNotifyUrl(StringUtils.trimToNull(wxPayProperties.getNotifyUrl())); |
| | | // WxPayService wxPayService = new WxPayServiceImpl(); |
| | | // wxPayService.setConfig(payConfig); |
| | | // this.wxPayService = wxPayService; |
| | | // } |
| | | |
| | | |
| | | |
| | | // /** |
| | | // * åå§åAppæ¯ä» |
| | | // */ |
| | | // public void load_wxAppPayService() { |
| | | // WxPayConfig payConfig = new WxPayConfig(); |
| | | // payConfig.setTradeType(WxPayConstants.TradeType.APP); |
| | | // payConfig.setSignType(WxPayConstants.SignType.MD5); |
| | | // payConfig.setAppId(""); |
| | | // payConfig.setMchId(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_MchId.getCode()))); |
| | | // payConfig.setMchKey(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_MchKey.getCode()))); |
| | | // payConfig.setKeyPath(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_KeyPath.getCode()))); |
| | | // payConfig.setNotifyUrl(StringUtils.trimToNull(sysDictService.getSysDictValue(SysDictEnum.WX_MINI_NotifyUrl.getCode()))); |
| | | // WxPayService wxPayService = new WxPayServiceImpl(); |
| | | // wxPayService.setConfig(payConfig); |
| | | // this.wxAppPayService = wxPayService; |
| | | // } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2022/12/7 17:27 |
| | | */ |
| | | @Data |
| | | public class WxMsgVO { |
| | | //ç¨æ·openId |
| | | private String touser; |
| | | //模çid |
| | | private String template_id; |
| | | //æ¨éæå |
| | | private Map<String , TemplateData> data; |
| | | //è·³è½¬è·¯å¾ ï¼é»è®¤è·³è½¬å°å°ç¨åºé¦é¡µ |
| | | private String page="pages/index/index"; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.wx; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2023/3/22 18:04 |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "wx.pay") |
| | | @Data |
| | | public class WxPayProperties { |
| | | |
| | | /** |
| | | * AppID |
| | | */ |
| | | private String appId; |
| | | |
| | | /** |
| | | * AppSecret |
| | | */ |
| | | private String appSecret; |
| | | |
| | | /** |
| | | * å¾®ä¿¡åæ·å· |
| | | */ |
| | | private String mchId; |
| | | |
| | | /** |
| | | * æ¯ä»APIå¯é¥ |
| | | */ |
| | | private String mchKey; |
| | | |
| | | /** |
| | | * æ¯ä»åè°å°å |
| | | */ |
| | | private String notifyUrl; |
| | | |
| | | /** |
| | | * æ¯ä»è¯ä¹¦(p12) |
| | | */ |
| | | private String keyPath; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.dto; |
| | | |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by IntelliJ IDEA. |
| | | * |
| | | * @Author : Rk |
| | | * @create 2024/3/15 14:42 |
| | | */ |
| | | @Data |
| | | public class SaveUnionApplyDTO { |
| | | |
| | | @ApiModelProperty(value = "æ¹æ¡åºç¡æ°æ®ä¸»é®") |
| | | private Integer baseSolutionId; |
| | | |
| | | @ApiModelProperty(value = "ä¿åä¸»é® å¤ä¸ªä»¥,åå²") |
| | | private List<Integer> applyIds; |
| | | |
| | | @ApiModelProperty(value = "å¼å§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date startDate; |
| | | |
| | | @ApiModelProperty(value = "ç»ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date endDate; |
| | | |
| | | |
| | | } |
| | |
| | | @TableField(exist = false) |
| | | private Integer timeUnit; |
| | | |
| | | @ApiModelProperty(value = "æ¹æ¡åºç¡çæ¬ä¸»é®", example = "1") |
| | | @TableField(exist = false) |
| | | private Integer solutionBaseId; |
| | | |
| | | @ApiModelProperty(value = "ææ°çæ¬çæ¹æ¡ä¸»é®", example = "1") |
| | | @TableField(exist = false) |
| | |
| | | @NotBlank(message = "éªè¯ç UUIDä¸è½ä¸ºç©º") |
| | | @ApiModelProperty(value = "éªè¯ç UUID") |
| | | private String uuid; |
| | | |
| | | @ApiModelProperty(value = "openid",hidden = true) |
| | | private String openid; |
| | | |
| | | } |
| | |
| | | @NotBlank(message = "éªè¯ç ä¸è½ä¸ºç©º") |
| | | @ApiModelProperty(value = "éªè¯ç ") |
| | | private String code; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.system.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author Eva.Caesar Liu |
| | | * @date 2023/02/14 11:14 |
| | | */ |
| | | @Data |
| | | @ApiModel("微信å°ç¨åºç»å½åæ°") |
| | | public class WxMiniLoginDTO implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "ç¨æ·å") |
| | | private String username; |
| | | |
| | | @ApiModelProperty(value = "å¯ç ") |
| | | private String password; |
| | | |
| | | @ApiModelProperty(value = "微信code") |
| | | private String code; |
| | | |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "å¯ç ") |
| | | @NotBlank(message = "åå§å¯ç ä¸è½ä¸ºç©º") |
| | | private String password; |
| | | @ApiModelProperty(value = "openid") |
| | | @NotBlank(message = "openid") |
| | | private String openid; |
| | | |
| | | @ApiModelProperty(value = "ç") |
| | | private String salt; |
| | |
| | | @ApiModelProperty(value = "0 å¯ç¨ 1 ç¦ç¨") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "微信å°ç¨åºOPENID") |
| | | private String openid; |
| | | |
| | | @ApiModelProperty(value = "æå±ä¼ä¸ä¿¡æ¯å¯¹") |
| | | @TableField(exist = false) |
| | | private Company company; |
| | |
| | | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.dao.business.dto.SaveUnionApplyDTO; |
| | | import com.doumee.dao.business.model.UnionApply; |
| | | import java.util.List; |
| | | |
| | |
| | | * @return long |
| | | */ |
| | | long count(UnionApply unionApply); |
| | | |
| | | /** |
| | | * ä¿ååå¹¶ |
| | | * @param saveUnionApplyDTO |
| | | */ |
| | | void merge(SaveUnionApplyDTO saveUnionApplyDTO); |
| | | } |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.UnionApplyMapper; |
| | | import com.doumee.dao.business.dto.SaveUnionApplyDTO; |
| | | import com.doumee.dao.business.join.InsuranceApplyJoinMapper; |
| | | import com.doumee.dao.business.model.InsuranceApply; |
| | | import com.doumee.dao.business.model.Solutions; |
| | | import com.doumee.dao.business.model.UnionApply; |
| | | import com.doumee.service.business.UnionApplyService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * åå¹¶æä¿åä¿¡æ¯è¡¨Serviceå®ç° |
| | |
| | | |
| | | @Autowired |
| | | private UnionApplyMapper unionApplyMapper; |
| | | |
| | | @Autowired |
| | | private InsuranceApplyJoinMapper insuranceApplyJoinMapper; |
| | | |
| | | @Override |
| | | public Integer create(UnionApply unionApply) { |
| | |
| | | QueryWrapper<UnionApply> wrapper = new QueryWrapper<>(unionApply); |
| | | return unionApplyMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void merge(SaveUnionApplyDTO saveUnionApplyDTO){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(user.getType().equals(Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"éåæ·ç¨æ·ï¼æ æ³è¿è¡è¯¥æä½"); |
| | | } |
| | | if(Objects.isNull(saveUnionApplyDTO) |
| | | || Objects.isNull(saveUnionApplyDTO.getApplyIds()) |
| | | || Objects.isNull(saveUnionApplyDTO.getStartDate()) |
| | | || Objects.isNull(saveUnionApplyDTO.getEndDate()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | List<InsuranceApply> insuranceApplyList = insuranceApplyJoinMapper.selectJoinList(InsuranceApply.class, |
| | | new MPJLambdaWrapper<InsuranceApply>() |
| | | .selectAll(InsuranceApply.class) |
| | | .selectAs(InsuranceApply::getSolutionBaseId,Solutions::getBaseId) |
| | | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) |
| | | .eq(InsuranceApply::getIsdeleted, Constants.ZERO) |
| | | .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey()) |
| | | .eq(Solutions::getBaseId,saveUnionApplyDTO.getBaseSolutionId()) |
| | | .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds()) |
| | | .isNull(InsuranceApply::getUnionApplyId) |
| | | ); |
| | | //æ¥è¯¢æ°æ®æ¯å¦å卿ªå¤äºå®¡æ¹éè¿çæ°æ® |
| | | if(insuranceApplyList.size()!=saveUnionApplyDTO.getApplyIds().size()){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"å卿°æ®å·²å¤çï¼è¯·å·æ°éè¯"); |
| | | } |
| | | |
| | | UnionApply unionApply = new UnionApply(); |
| | | unionApply.setCreateDate(new Date()); |
| | | unionApply.setCreator(user.getId()); |
| | | unionApply.setCompanyId(user.getCompanyId()); |
| | | unionApply.setStartTime(saveUnionApplyDTO.getStartDate()); |
| | | unionApply.setEndTime(saveUnionApplyDTO.getEndDate()); |
| | | unionApply.setCheckDate(new Date()); |
| | | unionApply.setStatus(Constants.UnionApplyStatus.UPLOAD.getKey()); |
| | | unionApply.setCheckUserId(user.getId()); |
| | | unionApply.setFee(insuranceApplyList.stream().map(i->i.getFee()).reduce(BigDecimal.ZERO,BigDecimal::add)); |
| | | unionApply.setCurrentFee(BigDecimal.ZERO); |
| | | unionApplyMapper.insert(unionApply); |
| | | |
| | | insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() |
| | | .set(InsuranceApply::getUnionApplyId,unionApply.getId()) |
| | | .set(InsuranceApply::getCheckDate,new Date()) |
| | | .set(InsuranceApply::getCheckUserId,user.getId()) |
| | | .in(InsuranceApply::getId,saveUnionApplyDTO.getApplyIds())); |
| | | |
| | | } |
| | | |
| | | |
| | | public void cancelMerge(Integer id){ |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(user.getType().equals(Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"éåæ·ç¨æ·ï¼æ æ³è¿è¡è¯¥æä½"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.dao.system.dto.LoginPhoneDTO; |
| | | import com.doumee.dao.system.dto.WxMiniLoginDTO; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | |
| | | * @author Eva.Caesar Liu |
| | | * @date 2023/03/21 14:49 |
| | | */ |
| | | String loginByPassword (LoginDTO dto,int type, HttpServletRequest request); |
| | | String loginByPhone (LoginPhoneDTO dto, int type, HttpServletRequest request); |
| | | String loginByPassword (LoginDTO dto,int type,Boolean checkCaptcha, HttpServletRequest request); |
| | | String loginByPhone (LoginPhoneDTO dto, int type,Boolean checkSmsCode, HttpServletRequest request); |
| | | |
| | | /** |
| | | * |
| | | * @param wxMiniLoginDTO |
| | | * @param request |
| | | * @return |
| | | */ |
| | | String loginByWxMini (WxMiniLoginDTO wxMiniLoginDTO, HttpServletRequest request); |
| | | |
| | | void cleaOpenid(); |
| | | } |
| | |
| | | package com.doumee.service.system.impl; |
| | | |
| | | import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.doumee.config.shiro.ShiroToken; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.dao.business.SmsEmailMapper; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.dao.system.dto.LoginPhoneDTO; |
| | | import com.doumee.dao.system.dto.WxMiniLoginDTO; |
| | | import com.doumee.dao.system.model.SystemLoginLog; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.impl.SmsEmailServiceImpl; |
| | | import com.doumee.service.common.CaptchaService; |
| | | import com.doumee.service.system.SystemLoginLogService; |
| | | import com.doumee.service.system.SystemLoginService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.authc.AuthenticationException; |
| | | import org.apache.shiro.subject.Subject; |
| | |
| | | @Autowired |
| | | private SystemLoginLogService systemLoginLogService; |
| | | |
| | | @Autowired |
| | | private SystemUserMapper systemUserMapper; |
| | | |
| | | |
| | | // /** |
| | | // * 微信ææï¼ç»å½åï¼ |
| | | // * @param code |
| | | // */ |
| | | // @Override |
| | | // public String wxEmpower(String code,Integer userId){ |
| | | // try { |
| | | // //è·åå¾®ä¿¡æææ°æ® |
| | | // WxMaJscode2SessionResult session = WxMiniConfig.wxMaService.getUserService().getSessionInfo(code); |
| | | // String openId = session.getOpenid(); |
| | | // if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(openId)) { |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"è·åopenid失败ï¼è¯·è系管çå"); |
| | | // } |
| | | // if(Objects.nonNull(userId)){ |
| | | // systemUserMapper.update(null,new UpdateWrapper<SystemUser>() |
| | | // .lambda() |
| | | // .set(SystemUser::getOpenid,null) |
| | | // .eq(SystemUser::getOpenid,openId) |
| | | // .ne(SystemUser::getId,userId)); |
| | | // |
| | | // systemUserMapper.update(null,new UpdateWrapper<SystemUser>() |
| | | // .lambda() |
| | | // .set(SystemUser::getOpenid,openId) |
| | | // .eq(SystemUser::getId,userId)); |
| | | // } |
| | | // return openId; |
| | | // } catch (WxErrorException e) { |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"微信ç»å½å¼å¸¸ï¼è¯·è系管çå"); |
| | | // } |
| | | // } |
| | | |
| | | @Override |
| | | public String loginByPassword(LoginDTO dto, int type,HttpServletRequest request) { |
| | | public void cleaOpenid(){ |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(StringUtils.isNotBlank(loginUserInfo.getOpenid())){ |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda() |
| | | .set(SystemUser::getOpenid,null) |
| | | .eq(SystemUser::getId,loginUserInfo.getId())); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public String loginByWxMini (WxMiniLoginDTO wxMiniLoginDTO, HttpServletRequest request){ |
| | | LoginDTO dto = new LoginDTO(); |
| | | if(StringUtils.isNotBlank(wxMiniLoginDTO.getCode())){ |
| | | try{ |
| | | WxMaJscode2SessionResult session = WxMiniConfig.wxMaService.getUserService().getSessionInfo(wxMiniLoginDTO.getCode()); |
| | | String openId = session.getOpenid(); |
| | | if (StringUtils.isNotBlank(openId)&&StringUtils.isBlank(wxMiniLoginDTO.getUsername())) { |
| | | SystemUser systemUser = systemUserMapper.selectOne(new QueryWrapper<SystemUser>() |
| | | .lambda().eq(SystemUser::getOpenid,openId) |
| | | .eq(SystemUser::getDeleted,Constants.ZERO) |
| | | .eq(SystemUser::getType,Constants.UserType.COMPANY.getKey()) |
| | | .orderByDesc(SystemUser::getCreateTime) |
| | | .last(" limit 1") |
| | | ); |
| | | if(Objects.nonNull(systemUser)){ |
| | | LoginPhoneDTO loginPhoneDTO = new LoginPhoneDTO(); |
| | | loginPhoneDTO.setPhone(systemUser.getMobile()); |
| | | return this.loginByPhone(loginPhoneDTO,Constants.ONE,false,request); |
| | | }else{ |
| | | return null; |
| | | } |
| | | }else{ |
| | | dto.setOpenid(openId); |
| | | } |
| | | } catch (WxErrorException e) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"微信ç»å½å¼å¸¸ï¼è¯·è系管çå"); |
| | | } |
| | | } |
| | | if(StringUtils.isBlank(wxMiniLoginDTO.getUsername()) |
| | | || StringUtils.isBlank(wxMiniLoginDTO.getPassword())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | dto.setUsername(wxMiniLoginDTO.getUsername()); |
| | | dto.setPassword(wxMiniLoginDTO.getPassword()); |
| | | return this.loginByPassword(dto,Constants.ONE,false,request); |
| | | } |
| | | |
| | | @Override |
| | | public String loginByPassword(LoginDTO dto, int type,Boolean checkCaptcha,HttpServletRequest request) { |
| | | SystemLoginLog loginLog = new SystemLoginLog(); |
| | | loginLog.setLoginUsername(dto.getUsername()); |
| | | loginLog.setLoginTime(new Date()); |
| | |
| | | loginLog.setServerIp(Utils.Server.getIP()); |
| | | // æ ¡éªéªè¯ç |
| | | try { |
| | | if(!debugModel){ |
| | | if(!debugModel&&checkCaptcha){ |
| | | captchaService.check(dto.getUuid(), dto.getCode()); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | loginLog.setUserId(((LoginUserInfo)subject.getPrincipal()).getId()); |
| | | loginLog.setSuccess(Boolean.TRUE); |
| | | systemLoginLogService.create(loginLog); |
| | | |
| | | //æ´æ°openidæå±ç¨æ·ä¿¡æ¯ |
| | | if(StringUtils.isNotBlank(dto.getOpenid())){ |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda() |
| | | .set(SystemUser::getOpenid,null) |
| | | .eq(SystemUser::getOpenid,dto.getOpenid()) |
| | | .ne(SystemUser::getId,loginLog.getUserId())); |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda() |
| | | .set(SystemUser::getOpenid,dto.getOpenid()) |
| | | .eq(SystemUser::getId,loginLog.getUserId())); |
| | | } |
| | | return (String)subject.getSession().getId(); |
| | | } catch (AuthenticationException e) { |
| | | log.error(ResponseStatus.ACCOUNT_INCORRECT.getMessage(), e); |
| | |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT.getCode(), Objects.isNull(e.getCause())?ResponseStatus.ACCOUNT_INCORRECT.getMessage():e.getCause().getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String loginByPhone (LoginPhoneDTO dto, int type, HttpServletRequest request) { |
| | | public String loginByPhone (LoginPhoneDTO dto, int type,Boolean checkSmsCode, HttpServletRequest request) { |
| | | SystemLoginLog loginLog = new SystemLoginLog(); |
| | | loginLog.setLoginUsername(dto.getPhone()); |
| | | loginLog.setLoginTime(new Date()); |
| | |
| | | loginLog.setOsInfo(Utils.User_Client.getOS(request)); |
| | | loginLog.setServerIp(Utils.Server.getIP()); |
| | | // æ ¡éªéªè¯ç |
| | | if(type!= Constants.TWO){ |
| | | try { |
| | | if(!debugModel){ |
| | | SmsEmailServiceImpl.isCaptcheValide(smsEmailMapper,dto.getPhone(), dto.getCode()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | loginLog.setReason(e.getMessage().length() > 200 ? (e.getMessage().substring(0, 190) + "...") : e.getMessage()); |
| | | loginLog.setSuccess(Boolean.FALSE); |
| | | systemLoginLogService.create(loginLog); |
| | | throw e; |
| | | try { |
| | | if(!debugModel&& checkSmsCode){ |
| | | SmsEmailServiceImpl.isCaptcheValide(smsEmailMapper,dto.getPhone(), dto.getCode()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | loginLog.setReason(e.getMessage().length() > 200 ? (e.getMessage().substring(0, 190) + "...") : e.getMessage()); |
| | | loginLog.setSuccess(Boolean.FALSE); |
| | | systemLoginLogService.create(loginLog); |
| | | throw e; |
| | | } |
| | | // æ ¡éªç¨æ·ååå¯ç |
| | | Subject subject = SecurityUtils.getSubject(); |
| | |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT.getCode(), Objects.isNull(e.getCause())?ResponseStatus.ACCOUNT_INCORRECT.getMessage():e.getCause().getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.system.dto.LoginDTO; |
| | | import com.doumee.dao.system.dto.LoginPhoneDTO; |
| | | import com.doumee.dao.system.dto.UpdatePwdDto; |
| | | import com.doumee.dao.system.dto.WebLoginDTO; |
| | | import com.doumee.dao.system.dto.*; |
| | | import com.doumee.service.system.SystemLoginService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @ApiOperation("ç»å½ - å端") |
| | | @PostMapping("/login") |
| | | public ApiResponse<String> login (@Validated @RequestBody LoginDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.TWO, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPassword(dto, Constants.TWO,true, request)); |
| | | } |
| | | |
| | | @PreventRepeat(limit = 10, lockTime = 10000) |
| | | @ApiOperation("çä¿¡éªè¯ç ç»å½") |
| | | @PostMapping("/loginByPhone") |
| | | public ApiResponse<String> loginByPhone (@Validated @RequestBody LoginPhoneDTO dto, HttpServletRequest request) { |
| | | return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.TWO, request)); |
| | | return ApiResponse.success(systemLoginService.loginByPhone(dto, Constants.TWO,true, request)); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation("éåºç»å½") |
| | | @PostMapping("/logout") |
| | | public ApiResponse logout () { |