|
@@ -0,0 +1,77 @@
|
|
|
+package com.caimei.controller.admin.auth;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.caimei.model.ResponseJson;
|
|
|
+import com.caimei.model.dto.ProductSaveDto;
|
|
|
+import com.caimei.model.vo.ProductFormVo;
|
|
|
+import com.caimei.model.vo.ProductListVo;
|
|
|
+import com.caimei.model.vo.ProductTypeListVo;
|
|
|
+import com.caimei.model.vo.TemplateListVo;
|
|
|
+import com.caimei.service.auth.AuthProductService;
|
|
|
+import com.caimei.service.auth.AuthTemplateService;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 授权牌模板API
|
|
|
+ * @author Aslee
|
|
|
+ * @date 2022/7/6
|
|
|
+ */
|
|
|
+@Api(tags = "授权牌模板API")
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RequestMapping("/auth/template")
|
|
|
+public class AuthTemplateApi {
|
|
|
+
|
|
|
+ private final AuthTemplateService authTemplateService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 授权牌模板列表
|
|
|
+ */
|
|
|
+ @ApiOperation("授权牌模板列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "listType", required = true, value = "列表类型:1管理员列表,2供应商列表"),
|
|
|
+ @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
|
|
|
+ @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
|
|
|
+ @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
|
|
|
+ })
|
|
|
+ @GetMapping("/list")
|
|
|
+ public ResponseJson<PageInfo<TemplateListVo>> getTemplateList(Integer listType, Integer authUserId,
|
|
|
+ @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
+ return authTemplateService.getTemplateList(listType, authUserId, pageNum, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("添加/编辑授权模板")
|
|
|
+ @ApiImplicitParam(name = "params", required = true, value = "templateId:模板id;templateImage:模板图片;authUserId:供应商用户id")
|
|
|
+ @PostMapping("/save")
|
|
|
+ public ResponseJson saveTemplate(@RequestBody String params){
|
|
|
+ JSONObject parseObject = JSONObject.parseObject(params);
|
|
|
+ Integer templateId = parseObject.getInteger("templateId");
|
|
|
+ String templateImage = parseObject.getString("templateImage");
|
|
|
+ Integer authUserId = parseObject.getInteger("authUserId");
|
|
|
+ Integer status = parseObject.getInteger("status");
|
|
|
+ String qrPosition = parseObject.getString("qrPosition");
|
|
|
+ if (null != templateId) {
|
|
|
+ if (StringUtils.isEmpty(templateImage)) {
|
|
|
+ return ResponseJson.error("授权牌模板不能为空");
|
|
|
+ }
|
|
|
+ if (null == authUserId) {
|
|
|
+ return ResponseJson.error("供应商用户id不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return authTemplateService.saveTemplate(templateId, templateImage, authUserId, status, qrPosition);
|
|
|
+ }
|
|
|
+}
|