Commit 2b455177 authored by 廖旭伟's avatar 廖旭伟

前台个人中心,个人信息修改,密码修改

parent 9c4547ce
......@@ -4643,6 +4643,7 @@ data|object|数据对象
  customerId|Long|客户ID
  masterplateId|Long|模版ID
  createTime|Date|收藏时间
  designMasterplate|object|模板对象
dict|object|字典对象
**响应消息样例:**
......@@ -4774,9 +4775,9 @@ msg|String|消息|-
```
### 个人信息
### 个人中心
**请求URL:** customer/info
**请求URL:** customer/personal
**请求方式:** GET
......@@ -4784,15 +4785,9 @@ msg|String|消息|-
**简要描述:** 查看客户管理,返回实例详细信息
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
id|Long|是|ID
**请求样例:**
```
http://localhost/customer/info?id=549
http://localhost/customer/personal
```
**响应参数:**
......@@ -4813,6 +4808,7 @@ data|object|数据对象
 sex|Integer|性别
 mailbox|String|邮箱
 job|String|职位
 avatar|String|头像图片地址
 customerSrc|Long|客户来源
 status|Integer|使用状态,1:正常,0:禁用,默认:0
 createUserId|Long|创建用户
......@@ -4850,6 +4846,150 @@ dict|object|字典对象
}
```
### 修改个人信息
**请求URL:** customer/personal/update
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 保存或更新客户管理:id为空时为新增保存,否则为更新提交
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:-------
loginName|String|是|用户登录账号
custName|String|是|客户真实名称
organization|String|是|单位名称
contactTelphone|String|是|联系电话
sex|Integer|是|性别
mailbox|String|是|邮箱
job|String|是|职位
avatarString|是|头像图片地址
**请求样例:**
```
{
"loginName":"6q0z8f",
"custName":"r7s2ru",
"organization":"074b9m",
"contactTelphone":"s11ai2",
"sex":5045,
"mailbox":"okie88",
"job":"sup79w",
"avatar":"sup79w"
}
```
**响应参数:**
参数名称 |参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 id|Long|保存后主键id
 entity|object|保存更新实体
  id|Long|主键ID,主键,自增长
  loginName|String|用户登录账号
  password|String|密码
  memberLevel|Integer|会员等级,,0:未开启,1:试用客户,2:VIP,3:设计师,默认0
  custName|String|客户真实名称
  organization|String|单位名称
  contactTelphone|String|联系电话
  enterpriseConsultant|String|企业顾问
  siteId|Long|站点ID
  sex|Integer|性别
  mailbox|String|邮箱
  job|String|职位
  avatar|String|头像图片地址
  customerSrc|Long|客户来源
  status|Integer|使用状态,1:正常,0:禁用,默认:0
  createUserId|Long|创建用户
  createTime|Date|注册时间
  updateTime|Date|更新时间
  lastLoginTime|Date|最后一次登录时间
  lastLoginAddress|String|最后一次登录地址
**响应消息样例:**
```
{
"msg":"新增模块成功",
"code":1,
"data":{}
}
}
```
### 修改个人密码
**请求URL:** customer/personal/change/password
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 保存或更新客户管理:id为空时为新增保存,否则为更新提交
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:-------
oldPassword|String|是|旧密码
newPassword|String|是|新密码
**请求样例:**
```
{
"oldPassword":"6q0z8f",
"newPassword":"r7s2ru"
}
```
**响应参数:**
参数名称 |参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 id|Long|保存后主键id
 entity|object|保存更新实体
  id|Long|主键ID,主键,自增长
  loginName|String|用户登录账号
  password|String|密码
  memberLevel|Integer|会员等级,,0:未开启,1:试用客户,2:VIP,3:设计师,默认0
  custName|String|客户真实名称
  organization|String|单位名称
  contactTelphone|String|联系电话
  enterpriseConsultant|String|企业顾问
  siteId|Long|站点ID
  sex|Integer|性别
  mailbox|String|邮箱
  job|String|职位
  avatar|String|头像图片地址
  customerSrc|Long|客户来源
  status|Integer|使用状态,1:正常,0:禁用,默认:0
  createUserId|Long|创建用户
  createTime|Date|注册时间
  updateTime|Date|更新时间
  lastLoginTime|Date|最后一次登录时间
  lastLoginAddress|String|最后一次登录地址
**响应消息样例:**
```
{
"msg":"新增模块成功",
"code":1,
"data":{}
}
}
```
### 模板中心
**请求URL:** design/masterplate/list
......
......@@ -35,4 +35,7 @@ public class CustomerVo extends BaseEntityLong {
private String query;
/** 站点编码 */
private String siteCode="";
private String oldPassword;
private String newPassword;
}
\ No newline at end of file
package com.mortals.xhx.module.customer.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.customer.model.CustomerWorkCollectEntity;
import com.mortals.xhx.module.design.model.DesignMasterplateEntity;
import lombok.Data;
import java.util.ArrayList;
......@@ -13,5 +14,8 @@ import java.util.List;
*/
@Data
public class CustomerWorkCollectVo extends BaseEntityLong {
/**
* 模板信息
*/
private DesignMasterplateEntity designMasterplate;
}
\ No newline at end of file
......@@ -30,4 +30,23 @@ public interface CustomerService extends ICRUDService<CustomerEntity,Long>{
*/
CustomerEntity doLogin(String loginName, String password, String loginIp) throws AppException;
/**
* 用户修改个人信息
* @param params
* @param context
* @return
* @throws AppException
*/
CustomerEntity updateByPersonal(CustomerEntity params, Context context) throws AppException;
/**
* 用户修改个人密码
* @param params
* @param context
* @return
* @throws AppException
*/
CustomerEntity changePassword(CustomerEntity params, Context context) throws AppException;
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.module.customer.model.CustomerEntityExt;
import com.mortals.xhx.module.customer.model.CustomerQuery;
import org.apache.commons.collections4.CollectionUtils;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
......@@ -100,4 +101,57 @@ public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, Cu
params.setLoginName(loginName);
return this.selectOne(params);
}
@Override
public CustomerEntity updateByPersonal(CustomerEntity params, Context context) throws AppException {
CustomerEntity update = new CustomerEntity();
update.setId(params.getId());
update.setLoginName(params.getLoginName());
update.setCustName(params.getCustName());
update.setAvatar(params.getAvatar());
update.setSex(params.getSex());
update.setOrganization(params.getOrganization());
update.setContactTelphone(params.getContactTelphone());
update.setMailbox(params.getMailbox());
update.setJob(params.getJob());
int iRet = this.dao.update(update);
if (iRet == 0) {
throw new AppException(-1002, "更新失败!");
} else {
params.setPassword(null);
return params;
}
}
@Override
public CustomerEntity changePassword(CustomerEntity params, Context context) throws AppException {
if(StringUtils.isEmpty(params.getOldPassword())||StringUtils.isEmpty(params.getNewPassword())){
throw new AppException("密码不能为空");
}
if(params.getOldPassword().equals(params.getNewPassword())){
throw new AppException("新密码不能与旧密码一致");
}
CustomerEntity old = this.get(params.getId());
if(old==null){
throw new AppException("客户信息不存在");
}
String newPwd = "";
String oldPwd = "";
try {
oldPwd = SecurityUtil.md5DoubleEncoding(params.getOldPassword());
newPwd = SecurityUtil.md5DoubleEncoding(params.getNewPassword());
}catch (Exception e) {
throw new AppException("密码转换异常");
}
if(old.getPassword().equals(oldPwd)){
CustomerEntity update = new CustomerEntity();
update.setId(params.getId());
update.setPassword(newPwd);
this.update(update,context);
old.setPassword(null);
}else {
throw new AppException("原来的密码不正确");
}
return old;
}
}
\ No newline at end of file
......@@ -8,6 +8,8 @@ import com.mortals.xhx.module.customer.dao.CustomerWorkCollectDao;
import com.mortals.xhx.module.customer.model.CustomerWorkCollectEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.service.CustomerWorkCollectService;
import com.mortals.xhx.module.design.model.DesignMasterplateEntity;
import com.mortals.xhx.module.design.service.DesignMasterplateService;
import com.mortals.xhx.module.masterplate.model.MasterplateUseInfoEntity;
import com.mortals.xhx.module.masterplate.service.MasterplateUseInfoService;
import org.apache.commons.collections4.CollectionUtils;
......@@ -26,13 +28,25 @@ import java.util.List;
@Service("customerWorkCollectService")
public class CustomerWorkCollectServiceImpl extends AbstractCRUDServiceImpl<CustomerWorkCollectDao, CustomerWorkCollectEntity, Long> implements CustomerWorkCollectService {
@Autowired
private DesignMasterplateService designMasterplateService;
@Override
protected CustomerWorkCollectEntity findBefore(CustomerWorkCollectEntity params, PageInfo pageInfo, Context context) throws AppException {
pageInfo.setPrePageResult(-1);
return super.findBefore(params, pageInfo, context);
}
@Override
protected void findAfter(CustomerWorkCollectEntity params, PageInfo pageInfo, Context context, List<CustomerWorkCollectEntity> list) throws AppException {
if(CollectionUtils.isNotEmpty(list)){
list.stream().forEach(item->{
DesignMasterplateEntity designMasterplateEntity = designMasterplateService.get(item.getMasterplateId());
item.setDesignMasterplate(designMasterplateEntity!=null?designMasterplateEntity:null);
});
}
}
@Override
protected void saveBefore(CustomerWorkCollectEntity entity, Context context) throws AppException {
this.validData(entity, context);
......
......@@ -7,19 +7,18 @@ 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.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.CustomerSatusEnum;
import com.mortals.xhx.common.code.CustomerSrcEnum;
import com.mortals.xhx.common.code.MemberLevelEnum;
import com.mortals.xhx.common.code.SexEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerQuery;
import com.mortals.xhx.module.customer.service.CustomerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
......@@ -154,4 +153,113 @@ public class CustomerController extends BaseCRUDJsonBodyMappingController<Custom
return 1;
}
@RequestMapping(value = {"personal"},method = {RequestMethod.POST, RequestMethod.GET})
public String personal() {
Map<String, Object> model = new HashMap();
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
return this.createFailJsonResp("请先登录");
} else {
JSONObject ret = new JSONObject();
String busiDesc = "用户查看个人信息";
Context context = this.getContext();
try {
CustomerEntity entity = this.service.get(this.getCurUser().getId(), context);
if (entity == null) {
throw new Exception(busiDesc + ",不存在或已被删除");
}
entity.setPassword(null);
ret.put("data", entity);
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var8) {
this.doException(this.request, busiDesc, model, var8);
Object msg = model.get("message_info");
return this.createFailJsonResp(msg == null ? "系统异常" : msg.toString());
}
this.init(model, context);
ret.put("code", 1);
ret.put("msg", model.remove("message_info"));
ret.put("dict", model.remove("dict"));
return ret.toJSONString();
}
}
@RequestMapping(value = {"personal/update"},method = {RequestMethod.POST})
public String updateByPersonal(@RequestBody CustomerEntity entity) {
Map<String, Object> model = new HashMap();
Context context = this.getContext();
IUser user = this.getCurUser();
if(user == null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
return this.createFailJsonResp("请先登录");
}
String busiDesc = "客户修改密码";
int code = 1;
try {
entity.setUpdateTime(new Date());
entity.setId(user.getId());
entity.setUpdateUserId(user.getId());
entity.setUpdateUser(user.getLoginName());
entity.setUpdateUserName(user.getRealName());
entity.setUpdateUserDeptId(user.getDeptId());
entity.setUpdateUserDeptName(user.getDeptName());
this.service.updateByPersonal(entity, context);
model.put("id", entity.getId());
code = this.saveAfter(entity, model, context);
model.put("entity", entity);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + entity.getId() + "]");
} catch (Exception var7) {
this.doException(this.request, busiDesc, model, var7);
model.put("entity", entity);
this.init(model, context);
code = this.saveException(entity, model, context, var7);
}
this.init(model, context);
JSONObject ret = new JSONObject();
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
@RequestMapping(value = {"personal/change/password"},method = {RequestMethod.POST})
public String changePassword(@RequestBody CustomerEntity entity) {
Map<String, Object> model = new HashMap();
Context context = this.getContext();
IUser user = this.getCurUser();
if(user == null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
return this.createFailJsonResp("请先登录");
}
String busiDesc = "客户修改密码";
int code = 1;
try {
entity.setUpdateTime(new Date());
entity.setId(user.getId());
entity.setUpdateUserId(user.getId());
entity.setUpdateUser(user.getLoginName());
entity.setUpdateUserName(user.getRealName());
entity.setUpdateUserDeptId(user.getDeptId());
entity.setUpdateUserDeptName(user.getDeptName());
this.service.changePassword(entity, context);
model.put("id", entity.getId());
code = this.saveAfter(entity, model, context);
model.put("entity", entity);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + entity.getId() + "]");
} catch (Exception var7) {
this.doException(this.request, busiDesc, model, var7);
model.put("entity", entity);
this.init(model, context);
code = this.saveException(entity, model, context, var7);
}
this.init(model, context);
JSONObject ret = new JSONObject();
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.web;
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.key.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
......@@ -36,9 +37,6 @@ import static com.mortals.framework.ap.SysConstains.*;
@RequestMapping("customer/work/collect")
public class CustomerWorkCollectController extends BaseCRUDJsonBodyMappingController<CustomerWorkCollectService,CustomerWorkCollectEntity,Long> {
@Autowired
private ParamService paramService;
public CustomerWorkCollectController(){
super.setModuleDesc( "客户收藏信息");
}
......
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