|
|
@@ -6,7 +6,7 @@ import com.uas.kanban.base.BaseService;
|
|
|
import com.uas.kanban.dao.KanbanDao;
|
|
|
import com.uas.kanban.dao.PanelDao;
|
|
|
import com.uas.kanban.dao.PanelInstanceDao;
|
|
|
-import com.uas.kanban.dao.UserPanelDao;
|
|
|
+import com.uas.kanban.dao.UserPanelRelationDao;
|
|
|
import com.uas.kanban.exception.OperationException;
|
|
|
import com.uas.kanban.model.*;
|
|
|
import com.uas.kanban.service.PanelInstanceService;
|
|
|
@@ -47,7 +47,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
private KanbanDao kanbanDao;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserPanelDao userPanelDao;
|
|
|
+ private UserPanelRelationDao userPanelRelationDao;
|
|
|
|
|
|
@Autowired
|
|
|
private ParameterService parameterService;
|
|
|
@@ -91,7 +91,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
* @return 生成的参数
|
|
|
*/
|
|
|
private List<Parameter> generateParameters(@NotEmpty("panelInstance") PanelInstance panelInstance) {
|
|
|
- String panelCode = userPanelDao.checkExist(panelInstance.getUserPanelCode()).getPanelCode();
|
|
|
+ String panelCode = userPanelRelationDao.checkExist(panelInstance.getUserPanelRelationCode()).getPanelCode();
|
|
|
Panel panel = panelDao.checkExist(panelCode);
|
|
|
String dataSourceCode = panel.getDataSourceCode();
|
|
|
List<Parameter> parameters = parameterService.getByPanelCode(panelCode);
|
|
|
@@ -165,7 +165,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
@Override
|
|
|
public Map<String, Object> parseData(@NotEmpty("code") String code, String kanbanCode) {
|
|
|
PanelInstance panelInstance = panelInstanceDao.checkExist(code);
|
|
|
- Panel panel = panelDao.checkExist(userPanelDao.checkExist(panelInstance.getUserPanelCode()).getPanelCode());
|
|
|
+ Panel panel = panelDao.checkExist(userPanelRelationDao.checkExist(panelInstance.getUserPanelRelationCode()).getPanelCode());
|
|
|
List<PanelInstance.RelatedKanban> relatedKanbans = panelInstance.getRelatedKanbans();
|
|
|
if (CollectionUtils.isEmpty(relatedKanbans)) {
|
|
|
throw new IllegalStateException("面板下没有看板");
|
|
|
@@ -228,31 +228,31 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
if (panelInstance == null) {
|
|
|
User user = SystemSession.getUser();
|
|
|
String userCode = user.getCode();
|
|
|
- UserPanel userPanel = userPanelDao.findByUserCodeAndPanelCode(userCode, panelCode);
|
|
|
- // 管理员可以查看所有面板,不必先分配,但是想要保存实例,就需要先建立关联
|
|
|
- if (userPanel == null) {
|
|
|
+ UserPanelRelation userPanelRelation = userPanelRelationDao.findByUserCodeAndPanelCode(userCode, panelCode);
|
|
|
+ // 管理员可以查看所有面板,不必先分配,但是想要保存实例,就需要先建立用户面板关系
|
|
|
+ if (userPanelRelation == null) {
|
|
|
if (user.getRole() == User.Role.Admin) {
|
|
|
- userPanel = userPanelDao.save(new UserPanel(userCode, panelCode));
|
|
|
- }else{
|
|
|
+ userPanelRelation = userPanelRelationDao.save(new UserPanelRelation(userCode, panelCode));
|
|
|
+ } else {
|
|
|
throw new IllegalArgumentException("用户未分配该面板");
|
|
|
}
|
|
|
}
|
|
|
- panelInstance = generateInstance(userPanel);
|
|
|
+ panelInstance = generateInstance(userPanelRelation);
|
|
|
}
|
|
|
return panelInstance;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据指定的用户面板生成面板实例
|
|
|
+ * 根据用户面板关系生成面板实例
|
|
|
*
|
|
|
- * @param userPanel 所指定的用户面板
|
|
|
+ * @param userPanelRelation 用户面板关系
|
|
|
* @return 面板实例
|
|
|
*/
|
|
|
- private PanelInstance generateInstance(@NotEmpty("userPanel") UserPanel userPanel) {
|
|
|
- String panelCode = userPanel.getPanelCode();
|
|
|
- Panel panel = panelDao.checkExist(panelCode);
|
|
|
+ private PanelInstance generateInstance(@NotEmpty("userPanelRelation") UserPanelRelation userPanelRelation) {
|
|
|
+ String panelCode = userPanelRelation.getPanelCode();
|
|
|
+ panelDao.checkExist(panelCode);
|
|
|
PanelInstance panelInstance = new PanelInstance();
|
|
|
- panelInstance.setUserPanelCode(userPanel.getCode());
|
|
|
+ panelInstance.setUserPanelRelationCode(userPanelRelation.getCode());
|
|
|
initSwitchFrequence(panelInstance);
|
|
|
panelInstance.toParameters(generateParameters(panelInstance));
|
|
|
List<Kanban> kanbans = kanbanDao.findByPanelCode(panelCode);
|
|
|
@@ -268,7 +268,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
*/
|
|
|
private void initSwitchFrequence(@NotEmpty("panelInstance") PanelInstance panelInstance)
|
|
|
throws IllegalArgumentException {
|
|
|
- Panel panel = panelDao.checkExist(userPanelDao.checkExist(panelInstance.getUserPanelCode()).getPanelCode());
|
|
|
+ Panel panel = panelDao.checkExist(userPanelRelationDao.checkExist(panelInstance.getUserPanelRelationCode()).getPanelCode());
|
|
|
switch (panel.getDisplay()) {
|
|
|
case AutoSwitch:
|
|
|
if (panelInstance.getSwitchFrequency() == null) {
|