增加启用,禁用接口

This commit is contained in:
zhouhao
2017-08-16 14:52:25 +08:00
parent ac9424c89f
commit 0b5136ab62
3 changed files with 40 additions and 4 deletions

View File

@@ -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();
}
}

View File

@@ -31,4 +31,7 @@ public interface OrganizationalService extends
TreeService<OrganizationalEntity, String>
, CrudService<OrganizationalEntity, String> {
void disable(String id);
void enable(String id);
}

View File

@@ -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();
}
}