|
@ -1,11 +1,14 @@
|
|
package com.yihu.jw.base.endpoint.saas;
|
|
package com.yihu.jw.base.endpoint.saas;
|
|
|
|
|
|
import com.yihu.jw.base.service.saas.SaasTypeDictService;
|
|
import com.yihu.jw.base.service.saas.SaasTypeDictService;
|
|
|
|
import com.yihu.jw.base.service.saas.SaasService;
|
|
import com.yihu.jw.base.service.user.UserService;
|
|
import com.yihu.jw.base.service.user.UserService;
|
|
|
|
import com.yihu.jw.base.util.ErrorCodeUtil;
|
|
import com.yihu.jw.entity.base.saas.SaasDO;
|
|
import com.yihu.jw.entity.base.saas.SaasDO;
|
|
import com.yihu.jw.base.service.saas.SaasService;
|
|
import com.yihu.jw.base.service.saas.SaasService;
|
|
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
|
|
import com.yihu.jw.entity.base.saas.SaasTypeDictDO;
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
import com.yihu.jw.entity.base.user.UserDO;
|
|
|
|
import com.yihu.jw.exception.code.BaseErrorCode;
|
|
import com.yihu.jw.restmodel.base.saas.SaasVO;
|
|
import com.yihu.jw.restmodel.base.saas.SaasVO;
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
@ -37,17 +40,26 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
|
|
private UserService userService;
|
|
private UserService userService;
|
|
@Autowired
|
|
@Autowired
|
|
private SaasTypeDictService saasTypeDictService;
|
|
private SaasTypeDictService saasTypeDictService;
|
|
|
|
@Autowired
|
|
|
|
private ErrorCodeUtil errorCodeUtil;
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.Saas.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
@PostMapping(value = BaseRequestMapping.Saas.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
@ApiOperation(value = "创建")
|
|
@ApiOperation(value = "创建")
|
|
public Envelop create(
|
|
|
|
@ApiParam(name = "saas", value = "Json数据", required = true)
|
|
|
|
@RequestParam(value = "saas") SaasDO saasDO,
|
|
|
|
@ApiParam(name = "user", value = "Json数据", required = true)
|
|
|
|
@RequestParam(value = "user") UserDO userDO) throws Exception {
|
|
|
|
if (userService.search("username=" + userDO.getUsername()).size() > 0) {
|
|
|
|
return failed("管理员用户名已存在", Envelop.class);
|
|
|
|
|
|
public Envelop create (
|
|
|
|
@ApiParam(name = "saasDO", value = "Json数据", required = true)
|
|
|
|
@RequestParam(value = "saasDO") SaasDO saasDO,
|
|
|
|
@ApiParam(name = "userDO", value = "Json数据", required = true)
|
|
|
|
@RequestParam(value = "userDO") UserDO userDO) throws Exception {
|
|
|
|
if (saasService.search("name=" + userDO.getName()).size() > 0) {
|
|
|
|
return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.NAME_IS_EXIST), Envelop.class);
|
|
|
|
}
|
|
|
|
if (userService.search("mobile=" + userDO.getMobile()).size() > 0) {
|
|
|
|
return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.MOBILE_IS_EXIST), Envelop.class);
|
|
|
|
}
|
|
|
|
if (userService.search("username=" + userDO.getEmail()).size() > 0) {
|
|
|
|
return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_EXIST), Envelop.class);
|
|
}
|
|
}
|
|
|
|
userDO.setUsername(userDO.getEmail());
|
|
saasService.save(saasDO, userDO);
|
|
saasService.save(saasDO, userDO);
|
|
return success("创建成功");
|
|
return success("创建成功");
|
|
}
|
|
}
|
|
@ -63,12 +75,12 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.Saas.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
@PostMapping(value = BaseRequestMapping.Saas.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
@ApiOperation(value = "更新")
|
|
@ApiOperation(value = "更新")
|
|
public Envelop update(
|
|
|
|
|
|
public Envelop update (
|
|
@ApiParam(name = "json", value = "Json数据", required = true)
|
|
@ApiParam(name = "json", value = "Json数据", required = true)
|
|
@RequestBody String jsonData) throws Exception {
|
|
@RequestBody String jsonData) throws Exception {
|
|
SaasDO saasDO = toEntity(jsonData, SaasDO.class);
|
|
SaasDO saasDO = toEntity(jsonData, SaasDO.class);
|
|
if (null == saasDO.getId()) {
|
|
if (null == saasDO.getId()) {
|
|
return failed("ID不能为空", Envelop.class);
|
|
|
|
|
|
return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Common.ID_IS_NULL), Envelop.class);
|
|
}
|
|
}
|
|
saasDO = saasService.save(saasDO);
|
|
saasDO = saasService.save(saasDO);
|
|
return success(saasDO);
|
|
return success(saasDO);
|
|
@ -76,7 +88,7 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
@GetMapping(value = BaseRequestMapping.Saas.PAGE)
|
|
@GetMapping(value = BaseRequestMapping.Saas.PAGE)
|
|
@ApiOperation(value = "获取分页")
|
|
@ApiOperation(value = "获取分页")
|
|
public PageEnvelop<SaasVO> page(
|
|
|
|
|
|
public PageEnvelop<SaasVO> page (
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
@ -88,13 +100,13 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
|
|
@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
@RequestParam(value = "size") int size) throws Exception {
|
|
@RequestParam(value = "size") int size) throws Exception {
|
|
List<SaasDO> saasDOS = saasService.search(fields, filters, sorts, page, size);
|
|
List<SaasDO> saasDOS = saasService.search(fields, filters, sorts, page, size);
|
|
int count = (int) saasService.getCount(filters);
|
|
|
|
|
|
int count = (int)saasService.getCount(filters);
|
|
return success(saasDOS, count, page, size, SaasVO.class);
|
|
return success(saasDOS, count, page, size, SaasVO.class);
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping(value = BaseRequestMapping.Saas.LIST)
|
|
@GetMapping(value = BaseRequestMapping.Saas.LIST)
|
|
@ApiOperation(value = "获取列表")
|
|
@ApiOperation(value = "获取列表")
|
|
public ListEnvelop<SaasVO> list(
|
|
|
|
|
|
public ListEnvelop<SaasVO> list (
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|