提交 a3403178 作者: zhenjie

Merge branch 'develop' of ssh://git.mmcuav.cn:8222/iuav/cms into develop

 Conflicts:
	csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/controller/CooperationController.java
	csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/dao/CooperationDao.java
	csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/entity/CooperationTagDO.java
	csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/service/CooperationService.java
	csm-service/cms-service-user/src/main/java/com/mmc/iuav/user/service/impl/CooperationServiceImpl.java
	csm-service/cms-service-user/src/main/resources/mapper/CooperationDao.xml
package com.mmc.iuav.user.model.qo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.domain.Page;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @Author LW
*
* @date 2023/6/27 14:59 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApplyQO {
@ApiModelProperty(value = "申请加盟类型", example = "1")
private Integer cooperationTagId;
@ApiModelProperty(value = "申请状态", example = "0")
private Integer applyStatus;
@ApiModelProperty(value = "开始时间", example = "2023-01-01 00:00:00")
private String startTime;
@ApiModelProperty(value = "结束时间", example = "2023-12-31 23:59:59")
private String endTime;
@ApiModelProperty(value = "页码", required = true, example = "1")
@NotNull(message = "页码不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true, example = "10")
@NotNull(message = "每页显示数不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.iuav.user.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @Author LW
*
* @date 2023/6/27 13:49 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AttachmentVO implements Serializable {
@ApiModelProperty(value = "附件url")
private String url;
@ApiModelProperty(value = "附件类型:0:图片 1:文件")
private Integer type;
}
......@@ -28,6 +28,8 @@ public class CooperationTagVO implements Serializable {
private String tagImg;
@ApiModelProperty(value = "合作标签描述")
private String tagDescription;
@ApiModelProperty(value = "注意事项")
private String tagRequire;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.mmc.iuav.user.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author LW
*
* @date 2023/6/27 16:04 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class UserApplyTagDetailsVO {
@ApiModelProperty(value = "企业名称")
private String companyName;
@ApiModelProperty(value = "社会信用代码")
private String creditCode;
@ApiModelProperty(value = "营业执照")
private String licenseImg;
@ApiModelProperty(value = "附件")
private List<AttachmentVO> attachmentList;
@ApiModelProperty(value = "备注")
private String remark;
}
package com.mmc.iuav.user.model.vo;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.group.Update;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -11,10 +10,11 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @author: zj
* @Date: 2023/5/17 22:02
* @author: zj @Date: 2023/5/17 22:02
*/
@Builder
@Data
......@@ -22,19 +22,43 @@ import java.io.Serializable;
@NoArgsConstructor
public class UserApplyTagVO implements Serializable {
private static final long serialVersionUID = -1004953417393220972L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "加盟标签id")
@NotNull(message = "加盟标签id不能为空", groups = { Insert.class })
@NotNull(
message = "加盟标签id不能为空",
groups = {Insert.class})
private Integer cooperationTagId;
@ApiModelProperty(value = "用户id")
private Integer userAccountId;
@ApiModelProperty(value = "申请人名称")
@NotBlank(message = "申请人名称不能为空", groups = { Insert.class })
@NotBlank(
message = "申请人名称不能为空",
groups = {Insert.class})
private String applyName;
@ApiModelProperty(value = "申请人手机号")
@NotBlank(message = "申请人手机号不能为空", groups = { Insert.class })
@NotBlank(
message = "申请人手机号不能为空",
groups = {Insert.class})
private String applyPhone;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "附件")
private List<AttachmentVO> attachmentList;
@ApiModelProperty(value = "申请时间")
private Date applyTime;
@ApiModelProperty(value = "加盟类型名称")
private String cooperationTagName;
@ApiModelProperty(value = "审批状态 0:申请中 1:通过 2:驳回")
private Integer approvalStatus;
}
package com.mmc.iuav.user.config;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
//Converter<S,T> S: 代表的是源,将要转换的数据类型 T:目标类型,将会转成什么数据类型
@Component
public class GlobalFormDateConvert implements Converter<String, Date> {
// 静态初始化定义日期字符串参数列表(需要转换的)
private static final List<String> paramList = new ArrayList<>();
// 静态初始化可能初夏你的日期格式
private static final String param1 = "yyyy-MM";
private static final String param2 = "yyyy-MM-dd";
private static final String param3 = "yyyy-MM-dd HH:mm";
private static final String param4 = "yyyy-MM-dd HH:mm:ss";
// 静态代码块,将日期参数加入到列表中
static {
paramList.add(param1);
paramList.add(param2);
paramList.add(param3);
paramList.add(param4);
}
// 自定义函数,将字符串转Date 参1:传入的日期字符串 参2:格式参数
public Date parseDate(String source, String format) {
Date date = null;
try {
// 日期格式转换器
DateFormat dateFormat = new SimpleDateFormat(format);
date = dateFormat.parse(source);
} catch (Exception e) {
e.printStackTrace();
}
return date;
}
// convert转换方法 ,s是将会传递过来的日期的字符串
@Override
public Date convert(String source) {
if (StringUtils.isEmpty(source)) {
return null;
}
source = source.trim(); // 去除首尾空格
// 正则表达式判断是哪一种格式参数
if (source.matches("^\\d{4}-\\d{1,2}$")) {
return parseDate(source, paramList.get(0));
} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) {
return parseDate(source, paramList.get(1));
} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$")) {
return parseDate(source, paramList.get(2));
} else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$")) {
return parseDate(source, paramList.get(3));
} else {
throw new IllegalArgumentException("还未定义该种字符串转Date的日期转换格式 --> 【日期格式】:" + source);
}
}
}
package com.mmc.iuav.user.config;
import com.fasterxml.jackson.databind.util.StdDateFormat;
import org.springframework.util.StringUtils;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
public class GlobalJsonDateConvert extends StdDateFormat {
private static final long serialVersionUID = -6738131740618766141L;
// 静态初始化final,共享
public static final GlobalJsonDateConvert instance = new GlobalJsonDateConvert();
// 覆盖parse(String)这个方法即可实现
@Override
public Date parse(String dateStr, ParsePosition pos) {
return getDate(dateStr, pos);
}
@Override
public Date parse(String dateStr) {
ParsePosition pos = new ParsePosition(0);
return getDate(dateStr, pos);
}
private Date getDate(String dateStr, ParsePosition pos) {
SimpleDateFormat sdf = null;
if (StringUtils.isEmpty(dateStr)) {
return null;
} else if (dateStr.matches("^\\d{4}-\\d{1,2}$")) {
sdf = new SimpleDateFormat("yyyy-MM");
return sdf.parse(dateStr, pos);
} else if (dateStr.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) {
sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse(dateStr, pos);
} else if (dateStr.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$")) {
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return sdf.parse(dateStr, pos);
} else if (dateStr.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$")) {
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.parse(dateStr, pos);
} else if (dateStr.length() == 23) {
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return sdf.parse(dateStr, pos);
}
return super.parse(dateStr, pos);
}
@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(date, toAppendTo, fieldPosition);
}
@Override
public GlobalJsonDateConvert clone() {
return new GlobalJsonDateConvert();
}
}
package com.mmc.iuav.user.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.converter.Converter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Configuration
public class WebConfig {
// JSON格式 全局日期转换器配置
@Bean
public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter =
new MappingJackson2HttpMessageConverter();
// 设置日期格式
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(GlobalJsonDateConvert.instance);
objectMapper.setSerializationInclusion(JsonInclude.Include.ALWAYS);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
// 设置中文编码格式
List<MediaType> list = new ArrayList<MediaType>();
list.add(MediaType.APPLICATION_JSON_UTF8);
mappingJackson2HttpMessageConverter.setSupportedMediaTypes(list);
return mappingJackson2HttpMessageConverter;
}
// 表单格式 全局日期转换器
@Bean
@Autowired
public ConversionService getConversionService(GlobalFormDateConvert globalDateConvert) {
ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
Set<Converter> converters = new HashSet<>();
converters.add(globalDateConvert);
factoryBean.setConverters(converters);
return factoryBean.getObject();
}
}
......@@ -3,12 +3,16 @@ package com.mmc.iuav.user.controller;
import com.mmc.iuav.group.Insert;
import com.mmc.iuav.group.Update;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.CompanyAuthVO;
import com.mmc.iuav.user.model.qo.ApplyQO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagDetailsVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.model.vo.UserCooperationTagVO;
import com.mmc.iuav.user.service.CooperationService;
import io.swagger.annotations.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -18,39 +22,70 @@ import java.util.List;
import java.util.Set;
/**
* @author: zj
* @Date: 2023/5/17 21:17
* @author: zj @Date: 2023/5/17 21:17
*/
@Api(tags = "合作加盟")
@RequestMapping("/cooperation/")
@RestController
public class CooperationController extends BaseController{
@Autowired
private CooperationService cooperationService;
public class CooperationController extends BaseController {
@Autowired private CooperationService cooperationService;
@ApiOperation(value = "加盟标签列表")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = CooperationTagVO.class) })
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = CooperationTagVO.class)})
@GetMapping("listTag")
public ResultBody listTag() {
return ResultBody.success(cooperationService.listTag());
}
@ApiOperation(value = "根据id获取标签信息")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = CooperationTagVO.class) })
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = CooperationTagVO.class)})
@GetMapping("getTagById")
public ResultBody getTagById(@RequestParam("id") Integer id) {
return cooperationService.getTagById(id);
}
@ApiOperation(value = "申请加盟")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("apply")
public ResultBody apply(@Validated(value = {Insert.class})@RequestBody UserApplyTagVO userApplyTagVO, HttpServletRequest request){
public ResultBody apply(
@Validated(value = {Insert.class}) @RequestBody UserApplyTagVO userApplyTagVO,
HttpServletRequest request) {
Integer userAccountId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
userApplyTagVO.setUserAccountId(userAccountId);
return cooperationService.apply(userApplyTagVO);
}
@ApiOperation(value = "后台申请列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = UserApplyTagVO.class)})
@PostMapping("listUserApplyTag")
public ResultBody<UserApplyTagVO> listUserApplyTag(@RequestBody ApplyQO applyQO) {
return ResultBody.success(cooperationService.listUserApplyTag(applyQO));
}
@ApiOperation(value = "强制删除")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("deleteApplyTag")
public ResultBody deleteApplyTag(Integer id) {
return ResultBody.success(cooperationService.deleteApplyTag(id));
}
@ApiOperation(value = "审批详情")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = UserApplyTagDetailsVO.class)})
@GetMapping("applyTagDetails")
public ResultBody applyTagDetails(
@RequestParam(value = "id") Integer id,
@RequestParam(value = "userAccountId") Integer userAccountId) {
return cooperationService.applyTagDetails(id, userAccountId);
}
@ApiOperation(value = "审批")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("approvalApplyTag")
public ResultBody approvalApplyTag(
@RequestParam(value = "id") Integer id, @RequestParam(value = "status") Boolean status) {
return ResultBody.success(cooperationService.approvalApplyTag(id, status));
}
@ApiOperation(value = "后台设置小程序用户标签")
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ResultBody.class) })
@PostMapping("changeUserTag")
......@@ -59,9 +94,9 @@ public class CooperationController extends BaseController{
}
@ApiOperation(value = "获取合作渠道标签", hidden = true)
@ApiResponses({ @ApiResponse(code = 200, message = "OK", response = CooperationTagVO.class) })
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = CooperationTagVO.class)})
@GetMapping("feignListCooperationTag")
public List<CooperationTagVO> feignListCooperationTag(){
public List<CooperationTagVO> feignListCooperationTag() {
return cooperationService.listTag();
}
}
package com.mmc.iuav.user.dao;
import com.mmc.iuav.user.entity.CooperationTagDO;
import com.mmc.iuav.user.entity.TagApplyResourceDO;
import com.mmc.iuav.user.entity.UserApplyTagDO;
import com.mmc.iuav.user.entity.UserTagDO;
import com.mmc.iuav.user.model.qo.ApplyQO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Set;
/**
* @author: zj
* @Date: 2023/5/17 21:20
* @author: zj @Date: 2023/5/17 21:20
*/
@Mapper
public interface CooperationDao {
/**
* 加盟标签列表
*
* @return
*/
List<CooperationTagDO> listTags();
/**
* 加盟申请
*
* @param userApplyTagDO
*/
void addApply(UserApplyTagDO userApplyTagDO);
/**
* 根据用户id获取合作申请
* @param userAccountId
* 根据id获取合作申请
*
* @param id
* @return
*/
UserApplyTagDO getUserApplyTag(Integer userAccountId);
UserApplyTagDO getUserApplyTag(Integer id);
/**
* 修改用户申请
*
* @param userApplyTagDO
*/
void updateUserApplyTag(UserApplyTagDO userApplyTagDO);
......@@ -48,24 +53,46 @@ public interface CooperationDao {
/**
* 用户设置渠道等级
*
* @param userTagDO
*/
void insertUserTag(UserTagDO userTagDO);
/**
* 修改用户渠道等级
*
* @param userTagDO
*/
void updateUserTag(UserTagDO userTagDO);
/**
* 根据id查询标签信息
*
* @param id
* @return
*/
CooperationTagDO getTagById(Integer id);
/**
* 添加加盟入驻的附件资源
*
* @param tagApplyResourceDO 标签应用资源做
*/
void addApplyResource(TagApplyResourceDO tagApplyResourceDO);
int countListUserApplyTag(ApplyQO applyQO);
List<UserApplyTagDO> listUserApplyTag(ApplyQO applyQO);
void deleteApplyTag(Integer id);
List<TagApplyResourceDO> getUserApplyResource(Integer id);
void updateApplyTagStatus(Integer id, int i);
int userTagInfo(Integer cooperationTagId, Integer userAccountId);
/**
* 删除用户原来的标签
* @param userAccountId
*/
......
......@@ -9,8 +9,7 @@ import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/17 21:24
* @author: zj @Date: 2023/5/17 21:24
*/
@Data
@NoArgsConstructor
......@@ -21,19 +20,19 @@ public class CooperationTagDO implements Serializable {
private String tagName;
private String tagImg;
private String tagDescription;
private String tagRequire;
private Date createTime;
private Integer userAccountId;
public CooperationTagVO buildCooperationTagVO(){
public CooperationTagVO buildCooperationTagVO() {
return CooperationTagVO.builder()
.id(id)
.tagName(tagName)
.tagImg(tagImg)
.tagRequire(tagRequire)
.tagDescription(tagDescription)
.createTime(createTime)
.build();
}
}
package com.mmc.iuav.user.entity;
import com.mmc.iuav.user.model.vo.AttachmentVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author LW
*
* @date 2023/6/27 13:56 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TagApplyResourceDO implements Serializable {
private Integer userApplyTagId;
private String url;
private Integer type;
private Date createTime;
private Date updateTime;
public TagApplyResourceDO(AttachmentVO d, Integer applyId) {
this.userApplyTagId = applyId;
this.type = d.getType();
this.url = d.getUrl();
}
public AttachmentVO buildAttachmentVO() {
return AttachmentVO.builder().url(url).type(type).build();
}
}
......@@ -6,10 +6,10 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @author: zj
* @Date: 2023/5/17 21:59
* @author: zj @Date: 2023/5/17 21:59
*/
@Data
@NoArgsConstructor
......@@ -22,18 +22,31 @@ public class UserApplyTagDO implements Serializable {
private String applyName;
private String applyPhone;
private String remark;
private Date createTime;
private Integer applyStatus;
public UserApplyTagVO buildUserApplyTagVO(){
return UserApplyTagVO.builder().id(id).cooperationTagId(cooperationTagId).userAccountId(this.userAccountId)
.applyName(this.applyName).applyPhone(this.applyPhone).remark(this.remark).build();
/** 辅助字段start */
private String tagName;
/** 辅助字段end */
public UserApplyTagVO buildUserApplyTagVO() {
return UserApplyTagVO.builder()
.id(id)
.cooperationTagId(cooperationTagId)
.userAccountId(this.userAccountId)
.applyName(this.applyName)
.applyPhone(this.applyPhone)
.remark(this.remark)
.applyTime(createTime)
.approvalStatus(applyStatus)
.cooperationTagName(tagName)
.build();
}
public UserApplyTagDO(UserApplyTagVO userApplyTagVO){
public UserApplyTagDO(UserApplyTagVO userApplyTagVO) {
this.cooperationTagId = userApplyTagVO.getCooperationTagId();
this.userAccountId = userApplyTagVO.getUserAccountId();
this.applyName = userApplyTagVO.getApplyName();
this.applyPhone = userApplyTagVO.getApplyPhone();
this.remark = userApplyTagVO.getRemark();
}
}
package com.mmc.iuav.user.service;
import com.mmc.iuav.page.PageResult;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.qo.ApplyQO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.model.vo.UserCooperationTagVO;
......@@ -9,18 +11,19 @@ import java.util.List;
import java.util.Set;
/**
* @author: zj
* @Date: 2023/5/17 21:19
* @author: zj @Date: 2023/5/17 21:19
*/
public interface CooperationService {
/**
* 加盟标签列表
*
* @return
*/
List<CooperationTagVO> listTag();
/**
* 用户申请加盟
*
* @param cooperationTagVO
* @return
*/
......@@ -35,8 +38,17 @@ public interface CooperationService {
/**
* 根据ID查询标签信息
*
* @param id
* @return
*/
ResultBody getTagById(Integer id);
PageResult listUserApplyTag(ApplyQO applyQO);
ResultBody deleteApplyTag(Integer id);
ResultBody applyTagDetails(Integer id, Integer userAccountId);
ResultBody approvalApplyTag(Integer id, Boolean status);
}
package com.mmc.iuav.user.service.impl;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.mmc.iuav.page.PageResult;
import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.response.ResultEnum;
import com.mmc.iuav.user.dao.CompanyAuthDao;
import com.mmc.iuav.user.dao.CooperationDao;
import com.mmc.iuav.user.entity.CompanyAuthDO;
import com.mmc.iuav.user.entity.CooperationTagDO;
import com.mmc.iuav.user.entity.UserApplyTagDO;
import com.mmc.iuav.user.entity.UserTagDO;
import com.mmc.iuav.user.entity.*;
import com.mmc.iuav.user.model.qo.ApplyQO;
import com.mmc.iuav.user.model.vo.AttachmentVO;
import com.mmc.iuav.user.model.vo.CooperationTagVO;
import com.mmc.iuav.user.model.vo.UserApplyTagDetailsVO;
import com.mmc.iuav.user.model.vo.UserApplyTagVO;
import com.mmc.iuav.user.model.vo.UserCooperationTagVO;
import com.mmc.iuav.user.service.CooperationService;
......@@ -22,39 +24,37 @@ import java.util.Set;
import java.util.stream.Collectors;
/**
* @author: zj
* @Date: 2023/5/17 21:19
* @author: zj @Date: 2023/5/17 21:19
*/
@Service
public class CooperationServiceImpl implements CooperationService {
@Autowired
private CooperationDao cooperationDao;
@Autowired private CooperationDao cooperationDao;
@Autowired
private CompanyAuthDao companyAuthDao;
@Autowired private CompanyAuthDao companyAuthDao;
@Override
public List<CooperationTagVO> listTag() {
List<CooperationTagDO> list = cooperationDao.listTags();
List<CooperationTagVO> resList = list.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
List<CooperationTagVO> resList =
list.stream().map(CooperationTagDO::buildCooperationTagVO).collect(Collectors.toList());
return resList;
}
@Override
public ResultBody apply(UserApplyTagVO userApplyTagVO) {
//判断企业认证
// 判断企业认证
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userApplyTagVO.getUserAccountId());
if (companyAuthDO == null) {
return ResultBody.error(ResultEnum.COMPANY_NOT_AUTH_ERROR);
}
UserApplyTagDO userApplyTagDO = new UserApplyTagDO(userApplyTagVO);
//判断是否已加盟
UserApplyTagDO existUserApplyTagDO = cooperationDao.getUserApplyTag(userApplyTagVO.getUserAccountId());
if (existUserApplyTagDO != null) {
cooperationDao.updateUserApplyTag(userApplyTagDO);
return ResultBody.success();
}
cooperationDao.addApply(userApplyTagDO);
List<AttachmentVO> attachmentList = userApplyTagVO.getAttachmentList();
for (AttachmentVO attachmentVO : attachmentList) {
TagApplyResourceDO tagApplyResourceDO =
new TagApplyResourceDO(attachmentVO, userApplyTagDO.getId());
cooperationDao.addApplyResource(tagApplyResourceDO);
}
return ResultBody.success();
}
......@@ -73,9 +73,78 @@ public class CooperationServiceImpl implements CooperationService {
@Override
public ResultBody getTagById(Integer id) {
CooperationTagDO cooperationTagDO = cooperationDao.getTagById(id);
if (cooperationTagDO == null){
if (cooperationTagDO == null) {
return ResultBody.success();
}
return ResultBody.success(cooperationTagDO.buildCooperationTagVO());
}
@Override
public PageResult listUserApplyTag(ApplyQO applyQO) {
int count = cooperationDao.countListUserApplyTag(applyQO);
if (count == 0) {
return PageResult.buildPage(applyQO.getPageNo(), applyQO.getPageSize(), count);
}
int pageNo = applyQO.getPageNo();
applyQO.buildCurrentPage();
List<UserApplyTagDO> userApplyTagList = cooperationDao.listUserApplyTag(applyQO);
List<UserApplyTagVO> list =
userApplyTagList.stream()
.map(UserApplyTagDO::buildUserApplyTagVO)
.collect(Collectors.toList());
return PageResult.buildPage(pageNo, applyQO.getPageSize(), count, list);
}
@Override
public ResultBody deleteApplyTag(Integer id) {
cooperationDao.deleteApplyTag(id);
return ResultBody.success();
}
@Override
public ResultBody applyTagDetails(Integer id, Integer userAccountId) {
// 初始化返回对象
UserApplyTagDetailsVO userApplyTagDetailsVO = new UserApplyTagDetailsVO();
// 获取企业认证信息
CompanyAuthDO companyAuthDO = companyAuthDao.getCompanyAuth(userAccountId);
// 获取申请信息
UserApplyTagDO userApplyTag = cooperationDao.getUserApplyTag(id);
// 获取附件信息
List<TagApplyResourceDO> tagApplyResourceList = cooperationDao.getUserApplyResource(id);
if (CollectionUtils.isNotEmpty(tagApplyResourceList)) {
List<AttachmentVO> list =
tagApplyResourceList.stream()
.map(TagApplyResourceDO::buildAttachmentVO)
.collect(Collectors.toList());
userApplyTagDetailsVO.setAttachmentList(list);
}
userApplyTagDetailsVO.setCompanyName(companyAuthDO.getCompanyName());
userApplyTagDetailsVO.setLicenseImg(companyAuthDO.getLicenseImg());
userApplyTagDetailsVO.setCreditCode(companyAuthDO.getCreditCode());
userApplyTagDetailsVO.setRemark(userApplyTag.getRemark());
return ResultBody.success(userApplyTagDetailsVO);
}
@Override
public ResultBody approvalApplyTag(Integer id, Boolean status) {
// 判断用户是否已经是该渠道
UserApplyTagDO userApplyTag = cooperationDao.getUserApplyTag(id);
int count =
cooperationDao.userTagInfo(
userApplyTag.getCooperationTagId(), userApplyTag.getUserAccountId());
if (count == 0) {
if (status) {
cooperationDao.updateApplyTagStatus(id, 1);
// 审批通过往用户标签表中新增一条数据
UserTagDO userTagDO = new UserTagDO();
userTagDO.setUserAccountId(userApplyTag.getUserAccountId());
userTagDO.setCooperationTagId(userApplyTag.getCooperationTagId());
cooperationDao.insertUserTag(userTagDO);
} else {
cooperationDao.updateApplyTagStatus(id, 2);
}
return ResultBody.success();
}
return ResultBody.success();
}
}
......@@ -4,14 +4,22 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.iuav.user.dao.CooperationDao">
<insert id="addApply" parameterType="com.mmc.iuav.user.entity.UserApplyTagDO" useGeneratedKeys="true" keyProperty="id">
<insert id="addApply" parameterType="com.mmc.iuav.user.entity.UserApplyTagDO" useGeneratedKeys="true"
keyProperty="id">
insert into user_apply_tag(cooperation_tag_id, user_account_id, apply_name, apply_phone, remark, create_time)
values(#{cooperationTagId}, #{userAccountId}, #{applyName}, #{applyPhone}, #{remark}, NOW())
values (#{cooperationTagId}, #{userAccountId}, #{applyName}, #{applyPhone}, #{remark}, NOW())
</insert>
<insert id="insertUserTag" useGeneratedKeys="true" parameterType="com.mmc.iuav.user.entity.UserTagDO" keyProperty="id">
<insert id="insertUserTag" useGeneratedKeys="true" parameterType="com.mmc.iuav.user.entity.UserTagDO"
keyProperty="id">
insert into user_tag(user_account_id, cooperation_tag_id, create_time)
values(#{userAccountId}, #{cooperationTagId}, NOW());
values (#{userAccountId}, #{cooperationTagId}, NOW());
</insert>
<insert id="addApplyResource">
insert into tag_apply_resource (user_apply_tag_id,
url,
`type`)
values (#{userApplyTagId}, #{url}, #{type})
</insert>
<insert id="batchInsertUserTag">
......@@ -48,21 +56,45 @@
</update>
<update id="updateUserTag">
update user_tag set cooperation_tag_id = #{cooperationTagId} where id = #{id}
update user_tag
set cooperation_tag_id = #{cooperationTagId}
where id = #{id}
</update>
<update id="removeUserTag">
update user_tag set is_deleted = 1 where user_account_id = #{userAccountId} and is_deleted = 0
</update>
<update id="updateApplyTagStatus">
update user_apply_tag
set apply_status = #{i}
where id = #{id}
</update>
<delete id="deleteApplyTag">
delete
from user_apply_tag
where id = #{id}
</delete>
<select id="listTags" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
select id, tag_name, tag_img, tag_description, create_time from cooperation_tag where is_deleted = 0
select id, tag_name, tag_img, tag_require, tag_description, create_time
from cooperation_tag
where is_deleted = 0
</select>
<select id="getUserApplyTag" resultType="com.mmc.iuav.user.entity.UserApplyTagDO">
select id, cooperation_tag_id, user_account_id, apply_name, apply_phone, apply_status, remark, create_time
select id,
cooperation_tag_id,
user_account_id,
apply_name,
apply_phone,
apply_status,
remark,
create_time
from user_apply_tag
where user_account_id = #{userAccountId} and is_deleted = 0
where id = #{id}
and is_deleted = 0
</select>
<select id="listUserCooperationTag" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
......@@ -71,7 +103,77 @@
</select>
<select id="getTagById" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
select id, tag_name, tag_img, tag_description, create_time from cooperation_tag where id = #{id} and is_deleted = 0
select id, tag_name, tag_img, tag_require, tag_description, create_time
from cooperation_tag
where id = #{id}
and is_deleted = 0
</select>
<select id="countListUserApplyTag" resultType="java.lang.Integer">
select count(*)
from user_apply_tag
<where>
is_deleted = 0
<if test="cooperationTagId != null">
and cooperation_tag_id = #{cooperationTagId}
</if>
<if test="applyStatus != null">
and apply_status = #{applyStatus}
</if>
<if test="startTime != null and startTime != '' ">
and create_time &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test="endTime != null and endTime != '' ">
and create_time &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d %H:%i:%s')
</if>
</where>
</select>
<select id="listUserApplyTag" resultType="com.mmc.iuav.user.entity.UserApplyTagDO">
SELECT
ua.id,
ua.cooperation_tag_id,
ua.user_account_id,
ua.apply_name,
ua.apply_phone,
ua.apply_status,
ua.remark,
ua.create_time,
ct.tag_name
FROM
user_apply_tag ua
INNER JOIN cooperation_tag ct ON ua.cooperation_tag_id = ct.id
<where>
ua.is_deleted = 0
<if test="cooperationTagId != null">
and ua.cooperation_tag_id = #{cooperationTagId}
</if>
<if test="applyStatus != null">
and ua.apply_status = #{applyStatus}
</if>
<if test="startTime != null and startTime != '' ">
and ua.create_time &gt;=
STR_TO_DATE(#{startTime},'%Y-%m-%d')
</if>
<if test="endTime != null and endTime != '' ">
and ua.create_time &lt;=
STR_TO_DATE(#{endTime},'%Y-%m-%d')
</if>
</where>
order by ua.create_time
limit #{pageNo},#{pageSize}
</select>
<select id="getUserApplyResource" resultType="com.mmc.iuav.user.entity.TagApplyResourceDO">
SELECT user_apply_tag_id,
url,
`type`
FROM tag_apply_resource
where user_apply_tag_id = #{id}
</select>
<select id="userTagInfo" resultType="java.lang.Integer">
select count(*)
from user_tag
where is_deleted = 0
and cooperation_tag_id = #{cooperationTagId}
and user_account_id = #{userAccountId}
</select>
<select id="listUserCooperationTagByUIds" resultType="com.mmc.iuav.user.entity.CooperationTagDO">
......
......@@ -18,4 +18,4 @@ patches:
images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/cms
newTag: 2537de8ac7f54ebbc6f0799d578a00b73632575e
newTag: 9b52210b702668e71172adf089dc2bb498d37438
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论