|
@@ -7,6 +7,7 @@ import com.caimei.service.auth.AuthTemplateService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -45,9 +46,10 @@ public class AuthTemplateServiceImpl implements AuthTemplateService {
|
|
|
@Override
|
|
|
public ResponseJson saveTemplate(Integer templateId, String templateImage, Integer authUserId, Integer status, String qrPosition, Integer qrSize, String logoSize, Integer authFlag, Integer productFlag) {
|
|
|
boolean insertFlag = null == templateId;
|
|
|
- if (insertFlag) {
|
|
|
- Integer width = null;
|
|
|
- Integer height = null;
|
|
|
+ Integer width = null;
|
|
|
+ Integer height = null;
|
|
|
+ String templateSize = null;
|
|
|
+ if (StringUtils.isNotEmpty(templateImage)) {
|
|
|
try {
|
|
|
BufferedImage image = ImageIO.read(new URL(templateImage));
|
|
|
width = image.getWidth();
|
|
@@ -55,16 +57,30 @@ public class AuthTemplateServiceImpl implements AuthTemplateService {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- String templateSize = (null == width ? 0 : width) + "," + (null == height ? 0 : height);
|
|
|
+ templateSize = (null == width ? 0 : width) + "," + (null == height ? 0 : height);
|
|
|
+ }
|
|
|
+ if (insertFlag) {
|
|
|
+ if (StringUtils.isEmpty(qrPosition)) {
|
|
|
+ // 默认左上角
|
|
|
+ qrPosition = "0,0";
|
|
|
+ }
|
|
|
authTemplateMapper.insertTemplate(templateImage, authUserId, templateSize, qrPosition, qrSize, logoSize);
|
|
|
} else {
|
|
|
+ TemplateVo dbTemplate = authTemplateMapper.getTemplateFormData(templateId, null, null, null, null);
|
|
|
if (null != authFlag && 1 == authFlag) {
|
|
|
authTemplateMapper.clearAuthFlag(authUserId);
|
|
|
}
|
|
|
if (null != productFlag && 1 == productFlag) {
|
|
|
authTemplateMapper.clearProductFlag(authUserId);
|
|
|
}
|
|
|
- authTemplateMapper.updateSelective(templateId, templateImage, authUserId, status, qrPosition, qrSize, logoSize, authFlag, productFlag);
|
|
|
+ if (null != dbTemplate) {
|
|
|
+ if (null != authUserId && !dbTemplate.getAuthUserId().equals(authUserId)) {
|
|
|
+ // 更新了供应商,不选中位置
|
|
|
+ authFlag = 0;
|
|
|
+ productFlag = 0;
|
|
|
+ }
|
|
|
+ authTemplateMapper.updateSelective(templateId, templateImage, templateSize, authUserId, status, qrPosition, qrSize, logoSize, authFlag, productFlag);
|
|
|
+ }
|
|
|
}
|
|
|
return ResponseJson.success();
|
|
|
}
|