Commit b60ef9ed by xjx

模块名字修改1

parent 9f808a7f
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-base-auth</artifactId> <artifactId>base-auth</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<!--基础组件--> <!--基础组件-->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base</artifactId> <artifactId>base</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-base-timers</artifactId> <artifactId>base-timers</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<!--基础组件--> <!--基础组件-->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base</artifactId> <artifactId>base</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-base</artifactId> <artifactId>base</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-dbctn</artifactId> <artifactId>dbctn</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<!--基础组件--> <!--基础组件-->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-sys</artifactId> <artifactId>sys</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-excel</artifactId> <artifactId>excel</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<!--基础组件--> <!--基础组件-->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-sys</artifactId> <artifactId>sys</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-generator</artifactId> <artifactId>generator</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<!--基础组件--> <!--基础组件-->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-sys</artifactId> <artifactId>sys</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<parent> <parent>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-oauth2</artifactId> <artifactId>oauth2</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<!--基础组件--> <!--基础组件-->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-sys</artifactId> <artifactId>sys</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-base-support</artifactId> <artifactId>base-support</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>guns-base</module> <module>base</module>
<module>guns-base-auth</module> <module>base-auth</module>
<module>guns-base-timers</module> <module>base-timers</module>
<module>guns-sys</module> <module>sys</module>
<module>guns-excel</module> <module>excel</module>
<module>guns-generator</module> <module>generator</module>
<module>guns-dbctn</module> <module>dbctn</module>
<module>guns-oauth2</module> <module>oauth2</module>
</modules> </modules>
</project> </project>
...@@ -11,44 +11,44 @@ ...@@ -11,44 +11,44 @@
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<artifactId>guns-vip-main</artifactId> <artifactId>business</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<dependencies> <dependencies>
<!-- guns-vip基础框架 --> <!-- 基础框架 -->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-sys</artifactId> <artifactId>sys</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<!-- excel高级导出 --> <!-- excel高级导出 -->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-excel</artifactId> <artifactId>excel</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<!-- 代码生成器 --> <!-- 代码生成器 -->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-generator</artifactId> <artifactId>generator</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<!-- 数据源容器 --> <!-- 数据源容器 -->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-dbctn</artifactId> <artifactId>dbctn</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<!-- oauth2认证 --> <!-- oauth2认证 -->
<dependency> <dependency>
<groupId>com.sql.admin</groupId> <groupId>com.sql.admin</groupId>
<artifactId>guns-oauth2</artifactId> <artifactId>oauth2</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
......
/**
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.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 com.sql.admin.config.web;
import com.sql.admin.base.auth.context.LoginContext;
import com.sql.admin.sys.core.beetl.BeetlConfiguration;
import com.sql.admin.sys.core.properties.BeetlProperties;
import org.beetl.core.resource.ClasspathResourceLoader;
import org.beetl.ext.spring.BeetlSpringViewResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* web 配置类
*
* @author fengshuonan
* @date 2016年11月12日 下午5:03:32
*/
@Configuration
public class BeetlConfig {
@Autowired
private BeetlProperties beetlProperties;
/**
* beetl的配置
*/
@Bean(initMethod = "init")
public BeetlConfiguration beetlConfiguration(LoginContext loginContext) {
BeetlConfiguration beetlConfiguration = new BeetlConfiguration(loginContext);
beetlConfiguration.setResourceLoader(new ClasspathResourceLoader(BeetlConfig.class.getClassLoader(), beetlProperties.getPrefix()));
beetlConfiguration.setConfigProperties(beetlProperties.getProperties());
return beetlConfiguration;
}
/**
* beetl的视图解析器
*/
@Bean
public BeetlSpringViewResolver beetlViewResolver(LoginContext loginContext) {
BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
beetlSpringViewResolver.setConfig(beetlConfiguration(loginContext));
beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
beetlSpringViewResolver.setOrder(0);
return beetlSpringViewResolver;
}
}
package com.sql.admin.config.web;
import cn.hutool.core.date.DateUtil;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import javax.annotation.PostConstruct;
import java.util.Date;
/**
* 默认的string to date的转化
*
* @author fengshuonan
* @Date 2019/2/12 20:09
*/
@Configuration
public class String2DateConfig {
@Autowired
private RequestMappingHandlerAdapter handlerAdapter;
/**
* 默认时间转化器
*/
@PostConstruct
public void addConversionConfig() {
ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) handlerAdapter.getWebBindingInitializer();
if ((initializer != null ? initializer.getConversionService() : null) != null) {
GenericConversionService genericConversionService = (GenericConversionService) initializer.getConversionService();
genericConversionService.addConverter(new StringToDateConverter());
}
}
/**
* 时间字符串转date的格式
*
* @author fengshuonan
* @Date 2019/10/22 13:42
*/
public static class StringToDateConverter implements Converter<String, Date> {
@Override
public Date convert(String dateString) {
if (ToolUtil.isEmpty(dateString)) {
return null;
} else {
return DateUtil.parse(dateString);
}
}
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.config.web;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* swagger配置类
*
* @author fengshuonan
* @date 2017年6月1日19:42:59
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) //这里采用包含注解的方式来确定要显示的接口
//.apis(RequestHandlerSelectors.basePackage("com.sql.admin.modular.system.controller")) //这里采用包扫描的方式来确定要显示的接口
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Guns Doc")
.description("Guns Api文档")
.termsOfServiceUrl("https://gitee.com/stylefeng/guns")
.contact(new Contact("stylefeng", "https://gitee.com/stylefeng/guns", ""))
.version("2.0")
.build();
}
}
package com.sql.admin.core.schedue.quartz;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
/**
* quartz的启动示例
*
* @author fengshuonan
* @Date 2019/2/24 16:55
*/
public class StartQuartzExample implements CommandLineRunner {
@Autowired
private Scheduler scheduler;
@Override
public void run(String... args) throws Exception {
// 启动调度器
scheduler.start();
//构建job信息
JobDetail jobDetail = JobBuilder.newJob(SampleQuartzJob.class).withIdentity(SampleQuartzJob.class.getName(), "aaa").build();
//表达式调度构建器(即任务执行的时间)
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("*/5 * * * * ?");
//按新的cronExpression表达式构建一个新的trigger
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(SampleQuartzJob.class.getName(), "aaa")
.withSchedule(scheduleBuilder).build();
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
System.out.println("创建定时任务失败" + e);
throw new Exception("创建定时任务失败");
}
}
}
package com.sql.admin.core.schedue.spring;
import org.springframework.scheduling.annotation.Scheduled;
/**
* 测试定时任务
*
* @author fengshuonan
* @Date 2019/2/24 16:29
*/
public class SpringTasks {
/**
* 上一次开始执行时间点之后5秒再执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(fixedRate = 5000)
public void beginAfter() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>开始之后5秒执行!");
}
/**
* 上一次执行完毕时间点之后5秒再执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(fixedDelay = 5000)
public void finishAfter() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>执行之后5秒才执行!");
}
/**
* 上一次执行完毕时间点之后5秒再执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(initialDelay = 1000, fixedRate = 5000)
public void stepAdd() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>第一次延迟1秒后执行,之后按fixedRate的规则每5秒执行一次!");
}
/**
* cron表达式执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(cron = "*/10 * * * * *")
public void cron() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>每隔10秒执行一次!");
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.modular.demos.controller;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* pdf预览
*
* @author fengshuonan
* @Date 2017年2月17日20:27:22
*/
@Controller
@Slf4j
public class PdfPreviewController extends BaseController {
private String PREFIX = "/demos/pdf/";
/**
* pdf预览
*/
@RequestMapping("/pdf")
public String pdf() {
return PREFIX + "pdf.html";
}
/**
* 预览
*/
@GetMapping(value = "/loadPdfFile", produces = "application/pdf")
@ResponseBody
public ClassPathResource loadPdfFile(@RequestParam(value = "file", required = false) String file) {
if (ToolUtil.isEmpty(file)) {
file = "demo.pdf";
}
try {
return new ClassPathResource("assets/expand/pdf/demo/" + file);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.modular.demos.controller;
import com.sql.admin.modular.demos.service.TranTestService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.SuccessResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 测试多数据源回滚
*
* @author stylefeng
* @Date 2018/7/20 23:39
*/
@RestController
@RequestMapping("/tran/multi")
public class TestMultiTranController extends BaseController {
@Autowired
private TranTestService testMultiDbService;
@RequestMapping("/success")
public Object testSuccess() {
testMultiDbService.beginTest();
return SuccessResponseData.success();
}
@RequestMapping("/fail")
public Object testFail() {
testMultiDbService.beginTestFail();
return SuccessResponseData.success();
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.modular.demos.controller;
import com.sql.admin.modular.demos.service.TranTestService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.SuccessResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 测试单数据源回滚
*
* @author stylefeng
* @Date 2018/7/20 23:39
*/
@RestController
@RequestMapping("/tran/single")
public class TestSingleTranController extends BaseController {
@Autowired
private TranTestService testMultiDbService;
@RequestMapping("/success")
public Object testSuccess() {
testMultiDbService.testSingleSuccess();
return SuccessResponseData.success();
}
@RequestMapping("/fail")
public Object testFail() {
testMultiDbService.testSingleFail();
return SuccessResponseData.success();
}
}
package com.sql.admin.modular.demos.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 管理员表
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@TableName("sys_user")
@Data
public class ExcelItem implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(value = "user_id", type = IdType.ID_WORKER)
@Excel(name = "用户id")
private Long userId;
/**
* 头像
*/
@TableField("avatar")
@Excel(name = "头像")
private String avatar;
/**
* 账号
*/
@TableField("account")
@Excel(name = "账号")
private String account;
/**
* 密码
*/
@TableField("password")
private String password;
/**
* md5密码盐
*/
@TableField("salt")
private String salt;
/**
* 名字
*/
@TableField("name")
@Excel(name = "姓名")
private String name;
/**
* 生日
*/
@TableField("birthday")
@Excel(name = "生日")
private Date birthday;
/**
* 性别(字典)
*/
@TableField("sex")
@Excel(name = "性别")
private String sex;
/**
* 电子邮件
*/
@TableField("email")
@Excel(name = "邮箱")
private String email;
/**
* 电话
*/
@TableField("phone")
@Excel(name = "电话")
private String phone;
/**
* 角色id(多个逗号隔开)
*/
@TableField("role_id")
@Excel(name = "角色id")
private String roleId;
/**
* 部门id(多个逗号隔开)
*/
@TableField("dept_id")
@Excel(name = "部门id")
private Long deptId;
/**
* 状态(字典)
*/
@TableField("status")
@Excel(name = "状态")
private String status;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
@Excel(name = "创建时间")
private Date createTime;
/**
* 创建人
*/
@TableField(value = "create_user", fill = FieldFill.INSERT)
private Long createUser;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 更新人
*/
@TableField(value = "update_user", fill = FieldFill.UPDATE)
private Long updateUser;
/**
* 乐观锁
*/
@TableField("version")
private Integer version;
}
package com.sql.admin.modular.demos.service;
import cn.hutool.core.util.RandomUtil;
import com.sql.admin.sys.modular.system.entity.User;
import com.sql.admin.sys.modular.system.mapper.UserMapper;
import com.sql.admin.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* <p>
* 管理员表 服务实现类
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@Service
public class GunsDbService extends ServiceImpl<UserMapper, User> {
@Autowired
private UserService userService;
@DataSource(name = "master")
public void gunsdb() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
userService.save(user);
}
}
package com.sql.admin.modular.demos.service;
import cn.hutool.core.util.RandomUtil;
import com.sql.admin.sys.modular.system.entity.User;
import com.sql.admin.sys.modular.system.mapper.UserMapper;
import com.sql.admin.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* <p>
* 管理员表 服务实现类
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@Service
public class OtherDbService extends ServiceImpl<UserMapper, User> {
@Autowired
private UserService userService;
@DataSource(name = "test")
public void otherdb() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
userService.save(user);
}
}
package com.sql.admin.modular.demos.service;
import cn.hutool.core.util.RandomUtil;
import com.sql.admin.sys.modular.system.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
* <p>
* 测试数据源能否回滚的例子
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@Service
public class TranTestService {
@Autowired
private GunsDbService gunsDbService;
@Autowired
private OtherDbService otherDbService;
@Transactional(rollbackFor = Exception.class)
public void testSingleSuccess() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
gunsDbService.save(user);
User user2 = new User();
user2.setAccount(RandomUtil.randomString(5));
user2.setPassword(RandomUtil.randomString(5));
user2.setCreateTime(new Date());
user2.setUpdateTime(new Date());
user2.setCreateUser(1L);
user2.setUpdateUser(1L);
gunsDbService.save(user2);
}
@Transactional(rollbackFor = Exception.class)
public void testSingleFail() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
gunsDbService.save(user);
User user2 = new User();
user2.setAccount(RandomUtil.randomString(5));
user2.setPassword(RandomUtil.randomString(5));
user2.setCreateTime(new Date());
user2.setUpdateTime(new Date());
user2.setCreateUser(1L);
user2.setUpdateUser(1L);
gunsDbService.save(user2);
int i = 1 / 0;
}
@Transactional(rollbackFor = Exception.class)
public void beginTest() {
gunsDbService.gunsdb();
otherDbService.otherdb();
}
@Transactional(rollbackFor = Exception.class)
public void beginTestFail() {
gunsDbService.gunsdb();
otherDbService.otherdb();
int i = 1 / 0;
}
}
package com.sql.admin.modular.form.controller;
import com.sql.admin.base.pojo.page.LayuiPageFactory;
import com.sql.admin.base.pojo.page.LayuiPageInfo;
import com.sql.admin.modular.form.entity.EgForm;
import com.sql.admin.modular.form.model.EgFormParam;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
/**
* Guns复杂表单的示例控制器
*
* @author stylefeng
* @Date 2019-02-18 21:37:43
*/
@Controller
@RequestMapping("/egForm")
public class EgFormController extends BaseController {
private String PREFIX = "/form";
/**
* 跳转到主页面
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("")
public String index() {
return PREFIX + "/egForm.html";
}
/**
* 新增页面
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("/add")
public String add() {
return PREFIX + "/egForm_add.html";
}
/**
* 新增接口
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("/addItem")
@ResponseBody
public ResponseData addItem(EgFormParam egFormParam) {
System.out.println(egFormParam);
return ResponseData.success();
}
/**
* 删除接口
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("/delete")
@ResponseBody
public ResponseData delete(EgFormParam egFormParam) {
System.out.println(egFormParam);
return ResponseData.success();
}
/**
* 查询列表
*
* @author stylefeng
* @Date 2019-02-18
*/
@ResponseBody
@RequestMapping("/list")
public LayuiPageInfo list(EgFormParam egFormParam) {
ArrayList<EgForm> records = new ArrayList<>();
EgForm egForm = new EgForm();
egForm.setName("高级表单");
egForm.setSingleTime("2019-03-27 14:16:03");
egForm.setBetweenTime("2019-02-07 - 2019-03-14");
egForm.setFenzuSelect("fenzuSelect");
egForm.setFormId(111L);
egForm.setLongText("xxxxxx");
egForm.setSex("M");
egForm.setSimpleSelect("111");
egForm.setMultiSelectHidden("shiro,mybatis-puls");
records.add(egForm);
records.add(egForm);
Page<EgForm> egFormPage = new Page<>();
egFormPage.setSize(10);
egFormPage.setTotal(2);
egFormPage.setRecords(records);
return LayuiPageFactory.createPageInfo(egFormPage);
}
}
package com.sql.admin.modular.form.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* Guns复杂表单的示例
* </p>
*
* @author stylefeng
* @since 2019-02-23
*/
@TableName("sys_eg_form")
@Data
public class EgForm implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId("FORM_ID")
private Long formId;
/**
* 名称
*/
@TableField("NAME")
private String name;
/**
* 单个时间
*/
@TableField("SINGLE_TIME")
private String singleTime;
/**
* 时间段
*/
@TableField("BETWEEN_TIME")
private String betweenTime;
/**
* 单行选择
*/
@TableField("SIMPLE_SELECT")
private String simpleSelect;
/**
* 分组选择
*/
@TableField("FENZU_SELECT")
private String fenzuSelect;
/**
* 搜索选择
*/
@TableField("MODULES")
private String modules;
/**
* 多个选择
*/
@TableField("MULTI_SELECT_HIDDEN")
private String multiSelectHidden;
/**
* 图片文件id
*/
@TableField("PICTURE_INPUT_HIDDEN")
private String pictureInputHidden;
/**
* 文件id
*/
@TableField("FILE_INPUT_HIDDEN")
private String fileInputHidden;
/**
* 开关标识
*/
@TableField("CLOSE_FLAG")
private String closeFlag;
/**
* 单选
*/
@TableField("SEX")
private String sex;
/**
* 复选框
*/
@TableField("CHECKBOX")
private String checkbox;
/**
* 数字
*/
@TableField("NUMBER")
private Integer number;
/**
* 长字段
*/
@TableField("LONG_TEXT")
private String longText;
}
package com.sql.admin.modular.form.model;
import cn.stylefeng.roses.kernel.model.validator.BaseValidatingParam;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* Guns复杂表单的示例
* </p>
*
* @author stylefeng
* @since 2019-02-18
*/
@Data
public class EgFormParam implements Serializable, BaseValidatingParam {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long formId;
/**
* 名称
*/
private String name;
/**
* 单个时间
*/
private String singleTime;
/**
* 时间段
*/
private String betweenTime;
/**
* 单行选择框
*/
private String simpleSelect;
/**
* 分组选择框
*/
private String fenzuSelect;
/**
* 搜索选择框
*/
private String modules;
/**
* 多个选择
*/
private String multiSelectHidden;
/**
* 图片文件id
*/
private String pictureInputHidden;
/**
* 文件id
*/
private String fileInputHidden;
/**
* close
*/
private String closeFlag;
/**
* 单选框
*/
private String sex;
/**
* 复选框
*/
private String[] checkbox;
/**
* 数字选择
*/
private Integer number;
/**
* 长字段
*/
private String longText;
@Override
public String checkParam() {
return null;
}
}
package com.sql.admin.modular.form.model;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* Guns复杂表单的示例
* </p>
*
* @author stylefeng
* @since 2019-02-18
*/
@Data
public class EgFormResult implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long formId;
/**
* 名称
*/
private String name;
/**
* 单个时间
*/
private String singleTime;
/**
* 时间段
*/
private String betweenTime;
/**
* 单行选择框
*/
private String simpleSelect;
/**
* 分组选择框
*/
private String fenzuSelect;
/**
* 搜索选择框
*/
private String modules;
/**
* 多个选择
*/
private String multiSelectHidden;
/**
* 图片文件id
*/
private String pictureInputHidden;
/**
* 文件id
*/
private String fileInputHidden;
/**
* close
*/
private String closeFlag;
/**
* 单选框
*/
private String sex;
/**
* 复选框
*/
private String[] checkbox;
/**
* 数字选择
*/
private Integer number;
/**
* 长字段
*/
private String longText;
}
restart.include.beetl=/beetl-2.9.3.jar
\ No newline at end of file
#Oracle配置
#spring:
# datasource:
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@127.0.0.1:1521:ORCLCDB
# username: GUNS
# password: GUNS
# filters: wall,mergeStat
#SQLServer配置
#spring:
# datasource:
# driverClassName: net.sourceforge.jtds.jdbc.Driver
# url: jdbc:jtds:sqlserver://127.0.0.1:3433;DatabaseName=guns
# username: guns
# password: 123456
# filters: wall,mergeStat
#PostgreSQL配置
#spring:
# datasource:
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://127.0.0.1:5432/guns
# username: postgres
# password: 123456
# filters: wall,mergeStat
# Mysql数据库
#spring:
# datasource:
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
# username: root
# password: root
# filters: wall,mergeStat
# Mysql数据库
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/guns_advanced?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
username: root
password: EUrD9jIZtEQf8G9r
filters: wall,mergeStat
# 连接池大小根据实际情况调整
max-active: 20
max-pool-prepared-statement-per-connection-size: 20
# 邮件发送配置(改为自己的账号和密码)
mail:
host: smtp.qq.com
port: 587
username: sn93@qq.com
password: xxxpassword
# 邮件发送(改为自己的账号)
mail:
from: sn93@qq.com
server:
port: 9666
# Mysql数据库
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.83:3306/guns_advanced?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
username: root
password: 123456
filters: wall,mergeStat
# 连接池大小根据实际情况调整
max-active: 20
max-pool-prepared-statement-per-connection-size: 20
# 邮件发送配置(改为自己的账号和密码)
mail:
host: smtp.qq.com
port: 587
username: sn93@qq.com
password: xxxpassword
# 邮件发送(改为自己的账号)
mail:
from: sn93@qq.com
server:
port: 80
max-http-header-size: 10240
beetl:
resource-auto-check: true #热加载beetl模板,开发时候用
spring:
profiles:
active: @spring.active@
mvc:
view:
prefix: /pages
servlet:
multipart:
max-request-size: 100MB
max-file-size: 100MB
jta:
atomikos:
properties:
max-actives: -1
mybatis-plus:
mapper-locations: classpath*:com/sql/**/mapping/*.xml
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
lazy-loading-enabled: true
multiple-result-sets-enabled: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
banner: false
db-config:
id-type: assign_id
table-underline: true
log:
path: _app_logs
{
"imageActionName": "uploadimage",
"imageFieldName": "upfile",
"imageMaxSize": 2048000,
"imageAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp"
],
"imageCompressEnable": true,
"imageCompressBorder": 1600,
"imageInsertAlign": "none",
"imageUrlPrefix": "",
"imagePathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"scrawlActionName": "uploadscrawl",
"scrawlFieldName": "upfile",
"scrawlPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"scrawlMaxSize": 2048000,
"scrawlUrlPrefix": "",
"scrawlInsertAlign": "none",
"snapscreenActionName": "uploadimage",
"snapscreenPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"snapscreenUrlPrefix": "",
"snapscreenInsertAlign": "none",
"catcherLocalDomain": [
"127.0.0.1",
"localhost",
"img.baidu.com"
],
"catcherActionName": "catchimage",
"catcherFieldName": "source",
"catcherPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"catcherUrlPrefix": "",
"catcherMaxSize": 2048000,
"catcherAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp"
],
"videoActionName": "uploadvideo",
"videoFieldName": "upfile",
"videoPathFormat": "/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}",
"videoUrlPrefix": "",
"videoMaxSize": 102400000,
"videoAllowFiles": [
".flv",
".swf",
".mkv",
".avi",
".rm",
".rmvb",
".mpeg",
".mpg",
".ogg",
".ogv",
".mov",
".wmv",
".mp4",
".webm",
".mp3",
".wav",
".mid"
],
"fileActionName": "uploadfile",
"fileFieldName": "upfile",
"filePathFormat": "/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}",
"fileUrlPrefix": "",
"fileMaxSize": 51200000,
"fileAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".flv",
".swf",
".mkv",
".avi",
".rm",
".rmvb",
".mpeg",
".mpg",
".ogg",
".ogv",
".mov",
".wmv",
".mp4",
".webm",
".mp3",
".wav",
".mid",
".rar",
".zip",
".tar",
".gz",
".7z",
".bz2",
".cab",
".iso",
".doc",
".docx",
".xls",
".xlsx",
".ppt",
".pptx",
".pdf",
".txt",
".md",
".xml"
],
"imageManagerActionName": "listimage",
"imageManagerListPath": "/ueditor/jsp/upload/image/",
"imageManagerListSize": 20,
"imageManagerUrlPrefix": "",
"imageManagerInsertAlign": "none",
"imageManagerAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp"
],
"fileManagerActionName": "listfile",
"fileManagerListPath": "/ueditor/jsp/upload/file/",
"fileManagerUrlPrefix": "",
"fileManagerListSize": 20,
"fileManagerAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".flv",
".swf",
".mkv",
".avi",
".rm",
".rmvb",
".mpeg",
".mpg",
".ogg",
".ogv",
".mov",
".wmv",
".mp4",
".webm",
".mp3",
".wav",
".mid",
".rar",
".zip",
".tar",
".gz",
".7z",
".bz2",
".cab",
".iso",
".doc",
".docx",
".xls",
".xlsx",
".ppt",
".pptx",
".pdf",
".txt",
".md",
".xml"
]
}
\ No newline at end of file
layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax','upload'], function () {
var layer = layui.layer;
var form = layui.form;
var table = layui.table;
var $ZTree = layui.ztree;
var $ax = layui.ax;
var laydate = layui.laydate;
var admin = layui.admin;
var upload = layui.upload;
/**
* 系统管理--用户管理
*/
var MgrUser = {
tableId: "userTable", //表格id
condition: {
name: "",
deptId: "",
timeLimit: ""
}
};
/**
* 初始化表格的列
*/
MgrUser.initColumn = function () {
return [[
{type: 'checkbox'},
{field: 'userId', hide: true, sort: true, title: '用户id'},
{field: 'account', sort: true, title: '账号'},
{field: 'name', sort: true, title: '姓名'},
{field: 'sexName', sort: true, title: '性别'},
{field: 'roleName', sort: true, title: '角色'},
{field: 'deptName', sort: true, title: '部门'},
{field: 'email', sort: true, title: '邮箱'},
{field: 'phone', sort: true, title: '电话'},
{field: 'createTime', sort: true, title: '创建时间'},
{field: 'status', sort: true, templet: '#statusTpl', title: '状态'}
]];
};
/**
* 导出excel按钮
*/
MgrUser.exportExcel = function () {
var checkRows = table.checkStatus(MgrUser.tableId);
if (checkRows.data.length === 0) {
Feng.error("请选择要导出的数据");
} else {
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
}
};
// 渲染表格
var tableResult = table.render({
elem: '#' + MgrUser.tableId,
url: Feng.ctxPath + '/mgr/list',
page: true,
height: "full-98",
cellMinWidth: 100,
cols: MgrUser.initColumn()
});
//渲染时间选择框
laydate.render({
elem: '#timeLimit',
range: true,
max: Feng.currentDate()
});
//执行实例
var uploadInst = upload.render({
elem: '#btnExp'
, url: '/excel/uploadExcel'
,accept: 'file'
, done: function (res) {
table.reload(MgrUser.tableId, {url: Feng.ctxPath + "/excel/getUploadData"});
}
, error: function () {
//请求异常回调
}
});
});
layui.use(['table', 'admin', 'ax'], function () {
var $ = layui.$;
var table = layui.table;
var $ax = layui.ax;
var admin = layui.admin;
/**
* Guns复杂表单的示例管理
*/
var EgForm = {
tableId: "egFormTable"
};
/**
* 初始化表格的列
*/
EgForm.initColumn = function () {
return [[
{type: 'checkbox'},
{field: 'formId', align: "center", hide: true, title: '主键id'},
{field: 'name', align: "center", sort: true, title: '名称'},
{field: 'singleTime', align: "center", sort: true, title: '单个时间', minWidth: 160},
{field: 'betweenTime', align: "center", sort: true, title: '时间段', minWidth: 187},
{field: 'simpleSelect', align: "center", sort: true, title: '单行选择'},
{field: 'fenzuSelect', align: "center", sort: true, title: '分组选择', minWidth: 104},
{field: 'modules', align: "center", sort: true, title: '搜索选择'},
{field: 'multiSelectHidden', align: "center", sort: true, title: '多个选择', minWidth: 143},
{
align: 'center', templet: function (d) {
// var url = d.imgUrl;
var url = 'https://pic.qqtn.com/up/2018-9/15367146917869444.jpg';
return '<img src="' + url + '" class="tdImg" />';
}, title: '缩略图', width: 90, unresize: true
},
{field: 'fileInputHidden', align: "center", sort: true, title: '文件id'},
{field: 'closeFlag', align: "center", sort: true, title: '开关标识'},
{field: 'sex', align: "center", sort: true, title: '单选'},
{field: 'checkbox', align: "center", sort: true, title: '复选框'},
{field: 'number', align: "center", sort: true, title: '数字'},
{field: 'longText', align: "center", sort: true, title: '长字段'},
{align: 'center', toolbar: '#tableBar', title: '操作'}
]];
};
/**
* 点击查询按钮
*/
EgForm.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
table.reload(EgForm.tableId, {
where: queryData, page: {curr: 1}
});
};
/**
* 弹出添加对话框
*/
EgForm.openAddDlg = function () {
admin.putTempData('formOk', false);
top.layui.admin.open({
type: 2,
title: '添加Guns复杂表单的示例',
content: Feng.ctxPath + '/egForm/add',
end: function () {
admin.getTempData('formOk') && table.reload(EgForm.tableId);
}
});
};
/**
* 导出excel按钮
*/
EgForm.exportExcel = function () {
var checkRows = table.checkStatus(EgForm.tableId);
if (checkRows.data.length === 0) {
Feng.error("请选择要导出的数据");
} else {
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
}
};
/**
* 点击删除
*
* @param data 点击按钮时候的行数据
*/
EgForm.onDeleteItem = function (data) {
var operation = function () {
var ajax = new $ax(Feng.ctxPath + "/egForm/delete", function (data) {
Feng.success("删除成功!");
table.reload(EgForm.tableId);
}, function (data) {
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("formId", data.formId);
ajax.start();
};
Feng.confirm("是否删除?", operation);
};
// 渲染表格
var tableResult = table.render({
elem: '#' + EgForm.tableId,
url: Feng.ctxPath + '/egForm/list',
page: true,
height: "full-98",
cellMinWidth: 100,
cols: EgForm.initColumn()
});
// 搜索按钮点击事件
$('#btnSearch').click(function () {
EgForm.search();
});
// 添加按钮点击事件
$('#btnAdd').click(function () {
window.location.href = Feng.ctxPath + "/egForm/add";
});
// 导出excel
$('#btnExp').click(function () {
EgForm.exportExcel();
});
// 工具条点击事件
table.on('tool(' + EgForm.tableId + ')', function (obj) {
var data = obj.data;
var layEvent = obj.event;
if (layEvent === 'delete') {
EgForm.onDeleteItem(data);
}
});
});
/**
* 详情对话框
*/
var EgFormInfoDlg = {
data: {
title: "",
singleTime: "",
beginTime: "",
endTime: "",
multiSelect: "",
pictureOne: "",
number: "",
singleSelectOne: "",
singleSelectTwo: "",
pictureTwo: "",
longText: ""
}
};
layui.use(['form', 'admin', 'ax', 'upload', 'laydate', 'selectPlus'], function () {
var $ = layui.jquery;
var $ax = layui.ax;
var form = layui.form;
var admin = layui.admin;
var upload = layui.upload;
var laydate = layui.laydate;
var selectPlus = layui.selectPlus;
//初始化时间选择器
laydate.render({
elem: '#singleTime'
, type: 'datetime'
});
laydate.render({
elem: '#betweenTime'
, range: true //或 range: '~' 来自定义分割字符
});
//初始化多选
var test = selectPlus.render({
el: '#multiSelect',
data: [{
"id": 1,
"name": "spring"
}, {
"id": 2,
"name": "shiro"
}, {
"id": 3,
"name": "mybatis-puls"
}, {
"id": 4,
"name": "beetl"
}],
valueName: "name",
values: ['abc'],
valueSeparator: " --- "
});
selectPlus.on('selectPlus(multiSelect)', function (obj) {
console.log(obj.checked); //当前是否选中状态
console.log(obj.values); //选中的数据
console.log(obj.checkedData); //选中的相关数据
console.log(obj.isAll); //是否是全选
console.log(obj.ele); //点击的DOM
$("#multiSelectHidden").val(obj.values);
});
//上传文件
upload.render({
elem: '#fileBtn'
, url: Feng.ctxPath + '/system/upload'
, accept: 'file'
, before: function (obj) {
obj.preview(function (index, file, result) {
$("#fileNameTip").html(file.name);
});
}
, done: function (res) {
$("#fileInputHidden").val(res.data.fileId);
Feng.success(res.message);
}
, error: function () {
Feng.error("上传图片失败!");
}
});
//普通图片上传
upload.render({
elem: '#picBtn'
, url: Feng.ctxPath + '/system/upload'
, before: function (obj) {
obj.preview(function (index, file, result) {
$('#img1').attr('src', result);
});
}
, done: function (res) {
$("#pictureInputHidden").val(res.data.fileId);
Feng.success(res.message);
}
, error: function () {
Feng.error("上传图片失败!");
}
});
//表单提交事件
form.on('submit(btnSubmit)', function (data) {
var ajax = new $ax(Feng.ctxPath + "/egForm/addItem", function (data) {
Feng.success("添加成功!");
//传给上个页面,刷新table用
admin.putTempData('formOk', true);
//关掉对话框
admin.closeThisDialog();
}, function (data) {
Feng.error("添加失败!" + data.responseJSON.message)
});
ajax.set(data.field);
ajax.start();
});
//返回按钮
$("#backupPage").click(function () {
window.location.href = Feng.ctxPath + "/egForm";
});
});
\ No newline at end of file
@layout("/common/_container.html",{plugins:["ztree"],js:["/assets/demos/excel_import.js"]}){
<div class="layui-body-header">
<span class="layui-body-header-title">用户管理</span>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-sm12">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-form toolbar">
<div class="layui-form-item">
<div class="layui-inline">
<button id="btnExp" class="layui-btn icon-btn">
<i class="layui-icon">&#xe67c;</i>导入excel并展示
</button>
</div>
</div>
</div>
<table class="layui-table" id="userTable" lay-filter="userTable"></table>
</div>
</div>
</div>
</div>
</div>
<script type="text/html" id="statusTpl">
<input type="checkbox" lay-filter="status" value="{{d.userId}}" lay-skin="switch" lay-text="正常|冻结" {{d.status=='ENABLE'?'checked':''}} />
</script>
@}
\ No newline at end of file
@layout("/common/_container.html",{js:["/assets/form/egForm.js"],css:["/assets/form/form.css"]}){
<div class="layui-body-header">
<span class="layui-body-header-title">Guns复杂表单的示例管理</span>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-form toolbar">
<div class="layui-form-item">
<div class="layui-inline">
<input id="condition" class="layui-input" type="text" placeholder="名称"/>
</div>
<div class="layui-inline">
<button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
<button id="btnAdd" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>
<button id="btnExp" class="layui-btn icon-btn"><i class="layui-icon">&#xe67d;</i>导出</button>
</div>
</div>
</div>
<table class="layui-table" id="egFormTable" lay-filter="egFormTable"></table>
</div>
</div>
</div>
</div>
</div>
<script type="text/html" id="tableBar">
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
</script>
@}
\ No newline at end of file
/**
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.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 com.sql.admin.config.web;
import com.sql.admin.base.auth.context.LoginContext;
import com.sql.admin.sys.core.beetl.BeetlConfiguration;
import com.sql.admin.sys.core.properties.BeetlProperties;
import org.beetl.core.resource.ClasspathResourceLoader;
import org.beetl.ext.spring.BeetlSpringViewResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* web 配置类
*
* @author fengshuonan
* @date 2016年11月12日 下午5:03:32
*/
@Configuration
public class BeetlConfig {
@Autowired
private BeetlProperties beetlProperties;
/**
* beetl的配置
*/
@Bean(initMethod = "init")
public BeetlConfiguration beetlConfiguration(LoginContext loginContext) {
BeetlConfiguration beetlConfiguration = new BeetlConfiguration(loginContext);
beetlConfiguration.setResourceLoader(new ClasspathResourceLoader(BeetlConfig.class.getClassLoader(), beetlProperties.getPrefix()));
beetlConfiguration.setConfigProperties(beetlProperties.getProperties());
return beetlConfiguration;
}
/**
* beetl的视图解析器
*/
@Bean
public BeetlSpringViewResolver beetlViewResolver(LoginContext loginContext) {
BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
beetlSpringViewResolver.setConfig(beetlConfiguration(loginContext));
beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
beetlSpringViewResolver.setOrder(0);
return beetlSpringViewResolver;
}
}
package com.sql.admin.config.web;
import cn.hutool.core.date.DateUtil;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import javax.annotation.PostConstruct;
import java.util.Date;
/**
* 默认的string to date的转化
*
* @author fengshuonan
* @Date 2019/2/12 20:09
*/
@Configuration
public class String2DateConfig {
@Autowired
private RequestMappingHandlerAdapter handlerAdapter;
/**
* 默认时间转化器
*/
@PostConstruct
public void addConversionConfig() {
ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) handlerAdapter.getWebBindingInitializer();
if ((initializer != null ? initializer.getConversionService() : null) != null) {
GenericConversionService genericConversionService = (GenericConversionService) initializer.getConversionService();
genericConversionService.addConverter(new StringToDateConverter());
}
}
/**
* 时间字符串转date的格式
*
* @author fengshuonan
* @Date 2019/10/22 13:42
*/
public static class StringToDateConverter implements Converter<String, Date> {
@Override
public Date convert(String dateString) {
if (ToolUtil.isEmpty(dateString)) {
return null;
} else {
return DateUtil.parse(dateString);
}
}
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.config.web;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* swagger配置类
*
* @author fengshuonan
* @date 2017年6月1日19:42:59
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) //这里采用包含注解的方式来确定要显示的接口
//.apis(RequestHandlerSelectors.basePackage("com.sql.admin.modular.system.controller")) //这里采用包扫描的方式来确定要显示的接口
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Guns Doc")
.description("Guns Api文档")
.termsOfServiceUrl("https://gitee.com/stylefeng/guns")
.contact(new Contact("stylefeng", "https://gitee.com/stylefeng/guns", ""))
.version("2.0")
.build();
}
}
package com.sql.admin.core.schedue.quartz;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
/**
* quartz的启动示例
*
* @author fengshuonan
* @Date 2019/2/24 16:55
*/
public class StartQuartzExample implements CommandLineRunner {
@Autowired
private Scheduler scheduler;
@Override
public void run(String... args) throws Exception {
// 启动调度器
scheduler.start();
//构建job信息
JobDetail jobDetail = JobBuilder.newJob(SampleQuartzJob.class).withIdentity(SampleQuartzJob.class.getName(), "aaa").build();
//表达式调度构建器(即任务执行的时间)
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("*/5 * * * * ?");
//按新的cronExpression表达式构建一个新的trigger
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(SampleQuartzJob.class.getName(), "aaa")
.withSchedule(scheduleBuilder).build();
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
System.out.println("创建定时任务失败" + e);
throw new Exception("创建定时任务失败");
}
}
}
package com.sql.admin.core.schedue.spring;
import org.springframework.scheduling.annotation.Scheduled;
/**
* 测试定时任务
*
* @author fengshuonan
* @Date 2019/2/24 16:29
*/
public class SpringTasks {
/**
* 上一次开始执行时间点之后5秒再执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(fixedRate = 5000)
public void beginAfter() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>开始之后5秒执行!");
}
/**
* 上一次执行完毕时间点之后5秒再执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(fixedDelay = 5000)
public void finishAfter() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>执行之后5秒才执行!");
}
/**
* 上一次执行完毕时间点之后5秒再执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(initialDelay = 1000, fixedRate = 5000)
public void stepAdd() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>第一次延迟1秒后执行,之后按fixedRate的规则每5秒执行一次!");
}
/**
* cron表达式执行
*
* @author fengshuonan
* @Date 2019/2/24 16:31
*/
@Scheduled(cron = "*/10 * * * * *")
public void cron() {
System.err.println("<<<<<调试信息,注释掉SchedulingConfig类中的内容来关闭这个定时任务!>>>>> spring task执行 >>>>>每隔10秒执行一次!");
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.modular.demos.controller;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* pdf预览
*
* @author fengshuonan
* @Date 2017年2月17日20:27:22
*/
@Controller
@Slf4j
public class PdfPreviewController extends BaseController {
private String PREFIX = "/demos/pdf/";
/**
* pdf预览
*/
@RequestMapping("/pdf")
public String pdf() {
return PREFIX + "pdf.html";
}
/**
* 预览
*/
@GetMapping(value = "/loadPdfFile", produces = "application/pdf")
@ResponseBody
public ClassPathResource loadPdfFile(@RequestParam(value = "file", required = false) String file) {
if (ToolUtil.isEmpty(file)) {
file = "demo.pdf";
}
try {
return new ClassPathResource("assets/expand/pdf/demo/" + file);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.modular.demos.controller;
import com.sql.admin.modular.demos.service.TranTestService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.SuccessResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 测试多数据源回滚
*
* @author stylefeng
* @Date 2018/7/20 23:39
*/
@RestController
@RequestMapping("/tran/multi")
public class TestMultiTranController extends BaseController {
@Autowired
private TranTestService testMultiDbService;
@RequestMapping("/success")
public Object testSuccess() {
testMultiDbService.beginTest();
return SuccessResponseData.success();
}
@RequestMapping("/fail")
public Object testFail() {
testMultiDbService.beginTestFail();
return SuccessResponseData.success();
}
}
/**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.sql.admin.modular.demos.controller;
import com.sql.admin.modular.demos.service.TranTestService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.SuccessResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 测试单数据源回滚
*
* @author stylefeng
* @Date 2018/7/20 23:39
*/
@RestController
@RequestMapping("/tran/single")
public class TestSingleTranController extends BaseController {
@Autowired
private TranTestService testMultiDbService;
@RequestMapping("/success")
public Object testSuccess() {
testMultiDbService.testSingleSuccess();
return SuccessResponseData.success();
}
@RequestMapping("/fail")
public Object testFail() {
testMultiDbService.testSingleFail();
return SuccessResponseData.success();
}
}
package com.sql.admin.modular.demos.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 管理员表
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@TableName("sys_user")
@Data
public class ExcelItem implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId(value = "user_id", type = IdType.ID_WORKER)
@Excel(name = "用户id")
private Long userId;
/**
* 头像
*/
@TableField("avatar")
@Excel(name = "头像")
private String avatar;
/**
* 账号
*/
@TableField("account")
@Excel(name = "账号")
private String account;
/**
* 密码
*/
@TableField("password")
private String password;
/**
* md5密码盐
*/
@TableField("salt")
private String salt;
/**
* 名字
*/
@TableField("name")
@Excel(name = "姓名")
private String name;
/**
* 生日
*/
@TableField("birthday")
@Excel(name = "生日")
private Date birthday;
/**
* 性别(字典)
*/
@TableField("sex")
@Excel(name = "性别")
private String sex;
/**
* 电子邮件
*/
@TableField("email")
@Excel(name = "邮箱")
private String email;
/**
* 电话
*/
@TableField("phone")
@Excel(name = "电话")
private String phone;
/**
* 角色id(多个逗号隔开)
*/
@TableField("role_id")
@Excel(name = "角色id")
private String roleId;
/**
* 部门id(多个逗号隔开)
*/
@TableField("dept_id")
@Excel(name = "部门id")
private Long deptId;
/**
* 状态(字典)
*/
@TableField("status")
@Excel(name = "状态")
private String status;
/**
* 创建时间
*/
@TableField(value = "create_time", fill = FieldFill.INSERT)
@Excel(name = "创建时间")
private Date createTime;
/**
* 创建人
*/
@TableField(value = "create_user", fill = FieldFill.INSERT)
private Long createUser;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private Date updateTime;
/**
* 更新人
*/
@TableField(value = "update_user", fill = FieldFill.UPDATE)
private Long updateUser;
/**
* 乐观锁
*/
@TableField("version")
private Integer version;
}
package com.sql.admin.modular.demos.service;
import cn.hutool.core.util.RandomUtil;
import com.sql.admin.sys.modular.system.entity.User;
import com.sql.admin.sys.modular.system.mapper.UserMapper;
import com.sql.admin.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* <p>
* 管理员表 服务实现类
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@Service
public class GunsDbService extends ServiceImpl<UserMapper, User> {
@Autowired
private UserService userService;
@DataSource(name = "master")
public void gunsdb() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
userService.save(user);
}
}
package com.sql.admin.modular.demos.service;
import cn.hutool.core.util.RandomUtil;
import com.sql.admin.sys.modular.system.entity.User;
import com.sql.admin.sys.modular.system.mapper.UserMapper;
import com.sql.admin.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* <p>
* 管理员表 服务实现类
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@Service
public class OtherDbService extends ServiceImpl<UserMapper, User> {
@Autowired
private UserService userService;
@DataSource(name = "test")
public void otherdb() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
userService.save(user);
}
}
package com.sql.admin.modular.demos.service;
import cn.hutool.core.util.RandomUtil;
import com.sql.admin.sys.modular.system.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
* <p>
* 测试数据源能否回滚的例子
* </p>
*
* @author stylefeng
* @since 2018-12-07
*/
@Service
public class TranTestService {
@Autowired
private GunsDbService gunsDbService;
@Autowired
private OtherDbService otherDbService;
@Transactional(rollbackFor = Exception.class)
public void testSingleSuccess() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
gunsDbService.save(user);
User user2 = new User();
user2.setAccount(RandomUtil.randomString(5));
user2.setPassword(RandomUtil.randomString(5));
user2.setCreateTime(new Date());
user2.setUpdateTime(new Date());
user2.setCreateUser(1L);
user2.setUpdateUser(1L);
gunsDbService.save(user2);
}
@Transactional(rollbackFor = Exception.class)
public void testSingleFail() {
User user = new User();
user.setAccount(RandomUtil.randomString(5));
user.setPassword(RandomUtil.randomString(5));
user.setCreateTime(new Date());
user.setUpdateTime(new Date());
user.setCreateUser(1L);
user.setUpdateUser(1L);
gunsDbService.save(user);
User user2 = new User();
user2.setAccount(RandomUtil.randomString(5));
user2.setPassword(RandomUtil.randomString(5));
user2.setCreateTime(new Date());
user2.setUpdateTime(new Date());
user2.setCreateUser(1L);
user2.setUpdateUser(1L);
gunsDbService.save(user2);
int i = 1 / 0;
}
@Transactional(rollbackFor = Exception.class)
public void beginTest() {
gunsDbService.gunsdb();
otherDbService.otherdb();
}
@Transactional(rollbackFor = Exception.class)
public void beginTestFail() {
gunsDbService.gunsdb();
otherDbService.otherdb();
int i = 1 / 0;
}
}
package com.sql.admin.modular.form.controller;
import com.sql.admin.base.pojo.page.LayuiPageFactory;
import com.sql.admin.base.pojo.page.LayuiPageInfo;
import com.sql.admin.modular.form.entity.EgForm;
import com.sql.admin.modular.form.model.EgFormParam;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
/**
* Guns复杂表单的示例控制器
*
* @author stylefeng
* @Date 2019-02-18 21:37:43
*/
@Controller
@RequestMapping("/egForm")
public class EgFormController extends BaseController {
private String PREFIX = "/form";
/**
* 跳转到主页面
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("")
public String index() {
return PREFIX + "/egForm.html";
}
/**
* 新增页面
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("/add")
public String add() {
return PREFIX + "/egForm_add.html";
}
/**
* 新增接口
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("/addItem")
@ResponseBody
public ResponseData addItem(EgFormParam egFormParam) {
System.out.println(egFormParam);
return ResponseData.success();
}
/**
* 删除接口
*
* @author stylefeng
* @Date 2019-02-18
*/
@RequestMapping("/delete")
@ResponseBody
public ResponseData delete(EgFormParam egFormParam) {
System.out.println(egFormParam);
return ResponseData.success();
}
/**
* 查询列表
*
* @author stylefeng
* @Date 2019-02-18
*/
@ResponseBody
@RequestMapping("/list")
public LayuiPageInfo list(EgFormParam egFormParam) {
ArrayList<EgForm> records = new ArrayList<>();
EgForm egForm = new EgForm();
egForm.setName("高级表单");
egForm.setSingleTime("2019-03-27 14:16:03");
egForm.setBetweenTime("2019-02-07 - 2019-03-14");
egForm.setFenzuSelect("fenzuSelect");
egForm.setFormId(111L);
egForm.setLongText("xxxxxx");
egForm.setSex("M");
egForm.setSimpleSelect("111");
egForm.setMultiSelectHidden("shiro,mybatis-puls");
records.add(egForm);
records.add(egForm);
Page<EgForm> egFormPage = new Page<>();
egFormPage.setSize(10);
egFormPage.setTotal(2);
egFormPage.setRecords(records);
return LayuiPageFactory.createPageInfo(egFormPage);
}
}
package com.sql.admin.modular.form.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* Guns复杂表单的示例
* </p>
*
* @author stylefeng
* @since 2019-02-23
*/
@TableName("sys_eg_form")
@Data
public class EgForm implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@TableId("FORM_ID")
private Long formId;
/**
* 名称
*/
@TableField("NAME")
private String name;
/**
* 单个时间
*/
@TableField("SINGLE_TIME")
private String singleTime;
/**
* 时间段
*/
@TableField("BETWEEN_TIME")
private String betweenTime;
/**
* 单行选择
*/
@TableField("SIMPLE_SELECT")
private String simpleSelect;
/**
* 分组选择
*/
@TableField("FENZU_SELECT")
private String fenzuSelect;
/**
* 搜索选择
*/
@TableField("MODULES")
private String modules;
/**
* 多个选择
*/
@TableField("MULTI_SELECT_HIDDEN")
private String multiSelectHidden;
/**
* 图片文件id
*/
@TableField("PICTURE_INPUT_HIDDEN")
private String pictureInputHidden;
/**
* 文件id
*/
@TableField("FILE_INPUT_HIDDEN")
private String fileInputHidden;
/**
* 开关标识
*/
@TableField("CLOSE_FLAG")
private String closeFlag;
/**
* 单选
*/
@TableField("SEX")
private String sex;
/**
* 复选框
*/
@TableField("CHECKBOX")
private String checkbox;
/**
* 数字
*/
@TableField("NUMBER")
private Integer number;
/**
* 长字段
*/
@TableField("LONG_TEXT")
private String longText;
}
package com.sql.admin.modular.form.model;
import cn.stylefeng.roses.kernel.model.validator.BaseValidatingParam;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* Guns复杂表单的示例
* </p>
*
* @author stylefeng
* @since 2019-02-18
*/
@Data
public class EgFormParam implements Serializable, BaseValidatingParam {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long formId;
/**
* 名称
*/
private String name;
/**
* 单个时间
*/
private String singleTime;
/**
* 时间段
*/
private String betweenTime;
/**
* 单行选择框
*/
private String simpleSelect;
/**
* 分组选择框
*/
private String fenzuSelect;
/**
* 搜索选择框
*/
private String modules;
/**
* 多个选择
*/
private String multiSelectHidden;
/**
* 图片文件id
*/
private String pictureInputHidden;
/**
* 文件id
*/
private String fileInputHidden;
/**
* close
*/
private String closeFlag;
/**
* 单选框
*/
private String sex;
/**
* 复选框
*/
private String[] checkbox;
/**
* 数字选择
*/
private Integer number;
/**
* 长字段
*/
private String longText;
@Override
public String checkParam() {
return null;
}
}
package com.sql.admin.modular.form.model;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* Guns复杂表单的示例
* </p>
*
* @author stylefeng
* @since 2019-02-18
*/
@Data
public class EgFormResult implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long formId;
/**
* 名称
*/
private String name;
/**
* 单个时间
*/
private String singleTime;
/**
* 时间段
*/
private String betweenTime;
/**
* 单行选择框
*/
private String simpleSelect;
/**
* 分组选择框
*/
private String fenzuSelect;
/**
* 搜索选择框
*/
private String modules;
/**
* 多个选择
*/
private String multiSelectHidden;
/**
* 图片文件id
*/
private String pictureInputHidden;
/**
* 文件id
*/
private String fileInputHidden;
/**
* close
*/
private String closeFlag;
/**
* 单选框
*/
private String sex;
/**
* 复选框
*/
private String[] checkbox;
/**
* 数字选择
*/
private Integer number;
/**
* 长字段
*/
private String longText;
}
restart.include.beetl=/beetl-2.9.3.jar
\ No newline at end of file
#Oracle配置
#spring:
# datasource:
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@127.0.0.1:1521:ORCLCDB
# username: GUNS
# password: GUNS
# filters: wall,mergeStat
#SQLServer配置
#spring:
# datasource:
# driverClassName: net.sourceforge.jtds.jdbc.Driver
# url: jdbc:jtds:sqlserver://127.0.0.1:3433;DatabaseName=guns
# username: guns
# password: 123456
# filters: wall,mergeStat
#PostgreSQL配置
#spring:
# datasource:
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://127.0.0.1:5432/guns
# username: postgres
# password: 123456
# filters: wall,mergeStat
# Mysql数据库
#spring:
# datasource:
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/guns?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
# username: root
# password: root
# filters: wall,mergeStat
# Mysql数据库
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/guns_advanced?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
username: root
password: EUrD9jIZtEQf8G9r
filters: wall,mergeStat
# 连接池大小根据实际情况调整
max-active: 20
max-pool-prepared-statement-per-connection-size: 20
# 邮件发送配置(改为自己的账号和密码)
mail:
host: smtp.qq.com
port: 587
username: sn93@qq.com
password: xxxpassword
# 邮件发送(改为自己的账号)
mail:
from: sn93@qq.com
server:
port: 9666
# Mysql数据库
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.125.100:3306/guns_advanced?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT
username: root
password: 123456
filters: wall,mergeStat
# 连接池大小根据实际情况调整
max-active: 20
max-pool-prepared-statement-per-connection-size: 20
# 邮件发送配置(改为自己的账号和密码)
mail:
host: smtp.qq.com
port: 587
username: sn93@qq.com
password: xxxpassword
# 邮件发送(改为自己的账号)
mail:
from: sn93@qq.com
server:
port: 80
max-http-header-size: 10240
beetl:
resource-auto-check: true #热加载beetl模板,开发时候用
spring:
profiles:
active: @spring.active@
mvc:
view:
prefix: /pages
servlet:
multipart:
max-request-size: 100MB
max-file-size: 100MB
jta:
atomikos:
properties:
max-actives: -1
mybatis-plus:
mapper-locations: classpath*:com/sql/**/mapping/*.xml
configuration:
map-underscore-to-camel-case: true
cache-enabled: true
lazy-loading-enabled: true
multiple-result-sets-enabled: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
banner: false
db-config:
id-type: assign_id
table-underline: true
log:
path: _app_logs
{
"imageActionName": "uploadimage",
"imageFieldName": "upfile",
"imageMaxSize": 2048000,
"imageAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp"
],
"imageCompressEnable": true,
"imageCompressBorder": 1600,
"imageInsertAlign": "none",
"imageUrlPrefix": "",
"imagePathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"scrawlActionName": "uploadscrawl",
"scrawlFieldName": "upfile",
"scrawlPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"scrawlMaxSize": 2048000,
"scrawlUrlPrefix": "",
"scrawlInsertAlign": "none",
"snapscreenActionName": "uploadimage",
"snapscreenPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"snapscreenUrlPrefix": "",
"snapscreenInsertAlign": "none",
"catcherLocalDomain": [
"127.0.0.1",
"localhost",
"img.baidu.com"
],
"catcherActionName": "catchimage",
"catcherFieldName": "source",
"catcherPathFormat": "/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}",
"catcherUrlPrefix": "",
"catcherMaxSize": 2048000,
"catcherAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp"
],
"videoActionName": "uploadvideo",
"videoFieldName": "upfile",
"videoPathFormat": "/ueditor/jsp/upload/video/{yyyy}{mm}{dd}/{time}{rand:6}",
"videoUrlPrefix": "",
"videoMaxSize": 102400000,
"videoAllowFiles": [
".flv",
".swf",
".mkv",
".avi",
".rm",
".rmvb",
".mpeg",
".mpg",
".ogg",
".ogv",
".mov",
".wmv",
".mp4",
".webm",
".mp3",
".wav",
".mid"
],
"fileActionName": "uploadfile",
"fileFieldName": "upfile",
"filePathFormat": "/ueditor/jsp/upload/file/{yyyy}{mm}{dd}/{time}{rand:6}",
"fileUrlPrefix": "",
"fileMaxSize": 51200000,
"fileAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".flv",
".swf",
".mkv",
".avi",
".rm",
".rmvb",
".mpeg",
".mpg",
".ogg",
".ogv",
".mov",
".wmv",
".mp4",
".webm",
".mp3",
".wav",
".mid",
".rar",
".zip",
".tar",
".gz",
".7z",
".bz2",
".cab",
".iso",
".doc",
".docx",
".xls",
".xlsx",
".ppt",
".pptx",
".pdf",
".txt",
".md",
".xml"
],
"imageManagerActionName": "listimage",
"imageManagerListPath": "/ueditor/jsp/upload/image/",
"imageManagerListSize": 20,
"imageManagerUrlPrefix": "",
"imageManagerInsertAlign": "none",
"imageManagerAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp"
],
"fileManagerActionName": "listfile",
"fileManagerListPath": "/ueditor/jsp/upload/file/",
"fileManagerUrlPrefix": "",
"fileManagerListSize": 20,
"fileManagerAllowFiles": [
".png",
".jpg",
".jpeg",
".gif",
".bmp",
".flv",
".swf",
".mkv",
".avi",
".rm",
".rmvb",
".mpeg",
".mpg",
".ogg",
".ogv",
".mov",
".wmv",
".mp4",
".webm",
".mp3",
".wav",
".mid",
".rar",
".zip",
".tar",
".gz",
".7z",
".bz2",
".cab",
".iso",
".doc",
".docx",
".xls",
".xlsx",
".ppt",
".pptx",
".pdf",
".txt",
".md",
".xml"
]
}
\ No newline at end of file
layui.use(['layer', 'form', 'table', 'ztree', 'laydate', 'admin', 'ax','upload'], function () {
var layer = layui.layer;
var form = layui.form;
var table = layui.table;
var $ZTree = layui.ztree;
var $ax = layui.ax;
var laydate = layui.laydate;
var admin = layui.admin;
var upload = layui.upload;
/**
* 系统管理--用户管理
*/
var MgrUser = {
tableId: "userTable", //表格id
condition: {
name: "",
deptId: "",
timeLimit: ""
}
};
/**
* 初始化表格的列
*/
MgrUser.initColumn = function () {
return [[
{type: 'checkbox'},
{field: 'userId', hide: true, sort: true, title: '用户id'},
{field: 'account', sort: true, title: '账号'},
{field: 'name', sort: true, title: '姓名'},
{field: 'sexName', sort: true, title: '性别'},
{field: 'roleName', sort: true, title: '角色'},
{field: 'deptName', sort: true, title: '部门'},
{field: 'email', sort: true, title: '邮箱'},
{field: 'phone', sort: true, title: '电话'},
{field: 'createTime', sort: true, title: '创建时间'},
{field: 'status', sort: true, templet: '#statusTpl', title: '状态'}
]];
};
/**
* 导出excel按钮
*/
MgrUser.exportExcel = function () {
var checkRows = table.checkStatus(MgrUser.tableId);
if (checkRows.data.length === 0) {
Feng.error("请选择要导出的数据");
} else {
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
}
};
// 渲染表格
var tableResult = table.render({
elem: '#' + MgrUser.tableId,
url: Feng.ctxPath + '/mgr/list',
page: true,
height: "full-98",
cellMinWidth: 100,
cols: MgrUser.initColumn()
});
//渲染时间选择框
laydate.render({
elem: '#timeLimit',
range: true,
max: Feng.currentDate()
});
//执行实例
var uploadInst = upload.render({
elem: '#btnExp'
, url: '/excel/uploadExcel'
,accept: 'file'
, done: function (res) {
table.reload(MgrUser.tableId, {url: Feng.ctxPath + "/excel/getUploadData"});
}
, error: function () {
//请求异常回调
}
});
});
layui.use(['table', 'admin', 'ax'], function () {
var $ = layui.$;
var table = layui.table;
var $ax = layui.ax;
var admin = layui.admin;
/**
* Guns复杂表单的示例管理
*/
var EgForm = {
tableId: "egFormTable"
};
/**
* 初始化表格的列
*/
EgForm.initColumn = function () {
return [[
{type: 'checkbox'},
{field: 'formId', align: "center", hide: true, title: '主键id'},
{field: 'name', align: "center", sort: true, title: '名称'},
{field: 'singleTime', align: "center", sort: true, title: '单个时间', minWidth: 160},
{field: 'betweenTime', align: "center", sort: true, title: '时间段', minWidth: 187},
{field: 'simpleSelect', align: "center", sort: true, title: '单行选择'},
{field: 'fenzuSelect', align: "center", sort: true, title: '分组选择', minWidth: 104},
{field: 'modules', align: "center", sort: true, title: '搜索选择'},
{field: 'multiSelectHidden', align: "center", sort: true, title: '多个选择', minWidth: 143},
{
align: 'center', templet: function (d) {
// var url = d.imgUrl;
var url = 'https://pic.qqtn.com/up/2018-9/15367146917869444.jpg';
return '<img src="' + url + '" class="tdImg" />';
}, title: '缩略图', width: 90, unresize: true
},
{field: 'fileInputHidden', align: "center", sort: true, title: '文件id'},
{field: 'closeFlag', align: "center", sort: true, title: '开关标识'},
{field: 'sex', align: "center", sort: true, title: '单选'},
{field: 'checkbox', align: "center", sort: true, title: '复选框'},
{field: 'number', align: "center", sort: true, title: '数字'},
{field: 'longText', align: "center", sort: true, title: '长字段'},
{align: 'center', toolbar: '#tableBar', title: '操作'}
]];
};
/**
* 点击查询按钮
*/
EgForm.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
table.reload(EgForm.tableId, {
where: queryData, page: {curr: 1}
});
};
/**
* 弹出添加对话框
*/
EgForm.openAddDlg = function () {
admin.putTempData('formOk', false);
top.layui.admin.open({
type: 2,
title: '添加Guns复杂表单的示例',
content: Feng.ctxPath + '/egForm/add',
end: function () {
admin.getTempData('formOk') && table.reload(EgForm.tableId);
}
});
};
/**
* 导出excel按钮
*/
EgForm.exportExcel = function () {
var checkRows = table.checkStatus(EgForm.tableId);
if (checkRows.data.length === 0) {
Feng.error("请选择要导出的数据");
} else {
table.exportFile(tableResult.config.id, checkRows.data, 'xls');
}
};
/**
* 点击删除
*
* @param data 点击按钮时候的行数据
*/
EgForm.onDeleteItem = function (data) {
var operation = function () {
var ajax = new $ax(Feng.ctxPath + "/egForm/delete", function (data) {
Feng.success("删除成功!");
table.reload(EgForm.tableId);
}, function (data) {
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("formId", data.formId);
ajax.start();
};
Feng.confirm("是否删除?", operation);
};
// 渲染表格
var tableResult = table.render({
elem: '#' + EgForm.tableId,
url: Feng.ctxPath + '/egForm/list',
page: true,
height: "full-98",
cellMinWidth: 100,
cols: EgForm.initColumn()
});
// 搜索按钮点击事件
$('#btnSearch').click(function () {
EgForm.search();
});
// 添加按钮点击事件
$('#btnAdd').click(function () {
window.location.href = Feng.ctxPath + "/egForm/add";
});
// 导出excel
$('#btnExp').click(function () {
EgForm.exportExcel();
});
// 工具条点击事件
table.on('tool(' + EgForm.tableId + ')', function (obj) {
var data = obj.data;
var layEvent = obj.event;
if (layEvent === 'delete') {
EgForm.onDeleteItem(data);
}
});
});
/**
* 详情对话框
*/
var EgFormInfoDlg = {
data: {
title: "",
singleTime: "",
beginTime: "",
endTime: "",
multiSelect: "",
pictureOne: "",
number: "",
singleSelectOne: "",
singleSelectTwo: "",
pictureTwo: "",
longText: ""
}
};
layui.use(['form', 'admin', 'ax', 'upload', 'laydate', 'selectPlus'], function () {
var $ = layui.jquery;
var $ax = layui.ax;
var form = layui.form;
var admin = layui.admin;
var upload = layui.upload;
var laydate = layui.laydate;
var selectPlus = layui.selectPlus;
//初始化时间选择器
laydate.render({
elem: '#singleTime'
, type: 'datetime'
});
laydate.render({
elem: '#betweenTime'
, range: true //或 range: '~' 来自定义分割字符
});
//初始化多选
var test = selectPlus.render({
el: '#multiSelect',
data: [{
"id": 1,
"name": "spring"
}, {
"id": 2,
"name": "shiro"
}, {
"id": 3,
"name": "mybatis-puls"
}, {
"id": 4,
"name": "beetl"
}],
valueName: "name",
values: ['abc'],
valueSeparator: " --- "
});
selectPlus.on('selectPlus(multiSelect)', function (obj) {
console.log(obj.checked); //当前是否选中状态
console.log(obj.values); //选中的数据
console.log(obj.checkedData); //选中的相关数据
console.log(obj.isAll); //是否是全选
console.log(obj.ele); //点击的DOM
$("#multiSelectHidden").val(obj.values);
});
//上传文件
upload.render({
elem: '#fileBtn'
, url: Feng.ctxPath + '/system/upload'
, accept: 'file'
, before: function (obj) {
obj.preview(function (index, file, result) {
$("#fileNameTip").html(file.name);
});
}
, done: function (res) {
$("#fileInputHidden").val(res.data.fileId);
Feng.success(res.message);
}
, error: function () {
Feng.error("上传图片失败!");
}
});
//普通图片上传
upload.render({
elem: '#picBtn'
, url: Feng.ctxPath + '/system/upload'
, before: function (obj) {
obj.preview(function (index, file, result) {
$('#img1').attr('src', result);
});
}
, done: function (res) {
$("#pictureInputHidden").val(res.data.fileId);
Feng.success(res.message);
}
, error: function () {
Feng.error("上传图片失败!");
}
});
//表单提交事件
form.on('submit(btnSubmit)', function (data) {
var ajax = new $ax(Feng.ctxPath + "/egForm/addItem", function (data) {
Feng.success("添加成功!");
//传给上个页面,刷新table用
admin.putTempData('formOk', true);
//关掉对话框
admin.closeThisDialog();
}, function (data) {
Feng.error("添加失败!" + data.responseJSON.message)
});
ajax.set(data.field);
ajax.start();
});
//返回按钮
$("#backupPage").click(function () {
window.location.href = Feng.ctxPath + "/egForm";
});
});
\ No newline at end of file
@layout("/common/_container.html",{plugins:["ztree"],js:["/assets/demos/excel_import.js"]}){
<div class="layui-body-header">
<span class="layui-body-header-title">用户管理</span>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-sm12">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-form toolbar">
<div class="layui-form-item">
<div class="layui-inline">
<button id="btnExp" class="layui-btn icon-btn">
<i class="layui-icon">&#xe67c;</i>导入excel并展示
</button>
</div>
</div>
</div>
<table class="layui-table" id="userTable" lay-filter="userTable"></table>
</div>
</div>
</div>
</div>
</div>
<script type="text/html" id="statusTpl">
<input type="checkbox" lay-filter="status" value="{{d.userId}}" lay-skin="switch" lay-text="正常|冻结" {{d.status=='ENABLE'?'checked':''}} />
</script>
@}
\ No newline at end of file
@layout("/common/_container.html",{js:["/assets/form/egForm.js"],css:["/assets/form/form.css"]}){
<div class="layui-body-header">
<span class="layui-body-header-title">Guns复杂表单的示例管理</span>
</div>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-sm12 layui-col-md12 layui-col-lg12">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-form toolbar">
<div class="layui-form-item">
<div class="layui-inline">
<input id="condition" class="layui-input" type="text" placeholder="名称"/>
</div>
<div class="layui-inline">
<button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
<button id="btnAdd" class="layui-btn icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>
<button id="btnExp" class="layui-btn icon-btn"><i class="layui-icon">&#xe67d;</i>导出</button>
</div>
</div>
</div>
<table class="layui-table" id="egFormTable" lay-filter="egFormTable"></table>
</div>
</div>
</div>
</div>
</div>
<script type="text/html" id="tableBar">
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
</script>
@}
\ No newline at end of file
package com.sql.admin.base;
import com.sql.admin.GunsApplication;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
/**
* 基础测试类
*
* @author stylefeng
* @Date 2017/5/21 16:10
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = GunsApplication.class)
@WebAppConfiguration
//@Transactional //打开的话测试之后数据可自动回滚
public class BaseJunit {
@Autowired
WebApplicationContext webApplicationContext;
protected MockMvc mockMvc;
@Before
public void setupMockMvc() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Before
public void initDatabase() {
}
}
DROP DATABASE IF EXISTS guns_test;
CREATE DATABASE IF NOT EXISTS guns_test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
use guns_test;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for test
-- ----------------------------
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`aaa` int(11) NOT NULL AUTO_INCREMENT,
`bbb` varchar(255) DEFAULT NULL,
PRIMARY KEY (`aaa`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
SET FOREIGN_KEY_CHECKS = 1;
...@@ -14,14 +14,13 @@ ...@@ -14,14 +14,13 @@
<artifactId>wc-admin</artifactId> <artifactId>wc-admin</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<name>guns-vip</name> <name>wc-admin</name>
<description>guns的vip版本</description>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>guns-base-support</module> <module>base-support</module>
<module>guns-vip-main</module> <module>business</module>
</modules> </modules>
<properties> <properties>
......
{"id":"192.168.125.80.tm159911335859200001","wasCommitted":true,"participants":[{"uri":"192.168.125.80.tm1","state":"COMMITTING","expires":1599113371289,"resourceName":"master"}]}
{"id":"192.168.125.80.tm159911335859200001","wasCommitted":true,"participants":[{"uri":"192.168.125.80.tm1","state":"TERMINATED","expires":1599113372496,"resourceName":"master"}]}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment