Browse Source

fix(server): 异常登录

Go 5 years ago
parent
commit
7d6b0ff8df

+ 5 - 5
front/project/admin/routes/show/message/page.js

@@ -157,7 +157,7 @@ export default class extends Page {
   }
   }
 
 
   initData() {
   initData() {
-    this.refreshTab(this.state.search.tab || 'inside');
+    this.refreshTab(this.state.search.tab || 'custom');
   }
   }
 
 
   refreshTab(tab) {
   refreshTab(tab) {
@@ -271,15 +271,15 @@ export default class extends Page {
       <Tabs activeKey={tab || 'inside'} onChange={(value) => {
       <Tabs activeKey={tab || 'inside'} onChange={(value) => {
         this.search({ tab: value });
         this.search({ tab: value });
       }}>
       }}>
-        <Tabs.TabPane tab="模版消息" key="inside">
+        {/* <Tabs.TabPane tab="模版消息" key="inside">
           {this.renderInside()}
           {this.renderInside()}
-        </Tabs.TabPane>
+        </Tabs.TabPane> */}
         <Tabs.TabPane tab="自定义消息" key="custom">
         <Tabs.TabPane tab="自定义消息" key="custom">
           {this.renderCustom()}
           {this.renderCustom()}
         </Tabs.TabPane>
         </Tabs.TabPane>
-        <Tabs.TabPane tab="邮件模版" key="email">
+        {/* <Tabs.TabPane tab="邮件模版" key="email">
           {this.renderEmail()}
           {this.renderEmail()}
-        </Tabs.TabPane>
+        </Tabs.TabPane> */}
       </Tabs>
       </Tabs>
     </div>;
     </div>;
   }
   }

+ 3 - 3
front/project/admin/routes/user/abnormal/page.js

@@ -72,9 +72,9 @@ export default class extends Page {
       dataIndex: 'handler',
       dataIndex: 'handler',
       render: (text, record) => {
       render: (text, record) => {
         return <div className="table-button">
         return <div className="table-button">
-          {record.isIgnore && '已忽略'}
-          {record.isAlert && '已警告'}
-          {record.isAlert && record.user.isFrozen && (
+          {!!record.isIgnore && '已忽略'}
+          {!!record.isAlert && '已警告'}
+          {!!record.isAlert && !!record.user.isFrozen && (
             <a onClick={() => {
             <a onClick={() => {
               this.noFrozenAction(record);
               this.noFrozenAction(record);
             }}>取消封禁</a>
             }}>取消封禁</a>

+ 9 - 4
front/project/h5/routes/textbook/main/page.js

@@ -33,6 +33,12 @@ export default class extends Page {
   refreshTab(tab) {
   refreshTab(tab) {
     this.setState({ tab });
     this.setState({ tab });
     Textbook.allHistory(tab.key).then(result => {
     Textbook.allHistory(tab.key).then(result => {
+      result = result.map(row => {
+        row.version = row[`${tab.key}Version`];
+        row.content = row[`${tab.key}Content`];
+        row.createTime = formatDate(row.createTime, 'YYYY-MM-DD HH:mm:ss');
+        return row;
+      });
       this.setState({ list: result });
       this.setState({ list: result });
     });
     });
   }
   }
@@ -43,13 +49,12 @@ export default class extends Page {
       <div>
       <div>
         <div className="tip">最近换库时间:{latest.startDate ? formatDate(latest.startDate, 'YYYY-MM-DD') : ''},已换库{day}天。</div>
         <div className="tip">最近换库时间:{latest.startDate ? formatDate(latest.startDate, 'YYYY-MM-DD') : ''},已换库{day}天。</div>
         <Tabs page={tab.key} tabs={TextbookSubjectTabs} onChange={(v) => {
         <Tabs page={tab.key} tabs={TextbookSubjectTabs} onChange={(v) => {
-          linkTo('/textbook/detail');
           this.refreshTab(v);
           this.refreshTab(v);
         }} />
         }} />
         <div>{hasService ? this.renderList() : this.renderEmpty()}</div>
         <div>{hasService ? this.renderList() : this.renderEmpty()}</div>
         <div className="fixed">
         <div className="fixed">
           <Button block disabled={!hasService} size="lager" onClick={() => {
           <Button block disabled={!hasService} size="lager" onClick={() => {
-            linkTo('/textbook/detail');
+            linkTo(`/textbook/detail/${tab.key}`);
           }}>
           }}>
             查阅机经
             查阅机经
           </Button>
           </Button>
@@ -66,9 +71,9 @@ export default class extends Page {
         {list.map(row => {
         {list.map(row => {
           return <div className="item">
           return <div className="item">
             <div className="title">
             <div className="title">
-              版本{row.version}<span className="date">{row.createTime && formatDate(row.createTime)}</span>
+              版本{row.version}<span className="date">{row.createTime}</span>
             </div>
             </div>
-            <div className="desc" dangerouslySetInnerHTML={{ __html: row.content }} />
+            <div className="desc" >{row.content}</div>
           </div>;
           </div>;
         })}
         })}
 
 

+ 2 - 2
front/project/www/routes/my/main/page.js

@@ -646,7 +646,7 @@ export default class extends Page {
     return !info.vip && <div className="vip-layout">
     return !info.vip && <div className="vip-layout">
       <div className="body">
       <div className="body">
         <div className='m-b-1'>
         <div className='m-b-1'>
-        开通 <Assets className="m-r-5" name="VIP" />解锁海量权限
+          开通 <Assets className="m-r-5" name="VIP" />解锁海量权限
         </div>
         </div>
         <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 自由组卷</div>
         <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 自由组卷</div>
         <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 导出笔记</div>
         <div className='t d-i-b m-r-2 t-1 t-s-12'><Icon className='t-4' type='check' /> 导出笔记</div>
@@ -674,7 +674,7 @@ export default class extends Page {
     return (
     return (
       number > 0 && (
       number > 0 && (
         <div className="message-layout">
         <div className="message-layout">
-          <div className="header">
+          <div className="header c-p">
             <Assets
             <Assets
               name="all"
               name="all"
               onCancel={() => {
               onCancel={() => {

+ 2 - 1
front/project/www/routes/page/index.js

@@ -1,5 +1,6 @@
 import home from './home';
 import home from './home';
 import login from './login';
 import login from './login';
+import id from './id';
 import order from './order';
 import order from './order';
 import cart from './cart';
 import cart from './cart';
 import demo from './demo';
 import demo from './demo';
@@ -7,4 +8,4 @@ import contract from './contract';
 import ready from './ready';
 import ready from './ready';
 import exportDetail from './export';
 import exportDetail from './export';
 
 
-export default [home, login, order, cart, demo, contract, ready, exportDetail];
+export default [home, login, id, order, cart, demo, contract, ready, exportDetail];

+ 4 - 0
front/project/www/stores/user.js

@@ -94,6 +94,10 @@ export default class UserStore extends BaseStore {
         if (this.adminLogin) {
         if (this.adminLogin) {
           window.location.href = window.location.href.replace(`token=${this.adminLogin}`, '').replace('&&', '&');
           window.location.href = window.location.href.replace(`token=${this.adminLogin}`, '').replace('&&', '&');
         }
         }
+      }).catch(() => {
+        if (this.adminLogin) {
+          window.location.href = window.location.href.replace(`token=${this.adminLogin}`, '').replace('&&', '&');
+        }
       });
       });
     }
     }
   }
   }

+ 1 - 1
server/data/src/main/java/com/qxgmat/data/relation/mapping/UserOrderRelationMapper.xml

@@ -19,7 +19,7 @@
     select
     select
     <include refid="Id_Column_List" />
     <include refid="Id_Column_List" />
     from `user_order` uo
     from `user_order` uo
-    where (uo.is_speed = 0 or (uo.is_speed = 1 and uo.pay_status>1)
+    where (uo.is_speed = 0 or (uo.is_speed = 1 and uo.pay_status>0))
     <if test="userId != null">
     <if test="userId != null">
       and uo.`user_id` = #{userId,jdbcType=VARCHAR}
       and uo.`user_id` = #{userId,jdbcType=VARCHAR}
     </if>
     </if>

+ 8 - 7
server/data/src/main/resources/db/migration/V1__init_table.sql

@@ -44,7 +44,9 @@ CREATE TABLE contract (
 INSERT INTO contract (id, `key`, title, content, create_time, update_time)
 INSERT INTO contract (id, `key`, title, content, create_time, update_time)
 VALUES
 VALUES
 	(1,'register','千行注册协议',NULL,NULL,'2019-09-03 01:08:57'),
 	(1,'register','千行注册协议',NULL,NULL,'2019-09-03 01:08:57'),
-	(2,'course','千行课程协议',NULL,NULL,NULL);
+	(2,'course','千行课程协议',NULL,NULL,NULL),
+	(3,'privacy','隐私协议',NULL,NULL,NULL),
+	(4,'legal','法律申明',NULL,NULL,NULL);
 
 
 CREATE TABLE course (
 CREATE TABLE course (
   id int(11) unsigned NOT NULL AUTO_INCREMENT,
   id int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -257,8 +259,7 @@ VALUES
 	(2,'非难度适应性','',0,0,1,0,0,'base',NULL),
 	(2,'非难度适应性','',0,0,1,0,0,'base',NULL),
 	(3,'千行CAT','',1,0,2,2,0,'qx_cat',NULL),
 	(3,'千行CAT','',1,0,2,2,0,'qx_cat',NULL),
 	(4,'净化版PREP-CAT','',1,0,2,1,0,NULL,NULL),
 	(4,'净化版PREP-CAT','',1,0,2,1,0,NULL,NULL),
-	(5,'GWD-CAT','',1,0,2,1,0,NULL,NULL),
-	(6,'净化版PREP-CAT','',1,0,2,0,0,'cat','净化版PREP-CAT');
+	(5,'GWD-CAT','',1,0,2,1,0,NULL,NULL);
 
 
 CREATE TABLE exercise_paper (
 CREATE TABLE exercise_paper (
   id int(11) unsigned NOT NULL AUTO_INCREMENT,
   id int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -891,7 +892,7 @@ VALUES
 	(70,'2019-07-06','2019-07-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
 	(70,'2019-07-06','2019-07-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
 	(71,'2019-07-15','2019-07-25','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
 	(71,'2019-07-15','2019-07-25','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
 	(72,'2019-07-25','2019-08-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
 	(72,'2019-07-25','2019-08-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
-	(73,'2019-08-03',NULL,'',2,'2019-08-28 20:56:40','',0,NULL,'',0,NULL,2,1,NULL,'2019-08-28 20:56:40');
+	(73,'2019-08-03',NULL,'',0,'2019-08-28 20:56:40','',0,NULL,'',0,NULL,0,0,NULL,'2019-08-28 20:56:40');
 
 
 CREATE TABLE textbook_library_history (
 CREATE TABLE textbook_library_history (
   id int(11) unsigned NOT NULL AUTO_INCREMENT,
   id int(11) unsigned NOT NULL AUTO_INCREMENT,
@@ -1092,7 +1093,7 @@ CREATE TABLE user_collect_experience (
   experience_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '经验id',
   experience_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '经验id',
   create_time datetime DEFAULT NULL,
   create_time datetime DEFAULT NULL,
   PRIMARY KEY (id),
   PRIMARY KEY (id),
-  KEY user_id (user_id,expericence_id)
+  KEY user_id (user_id,experience_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-收藏-心经';
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-收藏-心经';
 
 
 CREATE TABLE user_collect_question (
 CREATE TABLE user_collect_question (
@@ -1480,7 +1481,7 @@ CREATE TABLE user_search_history (
   question_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目id',
   question_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目id',
   question_no_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目编号id',
   question_no_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目编号id',
   create_time datetime DEFAULT NULL,
   create_time datetime DEFAULT NULL,
-  PRIMARY KEY (`id),
+  PRIMARY KEY (id),
   KEY user_id (user_id)
   KEY user_id (user_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-搜索题目-记录';
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-搜索题目-记录';
 
 
@@ -1524,7 +1525,7 @@ CREATE TABLE user_textbook_enroll (
   date datetime DEFAULT NULL COMMENT '报名日期',
   date datetime DEFAULT NULL COMMENT '报名日期',
   create_time datetime DEFAULT NULL,
   create_time datetime DEFAULT NULL,
   PRIMARY KEY (id),
   PRIMARY KEY (id),
-  KEY user_id (user_id,month)
+  KEY user_id (user_id,date)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-机经-报名';
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-机经-报名';
 
 
 CREATE TABLE user_textbook_feedback (
 CREATE TABLE user_textbook_feedback (

+ 1 - 1
server/gateway-api/src/main/java/com/qxgmat/controller/admin/UserController.java

@@ -1041,7 +1041,7 @@ public class UserController {
             throw new ParameterException("已处理");
             throw new ParameterException("已处理");
         }
         }
 
 
-        if (dto.getIsAlert() != null && dto.getIsAlert() > 1){
+        if (dto.getIsAlert() != null && dto.getIsAlert() > 0){
             User user = usersService.get(in.getUserId());
             User user = usersService.get(in.getUserId());
             usersService.edit(User.builder().id(user.getId()).totalAlert(user.getTotalAlert() + 1).build());
             usersService.edit(User.builder().id(user.getId()).totalAlert(user.getTotalAlert() + 1).build());
             messageExtendService.sendLoginAbnormal(user, in);
             messageExtendService.sendLoginAbnormal(user, in);

+ 12 - 14
server/gateway-api/src/main/java/com/qxgmat/controller/api/AuthController.java

@@ -136,15 +136,13 @@ public class AuthController {
     public Response<MyDto> directWechatPc(
     public Response<MyDto> directWechatPc(
             @RequestParam(required = false, defaultValue = "") String code,
             @RequestParam(required = false, defaultValue = "") String code,
             HttpSession session, HttpServletRequest request) {
             HttpSession session, HttpServletRequest request) {
-        User user = (User) shiroHelp.getLoginUser();
-        user = usersService.Oauth(user, code, "wechat_pc", true);
-        if (user.getId() != null && user.getId() > 0){
-            user = usersService.get(user.getId());
-            shiroHelp.getSession().login(shiroHelp.user(user.getArea()+":"+user.getMobile(), ""));
+        try{
+            shiroHelp.getSession().login(shiroHelp.oauth(code, "wechat_pc", true));
+        }catch (Exception e){
+            throw new ParameterException("登录失败");
         }
         }
-        user = shiroHelp.getLoginUser();
-
-        MyDto dto = processUser(user, request);
+        User openUser = (User) shiroHelp.getLoginUser();
+        MyDto dto = processUser(openUser, request);
         return ResponseHelp.success(dto);
         return ResponseHelp.success(dto);
     }
     }
 
 
@@ -157,13 +155,13 @@ public class AuthController {
             @RequestParam(required = false, defaultValue = "") String code,
             @RequestParam(required = false, defaultValue = "") String code,
             @RequestParam(required = false, defaultValue = "") boolean userInfo,
             @RequestParam(required = false, defaultValue = "") boolean userInfo,
             HttpSession session, HttpServletRequest request) {
             HttpSession session, HttpServletRequest request) {
-        User user = (User) shiroHelp.getLoginUser();
-        user = usersService.Oauth(user, code, "wechat_native", userInfo);
-        if (user.getId() != null && user.getId() > 0){
-            user = usersService.get(user.getId());
-            shiroHelp.getSession().login(shiroHelp.user(user.getArea()+":"+user.getMobile(), ""));
+        try{
+            shiroHelp.getSession().login(shiroHelp.oauth(code, "wechat_native", userInfo));
+        }catch (Exception e){
+            throw new ParameterException("登录失败");
         }
         }
-        MyDto dto = processUser(user, request);
+        User openUser = (User) shiroHelp.getLoginUser();
+        MyDto dto = processUser(openUser, request);
         return ResponseHelp.success(dto);
         return ResponseHelp.success(dto);
     }
     }
 
 

+ 1 - 6
server/gateway-api/src/main/java/com/qxgmat/controller/api/TextbookController.java

@@ -242,12 +242,7 @@ public class TextbookController
             @RequestParam(required = false) String year,
             @RequestParam(required = false) String year,
             HttpSession session) {
             HttpSession session) {
         User user = (User) shiroHelp.getLoginUser();
         User user = (User) shiroHelp.getLoginUser();
-        Date start;
-        try {
-            start = DateFormat.getDateInstance().parse(String.format("%s-01-01", year));
-        } catch (ParseException e) {
-            throw new ParameterException("日期格式错误");
-        }
+        Date start = Tools.baseDate(String.format("%s-01-01", year));
         Date end = Tools.addYear(start, 1);
         Date end = Tools.addYear(start, 1);
         List<TextbookLibrary> libraryList = textbookLibraryService.listByTime(start, end);
         List<TextbookLibrary> libraryList = textbookLibraryService.listByTime(start, end);
         textbookService.refreshLibraryResource(user, libraryList);
         textbookService.refreshLibraryResource(user, libraryList);

+ 12 - 0
server/gateway-api/src/main/java/com/qxgmat/dto/admin/extend/UserExtendDto.java

@@ -3,6 +3,8 @@ package com.qxgmat.dto.admin.extend;
 import com.nuliji.tools.annotation.Dto;
 import com.nuliji.tools.annotation.Dto;
 import com.qxgmat.data.dao.entity.User;
 import com.qxgmat.data.dao.entity.User;
 
 
+import java.util.Date;
+
 @Dto(entity = User.class)
 @Dto(entity = User.class)
 public class UserExtendDto {
 public class UserExtendDto {
     private Integer id;
     private Integer id;
@@ -21,6 +23,8 @@ public class UserExtendDto {
 
 
     private Integer isFrozen;
     private Integer isFrozen;
 
 
+    private Date createTime;
+
     public Integer getId() {
     public Integer getId() {
         return id;
         return id;
     }
     }
@@ -84,4 +88,12 @@ public class UserExtendDto {
     public void setIsFrozen(Integer isFrozen) {
     public void setIsFrozen(Integer isFrozen) {
         this.isFrozen = isFrozen;
         this.isFrozen = isFrozen;
     }
     }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
 }
 }

+ 14 - 2
server/gateway-api/src/main/java/com/qxgmat/service/UsersService.java

@@ -150,8 +150,19 @@ public class UsersService extends AbstractService {
         User mm = User.builder()
         User mm = User.builder()
                 .id(openUser != null ? openUser.getId() : null)
                 .id(openUser != null ? openUser.getId() : null)
                 .build();
                 .build();
-        if (openUser ==null || openUser.getAvatar() == null || openUser.getAvatar().isEmpty()) mm.setAvatar(data.getAvatar());
-        if (openUser == null || openUser.getNickname() == null|| openUser.getNickname().isEmpty() )mm.setNickname(data.getNickName());
+        if (openUser ==null || openUser.getAvatar() == null || openUser.getAvatar().isEmpty()) {
+            mm.setAvatar(data.getAvatar());
+            if(openUser != null){
+                openUser.setAvatar(data.getAvatar());
+            }
+        }
+        if (openUser == null || openUser.getNickname() == null|| openUser.getNickname().isEmpty()){
+            mm.setNickname(data.getNickName());
+            if(openUser != null){
+                openUser.setNickname(data.getNickName());
+            }
+        }
+
         switch(platform){
         switch(platform){
             case "wechat_pc":
             case "wechat_pc":
                 mm.setWechatOpenidPc(data.getOpenId());
                 mm.setWechatOpenidPc(data.getOpenId());
@@ -168,6 +179,7 @@ public class UsersService extends AbstractService {
         if (mm.getId() != null){
         if (mm.getId() != null){
             // 直接更新数据
             // 直接更新数据
             edit(mm);
             edit(mm);
+            return openUser;
         }
         }
 
 
         return mm;
         return mm;

+ 1 - 1
server/gateway-api/src/main/java/com/qxgmat/service/inline/UserAbnormalService.java

@@ -71,7 +71,7 @@ public class UserAbnormalService extends AbstractService {
         example.and(
         example.and(
                 example.createCriteria()
                 example.createCriteria()
                     .andEqualTo("userId", userId)
                     .andEqualTo("userId", userId)
-                    .andEqualTo("ip", ip)
+                    .andEqualTo("loginIp", ip)
                     .andEqualTo("isIgnore", 1)
                     .andEqualTo("isIgnore", 1)
         );
         );
         UserAbnormal abnormal = one(userAbnormalMapper, example);
         UserAbnormal abnormal = one(userAbnormalMapper, example);

+ 1 - 0
server/gateway-api/src/main/java/com/qxgmat/service/inline/UserCourseService.java

@@ -55,6 +55,7 @@ public class UserCourseService extends AbstractService {
     }
     }
 
 
     public List<UserCourse> listByCourse(Integer userId, Collection ids){
     public List<UserCourse> listByCourse(Integer userId, Collection ids){
+        if (ids == null || ids.size() == 0) return new ArrayList<>();
         Example example = new Example(UserCourse.class);
         Example example = new Example(UserCourse.class);
         example.and(
         example.and(
                 example.createCriteria()
                 example.createCriteria()