package cn.autoform.web.controller.publish;
|
|
import java.io.IOException;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import cn.autoform.db.entity.FormBaseEntity;
|
import cn.autoform.fw.exception.RestResult;
|
import cn.autoform.fw.utility.RestResultGenerator;
|
import cn.autoform.web.service.publish.PublishService;
|
|
@RestController
|
public class PublishController<T> {
|
|
@Autowired
|
private PublishService publishService = null;
|
|
@Value("${server.publishurl}")
|
private String publishurl;
|
|
/**
|
* 取得表单设置的密码
|
* @param tenantID
|
* @param formID
|
* @return
|
*/
|
@RequestMapping(value = "${requset.publish01}", method = RequestMethod.GET)
|
public RestResult<Map<String,String>> getPublishPasswordService(String tenantID, String formID) {
|
|
Map<String,String> rsMap = new HashMap<String,String>();
|
List<FormBaseEntity> listFormBaseEntity = publishService.getPublishInfo(tenantID, formID);
|
rsMap.put("requirepassword", listFormBaseEntity.get(0).getRequirepassword());
|
rsMap.put("accesspassword", listFormBaseEntity.get(0).getAccesspassword());
|
|
return RestResultGenerator.genSuccessResult(rsMap);
|
}
|
|
/**
|
* 初期化表单发布信息
|
* @param tenantID
|
* @param formID
|
* @return
|
*/
|
@RequestMapping(value = "${requset.publish02}", method = RequestMethod.GET)
|
public RestResult<Map<String,Object>> getPublishInfoService(String tenantID, String formID) {
|
Map<String,Object> rsMap = new HashMap<String,Object>();
|
List<FormBaseEntity> listFormBaseEntity = publishService.getPublishInfo(tenantID, formID);
|
String publishURL = publishurl + "/" + tenantID + "/" + formID;
|
if(listFormBaseEntity.isEmpty()) {
|
FormBaseEntity formBase = new FormBaseEntity();
|
formBase.setPublishURL(publishURL);
|
formBase.setRequirepassword("0");
|
rsMap.put("isPublish", "0");
|
rsMap.put("formbase", formBase);
|
|
} else {
|
|
FormBaseEntity formBase = listFormBaseEntity.get(0);
|
if(formBase.getPublishURL() == null){
|
|
formBase.setPublishURL(publishURL);
|
rsMap.put("isPublish", "0");
|
rsMap.put("formbase", formBase);
|
} else {
|
rsMap.put("isPublish", "1");
|
rsMap.put("formbase", formBase);
|
}
|
}
|
|
|
return RestResultGenerator.genSuccessResult(rsMap);
|
}
|
|
/**
|
* 更新表单发布信息
|
* @param formBaseEntity
|
* @return
|
*/
|
@RequestMapping(value = "${requset.publish03}", method = RequestMethod.POST)
|
public RestResult<String> updatePublishInfoService(@RequestBody FormBaseEntity formBaseEntity) {
|
int nRs = publishService.updatePublishInfo(formBaseEntity);
|
|
return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
|
}
|
|
|
|
@RequestMapping(value = "${requset.publish04}", method = RequestMethod.GET)
|
public RestResult<String> downloadPageService(String formID,String tenantID) throws IOException {
|
String url = publishurl + "/" + tenantID + "/" + formID;
|
String path = publishService.downloadPage(url,formID,tenantID);
|
|
return RestResultGenerator.genSuccessResult(path);
|
}
|
}
|