Commit ce6e0c38 authored by 廖旭伟's avatar 廖旭伟

微信扫码登录手机登录等

parent e511a534
ALTER TABLE `mortals_xhx_customer` ADD COLUMN `openId` varchar(128) DEFAULT NULL COMMENT '微信openid';
ALTER TABLE `mortals_xhx_customer_work_design` MODIFY COLUMN `updateTime` datetime DEFAULT NULL COMMENT '更新时间';
ALTER TABLE `mortals_xhx_customer_work_design_stat` MODIFY COLUMN `updateTime` datetime DEFAULT NULL COMMENT '更新时间';
ALTER TABLE `mortals_xhx_customer_work_design` ADD COLUMN `designType` tinyint(2) NOT NULL DEFAULT '1' COMMENT '作品类型:1:图片,2:视频';
ALTER TABLE `mortals_xhx_design_masterplate` ADD COLUMN `designType` tinyint(2) NOT NULL DEFAULT '1' COMMENT '作品类型:1:图片,2:视频';
ALTER TABLE `mortals_xhx_customer_work_collect` ADD COLUMN `designType` tinyint(2) NOT NULL DEFAULT '1' COMMENT '作品类型:1:图片,2:视频';
......@@ -59,10 +59,10 @@
<profiles.active>product</profiles.active>
<profiles.server.port>19211</profiles.server.port>
<profiles.queue.type>rabbitmq</profiles.queue.type>
<profiles.kafka.brokers>192.168.0.100:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.100</profiles.rabbitmq.host>
<profiles.kafka.brokers>127.0.0.1:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.nacos.server-addr>192.168.0.100:8848</profiles.nacos.server-addr>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>stp</profiles.nacos.namespace>
<profiles.log.level>info</profiles.log.level>
......
package com.mortals.xhx.common.code;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.IBaseEnum;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 设计类型
*/
public enum DesignTypeEnum implements IBaseEnum {
PICTURES(1,"图片", SysConstains.STYLE_DEFAULT),
VIDEOS(2,"视频", SysConstains.STYLE_DEFAULT),
;
private int value;
private String desc;
private String style;
DesignTypeEnum(int value, String desc, String style) {
this.value = value;
this.desc = desc;
this.style = style;
}
@Override
public int getValue() {
return this.value;
}
@Override
public String getDesc() {
return this.desc;
}
@Override
public String getStyle() {
return this.style;
}
public static DesignTypeEnum getByValue(int value) {
for (DesignTypeEnum e : DesignTypeEnum.values()) {
if (e.getValue() == value) {
return e;
}
}
return null;
}
public static Map<String,String> getEnumMap(int... eItem) {
Map<String,String> resultMap= new LinkedHashMap<String,String>();
for (DesignTypeEnum item : DesignTypeEnum.values()) {
try{
boolean hasE = false;
for (int e : eItem){
if(item.getValue()==e){
hasE = true;
break;
}
}
if(!hasE){
resultMap.put(item.getValue()+"", item.getDesc());
}
}catch(Exception ex){
}
}
return resultMap;
}
}
\ No newline at end of file
......@@ -93,7 +93,10 @@ public class CustomerEntity extends CustomerVo implements IUser {
*/
private String lastLoginAddress;
/**
* 微信openid
*/
private String openId;
public CustomerEntity(){}
/**
......@@ -330,8 +333,13 @@ public class CustomerEntity extends CustomerVo implements IUser {
this.lastLoginAddress = lastLoginAddress;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
@Override
public int hashCode() {
......
package com.mortals.xhx.module.customer.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.customer.model.vo.CustomerWorkCollectVo;
import lombok.Data;
/**
* 客户收藏信息实体对象
*
* @author zxfei
* @date 2022-06-13
*/
* 客户收藏信息实体对象
*
* @author zxfei
* @date 2023-07-11
*/
@Data
public class CustomerWorkCollectEntity extends CustomerWorkCollectVo {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
* 客户ID
*/
private Long customerId;
/**
* 模版ID
*/
* 模版ID
*/
private Long masterplateId;
public CustomerWorkCollectEntity(){}
/**
* 获取 客户ID
* @return Long
*/
public Long getCustomerId(){
return customerId;
}
/**
* 设置 客户ID
* @param customerId
*/
public void setCustomerId(Long customerId){
this.customerId = customerId;
}
/**
* 获取 模版ID
* @return Long
*/
public Long getMasterplateId(){
return masterplateId;
}
/**
* 设置 模版ID
* @param masterplateId
*/
public void setMasterplateId(Long masterplateId){
this.masterplateId = masterplateId;
}
* 作品类型:1:图片,2:视频
*/
private Integer designType;
@Override
public int hashCode() {
return this.getId().hashCode();
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
......@@ -70,23 +38,18 @@ public class CustomerWorkCollectEntity extends CustomerWorkCollectVo {
if (obj instanceof CustomerWorkCollectEntity) {
CustomerWorkCollectEntity tmp = (CustomerWorkCollectEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",customerId:").append(getCustomerId());
sb.append(",masterplateId:").append(getMasterplateId());
return sb.toString();
}
public void initAttrValue(){
this.customerId = null;
this.customerId = null;
this.masterplateId = -1L;
this.masterplateId = null;
this.designType = 1;
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.customer.model.vo.CustomerWorkDesignVo;
import lombok.Data;
/**
* 客户作品信息实体对象
*
* @author zxfei
* @date 2022-07-08
* @date 2023-07-11
*/
@Data
public class CustomerWorkDesignEntity extends CustomerWorkDesignVo {
private static final long serialVersionUID = 1L;
......@@ -56,154 +56,10 @@ public class CustomerWorkDesignEntity extends CustomerWorkDesignVo {
* 设计草稿
*/
private String draft;
public CustomerWorkDesignEntity(){}
/**
* 获取 客户ID
* @return Long
*/
public Long getCustomerId(){
return customerId;
}
/**
* 设置 客户ID
* @param customerId
*/
public void setCustomerId(Long customerId){
this.customerId = customerId;
}
/**
* 获取 作品名称
* @return String
*/
public String getWorkDesignName(){
return workDesignName;
}
/**
* 设置 作品名称
* @param workDesignName
*/
public void setWorkDesignName(String workDesignName){
this.workDesignName = workDesignName;
}
/**
* 获取 作品状态:0:草稿,1:发布
* @return Integer
*/
public Integer getWorkDesignStatus(){
return workDesignStatus;
}
/**
* 设置 作品状态:0:草稿,1:发布
* @param workDesignStatus
*/
public void setWorkDesignStatus(Integer workDesignStatus){
this.workDesignStatus = workDesignStatus;
}
/**
* 获取 作品描述
* @return String
*/
public String getWorkDesignDesc(){
return workDesignDesc;
}
/**
* 设置 作品描述
* @param workDesignDesc
*/
public void setWorkDesignDesc(String workDesignDesc){
this.workDesignDesc = workDesignDesc;
}
/**
* 获取 模版引用的图片
* @return String
*/
public String getPictureIds(){
return pictureIds;
}
/**
* 设置 模版引用的图片
* @param pictureIds
*/
public void setPictureIds(String pictureIds){
this.pictureIds = pictureIds;
}
/**
* 获取 模版引用的素材
* @return String
* 作品类型:1:图片,2:视频
*/
public String getPictureSrcIds(){
return pictureSrcIds;
}
/**
* 设置 模版引用的素材
* @param pictureSrcIds
*/
public void setPictureSrcIds(String pictureSrcIds){
this.pictureSrcIds = pictureSrcIds;
}
/**
* 获取 模版引用的背景
* @return String
*/
public String getPictureBackgroundIds(){
return pictureBackgroundIds;
}
/**
* 设置 模版引用的背景
* @param pictureBackgroundIds
*/
public void setPictureBackgroundIds(String pictureBackgroundIds){
this.pictureBackgroundIds = pictureBackgroundIds;
}
/**
* 获取 作品引用的字体
* @return String
*/
public String getFontIds(){
return fontIds;
}
/**
* 设置 作品引用的字体
* @param fontIds
*/
public void setFontIds(String fontIds){
this.fontIds = fontIds;
}
/**
* 获取 作品图片预览地址(相对地址)
* @return String
*/
public String getPreviewUrl(){
return previewUrl;
}
/**
* 设置 作品图片预览地址(相对地址)
* @param previewUrl
*/
public void setPreviewUrl(String previewUrl){
this.previewUrl = previewUrl;
}
/**
* 获取 设计草稿
* @return String
*/
public String getDraft(){
return draft;
}
/**
* 设置 设计草稿
* @param draft
*/
public void setDraft(String draft){
this.draft = draft;
}
private Integer designType;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -220,28 +76,13 @@ public class CustomerWorkDesignEntity extends CustomerWorkDesignVo {
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",customerId:").append(getCustomerId());
sb.append(",workDesignName:").append(getWorkDesignName());
sb.append(",workDesignStatus:").append(getWorkDesignStatus());
sb.append(",workDesignDesc:").append(getWorkDesignDesc());
sb.append(",pictureIds:").append(getPictureIds());
sb.append(",pictureSrcIds:").append(getPictureSrcIds());
sb.append(",pictureBackgroundIds:").append(getPictureBackgroundIds());
sb.append(",fontIds:").append(getFontIds());
sb.append(",previewUrl:").append(getPreviewUrl());
sb.append(",draft:").append(getDraft());
return sb.toString();
}
public void initAttrValue(){
this.customerId = null;
this.workDesignName = "";
this.workDesignStatus = null;
this.workDesignStatus = -1;
this.workDesignDesc = "";
......@@ -256,5 +97,7 @@ public class CustomerWorkDesignEntity extends CustomerWorkDesignVo {
this.previewUrl = "";
this.draft = "";
this.designType = 1;
}
}
\ No newline at end of file
......@@ -82,4 +82,13 @@ public interface CustomerService extends ICRUDService<CustomerEntity,Long>{
*/
CustomerEntity doSmsLogin(String mobileNumber, String verifyCode, String loginIp) throws AppException;
/**
* 微信扫码登录
* @param openId
* @param loginIp
* @return
* @throws AppException
*/
CustomerEntity doWeChatLogin(String openId, String loginIp) throws AppException;
}
\ No newline at end of file
......@@ -148,6 +148,16 @@ public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, Cu
@Override
public CustomerEntity updateByPersonal(CustomerEntity params, Context context) throws AppException {
CustomerEntity old = this.get(params.getId());
if(old==null){
throw new AppException("用户Id不正确!");
}
if(!old.getLoginName().equals(params.getLoginName())) {
CustomerEntity user = this.findByLoginName(params.getLoginName());
if (user != null) {
throw new AppException("用户名已存在!");
}
}
CustomerEntity update = new CustomerEntity();
update.setId(params.getId());
update.setLoginName(params.getLoginName());
......@@ -158,6 +168,7 @@ public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, Cu
update.setContactTelphone(params.getContactTelphone());
update.setMailbox(params.getMailbox());
update.setJob(params.getJob());
update.setOpenId(params.getOpenId());
int iRet = this.dao.update(update);
if (iRet == 0) {
throw new AppException(-1002, "更新失败!");
......@@ -253,6 +264,10 @@ public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, Cu
if(customer==null){
throw new AppException("手机号码:" + mobileNumber + "没有注册用户");
}
String verifyCode = cacheService.get(SMS_VERIFY_CODE_KEY + mobileNumber);
if(StringUtils.isNotEmpty(verifyCode)){
throw new AppException("当前手机号码已发送验证码,请稍后重试");
}
try {
Map<String, String> params = new HashMap<>();
params.put("appid",appid);
......@@ -308,6 +323,20 @@ public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, Cu
return customer;
}
@Override
public CustomerEntity doWeChatLogin(String openId, String loginIp) throws AppException {
CustomerEntity customer = this.selectOne(new CustomerQuery().openId(openId));
if(customer==null){
throw new AppException("用户未绑定微信");
}
CustomerEntity update = new CustomerEntity();
update.setId(customer.getId());
update.setLastLoginAddress(loginIp);
update.setLastLoginTime(new Date());
this.update(update);
return customer;
}
public static void main(String[] args){
try {
JSONObject jsonObject = new JSONObject();
......
......@@ -54,6 +54,10 @@ public class CustomerWorkCollectServiceImpl extends AbstractCRUDServiceImpl<Cust
protected void saveBefore(CustomerWorkCollectEntity entity, Context context) throws AppException {
this.validData(entity, context);
entity.setCustomerId(this.getContextUserId(context));
DesignMasterplateEntity masterplateEntity = designMasterplateService.get(entity.getMasterplateId());
if(masterplateEntity!=null){
entity.setDesignType(masterplateEntity.getDesignType());
}
CustomerWorkCollectEntity query = new CustomerWorkCollectEntity();
query.setCustomerId(entity.getCustomerId());
query.setMasterplateId(entity.getMasterplateId());
......
......@@ -7,10 +7,7 @@ import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.WorkDesignStatusEnum;
import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.customer.dao.CustomerWorkDesignDao;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignStatQuery;
import com.mortals.xhx.module.customer.model.*;
import com.mortals.xhx.module.customer.service.CustomerService;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignService;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignStatService;
......@@ -22,6 +19,8 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
......@@ -65,8 +64,13 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
if(CollectionUtils.isEmpty(cwdList)){
CustomerWorkDesignStatEntity cwdEntity = new CustomerWorkDesignStatEntity();
cwdEntity.setCustomerId(entity.getCustomerId());
cwdEntity.setCustomerDesignPictures(1);
cwdEntity.setCustomerDesignVideos(0);
if(entity.getDesignType()==1) {
cwdEntity.setCustomerDesignPictures(1);
cwdEntity.setCustomerDesignVideos(0);
}else {
cwdEntity.setCustomerDesignPictures(0);
cwdEntity.setCustomerDesignVideos(1);
}
cwdEntity.setCreateTime(new Date());
cwdEntity.setUpdateTime(new Date());
customerWorkDesignStatService.save(cwdEntity);
......@@ -74,7 +78,11 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
CustomerWorkDesignStatEntity cwdEntity = cwdList.get(0);
CustomerWorkDesignStatQuery updateEntity = new CustomerWorkDesignStatQuery();
updateEntity.setId(cwdEntity.getId());
updateEntity.setCustomerDesignPicturesIncrement(1);
if(entity.getDesignType()==1) {
updateEntity.setCustomerDesignPicturesIncrement(1);
}else {
updateEntity.setCustomerDesignVideosIncrement(1);
}
updateEntity.setUpdateTime(new Date());
customerWorkDesignStatService.update(updateEntity);
}
......@@ -135,6 +143,7 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
newMasterplate.setPreviewUrl(entity.getFrontCover());
newMasterplate.setDraft(workDesign.getDraft());
newMasterplate.setPlateType(entity.getPlateType()==null?1:entity.getPlateType());
newMasterplate.setDesignType(workDesign.getDesignType());
newMasterplate.setCreateTime(new Date());
designMasterplateService.save(newMasterplate,context);
return 1;
......@@ -152,7 +161,8 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
@Override
public int remove(Long[] ids, Context context) throws AppException {
this.removeBefore(ids, context);
List<CustomerWorkDesignEntity> list = this.get(ids,context);
List<Long> idList = new ArrayList<>(Arrays.asList(ids));
List<CustomerWorkDesignEntity> list = this.find(new CustomerWorkDesignQuery().idList(idList));
int iRet = this.dao.delete(ids);
if(CollectionUtils.isNotEmpty(list)){
list.forEach(e->{
......
package com.mortals.xhx.module.customer.web;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.DesignTypeEnum;
import com.mortals.xhx.common.key.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -43,6 +45,7 @@ public class CustomerWorkCollectController extends BaseCRUDJsonBodyMappingContro
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "designType", IBaseEnum.getEnumMap(DesignTypeEnum.class));
super.init(model, context);
}
......
......@@ -6,20 +6,24 @@ import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.DesignTypeEnum;
import com.mortals.xhx.common.code.WorkDesignStatusEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
......@@ -39,6 +43,7 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "workDesignStatus", IBaseEnum.getEnumMap(WorkDesignStatusEnum.class));
this.addDict(model, "designType", IBaseEnum.getEnumMap(DesignTypeEnum.class));
super.init(model, context);
}
......@@ -85,6 +90,7 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl
throw new AppException("非法用户,不可访问");
}
entity.setCustomerId(this.getCurUser().getId());
entity.setUpdateTime(entity.getCreateTime());
if(CollectionUtils.isNotEmpty(entity.getDesignContent())) {
entity.setDraft(JSONObject.toJSONString(entity.getDesignContent()));
}
......
package com.mortals.xhx.module.design.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.design.model.vo.DesignMasterplateVo;
import lombok.Data;
/**
* 模版管理实体对象
*
* @author zxfei
* @date 2022-07-26
* @date 2023-07-11
*/
@Data
public class DesignMasterplateEntity extends DesignMasterplateVo {
private static final long serialVersionUID = 1L;
......@@ -72,210 +72,10 @@ public class DesignMasterplateEntity extends DesignMasterplateVo {
* 版式。1:横版2竖版默认:1
*/
private Integer plateType;
public DesignMasterplateEntity(){}
/**
* 获取 模版名称
* @return String
*/
public String getMasterplateName(){
return masterplateName;
}
/**
* 设置 模版名称
* @param masterplateName
*/
public void setMasterplateName(String masterplateName){
this.masterplateName = masterplateName;
}
/**
* 获取 模版编码
* @return Integer
*/
public Integer getMasterplateCode(){
return masterplateCode;
}
/**
* 设置 模版编码
* @param masterplateCode
*/
public void setMasterplateCode(Integer masterplateCode){
this.masterplateCode = masterplateCode;
}
/**
* 获取 发布人
* @return Long
*/
public Long getCustomerId(){
return customerId;
}
/**
* 设置 发布人
* @param customerId
*/
public void setCustomerId(Long customerId){
this.customerId = customerId;
}
/**
* 获取 发布人名称
* @return String
*/
public String getCustomerName(){
return customerName;
}
/**
* 设置 发布人名称
* @param customerName
*/
public void setCustomerName(String customerName){
this.customerName = customerName;
}
/**
* 获取 模版描述
* @return String
*/
public String getMasterplateDesc(){
return masterplateDesc;
}
/**
* 设置 模版描述
* @param masterplateDesc
*/
public void setMasterplateDesc(String masterplateDesc){
this.masterplateDesc = masterplateDesc;
}
/**
* 获取 模版下载地址(相对地址)
* @return String
*/
public String getMasterplatePath(){
return masterplatePath;
}
/**
* 设置 模版下载地址(相对地址)
* @param masterplatePath
*/
public void setMasterplatePath(String masterplatePath){
this.masterplatePath = masterplatePath;
}
/**
* 获取 模版引用的图片
* @return String
*/
public String getPictureIds(){
return pictureIds;
}
/**
* 设置 模版引用的图片
* @param pictureIds
*/
public void setPictureIds(String pictureIds){
this.pictureIds = pictureIds;
}
/**
* 获取 模版引用的素材
* @return String
* 作品类型:1:图片,2:视频
*/
public String getPictureSrcIds(){
return pictureSrcIds;
}
/**
* 设置 模版引用的素材
* @param pictureSrcIds
*/
public void setPictureSrcIds(String pictureSrcIds){
this.pictureSrcIds = pictureSrcIds;
}
/**
* 获取 模版引用的背景
* @return String
*/
public String getPictureBackgroundIds(){
return pictureBackgroundIds;
}
/**
* 设置 模版引用的背景
* @param pictureBackgroundIds
*/
public void setPictureBackgroundIds(String pictureBackgroundIds){
this.pictureBackgroundIds = pictureBackgroundIds;
}
/**
* 获取 模版引用的字体
* @return String
*/
public String getFontIds(){
return fontIds;
}
/**
* 设置 模版引用的字体
* @param fontIds
*/
public void setFontIds(String fontIds){
this.fontIds = fontIds;
}
/**
* 获取 模版被引用的次数。默认:0
* @return Integer
*/
public Integer getMasterplateUseNum(){
return masterplateUseNum;
}
/**
* 设置 模版被引用的次数。默认:0
* @param masterplateUseNum
*/
public void setMasterplateUseNum(Integer masterplateUseNum){
this.masterplateUseNum = masterplateUseNum;
}
/**
* 获取 作品图片预览地址(相对地址)
* @return String
*/
public String getPreviewUrl(){
return previewUrl;
}
/**
* 设置 作品图片预览地址(相对地址)
* @param previewUrl
*/
public void setPreviewUrl(String previewUrl){
this.previewUrl = previewUrl;
}
/**
* 获取 设计草稿
* @return String
*/
public String getDraft(){
return draft;
}
/**
* 设置 设计草稿
* @param draft
*/
public void setDraft(String draft){
this.draft = draft;
}
/**
* 获取 版式。1:横版2竖版默认:1
* @return Integer
*/
public Integer getPlateType(){
return plateType;
}
/**
* 设置 版式。1:横版2竖版默认:1
* @param plateType
*/
public void setPlateType(Integer plateType){
this.plateType = plateType;
}
private Integer designType;
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -292,32 +92,13 @@ public class DesignMasterplateEntity extends DesignMasterplateVo {
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",masterplateName:").append(getMasterplateName());
sb.append(",masterplateCode:").append(getMasterplateCode());
sb.append(",customerId:").append(getCustomerId());
sb.append(",customerName:").append(getCustomerName());
sb.append(",masterplateDesc:").append(getMasterplateDesc());
sb.append(",masterplatePath:").append(getMasterplatePath());
sb.append(",pictureIds:").append(getPictureIds());
sb.append(",pictureSrcIds:").append(getPictureSrcIds());
sb.append(",pictureBackgroundIds:").append(getPictureBackgroundIds());
sb.append(",fontIds:").append(getFontIds());
sb.append(",masterplateUseNum:").append(getMasterplateUseNum());
sb.append(",previewUrl:").append(getPreviewUrl());
sb.append(",draft:").append(getDraft());
sb.append(",plateType:").append(getPlateType());
return sb.toString();
}
public void initAttrValue(){
this.masterplateName = "";
this.masterplateCode = null;
this.masterplateCode = -1;
this.customerId = null;
this.customerId = -1L;
this.customerName = "";
......@@ -333,12 +114,14 @@ public class DesignMasterplateEntity extends DesignMasterplateVo {
this.fontIds = "";
this.masterplateUseNum = null;
this.masterplateUseNum = -1;
this.previewUrl = "";
this.draft = "";
this.plateType = null;
this.plateType = -1;
this.designType = 1;
}
}
\ No newline at end of file
package com.mortals.xhx.module.design.web;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DesignTypeEnum;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -45,6 +47,7 @@ public class DesignMasterplateController extends BaseCRUDJsonBodyMappingControll
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "designType", IBaseEnum.getEnumMap(DesignTypeEnum.class));
super.init(model, context);
}
......
......@@ -52,8 +52,13 @@ public class PictureGroupController extends BaseCRUDJsonBodyMappingController<Pa
if(paramEntities.isEmpty()){
max = 1;
}else {
ParamEntity maxEntity = paramEntities.stream().max(Comparator.comparing(ParamEntity::getParamKey)).get();
max = DataUtil.converStr2Int(maxEntity.getParamKey(),paramEntities.size())+1;
for(ParamEntity item:paramEntities){
int temp = DataUtil.converStr2Int(item.getParamKey(),0);
if(max < temp){
max = temp;
}
}
max++;
}
entity.setParamKey(max+"");
entity.setName("素材分组");
......
package com.mortals.xhx.module.thirdlog.wechat;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.common.utils.StringUtils;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.service.CustomerService;
import com.mortals.xhx.module.thirdlog.sms.pdu.SMSLoginPdu;
import com.mortals.xhx.module.thirdlog.wechat.utils.WeChatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
* 微信扫码登录
*/
@RestController
@RequestMapping("wechat")
public class WeChatLoginController extends BaseJsonBodyController {
@Autowired
private CustomerService customerService;
@Autowired
private ICacheService cacheService;
private static String WX_VERIFY_CODE_KEY ="login:wx:verify:";
/**
* 微信appId
*/
@Value("${WeChat.pc.appID:wx55400ca31cbbe7fb}")
private String APP_ID;
/**
* 微信appSecret
*/
@Value("${WeChat.pc.appSecret:22555d29a9f914bac0400af5cf63d6b3}")
private String APP_SECRET;
@RequestMapping(
value = {"getLoginSoleCode"},
method = {RequestMethod.POST, RequestMethod.GET}
)
@UnAuth
public Rest<Object> sendSmsVerifyCode(){
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
String busiDesc = "获取微信登录验证码";
int code=1;
try {
String vCode = RandomUtil.randomNumbers(11);
cacheService.setnx(WX_VERIFY_CODE_KEY+vCode,vCode,90);
model.put("data",vCode);
model.put("message_info", busiDesc + "成功");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model.get("data"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@RequestMapping(
value = {"wxLoginOAuth"},
method = {RequestMethod.POST, RequestMethod.GET}
)
@UnAuth
public String wxLoginOAuth(HttpServletRequest request, HttpServletResponse response){
JSONObject ret = new JSONObject();
Map<String, Object> data = new HashMap<>();
try {
// 第三方发起微信授权登录请求,微信用户允许授权第三方应用后,微信会拉起应用或重定向到第三方网站,并且带上授权临时票据code参数;
String loginCode = request.getParameter("code");
//前端扫码登入传来的时间戳
String loginState = request.getParameter("state");
//用户拒绝授权时code为空,微信也不会请求该接口。为了防止非法请求,若code为空则返回
if (StringUtils.isEmpty(loginCode)) {
throw new AppException("登入请求被拒绝");
}
if (StringUtils.isEmpty(loginState)) {
throw new AppException("请求状态异常");
}
String vCode = cacheService.get(WX_VERIFY_CODE_KEY + loginState);
if (StringUtils.isEmpty(vCode)){
throw new AppException("微信登录验证码失效");
}
Map<String,String> accessTokenMap = WeChatUtils.getAccessToken(loginCode,APP_ID,APP_SECRET);
String access_token = accessTokenMap.get("access_token");//接口调用凭证,登录后右上角展示数据需要该值去获取
String openid = accessTokenMap.get("openid");//授权用户唯一标识
String ip = super.getRequestIP(request);
CustomerEntity customerEntity = customerService.doWeChatLogin(openid,ip);
customerEntity.setLastLoginAddress(ip);
customerEntity.setLoginTime(System.currentTimeMillis());
customerEntity.setToken(IdUtil.fastSimpleUUID());
customerEntity.setExpireTime(DateUtils.addCurrDate(7).getTime());
String token = authTokenService.createToken(customerEntity);
data.put("token", token);
data.put("customer", customerEntity);
recordSysLog(request, customerEntity, "客户扫码登录系统成功!");
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
return ret.toJSONString();
} catch (Exception e) {
log.error("login error ", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
@RequestMapping(
value = {"bind"},
method = {RequestMethod.POST, RequestMethod.GET}
)
@UnAuth
public String bind(HttpServletRequest request, HttpServletResponse response){
JSONObject ret = new JSONObject();
Map<String, Object> data = new HashMap<>();
try {
// 第三方发起微信授权登录请求,微信用户允许授权第三方应用后,微信会拉起应用或重定向到第三方网站,并且带上授权临时票据code参数;
String loginCode = request.getParameter("code");
//前端扫码登入传来的时间戳
String loginState = request.getParameter("state");
//用户拒绝授权时code为空,微信也不会请求该接口。为了防止非法请求,若code为空则返回
if (StringUtils.isEmpty(loginCode)) {
throw new AppException("登入请求被拒绝");
}
if (StringUtils.isEmpty(loginState)) {
throw new AppException("请求状态异常");
}
String vCode = cacheService.get(WX_VERIFY_CODE_KEY + loginState);
if (StringUtils.isEmpty(vCode)){
throw new AppException("微信登录验证码失效");
}
Map<String,String> accessTokenMap = WeChatUtils.getAccessToken(loginCode,APP_ID,APP_SECRET);
String access_token = accessTokenMap.get("access_token");//接口调用凭证,登录后右上角展示数据需要该值去获取
String openid = accessTokenMap.get("openid");//授权用户唯一标识
data.put("openId", openid);
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "微信扫码成功!");
return ret.toJSONString();
} catch (Exception e) {
log.error("bind error ", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
}
package com.mortals.xhx.module.thirdlog.wechat.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* description: json工具类 <br>
* version: 1.0 <br>
* @date: 2019/7/20 0019 上午 10:17 <br>
* @author: William <br>
*/
public class JsonUtils {
public static final ObjectMapper MAPPER = new ObjectMapper();
private static final Logger logger = LoggerFactory.getLogger(JsonUtils.class);
public static String serialize(Object obj) {
if (obj == null) {
return null;
}
if (obj.getClass() == String.class) {
return (String) obj;
}
try {
return MAPPER.writeValueAsString(obj);
} catch (JsonProcessingException e) {
logger.error("json序列化出错:" + obj, e);
return null;
}
}
public static <T> T parse(String json, Class<T> tClass) {
try {
return MAPPER.readValue(json, tClass);
} catch (IOException e) {
logger.error("json解析出错:" + json, e);
return null;
}
}
public static <E> List<E> parseList(String json, Class<E> eClass) {
try {
return MAPPER.readValue(json, MAPPER.getTypeFactory().constructCollectionType(List.class, eClass));
} catch (IOException e) {
logger.error("json解析出错:" + json, e);
return null;
}
}
public static <K, V> Map<K, V> parseMap(String json, Class<K> kClass, Class<V> vClass) {
try {
return MAPPER.readValue(json, MAPPER.getTypeFactory().constructMapType(Map.class, kClass, vClass));
} catch (IOException e) {
logger.error("json解析出错:" + json, e);
return null;
}
}
public static <T> T nativeRead(String json, TypeReference<T> type) {
try {
return MAPPER.readValue(json, type);
} catch (IOException e) {
logger.error("json解析出错:" + json, e);
return null;
}
}
}
package com.mortals.xhx.module.thirdlog.wechat.utils;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import org.springframework.beans.factory.annotation.Value;
import java.util.Map;
/**
* description: WeChatUtils 微信获取用户工具类<br>
*
* @date: 2021/8/19 0019 上午 10:05 <br>
* @author: William <br>
* version: 1.0 <br>
*/
public class WeChatUtils {
/**
* 获取微信accessToken路径
*/
private static final String GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
/**
* 微信appId
*/
@Value("${WeChat.pc.appID:wx55400ca31cbbe7fb}")
private static String APP_ID;
/**
* 微信appSecret
*/
@Value("${WeChat.pc.appSecret:22555d29a9f914bac0400af5cf63d6b3}")
private static String APP_SECRET;
/**
* description: getAccessToken 根据code获取accessToken<br>
* version: 1.0 <br>
* @date: 2021/8/19 0019 上午 10:10 <br>
* @author: William <br>
* @param code 微信用户授权code
* @return java.util.Map<java.lang.String,java.lang.String>
*/
public static Map<String,String> getAccessToken(String code){
return getAccessToken(code,APP_ID,APP_SECRET);
}
/**
* description: getAccessToken 根据code获取微信用户信息,返回map如果正确map包含access_token ,如果错误则包含:errcode<br>
* version: 1.0 <br>
* @date: 2021/8/19 0019 上午 10:11 <br>
* @author: William <br>
* @param code 微信授权code
* @param appId 微信appId
* @param appSecret 微信appSecret
* @return java.util.Map<java.lang.String,java.lang.String>
*/
public static Map<String,String> getAccessToken(String code,String appId,String appSecret){
//判断所有字段不能为空
if(isAnyBlank(code,appId,appSecret)){
throw new IllegalArgumentException("参数错误");
}
String requestUrl = GET_ACCESS_TOKEN_URL.replace("APPID",appId)
.replace("SECRET",appSecret).replace("CODE",code);
String result = HttpUtil.get(requestUrl);
return JsonUtils.parseMap(result, String.class, String.class);
}
/**
* description: isAnyBlank 判断是否存在空字符串,Hutool未编写<br>
* version: 1.0 <br>
* @date: 2021/8/19 0019 上午 10:25 <br>
* @author: William <br>
* @param strs 字符串
* @return java.lang.Boolean
*/
public static Boolean isAnyBlank(CharSequence... strs){
//如果为空直接返回true
if (ArrayUtil.isEmpty(strs)) {
return true;
}
for (CharSequence str : strs) {
if (StrUtil.isBlank(str)) {
return true;
}
}
return false;
}
}
server:
port: @profiles.server.port@
servlet:
context-path: /eas
tomcat:
uri-encoding: utf-8
spring:
application:
name: @project.artifactId@
name: eas-manager
profiles:
active: @profiles.active@
servlet:
......@@ -13,19 +16,29 @@ spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
cloud:
nacos:
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
discovery:
server-addr: @profiles.nacos.server-addr@ # Nacos 服务器地址
group: @profiles.nacos.group@
namespace: @profiles.nacos.namespace@
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务器地址
group: ${spring.cloud.nacos.discovery.group}
namespace: ${spring.cloud.nacos.discovery.namespace} # Nacos 命名空间 dev 的编号
file-extension: yaml
security:
enable: true
user:
name: admin
password: 1
redis:
host: @profiles.redis.uri@
port: @profiles.redis.port@
username: @profiles.redis.username@
password: @profiles.redis.password@
database: @profiles.redis.database@
timeout: 30000
pool:
max-idle: 30
min-idle: 0
max-active: 100
max-wait: 1000
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: @profiles.datasource.uri@
username: @profiles.datasource.username@
password: @profiles.datasource.password@
mybatis:
root-path: com.mortals
type-aliases-package: com.mortals.framework.model,com.mortals.xhx.common.**.model,com.mortals.xhx.**.model
......@@ -38,5 +51,16 @@ application:
uncheckUrl: /refresh,/error,/login/login,/login/index,/login/logout,/customer/login/login,/customer/login/logout,/securitycode/createCode,/customer/trial/save,/file/common/*,/file/preview/*,/test*,/api/asset/*,/api/*,/zwfw/*,/ws/*,/swagger-ui*,/topic/*,/uploads/*
workflow:
tenantId: ${spring.application.name}
cookie:
ssoServerUrl: http://sso.testnew.com
key: 026db82420614469897fcc2dc1b4ce38
domain: base.testnew.com
port: 111
token:
head: mortal
upload:
path: @profiles.filepath@
WeChat:
pc:
appID: wx55400ca31cbbe7fb
appSecret: 22555d29a9f914bac0400af5cf63d6b3
......@@ -9,7 +9,7 @@
<setting name="useGeneratedKeys" value="false" />
<setting name="defaultExecutorType" value="REUSE" />
<!-- 是否开始sql日志控制台打印 -->
<setting name="logImpl" value="STDOUT_LOGGING" />
<!-- <setting name="logImpl" value="STDOUT_LOGGING" />-->
</settings>
<plugins>
<plugin interceptor="com.mortals.framework.thirty.mybatis.MortalsPagePlugin">
......
......@@ -24,6 +24,7 @@
<result property="updateTime" column="updateTime" />
<result property="lastLoginTime" column="lastLoginTime" />
<result property="lastLoginAddress" column="lastLoginAddress" />
<result property="openId" column="openId" />
<result property="customerDesignPictures" column="customerDesignPictures" />
<result property="customerDesignVideos" column="customerDesignVideos" />
</resultMap>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment