Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/test' into test

yangzian 4 rokov pred
rodič
commit
1ca254a18f

+ 102 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/bytedance/advertise/controller/BytedanceVideoSlogenInfoController.java

@@ -12,20 +12,26 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.bytedance.advertise.entity.ByteDanceCreativeWordPackage;
 import org.jeecg.modules.bytedance.advertise.entity.BytedanceVideoSlogenInfo;
+import org.jeecg.modules.bytedance.advertise.service.IByteDanceGeneralCopywriterService;
 import org.jeecg.modules.bytedance.advertise.service.IBytedanceVideoSlogenInfoService;
 import org.jeecg.modules.bytedance.advertise.service.impl.BytedanceVideoSlogenInfoServiceImpl;
 import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
 import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
 import org.jeecg.modules.bytedance.common.utils.Check;
+import org.jeecg.modules.bytedance.common.utils.StringUtils;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * 头条视频文案信息
@@ -44,6 +50,8 @@ public class BytedanceVideoSlogenInfoController {
 	private IMaterialInfoService materialInfoService;
 	@Autowired
 	private ISysRoleService sysRoleService;
+	@Autowired
+	private IByteDanceGeneralCopywriterService byteDanceGeneralCopywriterService;
 	/**
 	  * 分页列表查询
 	 * @param slogenInfo
@@ -119,7 +127,7 @@ public class BytedanceVideoSlogenInfoController {
 	 *   添加
 	 * @param
 	 * @param
-	 * @param userId
+	 * @param
 	 * @return
 	 */
 	@ApiOperation(value="头条视频文案信息-批量添加", notes="头条视频文案信息-批量添加")
@@ -129,6 +137,50 @@ public class BytedanceVideoSlogenInfoController {
 		try {
 			String userId = materialInfo.getUserId();
 			JSONArray slogenArray = materialInfo.getSlogans();
+			for (int i = 0;i<slogenArray.size();i++) {
+				JSONObject slogenInfo = slogenArray.getJSONObject(i);
+				String title = slogenInfo.getString("title");
+				title = title.trim().replaceAll("[\\{]{2,}","{");
+				title = title.trim().replaceAll("[\\}]{2,}","}");
+                slogenInfo.put("title",title);
+				String reg = "\\{[\\u4e00-\\u9fa5\\-]{2,6}\\}";
+				Pattern pattern = Pattern.compile(reg);
+				Matcher matcher = pattern.matcher(title);
+				JSONArray creativeWordIdsArray = new JSONArray();
+
+				int len = StringUtils.lengthAsSlogan(title);
+				int left = title.indexOf("{");
+				int right = title.indexOf("}");
+				if(left >= 0 && right >= 0){
+				int times = 0;
+					while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
+						times++;
+						if(times>=3){
+							return  Result.errorMsg("动态词包不合法,词包数量超过2个");
+						}
+						String matchStr = matcher.group();//获取当前匹配的值
+						title = title.replace(matchStr,"");
+
+						ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(matchStr.substring(1,matchStr.length()-1));
+						if(Check.isNull(creativeWordPackage)){
+							return  Result.errorMsg("动态词包不合法,词包不存在或者含有单独的非词包大括号");
+						}
+						creativeWordIdsArray.add(creativeWordPackage.getCreativeWordId());
+						len = len - (right - left) + creativeWordPackage.getMaxWordLen();
+						left = title.indexOf("{");
+						right = title.indexOf("}");
+					}
+					if(title.contains("{") || title.contains("}")){
+						return result.error500("大括号单独出现或大括号中内容不合法");
+					}
+					slogenInfo.put("creative_word_ids",creativeWordIdsArray.toJSONString());
+				}
+				//校验标题长度,长度小于5和大于30的全部过滤
+				if(len<5 || len>30){
+					return result.error500("文案长度不合法,小于5或大于30");
+				}
+			}
+
 			JSONArray materialIds = materialInfo.getMaterialIds();
 			for(int i=0;i<materialIds.size();i++){
 				MaterialInfo materialInfo2 = materialInfoService.getById(materialIds.get(i).toString());
@@ -155,6 +207,7 @@ public class BytedanceVideoSlogenInfoController {
 	@PostMapping(value = "/edit")
 	public Result<BytedanceVideoSlogenInfo> edit(@RequestBody BytedanceVideoSlogenInfo slogenInfo) {
 		Result<BytedanceVideoSlogenInfo> result = new Result<>();
+		try{
 		BytedanceVideoSlogenInfo bytedanceVideoSlogenInfoEntity = bytedanceVideoSlogenInfoService.getById(slogenInfo.getId());
 		if(bytedanceVideoSlogenInfoEntity==null) {
 			result.error500("未找到对应实体");
@@ -163,9 +216,57 @@ public class BytedanceVideoSlogenInfoController {
 		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		slogenInfo.setUpdateBy(user.getId());
 		slogenInfo.setUpdateTime(new Date());
+
+		String title = slogenInfo.getSlogan();
+		title = title.trim().replaceAll("[\\{]{2,}", "{");
+		title = title.trim().replaceAll("[\\}]{2,}", "}");
+
+		String reg = "\\{[\\u4e00-\\u9fa5\\-]{2,6}\\}";
+		Pattern pattern = Pattern.compile(reg);
+		Matcher matcher = pattern.matcher(title);
+		JSONArray creativeWordIdsArray = new JSONArray();
+
+		int len = StringUtils.lengthAsSlogan(title);
+		int left = title.indexOf("{");
+		int right = title.indexOf("}");
+		if (left >= 0 && right >= 0) {
+			int times = 0;
+			while (matcher.find()) { //此处find()每次被调用后,会偏移到下一个匹配
+				times++;
+				if (times >= 3) {
+					return Result.errorMsg("动态词包不合法,词包数量超过2个");
+				}
+				String matchStr = matcher.group();//获取当前匹配的值
+				title = title.replace(matchStr,"");
+
+				ByteDanceCreativeWordPackage creativeWordPackage = byteDanceGeneralCopywriterService.selectCreativeWordPackageByName(matchStr.substring(1, matchStr.length() - 1));
+				if (Check.isNull(creativeWordPackage)) {
+					return Result.errorMsg("动态词包不合法,词包不存在或者含有单独的非词包大括号");
+				}
+				creativeWordIdsArray.add(creativeWordPackage.getCreativeWordId());
+				len = len - (right - left) + creativeWordPackage.getMaxWordLen();
+				left = title.indexOf("{");
+				right = title.indexOf("}");
+			}
+			if(title.contains("{") || title.contains("}")){
+				return result.error500("文案含有词包特殊字符,请检查");
+			}
+			slogenInfo.setCreativeWordIds(creativeWordIdsArray.toJSONString());
+		}
+		//校验标题长度,长度小于5和大于30的全部过滤
+		if (len < 5 || len > 30) {
+			return result.error500("文案长度不合法,小于5或大于30");
+		}
+
 		bytedanceVideoSlogenInfoService.updateById(slogenInfo);
 		result.success("修改成功!");
+		result.setCode(0);
 		return result;
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+			return result;
+		}
 	}
 
 	/**

+ 44 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysUserController.java

@@ -10,6 +10,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
@@ -24,6 +28,7 @@ import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.*;
+import org.jeecg.modules.bytedance.common.utils.Check;
 import org.jeecg.modules.system.entity.*;
 import org.jeecg.modules.system.model.DepartIdModel;
 import org.jeecg.modules.system.model.SysUserSysDepartModel;
@@ -57,6 +62,7 @@ import java.util.stream.Collectors;
  * @Author scott
  * @since 2018-12-20
  */
+@Api(tags="用户管理")
 @Slf4j
 @RestController
 @RequestMapping("/sys/user")
@@ -93,7 +99,8 @@ public class SysUserController {
 
     @Resource
     private BaseCommonService baseCommonService;
-
+    @Autowired
+    private ISysRoleService sysRoleService;
     /**
      * 获取用户列表数据
      * @param user
@@ -129,6 +136,42 @@ public class SysUserController {
 		return result;
 	}
 
+
+    /**
+     * 获取用户列表数据
+     *
+     * @param user
+     * @param pageNo
+     * @param pageSize
+     * @param
+     * @return
+     */
+    @ApiOperation(value="用户管理(运营)", notes="用户管理(运营)")
+    @RequestMapping(value = "/listV2", method = RequestMethod.GET)
+    public Result<Object> queryPageListV2(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        try {
+            String userId = user.getId();
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if (Check.isNull(roleCode)){
+                return Result.errorMsg("请输入正确的用户id。");
+            }
+            //角色为 管理员并且projectId是空表示:全量查询
+
+            if (!"admin".equals(roleCode)) {
+                user.setLeaderId(userId);
+            }
+
+            PageHelper.startPage(pageNo, pageSize);
+            List<SysUser> list = sysUserService.queryPageList(user);
+            PageInfo<SysUser> pageInfo = new PageInfo<>(list);
+            return Result.ok(pageInfo);
+        } catch (Exception e) {
+            log.error("获取用户列表数据-分页列表查询异常", e);
+        }
+        return Result.error("查询失败");
+    }
+
     //@RequiresRoles({"admin"})
     //@RequiresPermissions("user:add")
 	@RequestMapping(value = "/add", method = RequestMethod.POST)

+ 10 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysUser.java

@@ -182,4 +182,14 @@ public class SysUser implements Serializable {
 
     /**设备id uniapp推送用*/
     private String clientId;
+
+    /**
+     * 领导 ID
+     */
+    private String leaderId;
+
+    /**
+     * 领导姓名
+     */
+    private String leaderName;
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysUserMapper.java

@@ -139,4 +139,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
 	 * @return
 	 */
 	List<SysUser> queryByDepIds(@Param("departIds")List<String> departIds,@Param("username") String username);
+
+	List<SysUser> queryPageList(SysUser user);
 }

+ 39 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysUserMapper.xml

@@ -162,4 +162,43 @@
 			and username != #{username}
 		</if>
 	</select>
+
+	<!-- 查询用户列表-->
+	<select id="queryPageList" resultType="org.jeecg.modules.system.entity.SysUser">
+		SELECT t4.* from (
+		SELECT t1.*,t3.depart_name ,role.role_name,t2.create_time AS updTime
+		FROM sys_user t1
+		LEFT JOIN sys_user_depart t2 ON t1.id = t2.user_id
+		LEFT JOIN sys_depart t3 ON t2.dep_id = t3.id
+		LEFT JOIN sys_user_role userRole ON t1.id = userRole.user_id
+		LEFT JOIN sys_role role ON userRole.role_id = role.id
+		where t1.del_flag = 0
+		<if test="realname != null and realname != ''">
+			AND t1.realname LIKE CONCAT(CONCAT('%',#{realname}),'%')
+		</if>
+		<if test="username != null and username != ''">
+			AND t1.username LIKE CONCAT(CONCAT('%',#{username}),'%')
+		</if>
+		<if test="email != null and email != ''">
+			AND t1.email LIKE CONCAT(CONCAT('%',#{email}),'%')
+		</if>
+		<if test="phone != null and phone != ''">
+			AND t1.phone LIKE CONCAT(CONCAT('%',#{phone}),'%')
+		</if>
+		<if test="status != null and status != ''">
+			AND t1.`status` = #{status}
+		</if>
+		<if test="leaderName != null and leaderName != ''">
+			AND t1.leader_name LIKE CONCAT(CONCAT('%',#{leaderName}),'%')
+		</if>
+		<if test="sex != null and sex != ''">
+			AND t1.sex =#{sex}
+		</if>
+		<if test="leaderId != null and leaderId !=''">
+			and  (t1.leader_id = #{leaderId} or t1.id = #{leaderId})
+		</if>
+
+		) t4
+		GROUP BY t4.id
+	</select>
 </mapper>

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysUserService.java

@@ -233,4 +233,6 @@ public interface ISysUserService extends IService<SysUser> {
 	 * @return
 	 */
 	List<SysUser> queryByDepIds(List<String> departIds, String username);
+
+	List<SysUser> queryPageList(SysUser user);
 }

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java

@@ -438,5 +438,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
 	public List<SysUser> queryByDepIds(List<String> departIds, String username) {
 		return userMapper.queryByDepIds(departIds,username);
 	}
-
+	@Override
+	public List<SysUser> queryPageList(SysUser user) {
+		return userMapper.queryPageList(user);
+	}
 }