提交 18ff8afd 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 1fdf033f
package com.ibiz.service.web.dto;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.math.BigInteger;
import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.math.BigDecimal;
import com.ibiz.core.module2.valuerule.anno.healthcheck.*;
import com.ibiz.core.module2.domain.Healthcheck;
import org.springframework.cglib.beans.BeanCopier;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 服务DTO对象[HealthcheckDTO]
*/
public class HealthcheckDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 属性 [HEALTHCHECKID]
*
*/
@HealthcheckHealthcheckidDefault(info = "默认规则")
private String healthcheckid;
@JsonIgnore
private boolean healthcheckidDirtyFlag;
/**
* 获取 [HEALTHCHECKID]
*/
@JsonProperty("healthcheckid")
public String getHealthcheckid(){
return healthcheckid ;
}
/**
* 设置 [HEALTHCHECKID]
*/
@JsonProperty("healthcheckid")
public void setHealthcheckid(String healthcheckid){
this.healthcheckid = healthcheckid ;
this.healthcheckidDirtyFlag = true ;
}
/**
* 获取 [HEALTHCHECKID]脏标记
*/
@JsonIgnore
public boolean getHealthcheckidDirtyFlag(){
return healthcheckidDirtyFlag ;
}
public Healthcheck toDO() {
Healthcheck srfdomain = new Healthcheck();
if(getHealthcheckidDirtyFlag())
srfdomain.setHealthcheckid(healthcheckid);
return srfdomain;
}
public void fromDO(Healthcheck srfdomain) {
if(srfdomain == null )
return ;
if(srfdomain.getHealthcheckidDirtyFlag())
this.setHealthcheckid(srfdomain.getHealthcheckid());
}
public List<HealthcheckDTO> fromDOPage(List<Healthcheck> poPage) {
if(poPage == null)
return null;
List<HealthcheckDTO> dtos=new ArrayList<HealthcheckDTO>();
for(Healthcheck domain : poPage) {
HealthcheckDTO dto = new HealthcheckDTO();
dto.fromDO(domain);
dtos.add(dto);
}
return dtos;
}
}
package com.ibiz.service.web.resource;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import com.ibiz.service.web.dto.HealthcheckDTO;
import com.ibiz.core.module2.domain.Healthcheck;
import com.ibiz.core.module2.service.IHealthcheckService;
import com.ibiz.util.SearchContext;
import com.ibiz.core.module2.filter.HealthcheckSearchContext;
import com.ibiz.util.log.IBIZLog;
@Slf4j
@IBIZLog
@Api(tags = {"Healthcheck" })
@RestController
@RequestMapping("")
public class HealthcheckResource {
@Autowired
private IHealthcheckService healthcheckService;
public IHealthcheckService getHealthcheckService() {
return this.healthcheckService;
}
@ApiOperation(value = "GetDraft", tags = {"Healthcheck" }, notes = "GetDraft")
@RequestMapping(method = RequestMethod.GET, value = "/web/healthchecks/{healthcheck_id}/getdraft")
public ResponseEntity<HealthcheckDTO> getDraft(@PathVariable("healthcheck_id") String healthcheck_id, @RequestBody HealthcheckDTO healthcheckdto) {
Healthcheck healthcheck = healthcheckdto.toDO();
healthcheck = healthcheckService.getDraft(healthcheck) ;
healthcheckdto.fromDO(healthcheck);
return ResponseEntity.status(HttpStatus.OK).body(healthcheckdto);
}
@ApiOperation(value = "Remove", tags = {"Healthcheck" }, notes = "Remove")
@RequestMapping(method = RequestMethod.DELETE, value = "/web/healthchecks/{healthcheck_id}")
public ResponseEntity<Boolean> remove(@PathVariable("healthcheck_id") String healthcheck_id) {
HealthcheckDTO healthcheckdto = new HealthcheckDTO();
Healthcheck domain = new Healthcheck();
healthcheckdto.setHealthcheckid(healthcheck_id);
domain.setHealthcheckid(healthcheck_id);
Boolean rst = healthcheckService.remove(domain.getHealthcheckid());
if(rst){
return ResponseEntity.status(HttpStatus.OK).body(rst);
}else{
return ResponseEntity.status(HttpStatus.OK).body(rst);
}
}
@ApiOperation(value = "CheckKey", tags = {"Healthcheck" }, notes = "CheckKey")
@RequestMapping(method = RequestMethod.POST, value = "/web/healthchecks/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody HealthcheckDTO healthcheckdto) {
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "Update", tags = {"Healthcheck" }, notes = "Update")
@RequestMapping(method = RequestMethod.PUT, value = "/web/healthchecks/{healthcheck_id}")
public ResponseEntity<HealthcheckDTO> update(@PathVariable("healthcheck_id") String healthcheck_id, @RequestBody HealthcheckDTO healthcheckdto) {
Healthcheck domain = healthcheckdto.toDO();
domain.setHealthcheckid(healthcheck_id);
healthcheckService.update(domain);
HealthcheckDTO dto = new HealthcheckDTO();
dto.fromDO(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "Create", tags = {"Healthcheck" }, notes = "Create")
@RequestMapping(method = RequestMethod.POST, value = "/web/healthchecks")
public ResponseEntity<HealthcheckDTO> create(@RequestBody HealthcheckDTO healthcheckdto) {
HealthcheckDTO dto = new HealthcheckDTO();
Healthcheck domain = healthcheckdto.toDO();
healthcheckService.create(domain);
dto.fromDO(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "test", tags = {"Healthcheck" }, notes = "test")
@RequestMapping(method = RequestMethod.POST, value = "/web/healthchecks/{healthcheck_id}/test")
public ResponseEntity<HealthcheckDTO> test(@PathVariable("healthcheck_id") String healthcheck_id, @RequestBody HealthcheckDTO healthcheckdto) {
Healthcheck healthcheck = healthcheckdto.toDO();
healthcheck = healthcheckService.test(healthcheck) ;
healthcheckdto.fromDO(healthcheck);
return ResponseEntity.status(HttpStatus.OK).body(healthcheckdto);
}
@ApiOperation(value = "Get", tags = {"Healthcheck" }, notes = "Get")
@RequestMapping(method = RequestMethod.GET, value = "/web/healthchecks/{healthcheck_id}")
public ResponseEntity<HealthcheckDTO> get(@PathVariable("healthcheck_id") String healthcheck_id) {
HealthcheckDTO dto = new HealthcheckDTO();
Healthcheck domain = healthcheckService.get(healthcheck_id);
dto.fromDO(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "Save", tags = {"Healthcheck" }, notes = "Save")
@RequestMapping(method = RequestMethod.POST, value = "/web/healthchecks/{healthcheck_id}/save")
public ResponseEntity<Boolean> save(@RequestBody HealthcheckDTO healthcheckdto) {
Healthcheck healthcheck = healthcheckdto.toDO();
Boolean b = healthcheckService.save(healthcheck) ;
return ResponseEntity.status(HttpStatus.OK).body(b);
}
@ApiOperation(value = "获取DEFAULT", tags = {"Healthcheck" } ,notes = "获取DEFAULT")
@RequestMapping(method= RequestMethod.GET , value="/web/healthchecks/fetchdefault")
public ResponseEntity<Page<HealthcheckDTO>> fetchDefault(HealthcheckSearchContext context,Pageable pageable ,ServletRequest request) {
context.setPageable(pageable);
List<HealthcheckDTO> list = new ArrayList<HealthcheckDTO>();
Page<Healthcheck> domains = healthcheckService.searchDefault(context) ;
for(Healthcheck healthcheck : domains.getContent()){
HealthcheckDTO dto = new HealthcheckDTO();
dto.fromDO(healthcheck);
list.add(dto);
}
return ResponseEntity.status(HttpStatus.OK).body(new PageImpl(list,context.getPageable(),domains.getTotalElements()));
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册