优化一些代码
This commit is contained in:
parent
8be3046ae2
commit
f112d6a992
@ -51,7 +51,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
[ActionPermissionFilter(Permission = "system:dict:query")]
|
||||
public IActionResult GetInfo(long dictId = 0)
|
||||
{
|
||||
return SUCCESS(SysDictService.SelectDictTypeById(dictId));
|
||||
return SUCCESS(SysDictService.GetFirst(f => f.DictId == dictId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -37,16 +37,6 @@ namespace ZR.Repository.System
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据DictCode查询
|
||||
/// </summary>
|
||||
/// <param name="dictCode"></param>
|
||||
/// <returns></returns>
|
||||
public SysDictData SelectDictDataById(long dictCode)
|
||||
{
|
||||
return Db.Queryable<SysDictData>().Where(f => f.DictCode == dictCode).First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增保存字典数据信息
|
||||
/// </summary>
|
||||
@ -89,16 +79,6 @@ namespace ZR.Repository.System
|
||||
return Db.Deleteable<SysDictData>().In(dictCodes).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字典数据
|
||||
/// </summary>
|
||||
/// <param name="dictType"></param>
|
||||
/// <returns></returns>
|
||||
public int CountDictDataByType(string dictType)
|
||||
{
|
||||
return Db.Queryable<SysDictData>().Count(f => f.DictType == dictType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步修改字典类型
|
||||
/// </summary>
|
||||
|
||||
@ -30,36 +30,6 @@ namespace ZR.Repository.System
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id查询
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public SysDictType SelectDictTypeById(long id)
|
||||
{
|
||||
return Db.Queryable<SysDictType>().First(it => it.DictId == id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查字典类型唯一值
|
||||
/// </summary>
|
||||
/// <param name="dictType"></param>
|
||||
/// <returns></returns>
|
||||
public SysDictType CheckDictTypeUnique(string dictType)
|
||||
{
|
||||
return Db.Queryable<SysDictType>().First(it => it.DictType == dictType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除一个
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteDictTypeById(long id)
|
||||
{
|
||||
return Db.Deleteable<SysDictType>().In(id).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
@ -70,18 +40,6 @@ namespace ZR.Repository.System
|
||||
return Db.Deleteable<SysDictType>().In(id).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入
|
||||
/// </summary>
|
||||
/// <param name="sysDictType"></param>
|
||||
/// <returns></returns>
|
||||
public long InsertDictType(SysDictType sysDictType)
|
||||
{
|
||||
var result = Db.Insertable(sysDictType).IgnoreColumns(it => new { sysDictType.Update_by })
|
||||
.ExecuteReturnIdentity();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
|
||||
@ -12,13 +12,6 @@ namespace ZR.Service.IService
|
||||
{
|
||||
public List<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id查询
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public SysDictType SelectDictTypeById(long id);
|
||||
|
||||
/// <summary>
|
||||
/// 校验字典类型称是否唯一
|
||||
/// </summary>
|
||||
@ -26,13 +19,6 @@ namespace ZR.Service.IService
|
||||
/// <returns></returns>
|
||||
public string CheckDictTypeUnique(SysDictType dictType);
|
||||
|
||||
/// <summary>
|
||||
/// 删除一个
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteDictTypeById(long id);
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除字典数据信息
|
||||
/// </summary>
|
||||
|
||||
@ -132,7 +132,8 @@ namespace ZR.Service.System
|
||||
|
||||
if (child.DeptId.Equals(deptId))
|
||||
{
|
||||
DeptRepository.UdateDeptChildren(child);
|
||||
Saveable(child, it => new { it.Ancestors });
|
||||
//DeptRepository.UdateDeptChildren(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,9 +53,9 @@ namespace ZR.Service.System
|
||||
public SysDictData SelectDictDataById(long dictCode)
|
||||
{
|
||||
string CK = $"SelectDictDataByCode_{dictCode}";
|
||||
if (!(CacheHelper.GetCache(CK) is SysDictData list))
|
||||
if (CacheHelper.GetCache(CK) is not SysDictData list)
|
||||
{
|
||||
list = SysDictDataRepository.SelectDictDataById(dictCode);
|
||||
list = GetFirst(f => f.DictCode == dictCode);
|
||||
CacheHelper.SetCache(CK, list, 5);
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -14,7 +14,7 @@ namespace ZR.Service.System
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysDictService : BaseService<SysDictType>, ISysDictService
|
||||
{
|
||||
{
|
||||
private SysDictRepository sysDictRepository;
|
||||
private SysDictDataRepository DictDataRepository;
|
||||
|
||||
@ -34,16 +34,6 @@ namespace ZR.Service.System
|
||||
return sysDictRepository.SelectDictTypeList(dictType, pager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id查询
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public SysDictType SelectDictTypeById(long id)
|
||||
{
|
||||
return sysDictRepository.SelectDictTypeById(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验字典类型称是否唯一
|
||||
/// </summary>
|
||||
@ -51,7 +41,7 @@ namespace ZR.Service.System
|
||||
/// <returns></returns>
|
||||
public string CheckDictTypeUnique(SysDictType dictType)
|
||||
{
|
||||
SysDictType sysDictType = sysDictRepository.CheckDictTypeUnique(dictType.DictType);
|
||||
SysDictType sysDictType = GetFirst(f => f.DictType == dictType.DictType);
|
||||
if (sysDictType != null && sysDictType.DictId != dictType.DictId)
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
@ -59,16 +49,6 @@ namespace ZR.Service.System
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除一个
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteDictTypeById(long id)
|
||||
{
|
||||
return sysDictRepository.DeleteDictTypeById(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除字典数据信息
|
||||
/// </summary>
|
||||
@ -78,8 +58,8 @@ namespace ZR.Service.System
|
||||
{
|
||||
foreach (var dictId in dictIds)
|
||||
{
|
||||
SysDictType dictType = SelectDictTypeById(dictId);
|
||||
if (DictDataRepository.CountDictDataByType(dictType.DictType) > 0)
|
||||
SysDictType dictType = GetFirst(x => x.DictId == dictId);
|
||||
if (GetCount(f => f.DictType == dictType.DictType) > 0)
|
||||
{
|
||||
throw new CustomException($"{dictType.DictName}已分配,不能删除");
|
||||
}
|
||||
@ -99,7 +79,7 @@ namespace ZR.Service.System
|
||||
/// <returns></returns>
|
||||
public long InsertDictType(SysDictType sysDictType)
|
||||
{
|
||||
return sysDictRepository.InsertDictType(sysDictType);
|
||||
return Saveable(sysDictType, iColumns: it => new { sysDictType.Update_by }).DictId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -109,7 +89,7 @@ namespace ZR.Service.System
|
||||
/// <returns></returns>
|
||||
public int UpdateDictType(SysDictType sysDictType)
|
||||
{
|
||||
SysDictType oldDict = sysDictRepository.SelectDictTypeById(sysDictType.DictId);
|
||||
SysDictType oldDict = GetFirst(x => x.DictId == sysDictType.DictId);
|
||||
if (sysDictType.DictType != oldDict.DictType)
|
||||
{
|
||||
//同步修改 dict_data表里面的DictType值
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
<template>
|
||||
<el-dropdown trigger="click" @command="handleSetSize">
|
||||
<div>
|
||||
<div style="line-height: 50px">
|
||||
<svg-icon class-name="size-icon" icon-class="size" />
|
||||
</div>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size===item.value" :command="item.value">
|
||||
{{
|
||||
item.label }}
|
||||
{{item.label }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
@ -17,41 +16,40 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
sizeOptions: [
|
||||
{ label: 'Default', value: 'default' },
|
||||
{ label: 'Medium', value: 'medium' },
|
||||
{ label: 'Small', value: 'small' },
|
||||
{ label: 'Mini', value: 'mini' }
|
||||
]
|
||||
}
|
||||
{ label: "Default", value: "default" },
|
||||
{ label: "Medium", value: "medium" },
|
||||
{ label: "Small", value: "small" },
|
||||
{ label: "Mini", value: "mini" },
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
size() {
|
||||
return this.$store.getters.size
|
||||
}
|
||||
return this.$store.getters.size;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleSetSize(size) {
|
||||
this.$ELEMENT.size = size
|
||||
this.$store.dispatch('app/setSize', size)
|
||||
this.refreshView()
|
||||
this.$ELEMENT.size = size;
|
||||
this.$store.dispatch("app/setSize", size);
|
||||
this.refreshView();
|
||||
this.$message({
|
||||
message: 'Switch Size Success',
|
||||
type: 'success'
|
||||
})
|
||||
message: "Switch Size Success",
|
||||
type: "success",
|
||||
});
|
||||
},
|
||||
refreshView() {
|
||||
// In order to make the cached page re-rendered
|
||||
this.$store.dispatch('tagsView/delAllCachedViews', this.$route)
|
||||
this.$store.dispatch("tagsView/delAllCachedViews", this.$route);
|
||||
|
||||
const { fullPath } = this.$route
|
||||
const { fullPath } = this.$route;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$router.replace({
|
||||
path: '/redirect' + fullPath
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
path: "/redirect" + fullPath,
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -14,9 +14,9 @@
|
||||
<template v-if="device!=='mobile'">
|
||||
<search id="header-search" class="right-menu-item" />
|
||||
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
||||
<el-tooltip content="布局大小" effect="dark" placement="bottom">
|
||||
<!-- <el-tooltip content="布局大小" effect="dark" placement="bottom"> -->
|
||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
||||
</el-tooltip>
|
||||
<!-- </el-tooltip> -->
|
||||
</template>
|
||||
|
||||
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
|
||||
|
||||
@ -48,7 +48,12 @@
|
||||
<el-table-column prop="path" label="路由地址" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="visible" label="显示" :formatter="visibleFormat" width="70"></el-table-column>
|
||||
<el-table-column prop="status" label="状态" :formatter="statusFormat" width="70"></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="70">
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.status === '0'" >正常</el-tag>
|
||||
<el-tag type="warning" v-else >停用</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:menu:edit']">修改</el-button>
|
||||
|
||||
@ -12,6 +12,9 @@ const name = defaultSettings.title // 标题
|
||||
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
|
||||
// 这里只列一部分,具体配置参考文档
|
||||
module.exports = {
|
||||
css: {
|
||||
sourceMap: process.env.NODE_ENV == 'production' ? false : true //开启css source maps功能,前端可以看到css具体的行数
|
||||
},
|
||||
// 部署生产环境和开发环境下的URL。
|
||||
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
|
||||
// 例如 https://www.baidu.com/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.baidu.com/admin/,则设置 baseUrl 为 /admin/。
|
||||
|
||||
Binary file not shown.
@ -270,7 +270,7 @@ INSERT INTO `sys_menu` VALUES (2018, '用户添加', 100, 2, '#', NULL, 0, 0, 'F
|
||||
INSERT INTO `sys_menu` VALUES (2019, '用户查询', 100, 1, '#', NULL, 0, 0, 'F', '0', '0', 'system:user:query', '', '', '2021-02-24 10:31:33', '', NULL, '');
|
||||
INSERT INTO `sys_menu` VALUES (2020, '用户删除', 100, 4, '#', NULL, 0, 0, 'F', '0', '0', 'system:user:delete', '', '', '2021-02-24 10:32:01', '', NULL, '');
|
||||
INSERT INTO `sys_menu` VALUES (2021, '字典管理', 1, 5, 'dict', 'system/dict/index', 0, 0, 'C', '0', '0', 'system:dict:list', 'dict', '', '2021-02-24 10:37:50', 'admin', '2021-07-07 13:57:59', '');
|
||||
INSERT INTO `sys_menu` VALUES (2029, '用户角色', 1, 3, 'roleusers', 'system/roleusers/index', 0, 0, 'C', '0', '0', 'system:role:list', 'people', 'admin', '2021-04-04 18:44:25', 'admin', '2021-07-13 15:39:01', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (2029, '分配用户', 1, 3, 'roleusers', 'system/roleusers/index', 0, 0, 'C', '0', '0', 'system:role:list', 'people', 'admin', '2021-04-04 18:44:25', 'admin', '2021-07-13 15:39:01', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (2030, '修改排序', 102, 999, '#', NULL, 0, 0, 'F', '0', '0', 'system:menu:changeSort', '', 'admin', '2021-06-30 17:05:08', 'admin', '2021-06-30 17:07:06', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (2031, '新增用户', 2029, 1, '#', NULL, 0, 0, 'F', '0', '0', 'system:roleusers:add', NULL, 'admin', '2021-06-30 17:08:12', '', NULL, NULL);
|
||||
INSERT INTO `sys_menu` VALUES (2032, '删除用户', 2029, 2, '#', NULL, 0, 0, 'F', '0', '0', 'system:roleusers:del', NULL, 'admin', '2021-06-30 17:08:48', '', NULL, NULL);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user