|
@ -0,0 +1,98 @@
|
|
|
package com.yihu.jw.base.endpoint.servicePackage;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.base.service.servicePackage.ServicePackageISubtemService;
|
|
|
import com.yihu.jw.base.util.ConstantUtils;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServicePackageSubItemDO;
|
|
|
import com.yihu.jw.restmodel.qvo.ParamQvo;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author yeshijie on 2021/2/23.
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping(value = "servicePackageSubItem", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@Api(value = "服务子项管理", description = "服务子项管理", tags = {"wlyy基础服务 - 服务项管理服务接口"})
|
|
|
public class ServicePackageSubItemEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
@Autowired
|
|
|
private ServicePackageISubtemService subItemService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询所有服务子项
|
|
|
*/
|
|
|
@GetMapping(value = "getItemList")
|
|
|
@ApiOperation(value = "查询所有服务项")
|
|
|
public PageEnvelop<Map<String, Object>> getSubItemList(
|
|
|
@ApiParam(name = "jsonStr", value = "Json数据", required = true) @RequestParam String jsonStr
|
|
|
) throws Exception {
|
|
|
ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
|
|
|
Map<String, Object> map = subItemService.getSubItemList(qvo);
|
|
|
List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("list");
|
|
|
Integer count = (Integer) map.get("count");
|
|
|
return success(list, count, qvo.getPage(), qvo.getPageSize());
|
|
|
}
|
|
|
|
|
|
|
|
|
@PostMapping(value = "createSubItem")
|
|
|
@ApiOperation(value = "创建服务子项")
|
|
|
public Envelop createSubItem(
|
|
|
@ApiParam(name = "jsonStr", value = "Json数据", required = true) @RequestParam String jsonStr) throws Exception {
|
|
|
ServicePackageSubItemDO subItemDO = toEntity(jsonStr, ServicePackageSubItemDO.class);
|
|
|
JSONObject result = subItemService.createSubItem(subItemDO);
|
|
|
if (StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL, result.getString("response"))) {
|
|
|
return failed(result.getString("msg"));
|
|
|
}
|
|
|
return success(result.get("msg"));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 改变状态
|
|
|
*/
|
|
|
@PostMapping(value = "changeState")
|
|
|
@ApiOperation(value = "改变状态")
|
|
|
public ObjEnvelop changeState(
|
|
|
@ApiParam(name = "jsonStr", value = "jsonStr", required = true) @RequestParam String jsonStr) throws Exception {
|
|
|
try {
|
|
|
ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(qvo.getId())) {
|
|
|
return failed("ID不能为空", ObjEnvelop.class);
|
|
|
}
|
|
|
System.out.println("参数:" + JSON.toJSONString(qvo));
|
|
|
ServicePackageSubItemDO entity = subItemService.changeState(qvo);
|
|
|
return success(entity);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return failedObjEnvelopException(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@PostMapping(value = "deleteById")
|
|
|
@ApiOperation(value = "删除")
|
|
|
public Envelop delete(
|
|
|
@ApiParam(name = "ids", value = "id串,中间用,分隔", required = true) @RequestParam(value = "ids") String ids) throws Exception {
|
|
|
subItemService.deleteById(ids);
|
|
|
return success("删除成功");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|