Jacky Wong e1efa1a429 服务器停机重启后ip发生变化,修改ip | 4 years ago | |
---|---|---|
.mvn | 4 years ago | |
lib | 5 years ago | |
member-common | 4 years ago | |
member-services | 4 years ago | |
member-services-models | 4 years ago | |
member-web | 4 years ago | |
member-web-common | 4 years ago | |
member-weixin-service | 4 years ago | |
.gitignore | 4 years ago | |
README.md | 4 years ago | |
derby.log | 4 years ago | |
mvnw | 5 years ago | |
mvnw.cmd | 5 years ago | |
pom.xml | 4 years ago | |
updateAndStart.sh | 5 years ago |
使用Spring Boot + Spring-data-jpa 构建 接口文档使用swagger-ui管理, 文档url /doc.html
mvn启动命令mvn -f ./member-web/pom.xml spring-boot:run
服务器部署、启动命令:
screen -r MemberCenter (进入名为MemberCenter的screen)
(如果没有就用 screen -S MemberCenter 创建一个)
cd /usr/local/src/MemberCenter_DW/
git pull origin master
mvn clean package install
export workerid=0
export datacenterid=0
java -Dhttps.proxyHost=192.168.50.32 -Dhttps.proxyPort=1808 -Dhttp.proxyHost=192.168.50.32 -Dhttp.proxyPort=1808 -jar member-web/target/member-web-0.0.1-SNAPSHOT.jar
ctrl + a (松开后按 d) 退出当前screen,让其后台运行
在使用新添加的sql查询导出excel的接口时,因为不知道为什么使用react框架的request来请求时,post不行,使用了blob也不行,就改成了get的方式,参数从sessionStorge里去取,然后编码提交,如下:
{
title:"测试表格",
url:{
read:"/japi/birdgird/readSql?dsId=4028b2a26daf6c2d016db34bc5ca00a5&sqlId=40288ad66df10dc9016df1101fe40001",
add:"/japi/birdgird/add?dsId=4028b2a26daf6c2d016db34bc5ca00a5&tableName=contract",
edit:"/japi/birdgird/edit?dsId=4028b2a26daf6c2d016db34bc5ca00a5&tableName=contract&pkColumn=id",
delete:"/japi/birdgird/delete?dsId=4028b2a26daf6c2d016db34bc5ca00a5&tableName=contract&pkColumn=id"
},
checkable:true,
actions:[{
name:"导出excel", onClick: function() {
let dtoStr = sessionStorage.getItem('queryDto');
dtoStr = encodeURI(dtoStr);
window.location = "http://localhost:8090/sqlExport/export?dsId=4028b2a26daf6c2d016db34bc5ca00a5&sqlId=40288a9d6e357e33016e3598b42a0000&requestStr="+dtoStr;
}
}],
columns:[
{title:"主编号", data:"t.id", type:"text",hide:true},
{title:"名称",data:"t.name", type:"text",editor: {}, query: true},
{title:"个人电话",data:"t.personal_phone", type:"text",editor: {}, query: true},
{title:"个人手机",data:"t.personal_cellphone", type:"text",editor: {}, query: true},
{title:"组名称",data:"t2.name",type:"text"},
{title:"操作",type:"command",actions:[{
name: '行内按钮',
onClick: (data) => {
console.log(data);
}
}]}
],
}
启动时需要添加proxy代理信息:
java -Dhttps.proxyHost=192.168.50.32 -Dhttps.proxyPort=1808 -Dhttp.proxyHost=192.168.50.32 -Dhttp.proxyPort=1808 -jar xxxx.jar
启动时需要添加机器编号和数据中心编号,为了使部分对象生成分布式ID
export workerid=0
export datacenterid=0
java -Dhttps.proxyHost=192.168.50.32 -Dhttps.proxyPort=1808 -Dhttp.proxyHost=192.168.50.32 -Dhttp.proxyPort=1808 -jar xxxx.jar
添加了动态请求查询参数,格式如下:
GET {url}?page=1&size=10
GET {url}?page=1&size=10&sortField=crtDate&sortDirection=DESC
sortField
是需要排序的字段 sortDirection
是升降序GET {url}?name=yourname&age=20&...
非关键字(上面两条中的)的参数,直接视为等于的操作。GET {url}?age=20&ageOperate=LessEqual&...
使用 字段名+Operate
的参数来表示判断类型:操作类型 | 说明 |
---|---|
Equal | 等于(默认) |
NotEqual | 不等于 |
Less | (数字类型)小于 |
LessEqual | (数字类型)不大于 |
Greater | (数字类型)大于 |
GreaterEqual | (数字类型)不小于 |
Contains | (字符串)包含 |
StartWith | (字符串)以开头 |
EndWith | (字符串)以结尾 |
com.liangjian.dataplatform.member.entity.token.DynamicParamGetter
取:
Service层:
//...
@Service
public class YourService extends DynamicQueryService<YourEntity> implements IYourService {
@Autowired
private YourRepository yourRepository;
@Overrive
public JpaSpecificationExecutor<YourEntity> getJpaRepository() {
return yourRepository;
}
//父类已经包含了动态查询返回Page和返回List的方法
}
Controller层:
@Controller
public class YourController {
//...
@Autowired
private IYourService iYourService;
//例子:
@GetMapping("/page")
public Page<YourEntity> page() {
var params = DynamicParamGetter.DynamicParams.get();
return iYourService.queryPageByCondition(params);
}
@GetMapping("/page")
public List<YourEntity> list() {
var params = DynamicParamGetter.DynamicParams.get();
return iYourService.queryListByCondition(params);
}
}
这次直接增加CRUD的逻辑,直接restful风格。
/rest/api/model/{model}/{id}
根据Id获取/rest/api/model/{model}/dynamic/page
根据动态条件分页获取/rest/api/model/{model}/dynamic/list
根据动态条件获取列表/rest/api/model/{model}
添加/rest/api/model/{model}
更新/rest/api/model/{model}/{id}
删除步骤:
@Entity
@Table(name = "test_table")
public class TestTable {
//...
}
public interface TestTableRepository<TestTable,String>
extends JpaRepository<TestTable,String>,
JpaSpecificationExecutor<TestTable> {
//...
}
@Service
public class TestTableService<TestTable> extends DynamicApiService<TestTable> {
//返回model的映射名,在url中需要使用到
@Override
public String getMappedName() { ... }
//获取数据库映射对象的类名,json序列化/反序列化需要
@Override
public Class<TestTable> getModelClass() { ... }
//获取dao层的repository
@Override
public JpaRepository<TestTable,String> getJpaRepository() {...}
//获取dao层复杂查询构造器
@Override
public JpaSpecificationExecutor<TestTable> getJpaSpecificationExecutor(){...}
//下面两个可选实现,因为jpa的save是insert、update一起的,可能需要对id处理
//添加前处理
@Override
public void onAdd(TestTable testTable) { ... }
//更新前处理
@Override
public void onUpdate(TestTable testTable) { ... }
}