-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugin handle manage
- Loading branch information
Showing
13 changed files
with
668 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
soul-admin/src/main/java/org/dromara/soul/admin/controller/PluginHandleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package org.dromara.soul.admin.controller; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import org.dromara.soul.admin.dto.PluginHandleDTO; | ||
import org.dromara.soul.admin.page.CommonPager; | ||
import org.dromara.soul.admin.page.PageParameter; | ||
import org.dromara.soul.admin.query.PluginHandleQuery; | ||
import org.dromara.soul.admin.result.SoulAdminResult; | ||
import org.dromara.soul.admin.service.PluginHandleService; | ||
import org.dromara.soul.admin.vo.PluginHandleVO; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* this is a plugin handle controller. | ||
* @author liangziqiang. | ||
*/ | ||
@RestController | ||
@RequestMapping("/plugin-handle") | ||
public class PluginHandleController { | ||
private final PluginHandleService pluginHandleService; | ||
|
||
@Autowired(required = false) | ||
public PluginHandleController(final PluginHandleService pluginHandleService) { | ||
this.pluginHandleService = pluginHandleService; | ||
} | ||
|
||
/** | ||
* query plugin handle by plugin id. | ||
* @param pluginId plugin id. | ||
* @param currentPage current page. | ||
* @param pageSize page size | ||
* @return {@linkplain SoulAdminResult} | ||
*/ | ||
@GetMapping("") | ||
public SoulAdminResult queryPluginHandles(final String pluginId, final Integer currentPage, final Integer pageSize) { | ||
CommonPager<PluginHandleVO> commonPager = pluginHandleService.listByPage(new PluginHandleQuery(pluginId, new PageParameter(currentPage, pageSize))); | ||
return SoulAdminResult.success("query plugin handle success", commonPager); | ||
} | ||
|
||
/** | ||
* query plugin handle by plugin id. | ||
* @param pluginId plugin id. | ||
* @return {@linkplain SoulAdminResult} | ||
*/ | ||
@GetMapping("/all/{pluginId}") | ||
public SoulAdminResult queryAllPluginHandlesByPluginId(@PathVariable("pluginId") final String pluginId) { | ||
List<PluginHandleVO> pluginHandleVOS = pluginHandleService.list(pluginId); | ||
return SoulAdminResult.success("query plugin handle success", pluginHandleVOS); | ||
} | ||
|
||
/** | ||
* detail rule. | ||
* | ||
* @param id rule id. | ||
* @return {@linkplain SoulAdminResult} | ||
*/ | ||
@GetMapping("/{id}") | ||
public SoulAdminResult detailRule(@PathVariable("id") final String id) { | ||
PluginHandleVO pluginHandleVO = pluginHandleService.findById(id); | ||
return SoulAdminResult.success("detail plugin handle success", pluginHandleVO); | ||
} | ||
|
||
/** | ||
* create plugin handle. | ||
* @param pluginHandleDTO {@link PluginHandleDTO} | ||
* @return {@link SoulAdminResult} | ||
*/ | ||
@PostMapping("") | ||
public SoulAdminResult createPluginHandle(@RequestBody final PluginHandleDTO pluginHandleDTO) { | ||
Integer createCount = pluginHandleService.createOrUpdate(pluginHandleDTO); | ||
return SoulAdminResult.success("add plugin handle success", createCount); | ||
} | ||
|
||
/** | ||
* update plugin handle by id. | ||
* @param id plugin handle id | ||
* @param pluginHandleDTO {@linkplain PluginHandleDTO} | ||
* @return {@linkplain SoulAdminResult} | ||
*/ | ||
@PutMapping("/{id}") | ||
public SoulAdminResult updatePluginHandle(@PathVariable("id") final String id, @RequestBody final PluginHandleDTO pluginHandleDTO) { | ||
Objects.requireNonNull(pluginHandleDTO); | ||
pluginHandleDTO.setId(id); | ||
Integer updateCount = pluginHandleService.createOrUpdate(pluginHandleDTO); | ||
return SoulAdminResult.success("update plugin handle success", updateCount); | ||
} | ||
|
||
/** | ||
* batch delete some plugin handles by some id list. | ||
* @param ids plugin handle id list. | ||
* @return {@linkplain SoulAdminResult} | ||
*/ | ||
@DeleteMapping("/batch") | ||
public SoulAdminResult deletePluginHandles(@RequestBody final List<String> ids) { | ||
Integer deleteCount = pluginHandleService.deletePluginHandles(ids); | ||
return SoulAdminResult.success("delete plugin handle success", deleteCount); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
soul-admin/src/main/java/org/dromara/soul/admin/dto/PluginHandleDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.dromara.soul.admin.dto; | ||
|
||
import java.io.Serializable; | ||
import lombok.Data; | ||
|
||
/** | ||
* this plugin handle from web front. | ||
* @author liangziqiang | ||
*/ | ||
@Data | ||
public class PluginHandleDTO implements Serializable { | ||
/** | ||
* primary key. | ||
*/ | ||
private String id; | ||
|
||
/** | ||
* plugin id. | ||
*/ | ||
private String pluginId; | ||
|
||
/** | ||
* the attribute name. | ||
*/ | ||
private String field; | ||
|
||
/** | ||
* the attribute label. | ||
*/ | ||
private String label; | ||
|
||
/** | ||
* the data type. | ||
* 1 indicates number | ||
* 2 indicates string | ||
*/ | ||
private Integer dataType; | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
soul-admin/src/main/java/org/dromara/soul/admin/entity/PluginHandleDO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.dromara.soul.admin.entity; | ||
|
||
import java.util.Objects; | ||
import lombok.Data; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.dromara.soul.admin.dto.PluginHandleDTO; | ||
import org.dromara.soul.common.utils.UUIDUtils; | ||
|
||
/** | ||
* plugin handle json definition. | ||
* @author liangziqiang | ||
*/ | ||
@Data | ||
public class PluginHandleDO extends BaseDO { | ||
|
||
/** | ||
* plugin id. | ||
*/ | ||
private String pluginId; | ||
|
||
/** | ||
* the attribute name. | ||
*/ | ||
private String field; | ||
|
||
/** | ||
* the attribute label. | ||
*/ | ||
private String label; | ||
|
||
/** | ||
* the data type. | ||
* 1 indicates number | ||
* 2 indicates string | ||
*/ | ||
private Integer dataType; | ||
|
||
/** | ||
* build {@linkplain PluginHandleDO} instance. | ||
* @param pluginHandleDTO {@linkplain PluginHandleDTO} | ||
* @return {@linkplain PluginHandleDO} | ||
*/ | ||
public static PluginHandleDO buildPluginHandleDO(final PluginHandleDTO pluginHandleDTO) { | ||
if (Objects.isNull(pluginHandleDTO)) { | ||
return null; | ||
} | ||
|
||
PluginHandleDO pluginHandleDO = new PluginHandleDO(); | ||
pluginHandleDO.setId(pluginHandleDTO.getId()); | ||
pluginHandleDO.setPluginId(pluginHandleDTO.getPluginId()); | ||
pluginHandleDO.setField(pluginHandleDTO.getField()); | ||
pluginHandleDO.setLabel(pluginHandleDTO.getLabel()); | ||
pluginHandleDO.setDataType(pluginHandleDTO.getDataType()); | ||
if (StringUtils.isEmpty(pluginHandleDTO.getId())) { | ||
pluginHandleDO.setId(UUIDUtils.getInstance().generateShortUuid()); | ||
} | ||
return pluginHandleDO; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
soul-admin/src/main/java/org/dromara/soul/admin/mapper/PluginHandleMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.dromara.soul.admin.mapper; | ||
|
||
import java.util.List; | ||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
import org.dromara.soul.admin.entity.PluginHandleDO; | ||
import org.dromara.soul.admin.query.PluginHandleQuery; | ||
|
||
/** | ||
* The interface Plugin handle mapper. | ||
* @author liangziqiang | ||
*/ | ||
@Mapper | ||
public interface PluginHandleMapper { | ||
|
||
/** | ||
* Select plugin handle by id. | ||
* @param id the id. | ||
* @return the plugin handle do. | ||
*/ | ||
PluginHandleDO selectById(@Param("id") String id); | ||
|
||
/** | ||
* find plugin handle do list by plugin id. | ||
* @param pluginId the pluginId | ||
* @return the list | ||
*/ | ||
List<PluginHandleDO> findByPluginId(@Param("pluginId") String pluginId); | ||
|
||
/** | ||
* insert plugin handle. | ||
* @param record {@link PluginHandleDO} | ||
* @return affected rows | ||
*/ | ||
int insert(PluginHandleDO record); | ||
|
||
/** | ||
* insert selective plugin handle. | ||
* @param record {@link PluginHandleDO} | ||
* @return affected rows. | ||
*/ | ||
int insertSelective(PluginHandleDO record); | ||
|
||
/** | ||
* count plugin handle by query. | ||
* @param pluginHandleQuery {@linkplain PluginHandleQuery} | ||
* @return the count | ||
*/ | ||
int countByQuery(PluginHandleQuery pluginHandleQuery); | ||
|
||
/** | ||
* select plugin handle list by query. | ||
* @param pluginHandleQuery {@linkplain PluginHandleQuery} | ||
* @return the plugin handle list | ||
*/ | ||
List<PluginHandleDO> selectByQuery(PluginHandleQuery pluginHandleQuery); | ||
|
||
/** | ||
* update some selective columns in plugin_handle. | ||
* @param record {@linkplain PluginHandleDO} | ||
* @return affected rows | ||
*/ | ||
int updateByPrimaryKeySelective(PluginHandleDO record); | ||
|
||
/** | ||
* update plugin handle by primary key. | ||
* @param record {@linkplain PluginHandleDO} | ||
* @return affected rows. | ||
*/ | ||
int updateByPrimaryKey(PluginHandleDO record); | ||
|
||
/** | ||
* delete string id. | ||
* @param id plugin handle id | ||
* @return affected rows | ||
*/ | ||
int delete(String id); | ||
} |
25 changes: 25 additions & 0 deletions
25
soul-admin/src/main/java/org/dromara/soul/admin/query/PluginHandleQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.dromara.soul.admin.query; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.dromara.soul.admin.page.PageParameter; | ||
|
||
/** | ||
* this is plugin handle query. | ||
* @author liangziqiang | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class PluginHandleQuery { | ||
/** | ||
* plugin id. | ||
*/ | ||
private String pluginId; | ||
|
||
/** | ||
* page parameter. | ||
*/ | ||
private PageParameter pageParameter; | ||
} |
48 changes: 48 additions & 0 deletions
48
soul-admin/src/main/java/org/dromara/soul/admin/service/PluginHandleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.dromara.soul.admin.service; | ||
|
||
import java.util.List; | ||
import org.dromara.soul.admin.dto.PluginHandleDTO; | ||
import org.dromara.soul.admin.page.CommonPager; | ||
import org.dromara.soul.admin.query.PluginHandleQuery; | ||
import org.dromara.soul.admin.vo.PluginHandleVO; | ||
|
||
/** | ||
* this is plugin handle service. | ||
* @author liangziqiang | ||
*/ | ||
public interface PluginHandleService { | ||
/** | ||
* find page of rule by query. | ||
* @param pluginHandleQuery {@linkplain PluginHandleQuery} | ||
* @return {@link CommonPager} | ||
*/ | ||
CommonPager<PluginHandleVO> listByPage(PluginHandleQuery pluginHandleQuery); | ||
|
||
/** | ||
* create or update plugin handle. | ||
* @param pluginHandleDTO {@linkplain PluginHandleDTO} | ||
* @return affected rows | ||
*/ | ||
Integer createOrUpdate(PluginHandleDTO pluginHandleDTO); | ||
|
||
/** | ||
* delete plugin handles. | ||
* @param ids ids to delete | ||
* @return The number of rows deleted | ||
*/ | ||
Integer deletePluginHandles(List<String> ids); | ||
|
||
/** | ||
* find plugin handle by id. | ||
* @param id plugin handle id. | ||
* @return {@linkplain PluginHandleVO} | ||
*/ | ||
PluginHandleVO findById(String id); | ||
|
||
/** | ||
* find plugin handle list by plugin id. | ||
* @param pluginId the plugin id. | ||
* @return plugin handle list. | ||
*/ | ||
List<PluginHandleVO> list(String pluginId); | ||
} |
Oops, something went wrong.