mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-09 17:34:50 +08:00
移除异常
This commit is contained in:
@@ -63,7 +63,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@AccessLogger("查询列表")
|
||||
@Authorize(action = "R")
|
||||
public ResponseMessage list(QueryParam param) throws Exception {
|
||||
public ResponseMessage list(QueryParam param) {
|
||||
// 获取条件查询
|
||||
Object data;
|
||||
if (!param.isPaging())//不分页
|
||||
@@ -85,7 +85,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@AccessLogger("查询明细")
|
||||
@Authorize(action = "R")
|
||||
public ResponseMessage info(@PathVariable("id") PK id) throws Exception {
|
||||
public ResponseMessage info(@PathVariable("id") PK id) {
|
||||
PO po = getService().selectByPk(id);
|
||||
if (po == null)
|
||||
throw new BusinessException("data is not found!", 404);
|
||||
@@ -102,7 +102,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(value = "/total", method = RequestMethod.GET)
|
||||
@AccessLogger("查询总数")
|
||||
@Authorize(action = "R")
|
||||
public ResponseMessage total(QueryParam param) throws Exception {
|
||||
public ResponseMessage total(QueryParam param) {
|
||||
// 获取条件查询
|
||||
return ResponseMessage.ok(getService().total(param));
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@AccessLogger("新增")
|
||||
@Authorize(action = "C")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ResponseMessage add(@RequestBody PO object) throws Exception {
|
||||
public ResponseMessage add(@RequestBody PO object) {
|
||||
PK pk = getService().insert(object);
|
||||
return ResponseMessage.created(pk);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@AccessLogger("删除")
|
||||
@Authorize(action = "D")
|
||||
public ResponseMessage delete(@PathVariable("id") PK id) throws Exception {
|
||||
public ResponseMessage delete(@PathVariable("id") PK id) {
|
||||
PO old = getService().selectByPk(id);
|
||||
if (old == null) throw new NotFoundException("data is not found!");
|
||||
int number = getService().delete(id);
|
||||
@@ -147,7 +147,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
@AccessLogger("修改")
|
||||
@Authorize(action = "U")
|
||||
public ResponseMessage update(@PathVariable("id") PK id, @RequestBody(required = true) PO object) throws Exception {
|
||||
public ResponseMessage update(@PathVariable("id") PK id, @RequestBody(required = true) PO object) {
|
||||
PO old = getService().selectByPk(id);
|
||||
if (old == null) throw new NotFoundException("data is not found!");
|
||||
if (object instanceof GenericPo) {
|
||||
@@ -166,7 +166,7 @@ public abstract class GenericController<PO, PK> {
|
||||
@RequestMapping(method = RequestMethod.PUT)
|
||||
@AccessLogger("批量修改")
|
||||
@Authorize(action = "U")
|
||||
public ResponseMessage update(@RequestBody(required = true) String json) throws Exception {
|
||||
public ResponseMessage update(@RequestBody(required = true) String json) {
|
||||
int number;
|
||||
if (json.startsWith("[")) {
|
||||
List<PO> datas = JSON.parseArray(json, getPOType());
|
||||
|
||||
@@ -104,13 +104,13 @@ public class ConfigController extends GenericController<Config, String> {
|
||||
*/
|
||||
@RequestMapping(value = "/{name:.+}.map", method = RequestMethod.GET)
|
||||
@AccessLogger("根据配置名获取配置(map格式)")
|
||||
public Object configInfo(@PathVariable("name") String name) throws Exception {
|
||||
public Object configInfo(@PathVariable("name") String name) {
|
||||
return configService.get(name);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{name:.+}.array", method = RequestMethod.GET)
|
||||
@AccessLogger("根据配置名获取配置(list格式)")
|
||||
public Object listInfo(@PathVariable("name") String name) throws Exception {
|
||||
public Object listInfo(@PathVariable("name") String name) {
|
||||
String content = configService.getContent(name);
|
||||
if (content == null) content = "[]";
|
||||
return content;
|
||||
@@ -125,33 +125,33 @@ public class ConfigController extends GenericController<Config, String> {
|
||||
*/
|
||||
@RequestMapping(value = {"/{name:.+}/{key:.+}"}, method = RequestMethod.GET)
|
||||
@AccessLogger("根据配置名和键获取配置")
|
||||
public Object configInfo(@PathVariable("name") String name, @PathVariable("key") String key) throws Exception {
|
||||
public Object configInfo(@PathVariable("name") String name, @PathVariable("key") String key) {
|
||||
return configService.get(name, key, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequestMapping(value = "/{id:.+}", method = RequestMethod.GET)
|
||||
public ResponseMessage info(@PathVariable("id") String id) throws Exception {
|
||||
public ResponseMessage info(@PathVariable("id") String id) {
|
||||
return super.info(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Authorize(module = "config", action = "C")
|
||||
public ResponseMessage add(@RequestBody Config object) throws Exception {
|
||||
public ResponseMessage add(@RequestBody Config object) {
|
||||
return super.add(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Authorize(module = "config", action = "D")
|
||||
@RequestMapping(value = "/{id:.+}", method = RequestMethod.DELETE)
|
||||
public ResponseMessage delete(@PathVariable("id") String id) throws Exception {
|
||||
public ResponseMessage delete(@PathVariable("id") String id) {
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Authorize(module = "config", action = "U")
|
||||
@RequestMapping(value = "/{id:.+}", method = RequestMethod.PUT)
|
||||
public ResponseMessage update(@PathVariable("id") String id, @RequestBody Config object) throws Exception {
|
||||
public ResponseMessage update(@PathVariable("id") String id, @RequestBody Config object) {
|
||||
return super.update(id, object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ResourcesController extends GenericController<Resources, String> {
|
||||
@RequestMapping(value = "/{id:^[0-9a-zA-Z]*$}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
@AccessLogger("获取资源信息")
|
||||
public ResponseMessage info(@PathVariable("id") String id) throws Exception {
|
||||
public ResponseMessage info(@PathVariable("id") String id) {
|
||||
Resources resources;
|
||||
//如果id长度为32,则尝试通过md5获取
|
||||
if (id.length() == 32) {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class RoleController extends GenericController<Role, String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage list(QueryParam param)throws Exception {
|
||||
public ResponseMessage list(QueryParam param) {
|
||||
return super.list(param).exclude(Role.class, "modules");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class UserController extends GenericController<User, String> {
|
||||
|
||||
@Override
|
||||
@AccessLogger("获取列表")
|
||||
public ResponseMessage list(QueryParam param) throws Exception {
|
||||
public ResponseMessage list(QueryParam param) {
|
||||
param.excludes("password");
|
||||
return super.list(param)
|
||||
.exclude(User.class, "password", "modules", "userRoles")
|
||||
@@ -44,14 +44,14 @@ public class UserController extends GenericController<User, String> {
|
||||
|
||||
@Override
|
||||
@AccessLogger("获取用户详情")
|
||||
public ResponseMessage info(@PathVariable("id") String id) throws Exception {
|
||||
public ResponseMessage info(@PathVariable("id") String id) {
|
||||
return super.info(id).exclude(User.class, "password", "modules");
|
||||
}
|
||||
|
||||
@AccessLogger("禁用")
|
||||
@RequestMapping(value = "/{id}/disable", method = RequestMethod.PUT)
|
||||
@Authorize(action = "disable")
|
||||
public ResponseMessage disable(@PathVariable("id") String id) throws Exception {
|
||||
public ResponseMessage disable(@PathVariable("id") String id) {
|
||||
getService().disableUser(id);
|
||||
return ResponseMessage.ok();
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class UserController extends GenericController<User, String> {
|
||||
@AccessLogger("启用")
|
||||
@Authorize(action = "enable")
|
||||
@RequestMapping(value = "/{id}/enable", method = RequestMethod.PUT)
|
||||
public ResponseMessage enable(@PathVariable("id") String id) throws Exception {
|
||||
public ResponseMessage enable(@PathVariable("id") String id) {
|
||||
getService().enableUser(id);
|
||||
return ResponseMessage.ok();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface FormMapper extends GenericMapper<Form, String> {
|
||||
* @return 表单对象
|
||||
* @throws Exception
|
||||
*/
|
||||
Form selectUsing(String name) throws Exception;
|
||||
Form selectUsing(String name);
|
||||
|
||||
/**
|
||||
* 查询最新版本的表单列表
|
||||
@@ -27,7 +27,7 @@ public interface FormMapper extends GenericMapper<Form, String> {
|
||||
* @param param 查询参数
|
||||
* @return 表单列表
|
||||
*/
|
||||
List<Form> selectLatestList(QueryParam param) throws Exception;
|
||||
List<Form> selectLatestList(QueryParam param);
|
||||
|
||||
/**
|
||||
* 查询最新版本的表单数量
|
||||
@@ -35,6 +35,6 @@ public interface FormMapper extends GenericMapper<Form, String> {
|
||||
* @param param 查询参数
|
||||
* @return 表单数量
|
||||
*/
|
||||
int countLatestList(QueryParam param) throws Exception;
|
||||
int countLatestList(QueryParam param);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.hsweb.web.dao.profile;
|
||||
|
||||
import org.hsweb.web.bean.po.profile.UserProfile;
|
||||
import org.hsweb.web.dao.GenericMapper;
|
||||
|
||||
/**
|
||||
* Created by zhouhao on 16-7-4.
|
||||
*/
|
||||
public interface UserProfileMapper extends GenericMapper<UserProfile, String> {
|
||||
}
|
||||
@@ -15,11 +15,10 @@ public interface RoleModuleMapper extends GenericMapper<RoleModule, String> {
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<RoleModule> selectByRoleId(String roleId) throws Exception;
|
||||
List<RoleModule> selectByRoleId(String roleId) ;
|
||||
|
||||
int deleteByRoleId(String roleId) throws Exception;
|
||||
int deleteByRoleId(String roleId) ;
|
||||
|
||||
int deleteByModuleId(String moduleId) throws Exception;
|
||||
int deleteByModuleId(String moduleId) ;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@ public interface UserRoleMapper extends GenericMapper<UserRole, String> {
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 角色列表
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
List<UserRole> selectByUserId(String userId) throws Exception;
|
||||
List<UserRole> selectByUserId(String userId);
|
||||
|
||||
int deleteByUserId(String userId) throws Exception;
|
||||
int deleteByUserId(String userId);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,8 @@ public interface TemplateMapper extends GenericMapper<Template, String> {
|
||||
*
|
||||
* @param name 模板名字
|
||||
* @return 模板对象
|
||||
* @throws Exception
|
||||
*/
|
||||
Template selectUsing(String name) throws Exception;
|
||||
Template selectUsing(String name) ;
|
||||
|
||||
/**
|
||||
* 查询最新版本的模板列表
|
||||
@@ -25,7 +24,7 @@ public interface TemplateMapper extends GenericMapper<Template, String> {
|
||||
* @param param 查询参数
|
||||
* @return 模板列表
|
||||
*/
|
||||
List<Template> selectLatestList(QueryParam param) throws Exception;
|
||||
List<Template> selectLatestList(QueryParam param) ;
|
||||
|
||||
/**
|
||||
* 查询最新版本的模板数量
|
||||
@@ -33,6 +32,6 @@ public interface TemplateMapper extends GenericMapper<Template, String> {
|
||||
* @param param 查询参数
|
||||
* @return 模板数量
|
||||
*/
|
||||
int countLatestList(QueryParam param) throws Exception;
|
||||
int countLatestList(QueryParam param) ;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.hsweb.web.bean.po.user.User;
|
||||
* Created by generator
|
||||
*/
|
||||
public interface UserMapper extends GenericMapper<User, String> {
|
||||
User selectByUserName(String userName) throws Exception;
|
||||
User selectByUserName(String userName);
|
||||
|
||||
void updatePassword(User user);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class AbstractServiceImpl<Po, PK> implements GenericService<Po,
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public PagerResult<Po> selectPager(QueryParam param) throws Exception {
|
||||
public PagerResult<Po> selectPager(QueryParam param) {
|
||||
PagerResult<Po> pagerResult = new PagerResult<>();
|
||||
param.setPaging(false);
|
||||
int total = getMapper().total(param);
|
||||
@@ -44,7 +44,7 @@ public abstract class AbstractServiceImpl<Po, PK> implements GenericService<Po,
|
||||
}
|
||||
|
||||
@Override
|
||||
public PK insert(Po data) throws Exception {
|
||||
public PK insert(Po data) {
|
||||
PK primaryKey = null;
|
||||
if (data instanceof GenericPo) {
|
||||
if (((GenericPo) data).getId() == null)
|
||||
@@ -56,7 +56,7 @@ public abstract class AbstractServiceImpl<Po, PK> implements GenericService<Po,
|
||||
return primaryKey;
|
||||
}
|
||||
|
||||
public List<PK> batchInsert(List<Po> data, boolean skipFail) throws Exception {
|
||||
public List<PK> batchInsert(List<Po> data, boolean skipFail) {
|
||||
List<PK> pkList = new ArrayList<>();
|
||||
List<Po> insertData = new ArrayList<>();
|
||||
//build
|
||||
@@ -83,17 +83,17 @@ public abstract class AbstractServiceImpl<Po, PK> implements GenericService<Po,
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(PK pk) throws Exception {
|
||||
public int delete(PK pk) {
|
||||
return getMapper().delete(DeleteParam.build().where("id", pk));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Po data) throws Exception {
|
||||
public int update(Po data) {
|
||||
return getMapper().update(UpdateParam.build(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(List<Po> data) throws Exception {
|
||||
public int update(List<Po> data) {
|
||||
int i = 0;
|
||||
for (Po po : data) {
|
||||
i += getMapper().update(UpdateParam.build(po));
|
||||
@@ -103,27 +103,32 @@ public abstract class AbstractServiceImpl<Po, PK> implements GenericService<Po,
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Po> select(QueryParam param) throws Exception {
|
||||
public List<Po> select(QueryParam param) {
|
||||
return this.getMapper().select(param);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Po> select() throws Exception {
|
||||
public List<Po> select() {
|
||||
return this.getMapper().select(QueryParam.build().noPaging());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int total(QueryParam param) throws Exception {
|
||||
public int total(QueryParam param) {
|
||||
return this.getMapper().total(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Po selectByPk(PK pk) throws Exception {
|
||||
public Po selectByPk(PK pk) {
|
||||
return this.getMapper().selectByPk(pk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveOrUpdate(Po po) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void assertNotNull(Object po, String message) {
|
||||
if (po == null) throw new NotFoundException(message);
|
||||
}
|
||||
|
||||
@@ -37,13 +37,13 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_KEY, allEntries = true)
|
||||
public int update(Config data) throws Exception {
|
||||
public int update(Config data) {
|
||||
return configMapper.update(new UpdateParam<>(data).excludes("createDate").where("id",data.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_KEY, allEntries = true)
|
||||
public int delete(String s) throws Exception {
|
||||
public int delete(String s) {
|
||||
return super.delete(s);
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
*
|
||||
* @param name 配置名称
|
||||
* @return 配置内容
|
||||
* @throws Exception 异常信息
|
||||
* @异常信息
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'info.content.'+#name")
|
||||
public String getContent(String name) throws Exception {
|
||||
public String getContent(String name) {
|
||||
Config config = getMapper().selectByPk(name);
|
||||
if (config == null) return null;
|
||||
return config.getContent();
|
||||
@@ -67,11 +67,11 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
*
|
||||
* @param name 配置名称
|
||||
* @return 配置内容
|
||||
* @throws Exception 异常信息
|
||||
* @异常信息
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'info.'+#name")
|
||||
public Map<Object, Object> get(String name) throws Exception {
|
||||
public Map<Object, Object> get(String name) {
|
||||
Config config = getMapper().selectByPk(name);
|
||||
if (config == null) return new HashMap<>();
|
||||
return config.toMap();
|
||||
@@ -87,7 +87,7 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'info.'+#name+'.key.'+#key")
|
||||
public String get(String name, String key) throws Exception {
|
||||
public String get(String name, String key) {
|
||||
Object val = get(name).get(key);
|
||||
if (val == null) return null;
|
||||
return String.valueOf(val);
|
||||
@@ -124,7 +124,7 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'info.'+#name+'.key.'+#key+'.int'")
|
||||
public int getInt(String name, String key) throws Exception {
|
||||
public int getInt(String name, String key) {
|
||||
return StringUtils.toInt(get(name, key));
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'info.'+#name+'.key.'+#key+'.double'")
|
||||
public double getDouble(String name, String key) throws Exception {
|
||||
public double getDouble(String name, String key) {
|
||||
return StringUtils.toDouble(get(name, key));
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'info.'+#name+'.key.'+#key+'.long'")
|
||||
public long getLong(String name, String key) throws Exception {
|
||||
public long getLong(String name, String key) {
|
||||
return StringUtils.toLong(get(name, key));
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class ConfigServiceImpl extends AbstractServiceImpl<Config, String> imple
|
||||
|
||||
|
||||
@Override
|
||||
public String insert(Config data) throws Exception {
|
||||
public String insert(Config data) {
|
||||
Config old = this.selectByPk(data.getId());
|
||||
Assert.isNull(old, "配置已存在,请勿重复添加!");
|
||||
data.setCreateDate(new Date());
|
||||
|
||||
@@ -78,9 +78,6 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
case "oracle":
|
||||
dataType = "varchar2(32)";
|
||||
break;
|
||||
case "h2":
|
||||
dataType = "varchar2(32)";
|
||||
break;
|
||||
default:
|
||||
dataType = "varchar(32)";
|
||||
}
|
||||
@@ -100,15 +97,16 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableMetaData parseMeta(Form form) throws Exception {
|
||||
public TableMetaData parseMeta(Form form){
|
||||
return formParser.parse(form);
|
||||
}
|
||||
|
||||
@Override
|
||||
@WriteLock
|
||||
@LockName(value = "'form.lock.'+#form.name", isExpression = true)
|
||||
public void deploy(Form form) throws Exception {
|
||||
public void deploy(Form form) throws SQLException {
|
||||
TableMetaData metaData = formParser.parse(form);
|
||||
metaData.setProperty("version", form.getRevision());
|
||||
initDefaultField(metaData);
|
||||
TableMetaData lastDeployMetaData;
|
||||
if (tableMetaParser == null) {
|
||||
@@ -132,16 +130,17 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
//更新结构
|
||||
database.alterTable(metaData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@WriteLock
|
||||
@LockName(value = "'form.lock.'+#form.name", isExpression = true)
|
||||
public void unDeploy(Form form) throws Exception {
|
||||
public void unDeploy(Form form){
|
||||
database.removeTable(form.getName());
|
||||
}
|
||||
|
||||
public Table getTableByName(String name) throws Exception {
|
||||
public Table getTableByName(String name){
|
||||
try {
|
||||
Table table = database.getTable(name);
|
||||
if (table == null) {
|
||||
@@ -157,7 +156,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
@Transactional(readOnly = true)
|
||||
public <T> PagerResult<T> selectPager(String name, QueryParam param) throws Exception {
|
||||
public <T> PagerResult<T> selectPager(String name, QueryParam param) throws SQLException {
|
||||
PagerResult<T> result = new PagerResult<>();
|
||||
Table table = getTableByName(name);
|
||||
Query query = table.createQuery();
|
||||
@@ -173,7 +172,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
@Transactional(readOnly = true)
|
||||
public <T> List<T> select(String name, QueryParam param) throws Exception {
|
||||
public <T> List<T> select(String name, QueryParam param) throws SQLException {
|
||||
Table table = getTableByName(name);
|
||||
Query query = table.createQuery().setParam(param);
|
||||
return query.list();
|
||||
@@ -183,7 +182,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
@Transactional(readOnly = true)
|
||||
public int total(String name, QueryParam param) throws Exception {
|
||||
public int total(String name, QueryParam param) throws SQLException {
|
||||
Table table = getTableByName(name);
|
||||
Query query = table.createQuery().setParam(param);
|
||||
return query.total();
|
||||
@@ -192,7 +191,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public String insert(String name, Map<String, Object> data) throws Exception {
|
||||
public String insert(String name, Map<String, Object> data) throws SQLException {
|
||||
Table table = getTableByName(name);
|
||||
String primaryKeyName = getPrimaryKeyName(name);
|
||||
String pk = GenericPo.createUID();
|
||||
@@ -203,7 +202,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveOrUpdate(String name, Map<String, Object> data) throws Exception {
|
||||
public String saveOrUpdate(String name, Map<String, Object> data) throws SQLException {
|
||||
String id = (String) data.get(getPrimaryKeyName(name));
|
||||
if (id == null)
|
||||
id = getRepeatDataId(name, data);
|
||||
@@ -230,7 +229,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public boolean deleteByPk(String name, String pk) throws Exception {
|
||||
public boolean deleteByPk(String name, String pk) throws SQLException {
|
||||
String primaryKeyName = getPrimaryKeyName(name);
|
||||
Table table = getTableByName(name);
|
||||
Delete delete = table.createDelete().where(primaryKeyName, pk);
|
||||
@@ -240,7 +239,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public int delete(String name, DeleteParam where) throws Exception {
|
||||
public int delete(String name, DeleteParam where) throws SQLException {
|
||||
Table table = getTableByName(name);
|
||||
Delete delete = table.createDelete();
|
||||
delete.setParam(where);
|
||||
@@ -250,7 +249,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public int updateByPk(String name, String pk, UpdateParam<Map<String, Object>> param) throws Exception {
|
||||
public int updateByPk(String name, String pk, UpdateParam<Map<String, Object>> param) throws SQLException {
|
||||
Table table = getTableByName(name);
|
||||
Update update = table.createUpdate().setParam(param);
|
||||
update.where(getPrimaryKeyName(name), pk);
|
||||
@@ -260,7 +259,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public int update(String name, UpdateParam<Map<String, Object>> param) throws Exception {
|
||||
public int update(String name, UpdateParam<Map<String, Object>> param) throws SQLException {
|
||||
Table table = getTableByName(name);
|
||||
Update update = table.createUpdate().setParam(param);
|
||||
return update.exec();
|
||||
@@ -268,7 +267,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#tableName", isExpression = true)
|
||||
public String getPrimaryKeyName(String tableName) throws Exception {
|
||||
public String getPrimaryKeyName(String tableName){
|
||||
Table table = getTableByName(tableName);
|
||||
return table.getMeta().getProperty("primaryKey", "u_id").toString();
|
||||
}
|
||||
@@ -276,7 +275,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public <T> T selectByPk(String name, Object pk) throws Exception {
|
||||
public <T> T selectByPk(String name, Object pk) throws SQLException {
|
||||
Table<T> table = getTableByName(name);
|
||||
Query<T> query = table.createQuery().where(getPrimaryKeyName(name), pk);
|
||||
return query.single();
|
||||
@@ -341,7 +340,7 @@ public class DynamicFormServiceImpl implements DynamicFormService, ExpressionSco
|
||||
@Override
|
||||
@ReadLock
|
||||
@LockName(value = "'form.lock.'+#name", isExpression = true)
|
||||
public Map<String, Object> importExcel(String name, InputStream inputStream) throws Exception {
|
||||
public Map<String, Object> importExcel(String name, InputStream inputStream){
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<Map<String, Object>> excelData;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.util.Assert;
|
||||
import org.hsweb.commons.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -54,12 +55,12 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "#id")
|
||||
public Form selectByPk(String id) throws Exception {
|
||||
public Form selectByPk(String id) {
|
||||
return super.selectByPk(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createNewVersion(String oldVersionId) throws Exception {
|
||||
public String createNewVersion(String oldVersionId) {
|
||||
Form old = this.selectByPk(oldVersionId);
|
||||
assertNotNull(old, "表单不存在!");
|
||||
old.setId(RandomUtil.randomChar());
|
||||
@@ -74,7 +75,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insert(Form data) throws Exception {
|
||||
public String insert(Form data) {
|
||||
List<Form> old = this.select(QueryParam.build().where("name", data.getName()));
|
||||
Assert.isTrue(old.isEmpty(), "表单 [" + data.getName() + "] 已存在!");
|
||||
data.setCreateDate(new Date());
|
||||
@@ -92,7 +93,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
@CacheEvict(value = {CACHE_KEY}, key = "#data.name+':'+#data.version")
|
||||
}
|
||||
)
|
||||
public int update(Form data) throws Exception {
|
||||
public int update(Form data) {
|
||||
Form old = this.selectByPk(data.getId());
|
||||
assertNotNull(old, "表单不存在!");
|
||||
data.setUpdateDate(new Date());
|
||||
@@ -104,7 +105,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_KEY, key = "#id")
|
||||
public int delete(String id) throws Exception {
|
||||
public int delete(String id) {
|
||||
Form old = this.selectByPk(id);
|
||||
assertNotNull(old, "表单不存在!");
|
||||
Assert.isTrue(!old.isUsing(), "表单正在使用,无法删除!");
|
||||
@@ -113,19 +114,19 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Form> selectLatestList(QueryParam param) throws Exception {
|
||||
public List<Form> selectLatestList(QueryParam param) {
|
||||
return formMapper.selectLatestList(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int countLatestList(QueryParam param) throws Exception {
|
||||
public int countLatestList(QueryParam param) {
|
||||
return formMapper.countLatestList(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "#name+':'+#version")
|
||||
public Form selectByVersion(String name, int version) throws Exception {
|
||||
public Form selectByVersion(String name, int version) {
|
||||
QueryParam param = QueryParam.build()
|
||||
.where("name", name).where("version", version);
|
||||
List<Form> formList = formMapper.selectLatestList(param);
|
||||
@@ -133,7 +134,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public Form selectLatest(String name) throws Exception {
|
||||
public Form selectLatest(String name) {
|
||||
QueryParam param = QueryParam.build()
|
||||
.where("name", name).orderBy("version").asc();
|
||||
List<Form> formList = formMapper.selectLatestList(param);
|
||||
@@ -176,7 +177,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
@CacheEvict(value = {CACHE_KEY + ".deploy"}, key = "'deploy.'+target.selectByPk(#formId).getName()"),
|
||||
@CacheEvict(value = {CACHE_KEY}, key = "'using.'+target.selectByPk(#formId).getName()")
|
||||
})
|
||||
public void unDeploy(String formId) throws Exception {
|
||||
public void unDeploy(String formId) {
|
||||
Form old = this.selectByPk(formId);
|
||||
assertNotNull(old, "表单不存在");
|
||||
dynamicFormService.unDeploy(old);
|
||||
@@ -188,7 +189,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY + ".deploy", key = "'deploy.'+#name+'.html'")
|
||||
public String createDeployHtml(String name) throws Exception {
|
||||
public String createDeployHtml(String name) {
|
||||
History history = historyService.selectLastHistoryByType("form.deploy." + name);
|
||||
assertNotNull(history, "表单不存在");
|
||||
return formParser.parseHtml(JSON.parseObject(history.getChangeAfter(), Form.class));
|
||||
@@ -196,7 +197,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY + ".deploy", key = "'deploy.'+#name")
|
||||
public Form selectDeployed(String name) throws Exception {
|
||||
public Form selectDeployed(String name) {
|
||||
Form using = selectUsing(name);
|
||||
assertNotNull(using, "表单不存在或未部署");
|
||||
History history = historyService.selectLastHistoryByType("form.deploy." + name);
|
||||
@@ -205,7 +206,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createViewHtml(String formId) throws Exception {
|
||||
public String createViewHtml(String formId) {
|
||||
Form form = this.selectByPk(formId);
|
||||
assertNotNull(form, "表单不存在");
|
||||
return formParser.parseHtml(form);
|
||||
@@ -213,7 +214,7 @@ public class FormServiceImpl extends AbstractServiceImpl<Form, String> implement
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'using.'+#name")
|
||||
public Form selectUsing(String name) throws Exception {
|
||||
public Form selectUsing(String name) {
|
||||
return formMapper.selectUsing(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class HistoryServiceImpl extends AbstractServiceImpl<History, String> imp
|
||||
}
|
||||
|
||||
@Override
|
||||
public History selectLastHistoryByType(String type) throws Exception {
|
||||
public History selectLastHistoryByType(String type) {
|
||||
QueryParam queryParam = new QueryParam()
|
||||
.where("type", type)
|
||||
.doPaging(0, 1)
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ModuleMetaServiceImpl extends AbstractServiceImpl<ModuleMeta, Strin
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_NAME, allEntries = true)
|
||||
public int update(ModuleMeta data) throws Exception {
|
||||
public int update(ModuleMeta data) {
|
||||
return super.update(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ResourcesServiceImpl extends AbstractServiceImpl<Resources, String>
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'id.'+#id")
|
||||
@Transactional(readOnly = true)
|
||||
public Resources selectByPk(String id) throws Exception {
|
||||
public Resources selectByPk(String id) {
|
||||
return super.selectByPk(id);
|
||||
}
|
||||
|
||||
@@ -48,18 +48,18 @@ public class ResourcesServiceImpl extends AbstractServiceImpl<Resources, String>
|
||||
*/
|
||||
@Cacheable(value = CACHE_KEY, key = "'md5.'+#md5")
|
||||
@Transactional(readOnly = true)
|
||||
public Resources selectByMd5(String md5) throws Exception {
|
||||
public Resources selectByMd5(String md5) {
|
||||
return this.selectSingle(new QueryParam().where("md5", md5));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
public String insert(Resources data) throws Exception {
|
||||
public String insert(Resources data) {
|
||||
data.setId(this.newid(6));//6位随机id
|
||||
return super.insert(data);
|
||||
}
|
||||
|
||||
public String newid(int len) throws Exception {
|
||||
public String newid(int len) {
|
||||
String id = RandomUtil.randomChar(len);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (this.selectByPk(id) == null) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RoleServiceImpl extends AbstractServiceImpl<Role, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insert(Role data) throws Exception {
|
||||
public String insert(Role data) {
|
||||
String id = super.insert(data);
|
||||
List<RoleModule> roleModule = data.getModules();
|
||||
if (roleModule != null && roleModule.size() > 0) {
|
||||
@@ -52,7 +52,7 @@ public class RoleServiceImpl extends AbstractServiceImpl<Role, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Role data) throws Exception {
|
||||
public int update(Role data){
|
||||
int l = super.update(data);
|
||||
List<RoleModule> roleModule = data.getModules();
|
||||
if (roleModule != null && roleModule.size() > 0) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DynamicScriptServiceImpl extends AbstractServiceImpl<DynamicScript,
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insert(DynamicScript data) throws Exception {
|
||||
public String insert(DynamicScript data) {
|
||||
DynamicScript old = selectSingle(QueryParam.build().where("name", data.getName()).and("type", data.getType()));
|
||||
if (old != null) throw new BusinessException("已存在相同名称和类型的脚本!", 400);
|
||||
data.setStatus(1);
|
||||
@@ -50,13 +50,13 @@ public class DynamicScriptServiceImpl extends AbstractServiceImpl<DynamicScript,
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'script.'+#pk")
|
||||
public DynamicScript selectByPk(String pk) throws Exception {
|
||||
public DynamicScript selectByPk(String pk) {
|
||||
return super.selectByPk(pk);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_KEY, key = "'script.md5.'+#pk")
|
||||
public String getScriptMd5(String scriptId) throws Exception {
|
||||
public String getScriptMd5(String scriptId) {
|
||||
DynamicScript script = selectByPk(scriptId);
|
||||
assertNotNull(script, "脚本不存在");
|
||||
return MD5.defaultEncode(script.getContent());
|
||||
@@ -70,7 +70,7 @@ public class DynamicScriptServiceImpl extends AbstractServiceImpl<DynamicScript,
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_KEY, allEntries = true)
|
||||
public int update(DynamicScript data) throws Exception {
|
||||
public int update(DynamicScript data) {
|
||||
DynamicScript old = selectSingle(QueryParam.build()
|
||||
.where("name", data.getName())
|
||||
.and("type", data.getType())
|
||||
@@ -82,14 +82,13 @@ public class DynamicScriptServiceImpl extends AbstractServiceImpl<DynamicScript,
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_KEY, allEntries = true)
|
||||
public int update(List<DynamicScript> datas) throws Exception {
|
||||
int i = super.update(datas);
|
||||
return i;
|
||||
public int update(List<DynamicScript> datas) {
|
||||
return super.update(datas);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = CACHE_KEY, allEntries = true)
|
||||
public int delete(String pk) throws Exception {
|
||||
public int delete(String pk) {
|
||||
return super.delete(pk);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insert(Template data) throws Exception {
|
||||
public String insert(Template data) {
|
||||
data.setVersion(1);
|
||||
data.setUsing(false);
|
||||
data.setRelease(0);
|
||||
@@ -49,7 +49,7 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createNewVersion(String oldVersionId) throws Exception {
|
||||
public String createNewVersion(String oldVersionId) {
|
||||
Template old = templateMapper.selectByPk(oldVersionId);
|
||||
assertNotNull(old, "模板不存在");
|
||||
old.setId(null);
|
||||
@@ -63,13 +63,13 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Template> selectLatestList(QueryParam param) throws Exception {
|
||||
public List<Template> selectLatestList(QueryParam param) {
|
||||
return templateMapper.selectLatestList(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int countLatestList(QueryParam param) throws Exception {
|
||||
public int countLatestList(QueryParam param) {
|
||||
return templateMapper.countLatestList(param);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
@CacheEvict(value = CACHE_NAME,
|
||||
key = "'template.name.using'+target.selectByPk(#id).getName()",
|
||||
condition = "target.selectByPk(#id).isUsing()")
|
||||
public int update(Template data) throws Exception {
|
||||
public int update(Template data) {
|
||||
Template old = selectByPk(data.getId());
|
||||
assertNotNull(old, "模板不存在");
|
||||
data.setRevision(old.getRevision() + 1);
|
||||
@@ -94,7 +94,7 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
@CacheEvict(value = CACHE_NAME, key = "'template.deploy.name.'+target.selectByPk(#id).getName()")
|
||||
}
|
||||
)
|
||||
public void deploy(String id) throws Exception {
|
||||
public void deploy(String id) {
|
||||
Template old = templateMapper.selectByPk(id);
|
||||
assertNotNull(old, "模板不存在");
|
||||
Template usingTemplate = selectUsing(old.getName());
|
||||
@@ -121,7 +121,7 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
, @CacheEvict(value = CACHE_NAME, key = "'template.deploy.name'+target.selectByPk(#id).getName()")
|
||||
}
|
||||
)
|
||||
public void unDeploy(String id) throws Exception {
|
||||
public void unDeploy(String id) {
|
||||
Template old = templateMapper.selectByPk(id);
|
||||
assertNotNull(old, "模板不存在");
|
||||
old.setUsing(false);
|
||||
@@ -130,7 +130,7 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Template selectLatest(String name) throws Exception {
|
||||
public Template selectLatest(String name) {
|
||||
QueryParam param = QueryParam.build()
|
||||
.where("name", name).orderBy("version").desc().doPaging(0, 1);
|
||||
List<Template> templates = selectLatestList(param);
|
||||
@@ -139,14 +139,14 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_NAME, key = "'template.name.'+#name+':'+#version")
|
||||
public Template selectByVersion(String name, int version) throws Exception {
|
||||
public Template selectByVersion(String name, int version) {
|
||||
QueryParam param = QueryParam.build().where("name", name).and("version", version);
|
||||
return this.selectSingle(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_NAME, key = "'template.deploy.name.'+#name")
|
||||
public Template selectDeploy(String name) throws Exception {
|
||||
public Template selectDeploy(String name) {
|
||||
Template deployed = selectUsing(name);
|
||||
assertNotNull(deployed, "模板不存在或未部署");
|
||||
History history = historyService.selectLastHistoryByType("template.deploy." + name);
|
||||
@@ -156,7 +156,7 @@ public class TemplateServiceImpl extends AbstractServiceImpl<Template, String> i
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CACHE_NAME, key = "'template.using.name.'+#name")
|
||||
public Template selectUsing(String name) throws Exception {
|
||||
public Template selectUsing(String name) {
|
||||
QueryParam param = QueryParam.build().where("name", name).and("using", true);
|
||||
return this.selectSingle(param);
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ public class UserServiceImpl extends AbstractServiceImpl<User, String> implement
|
||||
return this.userMapper;
|
||||
}
|
||||
|
||||
public User selectByUserName(String username) throws Exception {
|
||||
public User selectByUserName(String username) {
|
||||
return this.getMapper().selectByUserName(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String insert(User data) throws Exception {
|
||||
public String insert(User data) {
|
||||
tryValidPo(data);
|
||||
Assert.isNull(selectByUserName(data.getUsername()), "用户已存在!");
|
||||
data.setId(RandomUtil.randomChar(6));
|
||||
@@ -70,12 +70,12 @@ public class UserServiceImpl extends AbstractServiceImpl<User, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> batchInsert(List<User> data, boolean skipFail) throws Exception {
|
||||
public List<String> batchInsert(List<User> data, boolean skipFail) {
|
||||
throw new UnsupportedOperationException("不支持此操作");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(User data) throws Exception {
|
||||
public int update(User data) {
|
||||
tryValidPo(data);
|
||||
User old = this.selectByUserName(data.getUsername());
|
||||
if (old != null && !old.getId().equals(data.getId())) {
|
||||
@@ -100,7 +100,7 @@ public class UserServiceImpl extends AbstractServiceImpl<User, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initAdminUser(User user) throws Exception {
|
||||
public void initAdminUser(User user) {
|
||||
QueryParam queryParam = new QueryParam().noPaging();
|
||||
queryParam.orderBy("sortIndex");
|
||||
List<Module> modules = moduleService.select(queryParam);
|
||||
@@ -112,14 +112,14 @@ public class UserServiceImpl extends AbstractServiceImpl<User, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGuestUser(User user) throws Exception {
|
||||
public void initGuestUser(User user) {
|
||||
List<UserRole> userRoles = userRoleMapper.select(new QueryParam().where("roleId", "guest").noPaging());
|
||||
user.setUserRoles(userRoles);
|
||||
user.initRoleInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableUser(String id) throws Exception {
|
||||
public void enableUser(String id) {
|
||||
User user = selectByPk(id);
|
||||
if (user == null) throw new NotFoundException("用户不存在!");
|
||||
user.setStatus(1);
|
||||
@@ -127,7 +127,7 @@ public class UserServiceImpl extends AbstractServiceImpl<User, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableUser(String id) throws Exception {
|
||||
public void disableUser(String id) {
|
||||
User user = selectByPk(id);
|
||||
if (user == null) throw new NotFoundException("用户不存在!");
|
||||
user.setStatus(-1);
|
||||
@@ -135,7 +135,7 @@ public class UserServiceImpl extends AbstractServiceImpl<User, String> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(String s) throws Exception {
|
||||
public int delete(String s) {
|
||||
throw new BusinessException("服务不支持", 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,19 @@ public interface GenericService<Po, Pk> {
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 分页结果
|
||||
* @throws Exception 查询异常
|
||||
* @ 查询异常
|
||||
*/
|
||||
PagerResult<Po> selectPager(QueryParam param) throws Exception;
|
||||
PagerResult<Po> selectPager(QueryParam param);
|
||||
|
||||
/**
|
||||
* 添加一条数据
|
||||
*
|
||||
* @param data 要添加的数据
|
||||
* @return 添加后生成的主键
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
Pk insert(Po data) throws Exception;
|
||||
Pk insert(Po data);
|
||||
|
||||
default List<Pk> batchInsert(List<Po> data) throws Exception {
|
||||
default List<Pk> batchInsert(List<Po> data) {
|
||||
return batchInsert(data, false);
|
||||
}
|
||||
|
||||
@@ -41,36 +40,34 @@ public interface GenericService<Po, Pk> {
|
||||
* @param data 数据集合
|
||||
* @param skipFail 是否跳过验证失败的的数据
|
||||
* @return 添加后产生的主键集合
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
List<Pk> batchInsert(List<Po> data, boolean skipFail) throws Exception;
|
||||
List<Pk> batchInsert(List<Po> data, boolean skipFail);
|
||||
|
||||
/**
|
||||
* 根据主键删除记录
|
||||
*
|
||||
* @param pk 主键
|
||||
* @return 影响记录数
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
int delete(Pk pk) throws Exception;
|
||||
int delete(Pk pk);
|
||||
|
||||
/**
|
||||
* 修改记录信息
|
||||
*
|
||||
* @param data 要修改的对象
|
||||
* @return 影响记录数
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
int update(Po data) throws Exception;
|
||||
int update(Po data);
|
||||
|
||||
/**
|
||||
* 批量修改记录
|
||||
*
|
||||
* @param data 要修改的记录集合
|
||||
* @return 影响记录数
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
int update(List<Po> data) throws Exception;
|
||||
int update(List<Po> data);
|
||||
|
||||
int saveOrUpdate(Po po);
|
||||
|
||||
/**
|
||||
* 根据条件集合查询记录,支持分页,排序。
|
||||
@@ -88,36 +85,33 @@ public interface GenericService<Po, Pk> {
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 查询结果
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
List<Po> select(QueryParam param) throws Exception;
|
||||
List<Po> select(QueryParam param);
|
||||
|
||||
/**
|
||||
* 查询记录总数,用于分页等操作。查询条件同 {@link GenericService#select}
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 查询结果,实现mapper中的sql应指定默认值,否则可能抛出异常
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
int total(QueryParam param) throws Exception;
|
||||
int total(QueryParam param);
|
||||
|
||||
/**
|
||||
* 根据主键查询记录
|
||||
*
|
||||
* @param pk 主键
|
||||
* @return 查询结果
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
Po selectByPk(Pk pk) throws Exception;
|
||||
Po selectByPk(Pk pk);
|
||||
|
||||
/**
|
||||
* 查询只返回单个结果
|
||||
*
|
||||
* @param param 查询条件
|
||||
* @return 单个结果
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
default Po selectSingle(QueryParam param) throws Exception {
|
||||
default Po selectSingle(QueryParam param) {
|
||||
param.doPaging(0, 1);
|
||||
List<Po> list = this.select(param);
|
||||
if (list.size() == 0) return null;
|
||||
|
||||
@@ -16,18 +16,16 @@ public interface ConfigService extends GenericService<Config, String> {
|
||||
*
|
||||
* @param name 配置名称
|
||||
* @return 配置内容
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
String getContent(String name) throws Exception;
|
||||
String getContent(String name);
|
||||
|
||||
/**
|
||||
* 根据配置名称,获取配置内容,并解析为map格式
|
||||
*
|
||||
* @param name 配置名称
|
||||
* @return 配置内容
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
Map<Object,Object> get(String name) throws Exception;
|
||||
Map<Object, Object> get(String name);
|
||||
|
||||
/**
|
||||
* 获取配置中指定key的值
|
||||
@@ -35,9 +33,9 @@ public interface ConfigService extends GenericService<Config, String> {
|
||||
* @param name 配置名称
|
||||
* @param key key 异常信息
|
||||
* @return 指定的key对应的value
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
String get(String name, String key) throws Exception;
|
||||
String get(String name, String key);
|
||||
|
||||
/**
|
||||
* 获取配置中指定key的值,并指定一个默认值,如果对应的key未获取到,则返回默认值
|
||||
@@ -53,17 +51,17 @@ public interface ConfigService extends GenericService<Config, String> {
|
||||
/**
|
||||
* 参照 {@link ConfigService#get(String, String)},将值转为int类型
|
||||
*/
|
||||
int getInt(String name, String key) throws Exception;
|
||||
int getInt(String name, String key);
|
||||
|
||||
/**
|
||||
* 参照 {@link ConfigService#get(String, String)},将值转为double类型
|
||||
*/
|
||||
double getDouble(String name, String key) throws Exception;
|
||||
double getDouble(String name, String key);
|
||||
|
||||
/**
|
||||
* 参照 {@link ConfigService#get(String, String)},将值转为long类型
|
||||
*/
|
||||
long getLong(String name, String key) throws Exception;
|
||||
long getLong(String name, String key);
|
||||
|
||||
/**
|
||||
* 参照 {@link ConfigService#get(String, String, String)},将值转为int类型
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.hsweb.web.bean.po.form.Form;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,33 +18,33 @@ public interface DynamicFormService {
|
||||
|
||||
Database getDefaultDatabase();
|
||||
|
||||
TableMetaData parseMeta(Form form) throws Exception;
|
||||
TableMetaData parseMeta(Form form) ;
|
||||
|
||||
void deploy(Form form) throws Exception;
|
||||
void deploy(Form form) throws SQLException;
|
||||
|
||||
void unDeploy(Form form) throws Exception;
|
||||
void unDeploy(Form form) ;
|
||||
|
||||
<T> PagerResult<T> selectPager(String name, QueryParam param) throws Exception;
|
||||
<T> PagerResult<T> selectPager(String name, QueryParam param) throws SQLException;
|
||||
|
||||
<T> List<T> select(String name, QueryParam param) throws Exception;
|
||||
<T> List<T> select(String name, QueryParam param) throws SQLException;
|
||||
|
||||
int total(String name, QueryParam param) throws Exception;
|
||||
int total(String name, QueryParam param) throws SQLException;
|
||||
|
||||
String insert(String name,Map<String, Object> data) throws Exception;
|
||||
String insert(String name,Map<String, Object> data) throws SQLException;
|
||||
|
||||
String saveOrUpdate(String name, Map<String, Object> map) throws Exception;
|
||||
String saveOrUpdate(String name, Map<String, Object> map) throws SQLException;
|
||||
|
||||
int delete(String name, DeleteParam param) throws Exception;
|
||||
int delete(String name, DeleteParam param) throws SQLException;
|
||||
|
||||
boolean deleteByPk(String name, String pk) throws Exception;
|
||||
boolean deleteByPk(String name, String pk) throws SQLException;
|
||||
|
||||
int update(String name, UpdateParam<Map<String, Object>> param) throws Exception;
|
||||
int update(String name, UpdateParam<Map<String, Object>> param) throws SQLException;
|
||||
|
||||
int updateByPk(String name, String pk, UpdateParam<Map<String, Object>> param) throws Exception;
|
||||
int updateByPk(String name, String pk, UpdateParam<Map<String, Object>> param) throws SQLException;
|
||||
|
||||
<T> T selectByPk(String name, Object pk) throws Exception;
|
||||
<T> T selectByPk(String name, Object pk) throws SQLException;
|
||||
|
||||
void exportExcel(String name, QueryParam param, OutputStream outputStream) throws Exception;
|
||||
|
||||
Map<String, Object> importExcel(String name, InputStream inputStream) throws Exception;
|
||||
Map<String, Object> importExcel(String name, InputStream inputStream) ;
|
||||
}
|
||||
|
||||
@@ -16,16 +16,15 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* 修改表单,不修改原始数据,而是新加入一条数据,版本号自动+1.
|
||||
*/
|
||||
@Override
|
||||
int update(Form data) throws Exception;
|
||||
int update(Form data) ;
|
||||
|
||||
/**
|
||||
* 创建一个新版本的表单
|
||||
*
|
||||
* @param oldVersionId 旧版本表单ID
|
||||
* @return 新版本表单ID
|
||||
* @throws Exception 创建异常
|
||||
*/
|
||||
String createNewVersion(String oldVersionId) throws Exception;
|
||||
String createNewVersion(String oldVersionId) ;
|
||||
|
||||
/**
|
||||
* 查询最新版本的表单列表
|
||||
@@ -33,7 +32,7 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @param param 查询参数
|
||||
* @return 表单列表
|
||||
*/
|
||||
List<Form> selectLatestList(QueryParam param) throws Exception;
|
||||
List<Form> selectLatestList(QueryParam param) ;
|
||||
|
||||
/**
|
||||
* 查询最新版本的表单数量
|
||||
@@ -41,14 +40,14 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @param param 查询参数
|
||||
* @return 表单数量
|
||||
*/
|
||||
int countLatestList(QueryParam param) throws Exception;
|
||||
int countLatestList(QueryParam param) ;
|
||||
|
||||
/**
|
||||
* 发布表单,发布表单后,可通过{@link DynamicFormService}进行调用.
|
||||
* 表单发布后,using属性自动改为true,其他已发布的版本将自动取消发布.
|
||||
*
|
||||
* @param formId 要发布的表单ID
|
||||
* @throws Exception 发布失败异常
|
||||
* @ 发布失败异常
|
||||
*/
|
||||
void deploy(String formId) throws Exception;
|
||||
|
||||
@@ -56,9 +55,9 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* 取消发布,取消发布后。表单失效。使用{@link DynamicFormService}后无法再进行调用
|
||||
*
|
||||
* @param formId 要取消发布的表单ID
|
||||
* @throws Exception 取消失败异常
|
||||
* @ 取消失败异常
|
||||
*/
|
||||
void unDeploy(String formId) throws Exception;
|
||||
void unDeploy(String formId) ;
|
||||
|
||||
/**
|
||||
* 创建当前已部署表单对应的html,用于前端渲染.
|
||||
@@ -66,20 +65,20 @@ public interface FormService extends GenericService<Form, String> {
|
||||
*
|
||||
* @param name 要创建html的表单名称
|
||||
* @return html字符串
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
String createDeployHtml(String name) throws Exception;
|
||||
String createDeployHtml(String name) ;
|
||||
|
||||
Form selectDeployed(String name) throws Exception;
|
||||
Form selectDeployed(String name) ;
|
||||
|
||||
/**
|
||||
* 根据表单名称,获取最新版本的表单
|
||||
*
|
||||
* @param name 表单名称
|
||||
* @return 表单对象,表单不存在将返回null
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
Form selectLatest(String name) throws Exception;
|
||||
Form selectLatest(String name) ;
|
||||
|
||||
/**
|
||||
* 根据表单名称和版本,获取表单
|
||||
@@ -87,27 +86,27 @@ public interface FormService extends GenericService<Form, String> {
|
||||
* @param name 表单名称
|
||||
* @param version 表单版本
|
||||
* @return 表单对象,表单不存在将返回null
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
Form selectByVersion(String name, int version) throws Exception;
|
||||
Form selectByVersion(String name, int version) ;
|
||||
|
||||
/**
|
||||
* 创建表单的html预览。
|
||||
*
|
||||
* @param id 表单ID
|
||||
* @return html 字符串
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
String createViewHtml(String id) throws Exception;
|
||||
String createViewHtml(String id) ;
|
||||
|
||||
/**
|
||||
* 查询当前正在使用的表单
|
||||
*
|
||||
* @param name 正在使用的表单名称
|
||||
* @return 表单对象。没有则返回null
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
Form selectUsing(String name) throws Exception;
|
||||
Form selectUsing(String name) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@ public interface HistoryService extends GenericService<History, String> {
|
||||
* @param type 类型
|
||||
* @return 查询结果
|
||||
*/
|
||||
History selectLastHistoryByType(String type) throws Exception;
|
||||
History selectLastHistoryByType(String type);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ public interface ResourcesService extends GenericService<Resources, String> {
|
||||
*
|
||||
* @param md5 md5值
|
||||
* @return 资源对象
|
||||
* @throws Exception
|
||||
*/
|
||||
Resources selectByMd5(String md5) throws Exception;
|
||||
Resources selectByMd5(String md5);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,27 +14,25 @@ public interface UserService extends GenericService<User, String> {
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 用户名对应的用户,如果不存在返回null
|
||||
* @throws Exception
|
||||
* @
|
||||
*/
|
||||
User selectByUserName(String username) throws Exception;
|
||||
User selectByUserName(String username) ;
|
||||
|
||||
/**
|
||||
* 将一个user初始化为超级管理员
|
||||
*
|
||||
* @param user 要初始化的user对象
|
||||
* @throws Exception 初始化失败异常
|
||||
*/
|
||||
void initAdminUser(User user) throws Exception;
|
||||
void initAdminUser(User user) ;
|
||||
|
||||
/**
|
||||
* 将一个user初始化为游客
|
||||
*
|
||||
* @param user 要初始化的user对象
|
||||
* @throws Exception 初始化失败异常
|
||||
*/
|
||||
void initGuestUser(User user) throws Exception;
|
||||
void initGuestUser(User user) ;
|
||||
|
||||
void enableUser(String id) throws Exception;
|
||||
void enableUser(String id) ;
|
||||
|
||||
void disableUser(String id) throws Exception;
|
||||
void disableUser(String id) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user