|
@@ -0,0 +1,78 @@
|
|
|
+package cn.rankin.userservice.controller;
|
|
|
+
|
|
|
+import cn.rankin.common.utils.api.model.APICode;
|
|
|
+import cn.rankin.common.utils.api.model.APIResult;
|
|
|
+import cn.rankin.common.utils.api.page.Page;
|
|
|
+import cn.rankin.common.utils.enums.BaseOrderEnum;
|
|
|
+import cn.rankin.data.api.user.dto.MerchantPermitDeviceDTO;
|
|
|
+import cn.rankin.data.api.user.dto.MerchantSearchDTO;
|
|
|
+import cn.rankin.data.api.user.dto.UserDeviceDTO;
|
|
|
+import cn.rankin.data.api.user.entity.Merchant;
|
|
|
+import cn.rankin.data.api.user.entity.MerchantPermitDevice;
|
|
|
+import cn.rankin.data.api.user.entity.UserDevice;
|
|
|
+import cn.rankin.data.api.user.vo.MerchantPermitDeviceVo;
|
|
|
+import cn.rankin.userservice.helper.RaStringHelper;
|
|
|
+import cn.rankin.userservice.service.MerchantPermitDeviceService;
|
|
|
+import cn.rankin.userservice.service.UserDeviceService;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/merchantPermitDevice")
|
|
|
+public class MerchantPermitDeviceController
|
|
|
+{
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MerchantPermitDeviceService merchantPermitDeviceService;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
+ public APIResult<Page<MerchantPermitDevice>> search(MerchantPermitDeviceDTO searchDTO) {
|
|
|
+ MerchantPermitDevice simple = new MerchantPermitDevice();
|
|
|
+ String merchantId = searchDTO.getMerchantId();
|
|
|
+ if (StringUtils.isNotBlank(merchantId)) {
|
|
|
+ simple.setMerchantId(merchantId);
|
|
|
+ }
|
|
|
+
|
|
|
+ String provinceCode = searchDTO.getProvinceCode();
|
|
|
+ if (StringUtils.isNotBlank(provinceCode)) {
|
|
|
+ simple.setProvinceCode(provinceCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ // sort
|
|
|
+ LinkedHashMap<String, BaseOrderEnum> sort = new LinkedHashMap<>();
|
|
|
+ sort.put("gmtModified", BaseOrderEnum.DESC);
|
|
|
+
|
|
|
+ return merchantPermitDeviceService.search(simple, searchDTO.getPageNo(), searchDTO.getPageSize(), sort);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(method = RequestMethod.POST)
|
|
|
+ public APIResult<MerchantPermitDevice> create(@Valid @RequestBody MerchantPermitDeviceDTO dto){
|
|
|
+ return merchantPermitDeviceService.create(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(method = RequestMethod.PUT)
|
|
|
+ public APIResult<MerchantPermitDevice> update(@Valid @RequestBody MerchantPermitDeviceDTO dto){
|
|
|
+ if (dto.getId() == null) {
|
|
|
+ return APIResult.error(APICode.PARAMETER_ERROR);
|
|
|
+ }
|
|
|
+ return merchantPermitDeviceService.update(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
|
|
+ public APIResult<Boolean> delete(@PathVariable String id) {
|
|
|
+ return merchantPermitDeviceService.delete(id);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
|
|
+ public APIResult<MerchantPermitDevice> getMerchantPermitDevice(@PathVariable String id) {
|
|
|
+ return merchantPermitDeviceService.getMerchantPermitDevice(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|