Sfoglia il codice sorgente

去掉marker中的accountType字段,暂时不考虑多账号类型绑定情况

luoshi 5 anni fa
parent
commit
9f740ce4b1

+ 8 - 10
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/dao/MarkerDao.java

@@ -2,7 +2,6 @@ package cn.com.qmth.stmms.biz.exam.dao;
 
 import java.util.List;
 
-import cn.com.qmth.stmms.common.enums.AccountType;
 import cn.com.qmth.stmms.common.enums.MarkStatus;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@@ -56,8 +55,8 @@ public interface MarkerDao extends PagingAndSortingRepository<Marker, Integer>,
     public void updateMarkSettingById(Integer id, String setting);
 
     @Modifying
-    @Query("update Marker m set m.accountType=?2, m.accountId=?3 where m.id=?1")
-    public void updateAccountById(Integer id, AccountType accountType, Integer accountId);
+    @Query("update Marker m set m.openAccountId=?2 where m.id=?1")
+    public void updateOpenAccountById(Integer id, Integer accountId);
 
     @Modifying
     @Query("update Marker m set m.finishCount=null, m.validCount=null, m.avgSpeed=null, m.avgScore=null, m.stdevScore=null "
@@ -72,13 +71,12 @@ public interface MarkerDao extends PagingAndSortingRepository<Marker, Integer>,
 
     public List<Marker> findByMode(String common);
 
-    @Query(value = "select m from Marker m, MarkGroup g where m.accountType=?1 and m.accountId=?2 and m.enable=?3 "
-            + "and m.examId=g.pk.examId and m.subjectCode=g.pk.subjectCode and m.groupNumber=g.pk.number and g.status in (?4)")
-    List<Marker> findByAccountTypeAndAccountIdAndEnableAndMarkStatus(AccountType accountType, Integer accountId, boolean enable,
-            MarkStatus... status);
+    @Query(value = "select m from Marker m, MarkGroup g where m.openAccountId=?1 and m.enable=?2 "
+            + "and m.examId=g.pk.examId and m.subjectCode=g.pk.subjectCode and m.groupNumber=g.pk.number and g.status in (?3)")
+    List<Marker> findByOpenAccountIdAndEnableAndMarkStatus(Integer accountId, boolean enable, MarkStatus... status);
 
-    @Query("select count(m) from Marker m where m.examId=?1 and m.subjectCode=?2 and m.groupNumber=?3 and m.accountType=?4 and m.accountId=?5")
-    long countByExamIdAndSubjectCodeAndGroupNumberAndAccountTypeAndAccountId(Integer examId, String subjectCode, Integer number,
-            AccountType accountType, Integer accountId);
+    @Query("select count(m) from Marker m where m.examId=?1 and m.subjectCode=?2 and m.groupNumber=?3 and m.openAccountId=?4")
+    long countByExamIdAndSubjectCodeAndGroupNumberAndOpenAccountId(Integer examId, String subjectCode, Integer number,
+            Integer openAccountId);
 
 }

+ 6 - 31
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/model/Marker.java

@@ -13,8 +13,6 @@ import javax.persistence.Table;
 import javax.persistence.Transient;
 
 import cn.com.qmth.stmms.biz.user.model.OpenAccount;
-import cn.com.qmth.stmms.biz.user.model.User;
-import cn.com.qmth.stmms.common.enums.AccountType;
 import cn.com.qmth.stmms.common.utils.AccessControlUtils;
 import org.apache.commons.lang.StringUtils;
 
@@ -54,12 +52,8 @@ public class Marker implements Serializable {
     @ExcelField(title = "密码", align = 2, sort = 40)
     private String password;
 
-    @Column(name = "account_type", nullable = true, length = 16)
-    @Enumerated(EnumType.STRING)
-    private AccountType accountType;
-
-    @Column(name = "account_id", nullable = true)
-    private Integer accountId;
+    @Column(name = "open_account_id", nullable = true)
+    private Integer openAccountId;
 
     @Column(name = "enable", nullable = false)
     private boolean enable;
@@ -136,9 +130,6 @@ public class Marker implements Serializable {
     @Transient
     private OpenAccount openAccount;
 
-    @Transient
-    private User user;
-
     @Transient
     private long markedCount;
 
@@ -180,20 +171,12 @@ public class Marker implements Serializable {
         this.password = password;
     }
 
-    public AccountType getAccountType() {
-        return accountType;
-    }
-
-    public void setAccountType(AccountType accountType) {
-        this.accountType = accountType;
+    public Integer getOpenAccountId() {
+        return openAccountId;
     }
 
-    public Integer getAccountId() {
-        return accountId;
-    }
-
-    public void setAccountId(Integer accountId) {
-        this.accountId = accountId;
+    public void setOpenAccountId(Integer openAccountId) {
+        this.openAccountId = openAccountId;
     }
 
     public String getLastLoginIp() {
@@ -279,14 +262,6 @@ public class Marker implements Serializable {
         this.openAccount = openAccount;
     }
 
-    public User getUser() {
-        return user;
-    }
-
-    public void setUser(User user) {
-        this.user = user;
-    }
-
     public long getMarkedCount() {
         return markedCount;
     }

+ 3 - 5
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/MarkerService.java

@@ -5,7 +5,6 @@ import java.util.List;
 import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
 import cn.com.qmth.stmms.biz.exam.model.Marker;
 import cn.com.qmth.stmms.biz.exam.query.MarkerSearchQuery;
-import cn.com.qmth.stmms.common.enums.AccountType;
 import cn.com.qmth.stmms.common.enums.MarkStatus;
 
 public interface MarkerService {
@@ -40,10 +39,9 @@ public interface MarkerService {
 
     void updateMarkSetting(Integer id, String setting);
 
-    void updateAccountById(Integer id, AccountType accountType, Integer accountId);
+    void updateOpenAccountById(Integer id, Integer openAccountId);
 
-    List<Marker> findByAccountAndMarkStatus(AccountType accountType, Integer accountId, MarkStatus... status);
+    List<Marker> findByOpenAccountAndMarkStatus(Integer openAccountId, MarkStatus... status);
 
-    long countByExamAndSubjectAndGroupAndAccount(Integer examId, String subjectCode, Integer groupNumber, AccountType accountType,
-            Integer accountId);
+    long countByExamAndSubjectAndGroupAndOpenAccount(Integer examId, String subjectCode, Integer groupNumber, Integer openAccountId);
 }

+ 7 - 9
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/service/impl/MarkerServiceImpl.java

@@ -9,7 +9,6 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 
-import cn.com.qmth.stmms.common.enums.AccountType;
 import cn.com.qmth.stmms.common.enums.MarkStatus;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -63,8 +62,8 @@ public class MarkerServiceImpl extends BaseQueryService<Marker> implements Marke
 
     @Transactional
     @Override
-    public void updateAccountById(Integer id, AccountType accountType, Integer accountId) {
-        markerDao.updateAccountById(id, accountType, accountId);
+    public void updateOpenAccountById(Integer id, Integer accountId) {
+        markerDao.updateOpenAccountById(id, accountId);
     }
 
     @Override
@@ -252,14 +251,13 @@ public class MarkerServiceImpl extends BaseQueryService<Marker> implements Marke
     }
 
     @Override
-    public List<Marker> findByAccountAndMarkStatus(AccountType accountType, Integer accountId, MarkStatus... status) {
-        return markerDao.findByAccountTypeAndAccountIdAndEnableAndMarkStatus(accountType, accountId, true, status);
+    public List<Marker> findByOpenAccountAndMarkStatus(Integer accountId, MarkStatus... status) {
+        return markerDao.findByOpenAccountIdAndEnableAndMarkStatus(accountId, true, status);
     }
 
     @Override
-    public long countByExamAndSubjectAndGroupAndAccount(Integer examId, String subjectCode, Integer groupNumber, AccountType accountType,
-            Integer accountId) {
-        return markerDao.countByExamIdAndSubjectCodeAndGroupNumberAndAccountTypeAndAccountId(examId, subjectCode, groupNumber, accountType,
-                accountId);
+    public long countByExamAndSubjectAndGroupAndOpenAccount(Integer examId, String subjectCode, Integer groupNumber,
+            Integer openAccountId) {
+        return markerDao.countByExamIdAndSubjectCodeAndGroupNumberAndOpenAccountId(examId, subjectCode, groupNumber, openAccountId);
     }
 }

+ 0 - 29
stmms-common/src/main/java/cn/com/qmth/stmms/common/enums/AccountType.java

@@ -1,29 +0,0 @@
-package cn.com.qmth.stmms.common.enums;
-
-/**
- * 评卷员绑定的账号类型
- */
-public enum AccountType {
-
-    USER("系统用户"), OPEN_ACCOUNT("外部账号");
-
-    private String name;
-
-    private AccountType(String name) {
-        this.name = name;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public static AccountType findByName(String text) {
-        for (AccountType obj : AccountType.values()) {
-            if (obj.getName().equalsIgnoreCase(text)) {
-                return obj;
-            }
-        }
-        return null;
-    }
-
-}

+ 10 - 17
stmms-web/src/main/java/cn/com/qmth/stmms/admin/exam/MarkerController.java

@@ -15,7 +15,6 @@ import cn.com.qmth.stmms.biz.exam.model.*;
 import cn.com.qmth.stmms.biz.exam.service.*;
 import cn.com.qmth.stmms.biz.user.model.OpenAccount;
 import cn.com.qmth.stmms.biz.user.service.UserService;
-import cn.com.qmth.stmms.common.enums.AccountType;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
@@ -106,11 +105,8 @@ public class MarkerController extends BaseExamController {
             marker.setGroup(group);
             marker.setMarkedCount(markService.markedCount(marker));
             marker.setCurrentCount(markService.applyCount(marker));
-            if (marker.getAccountType() != null && marker.getAccountId() != null) {
-                // 暂时只开放外部账号绑定
-                if (marker.getAccountType() == AccountType.OPEN_ACCOUNT) {
-                    marker.setOpenAccount(userService.findOpenAccount(marker.getAccountId()));
-                }
+            if (marker.getOpenAccountId() != null) {
+                marker.setOpenAccount(userService.findOpenAccount(marker.getOpenAccountId()));
             }
         }
         model.addAttribute("query", query);
@@ -575,21 +571,18 @@ public class MarkerController extends BaseExamController {
     @RequestMapping(value = "/account/bind", method = RequestMethod.POST)
     @ResponseBody
     @RoleRequire({ Role.SCHOOL_ADMIN, Role.SUBJECT_HEADER })
-    public boolean bindAccount(@RequestParam Integer markerId, @RequestParam AccountType accountType, @RequestParam Integer accountId) {
+    public boolean bindAccount(@RequestParam Integer markerId, @RequestParam Integer accountId) {
         Marker marker = markerService.findById(markerId);
         if (marker == null) {
             return false;
         }
-        if (accountType == AccountType.OPEN_ACCOUNT) {
-            OpenAccount oa = userService.findOpenAccount(accountId);
-            if (oa == null || !oa.isEnable()) {
-                return false;
-            }
+        OpenAccount oa = userService.findOpenAccount(accountId);
+        if (oa == null || !oa.isEnable()) {
+            return false;
         }
-        if (markerService
-                .countByExamAndSubjectAndGroupAndAccount(marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber(), accountType,
-                        accountId) == 0) {
-            markerService.updateAccountById(markerId, accountType, accountId);
+        if (markerService.countByExamAndSubjectAndGroupAndOpenAccount(marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber(),
+                accountId) == 0) {
+            markerService.updateOpenAccountById(markerId, accountId);
             return true;
         }
         return false;
@@ -599,7 +592,7 @@ public class MarkerController extends BaseExamController {
     @ResponseBody
     @RoleRequire({ Role.SCHOOL_ADMIN, Role.SUBJECT_HEADER })
     public boolean unbindOpenAccount(@RequestParam Integer markerId) {
-        markerService.updateAccountById(markerId, null, null);
+        markerService.updateOpenAccountById(markerId, null);
         return true;
     }
 }

+ 0 - 12
stmms-web/src/main/java/cn/com/qmth/stmms/common/controller/BaseController.java

@@ -136,18 +136,6 @@ public class BaseController {
                 }
             }
         });
-        // AccountType 类型转换
-        binder.registerCustomEditor(AccountType.class, new PropertyEditorSupport() {
-
-            @Override
-            public void setAsText(String text) {
-                try {
-                    setValue(AccountType.findByName(text));
-                } catch (Exception e) {
-                    setValue(null);
-                }
-            }
-        });
 
         // HistoryStatus 类型转换
         binder.registerCustomEditor(HistoryStatus.class, new PropertyEditorSupport() {

+ 3 - 6
stmms-web/src/main/java/cn/com/qmth/stmms/open/controller/OpenAccountController.java

@@ -11,9 +11,7 @@ import cn.com.qmth.stmms.biz.user.service.UserService;
 import cn.com.qmth.stmms.common.authorization.AuthorizationService;
 import cn.com.qmth.stmms.common.domain.OpenUser;
 import cn.com.qmth.stmms.common.domain.WebUser;
-import cn.com.qmth.stmms.common.enums.AccountType;
 import cn.com.qmth.stmms.common.enums.MarkStatus;
-import cn.com.qmth.stmms.common.session.model.StmmsSession;
 import cn.com.qmth.stmms.common.signature.SignatureInfo;
 import cn.com.qmth.stmms.common.signature.SignatureType;
 import cn.com.qmth.stmms.common.utils.RequestUtils;
@@ -85,8 +83,7 @@ public class OpenAccountController {
         OpenAccount account = RequestUtils.getOpenUser(request).getOpenAccount();
         ModelAndView modelAndView = new ModelAndView("modules/open/marker-list");
         // TODO - 增加评卷员列表,构造考试、科目、分组联动数据集合
-        List<Marker> markerList = markerService
-                .findByAccountAndMarkStatus(AccountType.OPEN_ACCOUNT, account.getId(), MarkStatus.TRIAL, MarkStatus.FORMAL);
+        List<Marker> markerList = markerService.findByOpenAccountAndMarkStatus(account.getId(), MarkStatus.TRIAL, MarkStatus.FORMAL);
         return modelAndView;
     }
 
@@ -95,8 +92,8 @@ public class OpenAccountController {
         // 评卷员与评卷分组校验
         OpenAccount account = RequestUtils.getOpenUser(request).getOpenAccount();
         Marker marker = markerService.findById(markerId);
-        if (marker == null || !marker.isEnable() || AccountType.OPEN_ACCOUNT != marker.getAccountType() || marker.getAccountId() == null
-                || !marker.getAccountId().equals(account.getId())) {
+        if (marker == null || !marker.isEnable() || marker.getOpenAccountId() == null || !marker.getOpenAccountId()
+                .equals(account.getId())) {
             return new ModelAndView("redirect:/open/marker/list");
         }
         MarkGroup group = groupService.findOne(marker.getExamId(), marker.getSubjectCode(), marker.getGroupNumber());

+ 1 - 2
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/markerAccount.jsp

@@ -14,7 +14,6 @@
 <form id="edit-form" action="${ctx}/admin/exam/marker/account/" method="post" class="form-horizontal">
     <tags:message content="${message}"/>
     <input name="markerId" type="hidden" value="${marker.id }"/>
-    <input name="accountType" type="hidden" value="OPEN_ACCOUNT"/>
     <div class="control-group">
         <label class="control-label">评卷员</label>
         <div class="controls">
@@ -33,7 +32,7 @@
     </div>
     <div class="form-actions">
         <a href="##" id="bind-button" class="btn btn-primary">绑定</a>
-        <c:if test="${marker.accountType != null || marker.accountId != null}">
+        <c:if test="${marker.openAccountId != null}">
             &nbsp;&nbsp;
             <a href="##" id="unbind-button" class="btn btn-warning">解绑</a>
         </c:if>

+ 1 - 1
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/markerList.jsp

@@ -191,7 +191,7 @@
                     ${marker.classCount}</a></td>
             <td>
                 <a href="${ctx}/admin/exam/marker/account/${marker.id}">
-                    <c:if test="${marker.accountType == null || marker.accountId == null}">#</c:if>
+                    <c:if test="${marker.openAccountId == null}">#</c:if>
                     <c:if test="${marker.openAccount != null}">${marker.openAccount.name}</c:if>
                 </a>
             </td>

+ 1 - 2
stmms-web/src/main/webapp/sql/stmms_ft.sql

@@ -340,8 +340,7 @@ CREATE TABLE `eb_marker`
     `name`                      varchar(64) NOT NULL COMMENT '姓名',
     `password`                  varchar(64) NOT NULL COMMENT '密码',
     `enable`                    tinyint(1)  NOT NULL COMMENT '是否启用',
-    `account_type`              varchar(16) DEFAULT NULL COMMENT '绑定账号类型',
-    `account_id`                int(11)     DEFAULT NULL COMMENT '绑定账号ID',
+    `open_account_id`           int(11)     DEFAULT NULL COMMENT '绑定外部账号ID',
     `mode`                      varchar(16) DEFAULT NULL COMMENT '评卷模式',
     `top_count`                 int(11)     DEFAULT NULL COMMENT '评卷数上限',
     `avg_score`                 double      DEFAULT NULL COMMENT '平均分',