|
|
@@ -2,11 +2,14 @@ package com.sckw.system.service;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.page.PageHelperUtil;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.StringUtils;
|
|
|
+import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.system.dao.SysDictDao;
|
|
|
import com.sckw.system.dao.SysDictTypeDao;
|
|
|
@@ -15,11 +18,13 @@ import com.sckw.system.model.SysDictType;
|
|
|
import com.sckw.system.model.vo.req.QueryDictTypePageReqVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 字典service接口
|
|
|
+ *
|
|
|
* @author zk
|
|
|
* @date 2023-05-30
|
|
|
*/
|
|
|
@@ -33,27 +38,31 @@ public class SysDictService {
|
|
|
SysDictDao sysDictDao;
|
|
|
|
|
|
/**
|
|
|
- * 添加新纪录
|
|
|
- * @param params
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
+ * @param params 实体
|
|
|
+ * @desc: 添加新纪录
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/7/7
|
|
|
*/
|
|
|
- public HttpResult addType(SysDictType params) throws Exception {
|
|
|
- /*params.setId(new IdWorker(1).nextId());
|
|
|
- params.setStatus(0);
|
|
|
- params.setCreateBy(0L);
|
|
|
- params.setCreateTime(new Date());
|
|
|
- params.setUpdateBy(0L);
|
|
|
- params.setUpdateTime(new Date());
|
|
|
- params.setDelFlag(0);*/
|
|
|
- params.setCreateBy(0L);
|
|
|
- params.setUpdateBy(0L);
|
|
|
- int count = sysDictTypeDao.insert(params);
|
|
|
- return count > 0 ? HttpResult.ok("添加成功!") : HttpResult.error();
|
|
|
+ public void addType(SysDictType params) throws SystemException {
|
|
|
+ checkType(params.getType());
|
|
|
+
|
|
|
+ if (sysDictTypeDao.insert(params) <= 0) {
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkType(String type) {
|
|
|
+ SysDictType sysDictType = new SysDictType();
|
|
|
+ sysDictType.setType(type);
|
|
|
+ List<SysDictType> list = sysDictTypeDao.select(sysDictType);
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.DICTTYPE_EXISTS);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新记录
|
|
|
+ *
|
|
|
* @param params
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
@@ -65,16 +74,18 @@ public class SysDictService {
|
|
|
|
|
|
/**
|
|
|
* 分页查询
|
|
|
+ *
|
|
|
* @param params
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public List<SysDict> findPage(Map<String, Object> params) throws Exception{
|
|
|
+ public List<SysDict> findPage(Map<String, Object> params) throws Exception {
|
|
|
return sysDictDao.findPage(params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加新纪录
|
|
|
+ *
|
|
|
* @param params
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
@@ -95,6 +106,7 @@ public class SysDictService {
|
|
|
|
|
|
/**
|
|
|
* 删除记录-根据主键
|
|
|
+ *
|
|
|
* @param ids
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
@@ -120,6 +132,7 @@ public class SysDictService {
|
|
|
|
|
|
/**
|
|
|
* 更新记录
|
|
|
+ *
|
|
|
* @param params
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
@@ -131,6 +144,7 @@ public class SysDictService {
|
|
|
|
|
|
/**
|
|
|
* 根据主键查询
|
|
|
+ *
|
|
|
* @param key
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
@@ -141,11 +155,12 @@ public class SysDictService {
|
|
|
|
|
|
/**
|
|
|
* 查询
|
|
|
+ *
|
|
|
* @param params
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public List<Map<String, Object>> findList(Map<String, Object> params) throws Exception{
|
|
|
+ public List<Map<String, Object>> findList(Map<String, Object> params) throws Exception {
|
|
|
return sysDictDao.findList(params);
|
|
|
}
|
|
|
|