diff --git a/hchyun-ui/README.md b/hchyun-ui/README.md index 48c1203..e512a0e 100644 --- a/hchyun-ui/README.md +++ b/hchyun-ui/README.md @@ -8,7 +8,7 @@ npm install --registry=https://registry.npm.taobao.org npm run dev ``` -浏览器访问 http://localhost:80 +浏览器访问 http://localhost:8080 ## 发布 diff --git a/hchyun-ui/src/api/test/stu.js b/hchyun-ui/src/api/test/stu.js index 5f528f7..904e893 100644 --- a/hchyun-ui/src/api/test/stu.js +++ b/hchyun-ui/src/api/test/stu.js @@ -8,7 +8,12 @@ export function listStu(query) { params: query }) } - +export function mapTest(){ + return request({ + url: '/test/map', + method: 'get', + }) +} // 查询学生详细 export function getStu(id) { return request({ @@ -50,4 +55,4 @@ export function exportStu(query) { method: 'get', params: query }) -} \ No newline at end of file +} diff --git a/hchyun-ui/src/api/tool/query.js b/hchyun-ui/src/api/tool/query.js new file mode 100644 index 0000000..fa0ce2c --- /dev/null +++ b/hchyun-ui/src/api/tool/query.js @@ -0,0 +1,78 @@ +import request from '@/utils/request' + +// 查询万能查询列表 +export function listQuery(query) { + return request({ + url: '/tool/query/list', + method: 'get', + params: query + }) +} + +// 查询万能查询详细 +export function getQuery(id) { + return request({ + url: '/tool/query/' + id, + method: 'get' + }) +} + +// 新增万能查询 +export function addQuery(data) { + return request({ + url: '/tool/query', + method: 'post', + data: data + }) +} + +// 修改万能查询 +export function updateQuery(data) { + return request({ + url: '/tool/query', + method: 'put', + data: data + }) +} + +// 删除万能查询 +export function delQuery(id) { + return request({ + url: '/tool/query/' + id, + method: 'delete' + }) +} + +// 导出万能查询 +export function exportQuery(query) { + return request({ + url: '/tool/query/export', + method: 'get', + params: query + }) +} + +// 获取条件 +export function getQueryInfo(id) { + return request({ + url: '/query/'+id, + method: 'get', + }) +} +// 修改条件 +export function editQueryInfo(data) { + return request({ + url: '/query', + method: 'put', + data: data + }) +} + +// 预览 +export function previewQueryData(data) { + return request({ + url: '/query/preview', + method: 'put', + data: data + }) +} diff --git a/hchyun-ui/src/router/index.js b/hchyun-ui/src/router/index.js index 1791440..f7729ae 100644 --- a/hchyun-ui/src/router/index.js +++ b/hchyun-ui/src/router/index.js @@ -118,6 +118,19 @@ export const constantRoutes = [ } ] }, + { + path: '/query', + component: Layout, + hidden: true, + children: [ + { + path: 'edit/:queryId(\\d+)', + component: (resolve) => require(['@/views/tool/query/uniQuery'], resolve), + name: 'UniQuery', + meta: { title: '万能查询配置' } + } + ] + }, { path: '/job', component: Layout, diff --git a/hchyun-ui/src/views/test/stu/index.vue b/hchyun-ui/src/views/test/stu/index.vue index 75f8408..f8439ab 100644 --- a/hchyun-ui/src/views/test/stu/index.vue +++ b/hchyun-ui/src/views/test/stu/index.vue @@ -55,7 +55,8 @@ size="mini" @click="handleAdd" v-hasPermi="['test:stu:add']" - >新增 + >新增 + 修改 + >修改 + 删除 + >删除 + 导出 + >导出 + - - - - - + + + + + - + - + - + - + 成绩信息 @@ -152,22 +158,23 @@ 删除 - - + + @@ -177,16 +184,25 @@ 取 消 + + + + + + diff --git a/hchyun-ui/src/views/tool/query/uniQuery.vue b/hchyun-ui/src/views/tool/query/uniQuery.vue new file mode 100644 index 0000000..852a51e --- /dev/null +++ b/hchyun-ui/src/views/tool/query/uniQuery.vue @@ -0,0 +1,267 @@ + + + diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/redis/RedisCache.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/redis/RedisCache.java index c84a75e..2ed786b 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/redis/RedisCache.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/core/redis/RedisCache.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; @@ -16,59 +17,54 @@ import org.springframework.stereotype.Component; * * @author hchyun **/ -@SuppressWarnings(value = { "unchecked", "rawtypes" }) +@SuppressWarnings(value = {"unchecked", "rawtypes"}) @Component -public class RedisCache -{ +public class RedisCache { @Autowired public RedisTemplate redisTemplate; /** * 缓存基本的对象,Integer、String、实体类等 * - * @param key 缓存的键值 + * @param key 缓存的键值 * @param value 缓存的值 */ - public void setCacheObject(final String key, final T value) - { + public void setCacheObject(final String key, final T value) { redisTemplate.opsForValue().set(key, value); } /** * 缓存基本的对象,Integer、String、实体类等 * - * @param key 缓存的键值 - * @param value 缓存的值 - * @param timeout 时间 + * @param key 缓存的键值 + * @param value 缓存的值 + * @param timeout 时间 * @param timeUnit 时间颗粒度 */ - public void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) - { + public void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) { redisTemplate.opsForValue().set(key, value, timeout, timeUnit); } /** * 设置有效时间 * - * @param key Redis键 + * @param key Redis键 * @param timeout 超时时间 * @return true=设置成功;false=设置失败 */ - public boolean expire(final String key, final long timeout) - { + public boolean expire(final String key, final long timeout) { return expire(key, timeout, TimeUnit.SECONDS); } /** * 设置有效时间 * - * @param key Redis键 + * @param key Redis键 * @param timeout 超时时间 - * @param unit 时间单位 + * @param unit 时间单位 * @return true=设置成功;false=设置失败 */ - public boolean expire(final String key, final long timeout, final TimeUnit unit) - { + public boolean expire(final String key, final long timeout, final TimeUnit unit) { return redisTemplate.expire(key, timeout, unit); } @@ -78,8 +74,7 @@ public class RedisCache * @param key 缓存键值 * @return 缓存键值对应的数据 */ - public T getCacheObject(final String key) - { + public T getCacheObject(final String key) { ValueOperations operation = redisTemplate.opsForValue(); return operation.get(key); } @@ -89,8 +84,7 @@ public class RedisCache * * @param key */ - public boolean deleteObject(final String key) - { + public boolean deleteObject(final String key) { return redisTemplate.delete(key); } @@ -100,20 +94,18 @@ public class RedisCache * @param collection 多个对象 * @return */ - public long deleteObject(final Collection collection) - { + public long deleteObject(final Collection collection) { return redisTemplate.delete(collection); } /** * 缓存List数据 * - * @param key 缓存的键值 + * @param key 缓存的键值 * @param dataList 待缓存的List数据 * @return 缓存的对象 */ - public long setCacheList(final String key, final List dataList) - { + public long setCacheList(final String key, final List dataList) { Long count = redisTemplate.opsForList().rightPushAll(key, dataList); return count == null ? 0 : count; } @@ -124,20 +116,18 @@ public class RedisCache * @param key 缓存的键值 * @return 缓存键值对应的数据 */ - public List getCacheList(final String key) - { + public List getCacheList(final String key) { return redisTemplate.opsForList().range(key, 0, -1); } /** * 缓存Set * - * @param key 缓存键值 + * @param key 缓存键值 * @param dataSet 缓存的数据 * @return 缓存数据的对象 */ - public long setCacheSet(final String key, final Set dataSet) - { + public long setCacheSet(final String key, final Set dataSet) { Long count = redisTemplate.opsForSet().add(key, dataSet); return count == null ? 0 : count; } @@ -148,8 +138,7 @@ public class RedisCache * @param key * @return */ - public Set getCacheSet(final String key) - { + public Set getCacheSet(final String key) { return redisTemplate.opsForSet().members(key); } @@ -159,8 +148,7 @@ public class RedisCache * @param key * @param dataMap */ - public void setCacheMap(final String key, final Map dataMap) - { + public void setCacheMap(final String key, final Map dataMap) { if (dataMap != null) { redisTemplate.opsForHash().putAll(key, dataMap); } @@ -172,32 +160,29 @@ public class RedisCache * @param key * @return */ - public Map getCacheMap(final String key) - { + public Map getCacheMap(final String key) { return redisTemplate.opsForHash().entries(key); } /** * 往Hash中存入数据 * - * @param key Redis键 - * @param hKey Hash键 + * @param key Redis键 + * @param hKey Hash键 * @param value 值 */ - public void setCacheMapValue(final String key, final String hKey, final T value) - { + public void setCacheMapValue(final String key, final String hKey, final T value) { redisTemplate.opsForHash().put(key, hKey, value); } /** * 获取Hash中的数据 * - * @param key Redis键 + * @param key Redis键 * @param hKey Hash键 * @return Hash中的对象 */ - public T getCacheMapValue(final String key, final String hKey) - { + public T getCacheMapValue(final String key, final String hKey) { HashOperations opsForHash = redisTemplate.opsForHash(); return opsForHash.get(key, hKey); } @@ -205,12 +190,11 @@ public class RedisCache /** * 获取多个Hash中的数据 * - * @param key Redis键 + * @param key Redis键 * @param hKeys Hash键集合 * @return Hash对象集合 */ - public List getMultiCacheMapValue(final String key, final Collection hKeys) - { + public List getMultiCacheMapValue(final String key, final Collection hKeys) { return redisTemplate.opsForHash().multiGet(key, hKeys); } @@ -220,8 +204,7 @@ public class RedisCache * @param pattern 字符串前缀 * @return 对象列表 */ - public Collection keys(final String pattern) - { + public Collection keys(final String pattern) { return redisTemplate.keys(pattern); } } diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/SecurityConfig.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/SecurityConfig.java index d1b613c..4aa76d3 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/SecurityConfig.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/config/SecurityConfig.java @@ -110,7 +110,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers("/webjars/**").anonymous() .antMatchers("/*/api-docs").anonymous() .antMatchers("/druid/**").anonymous() - .antMatchers("/test/**").anonymous() + .antMatchers("/tests/**").anonymous() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated() .and() diff --git a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysLoginService.java b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysLoginService.java index 12e89f5..25ed77f 100644 --- a/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysLoginService.java +++ b/hchyun/hchyun-framework/src/main/java/com/hchyun/framework/web/service/SysLoginService.java @@ -1,6 +1,7 @@ package com.hchyun.framework.web.service; import javax.annotation.Resource; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; @@ -20,12 +21,11 @@ import com.hchyun.framework.dao.factory.AsyncFactory; /** * 登录校验方法 - * + * * @author hchyun */ @Component -public class SysLoginService -{ +public class SysLoginService { @Autowired private TokenService tokenService; @@ -37,45 +37,36 @@ public class SysLoginService /** * 登录验证 - * + * * @param username 用户名 * @param password 密码 - * @param code 验证码 - * @param uuid 唯一标识 + * @param code 验证码 + * @param uuid 唯一标识 * @return 结果 */ - public String login(String username, String password, String code, String uuid) - { + public String login(String username, String password, String code, String uuid) { String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid; String captcha = redisCache.getCacheObject(verifyKey); redisCache.deleteObject(verifyKey); - if (captcha == null) - { + if (captcha == null) { AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"))); throw new CaptchaExpireException(); } - if (!code.equalsIgnoreCase(captcha)) - { + if (!code.equalsIgnoreCase(captcha)) { AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"))); throw new CaptchaException(); } // 用户验证 Authentication authentication = null; - try - { + try { // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(username, password)); - } - catch (Exception e) - { - if (e instanceof BadCredentialsException) - { + } catch (Exception e) { + if (e instanceof BadCredentialsException) { AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); throw new UserPasswordNotMatchException(); - } - else - { + } else { AsyncDao.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage())); throw new CustomException(e.getMessage()); } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java new file mode 100644 index 0000000..8554a00 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/QueryController.java @@ -0,0 +1,113 @@ +package com.hchyun.generator.controller; + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.core.entity.AjaxResult; +import com.hchyun.common.utils.ServerResult; +import com.hchyun.generator.entity.UniCon; +import com.hchyun.generator.entity.UniQuery; +import com.hchyun.generator.service.QueryService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * @Author 18209 + * @Date 2021/1/30 18:25 + * @Version 1.0 + */ +@RestController +@RequestMapping("/query") +public class QueryController { + protected final Logger logger = LoggerFactory.getLogger(QueryController.class); + + + + @Autowired + private QueryService queryService; + + @PreAuthorize("@ss.hasPermi('query:list')") + @GetMapping("/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id){ + try { + ServerResult serverResult = queryService.selectQueryById(id); + if (serverResult.isStart()){ + UniQuery uniQuery = serverResult.getData(); + Map modeMap = new HashMap(); + List uniCons = uniQuery.getUniCons(); + uniQuery.setUniCons(null); + modeMap.put("info",uniQuery); + modeMap.put("list",uniCons); + return AjaxResult.success(modeMap); + }else { + return AjaxResult.error(serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } +// @PreAuthorize("@ss.hasPermi('query:list')") +// @GetMapping("/list") +// public AjaxResult list(UniQuery uniQuery){ +// try { +// return AjaxResult.success(); +// }catch (RuntimeException e){ +// logger.error(e.getMessage()); +// return AjaxResult.error(ReturnConstants.SYS_ERROR); +// } +// } + + @PreAuthorize("@ss.hasPermi('query:edit')") + @PutMapping + public AjaxResult edit(@Validated @RequestBody UniQuery uniQuery){ + try { + ServerResult serverResult = queryService.updateQueryInfo(uniQuery); + if (serverResult.isStart()){ + return AjaxResult.success(); + }else { + return AjaxResult.error(serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + @PreAuthorize("@ss.hasPermi('query:preview')") + @PutMapping("preview") + public AjaxResult Preview(@Validated @RequestBody UniQuery uniQuery){ + try { + ServerResult>> serverResult = queryService.previewQuery(uniQuery); + if (serverResult.isStart()){ + return AjaxResult.success(serverResult.getData()); + }else { + return AjaxResult.error(serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + @PreAuthorize("@ss.hasPermi('query:edit')") + @GetMapping("/export/{id}") + public AjaxResult Export(@PathVariable("id") Long id){ + try { + return AjaxResult.success(); + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + + + +} diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/SysTest.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/SysTest.java index 07ad00e..80729bf 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/SysTest.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/SysTest.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.Map; @RestController -@RequestMapping("/test") +@RequestMapping("/tests") public class SysTest { @Autowired private InterTableDao interTableDao; diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java new file mode 100644 index 0000000..f8774e6 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/UniQueryController.java @@ -0,0 +1,192 @@ +package com.hchyun.generator.controller; + +import java.io.Serializable; +import java.util.List; + + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.core.controller.HcyBaseController; +import com.hchyun.common.utils.ServerResult; +import com.hchyun.common.utils.poi.ExcelUtil; +import com.hchyun.generator.entity.UniQuery; +import com.hchyun.generator.service.UniQueryService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.hchyun.common.annotation.Log; +import com.hchyun.common.core.entity.AjaxResult; +import com.hchyun.common.enums.BusinessType; + +/** + * 万能查询Controller + * + * @author hchyun + * @date 2021-01-30 + */ +@Api(value = "万能查询管理",tags = "万能查询管理") +@RestController +@RequestMapping("/tool/query") +public class UniQueryController extends HcyBaseController { + protected final Logger logger = LoggerFactory.getLogger(UniQueryController.class); + + @Autowired + private UniQueryService uniQueryService; + + /** + * 查询万能查询列表 + */ + @ApiOperation("查询万能查询列表") + @PreAuthorize("@ss.hasPermi('tool:query:list')") + @GetMapping("/list") + public Serializable list(UniQuery uniQuery) { + try { + startPage(); + ServerResult> serverResult = uniQueryService.selectUniQueryList(uniQuery); + if (serverResult.isStart()) { + return getDataTable(serverResult.getData()); + } else { + return AjaxResult.info(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 导出万能查询列表 + */ + @ApiOperation("导出万能查询列表") + @PreAuthorize("@ss.hasPermi('tool:query:export')") + @Log(title = "万能查询", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(UniQuery uniQuery) { + try { + ServerResult> serverResult = uniQueryService.selectUniQueryList(uniQuery); + ExcelUtil util = new ExcelUtil(UniQuery. class); + if (serverResult.isStart()) { + return util.exportExcel(serverResult.getData(), "query"); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 获取万能查询详细信息 + */ + @ApiOperation("获取万能查询详细信息") + @ApiImplicitParam(name = "id" , value = "万能查询id" , required = true, dataType = "Long" , paramType = "path") + @PreAuthorize("@ss.hasPermi('tool:query:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + try { + ServerResult serverResult = uniQueryService.selectUniQueryById(id); + if (serverResult.isStart()) { + return AjaxResult.success(serverResult.getData()); + } else { + return AjaxResult.info(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 新增万能查询 + */ + @ApiOperation("新增万能查询") + @ApiImplicitParam(name = "uniQuery" , value = "新增万能查询信息" , dataType = "UniQuery") + @PreAuthorize("@ss.hasPermi('tool:query:add')") + @Log(title = "万能查询", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody UniQuery uniQuery) { + if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) { + return AjaxResult.error("名称不能为空!"); + } + if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) { + return AjaxResult.error("描述不能为空!"); + } + try { + ServerResult serverResult = uniQueryService.insertUniQuery(uniQuery); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 修改万能查询 + */ + @ApiOperation("修改万能查询") + @ApiImplicitParam(name = "uniQuery" , value = "修改万能查询信息" , dataType = "UniQuery") + @PreAuthorize("@ss.hasPermi('tool:query:edit')") + @Log(title = "万能查询", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody UniQuery uniQuery) { + try { + + if (uniQuery.getUqName() == null || uniQuery.getUqName().equals("")) { + return AjaxResult.error("名称不能为空!"); + } + if (uniQuery.getUqDescribe() == null || uniQuery.getUqDescribe().equals("")) { + return AjaxResult.error("描述不能为空!"); + } + ServerResult serverResult = uniQueryService.updateUniQuery(uniQuery); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 删除万能查询 + */ + @ApiOperation("删除万能查询") + @ApiImplicitParam(name = "ids" , value = "万能查询ids" , required = true, dataType = "Long" , paramType = "path") + @PreAuthorize("@ss.hasPermi('tool:query:remove')") + @Log(title = "万能查询", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + try { + if (ids.length<0){ + return AjaxResult.error("id不能为空!"); + } + ServerResult serverResult = uniQueryService.deleteUniQueryByIds(ids); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/QueryDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/QueryDao.java new file mode 100644 index 0000000..5ab29ff --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/QueryDao.java @@ -0,0 +1,26 @@ +package com.hchyun.generator.dao; + +import com.hchyun.generator.entity.UniCon; +import com.hchyun.generator.entity.UniQuery; + +import java.util.List; +import java.util.Map; + +/** + * @Author 18209 + * @Date 2021/1/30 18:52 + * @Version 1.0 + */ +public interface QueryDao { + + UniQuery selectQueryInfo(Long id); + + Integer updateQueryInfo(UniQuery uniQuery); + + + Integer deleteUniCon(Long uqId); + + Integer insertUniCon(List uniCons); + + List> UniQuery(String paramSQL); +} diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/UniQueryDao.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/UniQueryDao.java new file mode 100644 index 0000000..9642984 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/dao/UniQueryDao.java @@ -0,0 +1,68 @@ +package com.hchyun.generator.dao; + + +import com.hchyun.generator.entity.UniQuery; + +import java.util.List; + +/** + * 万能查询Mapper接口 + * + * @author hchyun + * @date 2021-01-30 + */ +public interface UniQueryDao +{ + /** + * 查询万能查询 + * + * @param id 万能查询ID + * @return 万能查询 + */ + UniQuery selectUniQueryById(Long id); + + /** + * 查询万能查询列表 + * + * @param uniQuery 万能查询 + * @return 万能查询集合 + */ + List selectUniQueryList(UniQuery uniQuery); + + /** + * 新增万能查询 + * + * @param uniQuery 万能查询 + * @return 结果 + */ + int insertUniQuery(UniQuery uniQuery); + + /** + * 修改万能查询 + * + * @param uniQuery 万能查询 + * @return 结果 + */ + int updateUniQuery(UniQuery uniQuery); + + /** + * 删除万能查询 + * + * @param id 万能查询ID + * @return 结果 + */ + int deleteUniQueryById(Long id); + + /** + * 批量删除万能查询 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteUniQueryByIds(Long[] ids); + + + + + +} diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniCon.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniCon.java new file mode 100644 index 0000000..09dac1a --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniCon.java @@ -0,0 +1,127 @@ +package com.hchyun.generator.entity; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 万能查询条件对象 sys_uni_con + * + * @author hchyun + * @date 2021-01-30 + */ +public class UniCon { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + + /** + * 万能查询tableid + */ + private Long uqId; + + /** + * 名称(lable) + */ + private String ucName; + + /** + * 关键字 + */ + private String ucKey; + + /** + * 查询条件 + */ + private String ucCon; + + /** + * 模拟数据 + */ + private String ucMock; + + /** + * 描述 + */ + private String ucDescribe; + + /** 输入类型 */ + private String ucType; + + /** 显示类型 */ + private Integer type; + + public String getUcType() { + return ucType; + } + + public void setUcType(String ucType) { + this.ucType = ucType; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setUqId(Long uqId) { + this.uqId = uqId; + } + + public Long getUqId() { + return uqId; + } + + public void setUcName(String ucName) { + this.ucName = ucName; + } + + public String getUcName() { + return ucName; + } + + public void setUcKey(String ucKey) { + this.ucKey = ucKey; + } + + public String getUcKey() { + return ucKey; + } + + public void setUcCon(String ucCon) { + this.ucCon = ucCon; + } + + public String getUcCon() { + return ucCon; + } + + public String getUcMock() { + return ucMock; + } + + public void setUcMock(String ucMock) { + this.ucMock = ucMock; + } + + public String getUcDescribe() { + return ucDescribe; + } + + public void setUcDescribe(String ucDescribe) { + this.ucDescribe = ucDescribe; + } +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java new file mode 100644 index 0000000..4030312 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/UniQuery.java @@ -0,0 +1,93 @@ +package com.hchyun.generator.entity; + +import com.hchyun.common.core.entity.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.List; + +/** + * 万能查询对象 sys_uni_query + * + * @author hchyun + * @date 2021-01-30 + */ +public class UniQuery extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * id + */ + private Long id; + + /** + * 名称 + */ + private String uqName; + + /** + * sql语句 + */ + private String uqSql; + + /** + * 描述 + */ + private String uqDescribe; + + private List uniCons; + + public List getUniCons() { + return uniCons; + } + + public void setUniCons(List uniCons) { + this.uniCons = uniCons; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setUqName(String uqName) { + this.uqName = uqName; + } + + public String getUqName() { + return uqName; + } + + public void setUqSql(String uqSql) { + this.uqSql = uqSql; + } + + public String getUqSql() { + return uqSql; + } + + public void setUqDescribe(String uqDescribe) { + this.uqDescribe = uqDescribe; + } + + public String getUqDescribe() { + return uqDescribe; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("uqName", getUqName()) + .append("uqSql", getUqSql()) + .append("uqDescribe", getUqDescribe()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/QueryService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/QueryService.java new file mode 100644 index 0000000..b035f67 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/QueryService.java @@ -0,0 +1,35 @@ +package com.hchyun.generator.service; + +import com.hchyun.common.utils.ServerResult; +import com.hchyun.generator.entity.UniQuery; + +import java.util.List; +import java.util.Map; + +/** + * @Author 18209 + * @Date 2021/1/30 18:54 + * @Version 1.0 + */ +public interface QueryService { + /** + * 通过id查询基础信息 + * @param id + * @return + */ + ServerResult selectQueryById(Long id); + + /** + * 修改基础信息 + * @param uniQuery + * @return + */ + ServerResult updateQueryInfo(UniQuery uniQuery); + + /** + * 预览万能查询数据 + * @param uniQuery + * @return + */ + ServerResult>> previewQuery(UniQuery uniQuery); +} diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/UniQueryService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/UniQueryService.java new file mode 100644 index 0000000..c888c2b --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/UniQueryService.java @@ -0,0 +1,63 @@ +package com.hchyun.generator.service; + +import java.util.List; + +import com.hchyun.common.utils.ServerResult; +import com.hchyun.generator.entity.UniQuery; + +/** + * 万能查询Service接口 + * + * @author hchyun + * @date 2021-01-30 + */ +public interface UniQueryService +{ + /** + * 查询万能查询 + * + * @param id 万能查询ID + * @return 万能查询 + */ + ServerResult selectUniQueryById(Long id); + + /** + * 查询万能查询列表 + * + * @param uniQuery 万能查询 + * @return 万能查询集合 + */ + ServerResult> selectUniQueryList(UniQuery uniQuery); + + /** + * 新增万能查询 + * + * @param uniQuery 万能查询 + * @return 结果 + */ + ServerResult insertUniQuery(UniQuery uniQuery); + + /** + * 修改万能查询 + * + * @param uniQuery 万能查询 + * @return 结果 + */ + ServerResult updateUniQuery(UniQuery uniQuery); + + /** + * 批量删除万能查询 + * + * @param ids 需要删除的万能查询ID + * @return 结果 + */ + ServerResult deleteUniQueryByIds(Long[] ids); + + /** + * 删除万能查询信息 + * + * @param id 万能查询ID + * @return 结果 + */ + ServerResult deleteUniQueryById(Long id); +} diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java new file mode 100644 index 0000000..482787d --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/QueryServiceImpl.java @@ -0,0 +1,76 @@ +package com.hchyun.generator.service.impl; + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.utils.ServerResult; +import com.hchyun.generator.dao.QueryDao; +import com.hchyun.generator.dao.UniQueryDao; +import com.hchyun.generator.entity.UniQuery; +import com.hchyun.generator.service.QueryService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +/** + * @Author 18209 + * @Date 2021/1/30 18:54 + * @Version 1.0 + */ +@Service +public class QueryServiceImpl implements QueryService { + private Logger logger = LoggerFactory.getLogger(QueryServiceImpl.class); + @Autowired + private QueryDao queryDao; + @Autowired + private UniQueryDao uniQueryDao; + + @Override + public ServerResult selectQueryById(Long id) { + try { + UniQuery uniQuery = queryDao.selectQueryInfo(id); + if (uniQuery != null) { + return new ServerResult(true, uniQuery); + } else { + return new ServerResult(false, ReturnConstants.RESULT_EMPTY); + } + + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return new ServerResult(false, ReturnConstants.SYS_FAILL); + } + } + + @Override + @Transactional + public ServerResult updateQueryInfo(UniQuery uniQuery) { + try { + Integer uqrenewal = uniQueryDao.updateUniQuery(uniQuery); + if (uqrenewal > 0) { + queryDao.deleteUniCon(uniQuery.getId()); + Integer ucrenewal = queryDao.insertUniCon(uniQuery.getUniCons()); + if (ucrenewal>0){ + return new ServerResult(true); + } + } + return new ServerResult(false,"操作失败!"); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return new ServerResult(false, ReturnConstants.SYS_FAILL); + } + } + + @Override + public ServerResult>> previewQuery(UniQuery uniQuery) { + try { + List> dataMap = queryDao.UniQuery(uniQuery.getUqSql()); + return new ServerResult>>(true,dataMap); + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult>>(false,e.getMessage()); + } + } +} diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/UniQueryServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/UniQueryServiceImpl.java new file mode 100644 index 0000000..9274325 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/UniQueryServiceImpl.java @@ -0,0 +1,156 @@ +package com.hchyun.generator.service.impl; + +import java.util.List; + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.utils.SecurityUtils; +import com.hchyun.common.utils.ServerResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.hchyun.generator.dao.UniQueryDao; +import com.hchyun.generator.entity.UniQuery; +import com.hchyun.generator.service.UniQueryService; + +/** + * 万能查询Service业务层处理 + * + * @author hchyun + * @date 2021-01-30 + */ +@Service +public class UniQueryServiceImpl implements UniQueryService { + private Logger logger = LoggerFactory.getLogger(UniQueryServiceImpl.class); + + @Autowired + private UniQueryDao uniQueryDao; + + /** + * 查询万能查询 + * + * @param id 万能查询ID + * @return 万能查询 + */ + @Override + public ServerResult selectUniQueryById(Long id) { + try { + UniQuery uniQuery = uniQueryDao.selectUniQueryById(id); + if (uniQuery != null){ + return new ServerResult(true,uniQuery); + }else { + return new ServerResult(false, ReturnConstants.RESULT_EMPTY); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 查询万能查询列表 + * + * @param uniQuery 万能查询 + * @return 万能查询 + */ + @Override + public ServerResult> selectUniQueryList(UniQuery uniQuery) { + try { + List uniQueryList = uniQueryDao.selectUniQueryList(uniQuery); + if (uniQueryList.size()>0){ + return new ServerResult>(true,uniQueryList); + }else { + return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult>(false,ReturnConstants.DB_EX); + } + } + + /** + * 新增万能查询 + * + * @param uniQuery 万能查询 + * @return 结果 + */ + @Override + public ServerResult insertUniQuery(UniQuery uniQuery) { + try { + uniQuery.setCreateBy(SecurityUtils.getUserId()); + Integer renewal = uniQueryDao.insertUniQuery(uniQuery); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 修改万能查询 + * + * @param uniQuery 万能查询 + * @return 结果 + */ + @Override + public ServerResult updateUniQuery(UniQuery uniQuery) { + try { + uniQuery.setUpdateBy(SecurityUtils.getUserId()); + Integer renewal = uniQueryDao.updateUniQuery(uniQuery); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 批量删除万能查询 + * + * @param ids 需要删除的万能查询ID + * @return 结果 + */ + @Override + public ServerResult deleteUniQueryByIds(Long[] ids) { + try { + Integer renewal = uniQueryDao.deleteUniQueryByIds(ids); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 删除万能查询信息 + * + * @param id 万能查询ID + * @return 结果 + */ + @Override + public ServerResult deleteUniQueryById(Long id) { + try { + Integer renewal = uniQueryDao.deleteUniQueryById(id); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } +} \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/resources/mapper/generator/QueryMapper.xml b/hchyun/hchyun-generator/src/main/resources/mapper/generator/QueryMapper.xml new file mode 100644 index 0000000..38d88e1 --- /dev/null +++ b/hchyun/hchyun-generator/src/main/resources/mapper/generator/QueryMapper.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + delete from sys_uni_con where uq_id = #{uqId} + + + insert into sys_uni_con(uq_id,uc_name,uc_key,uc_con,uc_mock,uc_describe,uc_type,type) values + + (#{item.uqId},#{item.ucName},#{item.ucKey},#{item.ucCon},#{item.ucMock},#{item.ucDescribe},#{item.ucType},#{item.type}) + + + + \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/resources/vm/java/class.java.vm b/hchyun/hchyun-generator/src/main/resources/vm/java/class.java.vm index bc2cd12..bc324b3 100644 --- a/hchyun/hchyun-generator/src/main/resources/vm/java/class.java.vm +++ b/hchyun/hchyun-generator/src/main/resources/vm/java/class.java.vm @@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Map; + + + #if($Permission) @Api(value = "${functionName}",tags = "${functionName}") #end diff --git a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysConfigServiceImpl.java b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysConfigServiceImpl.java index 2055d80..e427500 100644 --- a/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysConfigServiceImpl.java +++ b/hchyun/hchyun-system/src/main/java/com/hchyun/system/service/impl/SysConfigServiceImpl.java @@ -3,6 +3,7 @@ package com.hchyun.system.service.impl; import java.util.Collection; import java.util.List; import javax.annotation.PostConstruct; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hchyun.common.annotation.DataSource; @@ -19,12 +20,11 @@ import com.hchyun.system.service.ISysConfigService; /** * 参数配置 服务层实现 - * + * * @author hchyun */ @Service -public class SysConfigServiceImpl implements ISysConfigService -{ +public class SysConfigServiceImpl implements ISysConfigService { @Autowired private SysConfigDao configMapper; @@ -35,25 +35,22 @@ public class SysConfigServiceImpl implements ISysConfigService * 项目启动时,初始化参数到缓存 */ @PostConstruct - public void init() - { + public void init() { List configsList = configMapper.selectConfigList(new SysConfig()); - for (SysConfig config : configsList) - { + for (SysConfig config : configsList) { redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); } } /** * 查询参数配置信息 - * + * * @param configId 参数配置ID * @return 参数配置信息 */ @Override @DataSource(DataSourceType.MASTER) - public SysConfig selectConfigById(Long configId) - { + public SysConfig selectConfigById(Long configId) { SysConfig config = new SysConfig(); config.setConfigId(configId); return configMapper.selectConfig(config); @@ -61,23 +58,20 @@ public class SysConfigServiceImpl implements ISysConfigService /** * 根据键名查询参数配置信息 - * + * * @param configKey 参数key * @return 参数键值 */ @Override - public String selectConfigByKey(String configKey) - { + public String selectConfigByKey(String configKey) { String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey))); - if (StringUtils.isNotEmpty(configValue)) - { + if (StringUtils.isNotEmpty(configValue)) { return configValue; } SysConfig config = new SysConfig(); config.setConfigKey(configKey); SysConfig retConfig = configMapper.selectConfig(config); - if (StringUtils.isNotNull(retConfig)) - { + if (StringUtils.isNotNull(retConfig)) { redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); return retConfig.getConfigValue(); } @@ -86,28 +80,25 @@ public class SysConfigServiceImpl implements ISysConfigService /** * 查询参数配置列表 - * + * * @param config 参数配置信息 * @return 参数配置集合 */ @Override - public List selectConfigList(SysConfig config) - { + public List selectConfigList(SysConfig config) { return configMapper.selectConfigList(config); } /** * 新增参数配置 - * + * * @param config 参数配置信息 * @return 结果 */ @Override - public int insertConfig(SysConfig config) - { + public int insertConfig(SysConfig config) { int row = configMapper.insertConfig(config); - if (row > 0) - { + if (row > 0) { redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); } return row; @@ -115,16 +106,14 @@ public class SysConfigServiceImpl implements ISysConfigService /** * 修改参数配置 - * + * * @param config 参数配置信息 * @return 结果 */ @Override - public int updateConfig(SysConfig config) - { + public int updateConfig(SysConfig config) { int row = configMapper.updateConfig(config); - if (row > 0) - { + if (row > 0) { redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); } return row; @@ -132,24 +121,20 @@ public class SysConfigServiceImpl implements ISysConfigService /** * 批量删除参数信息 - * + * * @param configIds 需要删除的参数ID * @return 结果 */ @Override - public int deleteConfigByIds(Long[] configIds) - { - for (Long configId : configIds) - { + public int deleteConfigByIds(Long[] configIds) { + for (Long configId : configIds) { SysConfig config = selectConfigById(configId); - if (StringUtils.equals(UserConstants.YES, config.getConfigType())) - { + if (StringUtils.equals(UserConstants.YES, config.getConfigType())) { throw new CustomException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); } } int count = configMapper.deleteConfigByIds(configIds); - if (count > 0) - { + if (count > 0) { Collection keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); redisCache.deleteObject(keys); } @@ -160,25 +145,22 @@ public class SysConfigServiceImpl implements ISysConfigService * 清空缓存数据 */ @Override - public void clearCache() - { + public void clearCache() { Collection keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*"); redisCache.deleteObject(keys); } /** * 校验参数键名是否唯一 - * + * * @param config 参数配置信息 * @return 结果 */ @Override - public String checkConfigKeyUnique(SysConfig config) - { + public String checkConfigKeyUnique(SysConfig config) { Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); SysConfig info = configMapper.checkConfigKeyUnique(config.getConfigKey()); - if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -186,12 +168,11 @@ public class SysConfigServiceImpl implements ISysConfigService /** * 设置cache key - * + * * @param configKey 参数键 * @return 缓存键key */ - private String getCacheKey(String configKey) - { + private String getCacheKey(String configKey) { return Constants.SYS_CONFIG_KEY + configKey; } } diff --git a/hchyun/hchyun-system/src/main/resources/mapper/system/UniQueryMapper.xml b/hchyun/hchyun-system/src/main/resources/mapper/system/UniQueryMapper.xml new file mode 100644 index 0000000..39e018e --- /dev/null +++ b/hchyun/hchyun-system/src/main/resources/mapper/system/UniQueryMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + select id, uq_name, uq_sql, uq_describe, create_by, create_time, update_by, update_time from sys_uni_query + + + + + + + + insert into sys_uni_query + + uq_name, + uq_sql, + uq_describe, + create_by, + update_by, + + + #{uqName}, + #{uqSql}, + #{uqDescribe}, + #{createBy}, + #{updateBy}, + + + + + update sys_uni_query + + uq_name = #{uqName}, + uq_sql = #{uqSql}, + uq_describe = #{uqDescribe}, + create_by = #{createBy}, + update_by = #{updateBy}, + + where id = #{id} + + + + delete from sys_uni_query where id = #{id} + + + + delete from sys_uni_query where id in + + #{id} + + + \ No newline at end of file diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/Test.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/Test.java new file mode 100644 index 0000000..84cbdfb --- /dev/null +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/Test.java @@ -0,0 +1,27 @@ +package com.hchyun.test.controller; + +import com.hchyun.test.dao.ResultsDao; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +/** + * @Author 18209 + * @Date 2021/1/29 17:36 + * @Version 1.0 + */ +@RestController +@RequestMapping("/test") +public class Test { + @Autowired + private ResultsDao resultsDao; + + @GetMapping("/map") + public List> mapTest(){ + return resultsDao.testMap(); + } +} diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java index 3abb0c4..4276556 100644 --- a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/ResultsDao.java @@ -1,19 +1,20 @@ package com.hchyun.test.dao; import java.util.List; +import java.util.Map; + import com.hchyun.test.entity.Results; /** * 成绩Mapper接口 - * + * * @author hchyun * @date 2021-01-24 */ -public interface ResultsDao -{ +public interface ResultsDao { /** * 查询成绩 - * + * * @param id 成绩ID * @return 成绩 */ @@ -21,7 +22,7 @@ public interface ResultsDao /** * 查询成绩列表 - * + * * @param results 成绩 * @return 成绩集合 */ @@ -29,7 +30,7 @@ public interface ResultsDao /** * 新增成绩 - * + * * @param results 成绩 * @return 结果 */ @@ -37,7 +38,7 @@ public interface ResultsDao /** * 修改成绩 - * + * * @param results 成绩 * @return 结果 */ @@ -45,7 +46,7 @@ public interface ResultsDao /** * 删除成绩 - * + * * @param id 成绩ID * @return 结果 */ @@ -53,9 +54,11 @@ public interface ResultsDao /** * 批量删除成绩 - * + * * @param ids 需要删除的数据ID * @return 结果 */ public int deleteResultsByIds(Long[] ids); + + List> testMap(); } diff --git a/hchyun/hchyun-test/src/main/resources/mapper/test/ResultsMapper.xml b/hchyun/hchyun-test/src/main/resources/mapper/test/ResultsMapper.xml index a74e6a0..6444ba3 100644 --- a/hchyun/hchyun-test/src/main/resources/mapper/test/ResultsMapper.xml +++ b/hchyun/hchyun-test/src/main/resources/mapper/test/ResultsMapper.xml @@ -16,6 +16,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, s_id, java, images, file from sys_results + + +