|
@ -2,17 +2,24 @@ package com.yihu.jw.base.service;
|
|
|
|
|
|
import com.yihu.jw.base.dao.ModuleDao;
|
|
import com.yihu.jw.base.dao.ModuleDao;
|
|
import com.yihu.jw.base.dao.ModuleDao;
|
|
import com.yihu.jw.base.dao.ModuleDao;
|
|
|
|
import com.yihu.jw.base.dao.SaasModuleDao;
|
|
import com.yihu.jw.base.model.Module;
|
|
import com.yihu.jw.base.model.Module;
|
|
import com.yihu.jw.base.model.Module;
|
|
import com.yihu.jw.base.model.Module;
|
|
|
|
import com.yihu.jw.base.model.SaasModule;
|
|
import com.yihu.jw.mysql.query.BaseJpaService;
|
|
import com.yihu.jw.mysql.query.BaseJpaService;
|
|
import com.yihu.jw.restmodel.base.BaseContants;
|
|
import com.yihu.jw.restmodel.base.BaseContants;
|
|
|
|
import com.yihu.jw.restmodel.base.MModule;
|
|
import com.yihu.jw.restmodel.common.CommonContants;
|
|
import com.yihu.jw.restmodel.common.CommonContants;
|
|
import com.yihu.jw.restmodel.exception.ApiException;
|
|
import com.yihu.jw.restmodel.exception.ApiException;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by chenweida on 2017/5/19.
|
|
* Created by chenweida on 2017/5/19.
|
|
*/
|
|
*/
|
|
@ -20,6 +27,11 @@ import org.springframework.util.StringUtils;
|
|
public class ModuleService extends BaseJpaService<Module, ModuleDao> {
|
|
public class ModuleService extends BaseJpaService<Module, ModuleDao> {
|
|
@Autowired
|
|
@Autowired
|
|
private ModuleDao moduleDao;
|
|
private ModuleDao moduleDao;
|
|
|
|
@Autowired
|
|
|
|
private SaasModuleDao saasModuleDao;
|
|
|
|
@Autowired
|
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
public Module createModule(Module module) throws ApiException {
|
|
public Module createModule(Module module) throws ApiException {
|
|
@ -73,4 +85,25 @@ public class ModuleService extends BaseJpaService<Module, ModuleDao> {
|
|
}
|
|
}
|
|
module.setStatus(-1);
|
|
module.setStatus(-1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public void assignModule(String saasCode, String moduleCodes) {
|
|
|
|
//先删除原来已经分配好的模块
|
|
|
|
saasModuleDao.deleteBySaasCode(saasCode);
|
|
|
|
//分配新的模块
|
|
|
|
String [] moduleCodeArr=moduleCodes.split(",");
|
|
|
|
List<SaasModule> saasModuleList=new ArrayList<>();
|
|
|
|
for(String moduleCode:moduleCodeArr){
|
|
|
|
SaasModule saasModule=new SaasModule();
|
|
|
|
saasModule.setModuleId(moduleCode);
|
|
|
|
saasModule.setSaasId(saasCode);
|
|
|
|
saasModuleList.add(saasModule);
|
|
|
|
}
|
|
|
|
saasModuleDao.save(saasModuleList);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<MModule> getSaasModules(String saasCode) {
|
|
|
|
String sql=" select m.code,m.parent_code,m.name from base_module m,base_saas_module sm where m.code=sm.module_id and m.status=0 and sm.saas_id=?";
|
|
|
|
return jdbcTemplate.queryForList(sql,MModule.class,saasCode);
|
|
|
|
}
|
|
}
|
|
}
|