|
|
@@ -6,7 +6,6 @@ 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.UserPanelRelationDao;
|
|
|
import com.uas.kanban.exception.OperationException;
|
|
|
import com.uas.kanban.model.*;
|
|
|
import com.uas.kanban.service.PanelInstanceService;
|
|
|
@@ -48,9 +47,6 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
@Autowired
|
|
|
private KanbanDao kanbanDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserPanelRelationDao userPanelRelationDao;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ParameterService parameterService;
|
|
|
|
|
|
@@ -82,7 +78,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
parameter.mayInitValue();
|
|
|
}
|
|
|
}
|
|
|
- List<Parameter> references = generateParameters(panelInstance);
|
|
|
+ List<Parameter> references = generateParameters(panelInstance.getPanelCode());
|
|
|
// 重置 SQL 类型的参数(其值是解析出来的,不进行保存)
|
|
|
resetSQLParameter(parameters, references);
|
|
|
panelInstance.toParameters(parameters);
|
|
|
@@ -93,13 +89,12 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据关联的面板,为面板实例生成参数
|
|
|
+ * 根据面板,为面板实例生成参数
|
|
|
*
|
|
|
- * @param panelInstance 面板实例
|
|
|
+ * @param panelCode 面板 code
|
|
|
* @return 生成的参数
|
|
|
*/
|
|
|
- private List<Parameter> generateParameters(@NotEmpty("panelInstance") PanelInstance panelInstance) {
|
|
|
- String panelCode = userPanelRelationDao.checkExist(panelInstance.getUserPanelRelationCode()).getPanelCode();
|
|
|
+ private List<Parameter> generateParameters(@NotEmpty("panelCode") String panelCode) {
|
|
|
List<Parameter> parameters = parameterService.getByPanelCode(panelCode);
|
|
|
if (CollectionUtils.isEmpty(parameters)) {
|
|
|
return null;
|
|
|
@@ -202,7 +197,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(userPanelRelationDao.checkExist(panelInstance.getUserPanelRelationCode()).getPanelCode());
|
|
|
+ Panel panel = panelDao.checkExist(panelInstance.getPanelCode());
|
|
|
List<PanelInstance.RelatedKanban> relatedKanbans = panelInstance.getRelatedKanbans();
|
|
|
if (CollectionUtils.isEmpty(relatedKanbans)) {
|
|
|
throw new IllegalStateException("面板下没有看板");
|
|
|
@@ -267,18 +262,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
if (panelInstance != null) {
|
|
|
deleteOne(panelInstance.getCode());
|
|
|
}
|
|
|
- User user = SystemSession.getUser();
|
|
|
- String userCode = user.getCode();
|
|
|
- UserPanelRelation userPanelRelation = userPanelRelationDao.findByUserCodeAndPanelCode(userCode, panelCode);
|
|
|
- // 管理员可以查看所有面板,不必先分配,但是想要保存实例,就需要先建立用户面板关系
|
|
|
- if (userPanelRelation == null) {
|
|
|
- if (user.getRole() == User.Role.Admin) {
|
|
|
- userPanelRelation = userPanelRelationDao.save(new UserPanelRelation(userCode, panelCode));
|
|
|
- } else {
|
|
|
- throw new IllegalArgumentException("用户未分配该面板");
|
|
|
- }
|
|
|
- }
|
|
|
- panelInstance = generateInstance(userPanelRelation);
|
|
|
+ panelInstance = generateInstance(panelCode);
|
|
|
}
|
|
|
try {
|
|
|
NewbieJdbcSupport jdbc = dataSourceManager.getJdbc(panel.getDataSourceCode());
|
|
|
@@ -323,22 +307,22 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据用户面板关系生成面板实例
|
|
|
+ * 根据用户和面板,删除相应的实例
|
|
|
*
|
|
|
- * @param userPanelRelation 用户面板关系
|
|
|
+ * @param panelCode 面板 code
|
|
|
* @return 面板实例
|
|
|
*/
|
|
|
- private PanelInstance generateInstance(@NotEmpty("userPanelRelation") UserPanelRelation userPanelRelation) {
|
|
|
- String panelCode = userPanelRelation.getPanelCode();
|
|
|
+ private PanelInstance generateInstance(@NotEmpty("panelCode") String panelCode) {
|
|
|
Panel panel = panelDao.checkExist(panelCode);
|
|
|
PanelInstance panelInstance = new PanelInstance();
|
|
|
- panelInstance.setUserPanelRelationCode(userPanelRelation.getCode());
|
|
|
+ panelInstance.setUserCode(SystemSession.getUser().getCode());
|
|
|
+ panelInstance.setPanelCode(panelCode);
|
|
|
panelInstance.setPanelVersion(panel.getVersion());
|
|
|
initSwitchFrequence(panelInstance);
|
|
|
- panelInstance.toParameters(generateParameters(panelInstance));
|
|
|
+ panelInstance.toParameters(generateParameters(panelCode));
|
|
|
List<Kanban> kanbans = kanbanDao.findByPanelCode(panelCode);
|
|
|
if (CollectionUtils.isEmpty(kanbans)) {
|
|
|
- throw new IllegalStateException("面板 '" + panel.getName() + "' 未关联看板,请联系管理员");
|
|
|
+ throw new IllegalStateException("面板 '" + panel.getName() + "' 未关联看板");
|
|
|
}
|
|
|
panelInstance.initKanbanCodes(kanbans);
|
|
|
return panelInstanceDao.save(panelInstance);
|
|
|
@@ -351,7 +335,7 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
*/
|
|
|
private void initSwitchFrequence(@NotEmpty("panelInstance") PanelInstance panelInstance)
|
|
|
throws IllegalArgumentException {
|
|
|
- Panel panel = panelDao.checkExist(userPanelRelationDao.checkExist(panelInstance.getUserPanelRelationCode()).getPanelCode());
|
|
|
+ Panel panel = panelDao.checkExist(panelInstance.getPanelCode());
|
|
|
switch (panel.getDisplay()) {
|
|
|
case AutoSwitch:
|
|
|
if (panelInstance.getSwitchFrequency() == null) {
|