mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-09 01:14:16 +08:00
增加启用,禁用接口
This commit is contained in:
@@ -31,10 +31,7 @@ import org.hswebframework.web.entity.organizational.PersonEntity;
|
||||
import org.hswebframework.web.logging.AccessLogger;
|
||||
import org.hswebframework.web.service.organizational.OrganizationalService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -69,4 +66,20 @@ public class OrganizationalController implements SimpleGenericEntityController<O
|
||||
organizationalService.updateBatch(batch);
|
||||
return ResponseMessage.ok();
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/disable")
|
||||
@Authorize(action = Permission.ACTION_DISABLE)
|
||||
@AccessLogger("禁用机构")
|
||||
public ResponseMessage<Boolean> disable(@PathVariable String id) {
|
||||
organizationalService.disable(id);
|
||||
return ResponseMessage.ok();
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/enable")
|
||||
@Authorize(action = Permission.ACTION_ENABLE)
|
||||
@AccessLogger("启用机构")
|
||||
public ResponseMessage<Boolean> enable(@PathVariable String id) {
|
||||
organizationalService.enable(id);
|
||||
return ResponseMessage.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,7 @@ public interface OrganizationalService extends
|
||||
TreeService<OrganizationalEntity, String>
|
||||
, CrudService<OrganizationalEntity, String> {
|
||||
|
||||
void disable(String id);
|
||||
|
||||
void enable(String id);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import org.hswebframework.web.service.organizational.OrganizationalService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 默认的服务实现
|
||||
*
|
||||
@@ -51,4 +53,22 @@ public class SimpleOrganizationalService extends AbstractTreeSortService<Organiz
|
||||
entity.setStatus(DataStatus.STATUS_ENABLED);
|
||||
return super.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable(String id) {
|
||||
Objects.requireNonNull(id);
|
||||
createUpdate()
|
||||
.set(OrganizationalEntity.status, DataStatus.STATUS_DISABLED)
|
||||
.where(OrganizationalEntity.id, id)
|
||||
.exec();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable(String id) {
|
||||
Objects.requireNonNull(id);
|
||||
createUpdate()
|
||||
.set(OrganizationalEntity.status, DataStatus.STATUS_ENABLED)
|
||||
.where(OrganizationalEntity.id, id)
|
||||
.exec();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user