update
This commit is contained in:
parent
a7c14b9698
commit
6816ae95b5
42
pom.xml
42
pom.xml
|
|
@ -209,27 +209,6 @@
|
|||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<profiles>
|
||||
<!-- 默认激活 dev 开发环境 -->
|
||||
<!-- production使用 mvn xxx -Pproduction -->
|
||||
<profile>
|
||||
<!-- 本地开发环境 -->
|
||||
<id>development</id>
|
||||
<properties>
|
||||
<profiles.active>dev</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<!-- 生产环境 -->
|
||||
<id>production</id>
|
||||
<properties>
|
||||
<profiles.active>production</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<finalName>blade</finalName>
|
||||
<resources>
|
||||
|
|
@ -263,4 +242,25 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<!-- 默认激活 dev 开发环境 -->
|
||||
<!-- production使用 mvn xxx -Pproduction -->
|
||||
<profile>
|
||||
<!-- 本地开发环境 -->
|
||||
<id>development</id>
|
||||
<properties>
|
||||
<profiles.active>dev</profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<!-- 生产环境 -->
|
||||
<id>production</id>
|
||||
<properties>
|
||||
<profiles.active>production</profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<properties>
|
||||
<Property name="logdir">${sys:catalina.base}/logs/springblade</Property>
|
||||
<!-- 日志切割的最小单位 -->
|
||||
<property name="EVERY_FILE_SIZE">100M</property>
|
||||
<property name="EVERY_FILE_SIZE">10M</property>
|
||||
</properties>
|
||||
<appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
|
|
|
|||
|
|
@ -1,52 +1,52 @@
|
|||
package com.smallchill.test.example.excel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
|
||||
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.smallchill.core.base.controller.BladeController;
|
||||
|
||||
public class ExampleExcel extends BladeController {
|
||||
|
||||
/**
|
||||
* excel视图方式
|
||||
*/
|
||||
@RequestMapping("/export")
|
||||
public String exportMerchantProfitQuery(ModelMap modelMap,
|
||||
HttpServletResponse response) {
|
||||
List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
|
||||
entityList.add(new ExcelExportEntity("商户名称", "merchantName", 35));
|
||||
entityList.add(new ExcelExportEntity("商户号", "merchantId", 15));
|
||||
entityList.add(new ExcelExportEntity("商户类型", "merchantType", 15));
|
||||
entityList.add(new ExcelExportEntity("联系人", "userName", 15));
|
||||
entityList.add(new ExcelExportEntity("总分润", "allProfit", 15));
|
||||
List<Map<String, String>> dataResult = new ArrayList<Map<String, String>>();
|
||||
Map<String, String> map;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
map = new HashMap<String, String>();
|
||||
map.put("merchantName", "1" + i);
|
||||
map.put("merchantId", "2" + i);
|
||||
map.put("merchantType", "大中华");
|
||||
map.put("userName", "abc" + i);
|
||||
map.put("allProfit", "def" + i);
|
||||
dataResult.add(map);
|
||||
}
|
||||
|
||||
modelMap.put(MapExcelConstants.ENTITY_LIST, entityList);
|
||||
modelMap.put(MapExcelConstants.MAP_LIST, dataResult);
|
||||
modelMap.put(MapExcelConstants.FILE_NAME, "商户利润");
|
||||
modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("商户利润详情", "商户"));
|
||||
return MapExcelConstants.JEECG_MAP_EXCEL_VIEW;
|
||||
}
|
||||
|
||||
}
|
||||
package com.smallchill.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
|
||||
import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.smallchill.core.base.controller.BladeController;
|
||||
|
||||
public class ExcelTest extends BladeController {
|
||||
|
||||
/**
|
||||
* excel视图方式
|
||||
*/
|
||||
@RequestMapping("/export")
|
||||
public String exportMerchantProfitQuery(ModelMap modelMap,
|
||||
HttpServletResponse response) {
|
||||
List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
|
||||
entityList.add(new ExcelExportEntity("商户名称", "merchantName", 35));
|
||||
entityList.add(new ExcelExportEntity("商户号", "merchantId", 15));
|
||||
entityList.add(new ExcelExportEntity("商户类型", "merchantType", 15));
|
||||
entityList.add(new ExcelExportEntity("联系人", "userName", 15));
|
||||
entityList.add(new ExcelExportEntity("总分润", "allProfit", 15));
|
||||
List<Map<String, String>> dataResult = new ArrayList<Map<String, String>>();
|
||||
Map<String, String> map;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
map = new HashMap<String, String>();
|
||||
map.put("merchantName", "1" + i);
|
||||
map.put("merchantId", "2" + i);
|
||||
map.put("merchantType", "大中华");
|
||||
map.put("userName", "abc" + i);
|
||||
map.put("allProfit", "def" + i);
|
||||
dataResult.add(map);
|
||||
}
|
||||
|
||||
modelMap.put(MapExcelConstants.ENTITY_LIST, entityList);
|
||||
modelMap.put(MapExcelConstants.MAP_LIST, dataResult);
|
||||
modelMap.put(MapExcelConstants.FILE_NAME, "商户利润");
|
||||
modelMap.put(NormalExcelConstants.PARAMS, new ExportParams("商户利润详情", "商户"));
|
||||
return MapExcelConstants.JEECG_MAP_EXCEL_VIEW;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
package com.smallchill.test.example.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.smallchill.core.base.controller.BladeController;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.platform.model.Notice;
|
||||
|
||||
/**
|
||||
* javabean模块
|
||||
*
|
||||
*/
|
||||
public class ExampleBlade extends BladeController{
|
||||
|
||||
public void one(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
//根据主键值查询一条数据
|
||||
Notice notice = dao.findById(getParameter("id"));
|
||||
System.out.println(notice);
|
||||
}
|
||||
|
||||
public void more(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
//指定表名、查询条件查询多条数据
|
||||
List<Notice> list = dao.findBy("tb_tfw_tzgg", "f_it_xl = #{xl},f_it_cjr = #{cjr}", Paras.create().set("xl", 1).set("cjr", 1));
|
||||
System.out.println(list);
|
||||
}
|
||||
|
||||
public void other(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
//指定表名、查询条件查询多条数据(完整sql)
|
||||
List<Notice> list = dao.find("select * from tb_tfw_tzgg where f_it_xl = #{xl} and f_it_cjr = #{cjr}", Paras.create().set("xl", 1).set("cjr", 1));
|
||||
System.out.println(list);
|
||||
}
|
||||
|
||||
public void save(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
//自动映射前缀为notice.xx类型的数据
|
||||
//uri : /notice/save?notice.f_vc_bt=123¬ice.f_dt_cjsj=2016-02-02¬ice.f_it_cjr=1
|
||||
Notice notice = mapping("notice", Notice.class);
|
||||
//根据model新增
|
||||
int id = dao.saveRtId(notice);
|
||||
//新增成功后自动返回id
|
||||
System.out.println(id);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
//自动映射前缀为notice.xx类型的数据
|
||||
Notice notice = mapping("notice", Notice.class);
|
||||
//根据model修改
|
||||
dao.update(notice);
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
//指定表名、字段名根据传入的集合删除多条数据
|
||||
dao.deleteByIds("1,2,3,4,5");
|
||||
}
|
||||
|
||||
public void count(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
Notice notice = new Notice();
|
||||
notice.setF_vc_bt("this is title");
|
||||
//查询出tb_tfw_tzgg表所有f_vc_bt字段值为"this is title"的总数
|
||||
dao.count(notice);
|
||||
}
|
||||
|
||||
public void countBy(){
|
||||
Blade dao = Blade.create(Notice.class);
|
||||
//查询出tb_tfw_tzgg表所有f_vc_bt字段值为"this is title"并且f_it_cjr字段为1的总数
|
||||
dao.count("f_vc_bt = #{bt} and f_it_cjr = #{cjr}", Paras.create().set("bt", "this is title").set("cjr", 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package com.smallchill.test.example.intercept;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.smallchill.core.aop.Invocation;
|
||||
import com.smallchill.core.intercept.BladeInterceptor;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
|
||||
public class ExampleIntercept extends BladeInterceptor {
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation inv) {
|
||||
|
||||
//在controller中使用
|
||||
//@Before(ExampleIntercept.class)
|
||||
//可以在执行方法前先执行ExampleIntercept的intercept方法
|
||||
//这样达到细粒度拦截的目的
|
||||
//controller方法必须带有@ResponseBody注解
|
||||
|
||||
HttpServletRequest request = inv.getRequest();
|
||||
String test = request.getParameter("test");
|
||||
if (StrKit.notBlank(test)) {
|
||||
return invoke();
|
||||
} else {
|
||||
return result.addError("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package com.smallchill.test.example.intercept;
|
||||
|
||||
import com.smallchill.common.vo.User;
|
||||
import com.smallchill.core.aop.Invocation;
|
||||
import com.smallchill.core.intercept.BladeValidator;
|
||||
import com.smallchill.core.plugins.dao.Blade;
|
||||
import com.smallchill.core.toolbox.Paras;
|
||||
import com.smallchill.core.toolbox.kit.StrKit;
|
||||
|
||||
public class ExampleValidator extends BladeValidator{
|
||||
|
||||
@Override
|
||||
protected void doValidate(Invocation inv) {
|
||||
|
||||
//在controller中使用
|
||||
//@Before(ExampleValidator.class)
|
||||
//可以在执行方法前先执行ExampleIntercept的doValidate方法
|
||||
//这样达到细粒度拦截的目的
|
||||
//controller方法必须带有@ResponseBody注解
|
||||
//例如请求uri为:/test/validate?abc.account=123&abc.email=123&abc.password=1
|
||||
//这样就会按照执行顺序进行后端校验,如果当中有一个出错则直接返回错误信息
|
||||
|
||||
validateRequired("abc.account", "请输入账号");
|
||||
validateAccount("abc.account", "该账号已存在");
|
||||
validateRequired("abc.name", "请输入姓名");
|
||||
validateEmail("abc.email", "请输入正确的邮箱");
|
||||
validateString("abc.password", 5, 20, "请输入5到20位的密码");
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义校验方法
|
||||
* 可以数据库交互,推荐dao工具为Blade或者Blade
|
||||
* Blade针对于javabean,Blade针对于通用模型
|
||||
*/
|
||||
protected void validateAccount(String field, String errorMessage) {
|
||||
String account = request.getParameter(field);
|
||||
if (StrKit.isBlank(account)) {
|
||||
addError("请输入账号!");
|
||||
}
|
||||
if (Blade.create(User.class).isExist("SELECT * FROM tfw_user WHERE account = #{account} and status=1", Paras.create().set("account", account))) {
|
||||
addError(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.test.other;
|
||||
package com.smallchill.test.proxy;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.smallchill.test.other;
|
||||
package com.smallchill.test.proxy;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
Loading…
Reference in New Issue
Block a user