字典类型优化

v1.4.1
hiparker 4 years ago
parent cf94970bca
commit 9a41ccce3f

@ -1,3 +1,18 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.common.enums;

@ -1,3 +1,18 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.common.enums;
/**

@ -1,3 +1,18 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.common.enums;
/**

@ -1,36 +1,85 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.common.enums;
/**
* @Author:
* @CreateTime: 2020-09-17 23:40
* @Description:
*
*
* @author :
* @date : 2020-09-17 23:40
*/
public enum DictType {
/** no_yes */
NO_YES_NO("0"),
NO_YES_YES("1"),
/** 是否 */
NO_YES_NO("no_yes","0"),
NO_YES_YES("no_yes","1"),
;
private final String code;
private final String type;
private final String value;
DictType(String type, String value){
this.type = type;
this.value = value;
}
DictType(String code){
this.code = code;
public String getValue() {
return value;
}
public String getCode(){
return this.code;
public String getType() {
return this.type;
}
public static DictType getType(String code) {
/**
*
* @param type
* @param value
* @return DictType
*/
public static DictType getDict(String type, String value) {
DictType[] var1 = values();
for (DictType type : var1) {
if (type.code.equalsIgnoreCase(code)) {
return type;
for (DictType dict : var1) {
if(dict.type.equals(type) &&
dict.value.equalsIgnoreCase(value)
){
return dict;
}
}
return null;
}
/**
*
* @param type
* @param value
* @return boolean
*/
public static boolean hasDict(String type, String value) {
DictType[] var1 = values();
for (DictType dict : var1) {
if(dict.type.equals(type) &&
dict.value.equalsIgnoreCase(value)
){
return true;
}
}
return false;
}
}

@ -1,3 +1,18 @@
/**
* Copyright 2020 OPSLI https://www.opsli.com
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.opsli.common.enums;
/**

@ -284,7 +284,7 @@ public enum JavaCodeBuilder {
StringBuilder stb = new StringBuilder();
boolean izNotNull = false;
// 如果非空 则开启非空验证
if(DictType.NO_YES_YES.getCode().equals(columnModel.getIzNotNull())){
if(DictType.NO_YES_YES.getValue().equals(columnModel.getIzNotNull())){
izNotNull = true;
stb.append("ValiArgsType.").append(ValiArgsType.IS_NOT_NULL);
}

@ -76,7 +76,7 @@ public enum VueCodeBuilder {
List<CreaterTableColumnModel> moreQueryList = new ArrayList<>();
for (CreaterTableColumnModel createrTableColumnModel : columnList) {
if (StringUtils.isNotBlank(createrTableColumnModel.getQueryType()) &&
createrTableColumnModel.getIzShowList().equals(DictType.NO_YES_YES.getCode())
createrTableColumnModel.getIzShowList().equals(DictType.NO_YES_YES.getValue())
) {
queryList.add(createrTableColumnModel);
}
@ -145,7 +145,7 @@ public enum VueCodeBuilder {
String[] validateTypes = validateType.split(",");
Set<String> validateTypeSet = new HashSet<>(Arrays.asList(validateTypes));
// 如果非空 则开启非空验证
if(DictType.NO_YES_YES.getCode().equals(columnModel.getIzNotNull())){
if(DictType.NO_YES_YES.getValue().equals(columnModel.getIzNotNull())){
validateTypeSet.add(ValiArgsType.IS_NOT_NULL.toString());
}
@ -165,7 +165,7 @@ public enum VueCodeBuilder {
// 处理数据
if(columnList.size() == 1){
if(DictType.NO_YES_YES.getCode().equals(columnList.get(0).getIzShowForm()) &&
if(DictType.NO_YES_YES.getValue().equals(columnList.get(0).getIzShowForm()) &&
StringUtils.isNotBlank(columnList.get(0).getShowType())
){
List<CreaterTableColumnModel> formTmpList = new ArrayList<>();
@ -175,7 +175,7 @@ public enum VueCodeBuilder {
}else{
for (int i = 0; i < columnList.size(); i+=2) {
List<CreaterTableColumnModel> formTmpList = new ArrayList<>();
if(DictType.NO_YES_YES.getCode().equals(columnList.get(i).getIzShowForm()) &&
if(DictType.NO_YES_YES.getValue().equals(columnList.get(i).getIzShowForm()) &&
StringUtils.isNotBlank(columnList.get(i).getShowType())
){
formTmpList.add(columnList.get(i));

@ -157,11 +157,11 @@ public class MySQLSyncBuilder implements SyncStrategy {
}
// 判断是否为主键
if(DictType.NO_YES_YES.getCode().equals(tmp.getIzPk())){
if(DictType.NO_YES_YES.getValue().equals(tmp.getIzPk())){
str.append(" ").append("PRIMARY KEY");
}else{
// 判断是否非空
if(DictType.NO_YES_YES.getCode().equals(tmp.getIzNotNull())){
if(DictType.NO_YES_YES.getValue().equals(tmp.getIzNotNull())){
str.append(" ").append("NOT NULL");
}
}

@ -80,7 +80,7 @@ public class TableServiceImpl extends CrudServiceImpl<TableMapper, CreaterTable,
if(!model.getIzApi()){
// 新增后 默认未同步
model.setIzSync(
DictType.NO_YES_NO.getCode());
DictType.NO_YES_NO.getValue());
}
// 默认旧表名称为当前新增名称(用于删除表操作)
@ -108,7 +108,7 @@ public class TableServiceImpl extends CrudServiceImpl<TableMapper, CreaterTable,
// 修改后 默认未同步
model.setIzSync(
DictType.NO_YES_NO.getCode());
DictType.NO_YES_NO.getValue());
// 默认旧表名称为 修改前表名 便于改表后删除操作
model.setOldTableName(oldModel.getTableName());

@ -63,7 +63,7 @@ public enum SystemMsg implements BaseMsg {
EXCEPTION_USER_FILE_NULL(20310,"请选择文件"),
EXCEPTION_USER_ILLEGAL_PARAMETER(20311,"非法参数"),
EXCEPTION_USER_LOCK_SELF(20312,"不可锁定自身"),
EXCEPTION_USER_DEL_SELF(20312,"不可删除自身"),
EXCEPTION_USER_DEL_SELF(20313,"不可删除自身"),
/**

@ -149,7 +149,7 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
QueryWrapper<SysArea> wrapper = new QueryWrapper<>();
// code 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("area_code", model.getAreaCode());
// 重复校验排除自身
@ -176,7 +176,7 @@ public class SysAreaServiceImpl extends CrudServiceImpl<SysAreaMapper, SysArea,
QueryWrapper<SysArea> wrapper = new QueryWrapper<>();
wrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds)
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID));
return mapper.hasChildren(wrapper);

@ -301,7 +301,7 @@ public class DictDetailServiceImpl extends CrudServiceImpl<DictDetailMapper, Sys
QueryWrapper<SysDictDetail> wrapper = new QueryWrapper<>();
// name 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("type_code", model.getTypeCode());
// 名称 或者 Val 重复

@ -173,7 +173,7 @@ public class DictServiceImpl extends CrudServiceImpl<DictMapper, SysDict, DictMo
QueryWrapper<SysDict> wrapper = new QueryWrapper<>();
// code 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("type_code", model.getTypeCode());
// 重复校验排除自身

@ -199,7 +199,7 @@ public class MenuServiceImpl extends CrudServiceImpl<MenuMapper, SysMenu, MenuMo
QueryWrapper<SysMenu> wrapper = new QueryWrapper<>();
// code 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("menu_code", model.getMenuCode());
// 重复校验排除自身

@ -216,7 +216,7 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
return null;
}
QueryWrapper<SysOrg> wrapper = new QueryWrapper<>();
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("org_code", model.getOrgCode());
// 重复校验排除自身
@ -245,7 +245,7 @@ public class SysOrgServiceImpl extends CrudServiceImpl<SysOrgMapper, SysOrg, Sys
QueryWrapper<SysOrg> wrapper = new QueryWrapper<>();
wrapper.in(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentIds)
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.groupBy(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID));
return mapper.hasChildren(wrapper);

@ -181,7 +181,7 @@ public class RoleServiceImpl extends CrudServiceImpl<RoleMapper, SysRole, RoleMo
QueryWrapper<SysRole> wrapper = new QueryWrapper<>();
// code 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("role_code", model.getRoleCode());
// 重复校验排除自身

@ -212,7 +212,7 @@ public class TenantServiceImpl extends CrudServiceImpl<TenantMapper, SysTenant,
QueryWrapper<SysTenant> wrapper = new QueryWrapper<>();
// name 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("tenant_name", model.getTenantName());
// 重复校验排除自身

@ -146,7 +146,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
roleQueryWrapper.eq("role_code", defRole);
roleQueryWrapper.eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC),
DictType.NO_YES_NO.getCode());
DictType.NO_YES_NO.getValue());
SysRole sysRole = iRoleService.getOne(roleQueryWrapper);
if(sysRole != null){
// 设置用户默认角色
@ -599,7 +599,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
// 逻辑删除 查询未删除数据
queryWrapper.eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC), DictType.NO_YES_NO.getCode());
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_DELETE_LOGIC), DictType.NO_YES_NO.getValue());
return mapper.findList(queryWrapper);
}
@ -641,7 +641,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
// no 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("no", model.getNo());
// 重复校验排除自身
@ -665,7 +665,7 @@ public class UserServiceImpl extends CrudServiceImpl<UserMapper, SysUser, UserMo
QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
// name 唯一
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getCode())
wrapper.eq(MyBatisConstants.FIELD_DELETE_LOGIC, DictType.NO_YES_NO.getValue())
.eq("username", model.getUsername());
// 重复校验排除自身

@ -295,8 +295,7 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
// 演示模式 不允许操作
super.demoError();
DictType dictType = DictType.getType(locked);
if(dictType == null){
if(!DictType.hasDict(DictType.NO_YES_YES.getType(), locked)){
// 非法参数
throw new ServiceException(SystemMsg.EXCEPTION_USER_ILLEGAL_PARAMETER);
}
@ -304,7 +303,7 @@ public class UserRestController extends BaseRestController<SysUser, UserModel, I
// 锁定账户
boolean lockAccountFlag = IService.lockAccount(userId, locked);
if(!lockAccountFlag){
return ResultVo.error("锁定账户失败");
return ResultVo.error("变更用户状态账户失败");
}
return ResultVo.success();
}

Loading…
Cancel
Save