Skip to content

Commit 043b7de

Browse files
committed
优化命名
1 parent 0198fd2 commit 043b7de

File tree

25 files changed

+113
-114
lines changed

25 files changed

+113
-114
lines changed

hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/GenericEntityController.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@
2020

2121
import org.hswebframework.web.commons.entity.Entity;
2222
import org.hswebframework.web.commons.entity.GenericEntity;
23-
import org.hswebframework.web.controller.message.ResponseMessage;
2423
import org.hswebframework.web.service.CrudService;
25-
import org.springframework.web.bind.annotation.PathVariable;
26-
import org.springframework.web.bind.annotation.RequestBody;
27-
28-
import static org.hswebframework.web.controller.message.ResponseMessage.ok;
2924

3025
/**
3126
* 通用实体的增删改查控制器
@@ -39,11 +34,4 @@ public interface GenericEntityController<E extends GenericEntity<PK>, PK, Q exte
3934
extends CrudController<E, PK, Q> {
4035

4136
CrudService<E, PK> getService();
42-
43-
@Override
44-
default ResponseMessage updateByPrimaryKey(@PathVariable PK id, @RequestBody E data) {
45-
// 设置id属性
46-
data.setId(id);
47-
return ok(getService().updateByPk(data));
48-
}
4937
}

hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/GenericEntityUpdateController.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/QueryController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.hswebframework.web.controller;
1919

20+
import org.hswebframework.web.NotFoundException;
2021
import org.hswebframework.web.authorization.Permission;
2122
import org.hswebframework.web.authorization.annotation.Authorize;
2223
import org.hswebframework.web.commons.entity.Entity;
@@ -71,7 +72,12 @@ default ResponseMessage list(Q param) {
7172
@GetMapping(path = "/{id}")
7273
@AccessLogger("{get_by_id}")
7374
default ResponseMessage getByPrimaryKey(@PathVariable PK id) {
74-
return ok(getService().selectByPk(id));
75+
return ok(assertNotNull(getService().selectByPk(id)));
76+
}
77+
78+
static Object assertNotNull(Object obj) {
79+
if (null == obj) throw new NotFoundException("{data_not_exist}");
80+
return obj;
7581
}
7682

7783
}

hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/UpdateController.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
package org.hswebframework.web.controller;
1919

20+
2021
import org.hswebframework.web.authorization.Permission;
2122
import org.hswebframework.web.authorization.annotation.Authorize;
2223
import org.hswebframework.web.controller.message.ResponseMessage;
2324
import org.hswebframework.web.logging.AccessLogger;
25+
import org.hswebframework.web.service.UpdateService;
2426
import org.springframework.web.bind.annotation.PathVariable;
2527
import org.springframework.web.bind.annotation.PutMapping;
2628
import org.springframework.web.bind.annotation.RequestBody;
@@ -31,8 +33,12 @@
3133
* @author zhouhao
3234
*/
3335
public interface UpdateController<E, PK> {
36+
UpdateService<E, PK> getService();
37+
3438
@Authorize(action = Permission.ACTION_UPDATE)
3539
@PutMapping(path = "/{id}")
3640
@AccessLogger("{update_by_primary_key}")
37-
ResponseMessage updateByPrimaryKey(@PathVariable PK id, @RequestBody E data);
41+
default ResponseMessage updateByPrimaryKey(@PathVariable PK id, @RequestBody E data) {
42+
return ResponseMessage.ok(getService().updateByPk(id, data));
43+
}
3844
}

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/CrudDao.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,26 @@
1919
package org.hswebframework.web.dao;
2020

2121
import org.hswebframework.web.dao.dynamic.UpdateByEntityDao;
22-
import org.hswebframework.web.dao.dynamic.DeleteByBeanDao;
23-
import org.hswebframework.web.dao.dynamic.QueryByBeanDao;
22+
import org.hswebframework.web.dao.dynamic.DeleteByEntityDao;
23+
import org.hswebframework.web.dao.dynamic.QueryByEntityDao;
2424

2525
/**
26-
* TODO 完成注释
26+
* 通用增删改查DAO接口,定义了增删改查.以及动态条件查询,修改,删除。
2727
*
28+
* @param <E> PO类型
29+
* @param <PK> 主键类型
2830
* @author zhouhao
31+
* @see InsertDao
32+
* @see DeleteDao
33+
* @see DeleteByEntityDao
34+
* @see UpdateByEntityDao
35+
* @see QueryByEntityDao
36+
* @since 3.0
2937
*/
30-
public interface CrudDao<PO, PK> extends
31-
InsertDao<PO>,
38+
public interface CrudDao<E, PK> extends
39+
InsertDao<E>,
3240
DeleteDao<PK>,
33-
DeleteByBeanDao,
41+
DeleteByEntityDao,
3442
UpdateByEntityDao,
35-
QueryByBeanDao<PO> {
43+
QueryByEntityDao<E> {
3644
}

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/Dao.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
package org.hswebframework.web.dao;
2020

2121
/**
22-
* TODO 完成注释
22+
* Dao的总接口,用于标识类为Dao
2323
*
2424
* @author zhouhao
25+
* @since 3.0
2526
*/
2627
public interface Dao {
2728
}

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/DeleteDao.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,18 @@
1919
package org.hswebframework.web.dao;
2020

2121
/**
22-
* TODO 完成注释
22+
* 通用删除dao
2323
*
24+
* @param <PK> 主键类型
2425
* @author zhouhao
2526
* @since 3.0
2627
*/
27-
public interface DeleteDao<PK> extends Dao{
28+
public interface DeleteDao<PK> extends Dao {
29+
/**
30+
* 根据主键删除数据,并返回被删除数据的数量
31+
*
32+
* @param pk 主键
33+
* @return 删除的数据数量, 理论上此返回值应该为0或者1.
34+
*/
2835
int deleteByPk(PK pk);
2936
}

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/InsertDao.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
package org.hswebframework.web.dao;
2020

2121
/**
22-
* TODO 完成注释
22+
* 通用数据插入DAO接口
2323
*
2424
* @author zhouhao
2525
* @since 3.0
2626
*/
27-
public interface InsertDao<PO> extends Dao {
28-
void insert(PO po);
27+
public interface InsertDao<E> extends Dao {
28+
void insert(E e);
2929
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import org.hswebframework.web.commons.entity.Entity;
2222

2323
/**
24-
* TODO 完成注释
24+
* 根据实体类条件进行删除,删除条件根据实体类进行解析。解析方式和{@link QueryByEntityDao#query}一致
2525
*
2626
* @author zhouhao
2727
* @since 3.0
2828
*/
29-
public interface DeleteByBeanDao {
29+
public interface DeleteByEntityDao {
3030
int delete(Entity entity);
3131
}

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/dynamic/QueryByEntityDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import java.util.List;
2424

2525
/**
26-
* TODO 完成注释
27-
*
26+
* 根据实体类动态查询,可传入特定的实体类进行查询。
27+
* 目前支持{@link org.hswebframework.web.commons.entity.param.QueryParamEntity} 动态查询
2828
* @author zhouhao
2929
* @since 3.0
3030
*/

0 commit comments

Comments
 (0)