|
@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -37,14 +38,23 @@ public class ByteDanceBudgetTemplateServiceImpl extends ServiceImpl<ByteDanceBud
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> insertTemplate(ByteDanceBudgetTemplate template) {
|
|
public Map<String, Object> insertTemplate(ByteDanceBudgetTemplate template) {
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
- LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
- CTopOauthToken token = tokenService.getOAuthTokenByAccountId(user.getId());
|
|
|
|
- template.setAdvertiserId(token.getAdvertiserId());
|
|
|
|
- template.setToutiaoId(token.getAccountId());
|
|
|
|
|
|
+ QueryWrapper<ByteDanceBudgetTemplate> queryWrapper = new QueryWrapper<ByteDanceBudgetTemplate>();
|
|
|
|
+ queryWrapper.eq("name", template.getName());
|
|
|
|
+ queryWrapper.ne("id", template.getId());
|
|
|
|
+ List<ByteDanceBudgetTemplate> templateExistList = this.list(queryWrapper);
|
|
|
|
+ if (templateExistList != null && templateExistList.size() > 0) {
|
|
|
|
+ resultMap.put("success", false);
|
|
|
|
+ resultMap.put("message", "模板名称已存在,请修改后重试");
|
|
|
|
+ return resultMap;
|
|
|
|
+ }
|
|
template.setStatus(1);
|
|
template.setStatus(1);
|
|
- template.setStartDate(template.getStartDate().substring(0, 10));
|
|
|
|
- template.setEndDate(template.getEndDate().substring(0, 10));
|
|
|
|
- budgetTemplateMapper.insert(template);
|
|
|
|
|
|
+ if (template.getStartDate() != null) {
|
|
|
|
+ template.setStartDate(template.getStartDate().substring(0, 10));
|
|
|
|
+ }
|
|
|
|
+ if (template.getEndDate() != null) {
|
|
|
|
+ template.setEndDate(template.getEndDate().substring(0, 10));
|
|
|
|
+ }
|
|
|
|
+ this.saveOrUpdate(template);
|
|
resultMap.put("success", true);
|
|
resultMap.put("success", true);
|
|
resultMap.put("message", "模板保存成功");
|
|
resultMap.put("message", "模板保存成功");
|
|
return resultMap;
|
|
return resultMap;
|