Commit 3b68e1c6 authored by zhangyong's avatar zhangyong

1

parent 26d95675
......@@ -26,6 +26,11 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
......
......@@ -38,7 +38,11 @@ public class SystemCtrlController {
String code = request.getParameter("code");
String langID = request.getParameter("langID");
return systemCtrlService.queryTSystemCtrlByCode(code, langID);
Map<String, Object> result = systemCtrlService.queryTSystemCtrlByCode(code, langID);
if(result != null) {
return Rjx.jsonOk().setData(result).toJson();
}else {
return Rjx.jsonErr().setCode(-1).setMessage("数据字典查询出错").toJson();
}
}
}
......@@ -11,7 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.shop.pojo.TCustomer;
import com.egolm.shop.service.UserService;
import io.swagger.annotations.Api;
......@@ -31,6 +33,7 @@ public class UserController {
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "districtID", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "组织机构", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
})
......@@ -47,4 +50,100 @@ public class UserController {
}
@ApiOperation("登陆")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "userNO", dataType = "String", required = false, value = "账号(账号/名称/手机号)", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "password", dataType = "String", required = false, value = "密码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "openID", dataType = "String", required = false, value = "openID(优先级小于账号)", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
})
@RequestMapping(value = "/login",method=RequestMethod.POST)
public String login(HttpServletRequest request, HttpServletResponse response) {
String userNO = request.getParameter("userNO")==null?"":request.getParameter("userNO");
String password = request.getParameter("password")==null?"":request.getParameter("password");
String openID = request.getParameter("openID");
Map<String,Object> params = new HashMap<String,Object>();
params.put("userNO", userNO);
params.put("password", password);
params.put("openID", openID);
return userService.login(params);
}
@ApiOperation("获取店铺信息")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "custNO", dataType = "String", required = true, value = "账号编码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = false, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
})
@RequestMapping(value = "/userInfo",method=RequestMethod.GET)
public String userInfo(HttpServletRequest request, HttpServletResponse response) {
String custNO = request.getParameter("custNO");
String shopNO = request.getParameter("shopNO")==null?"":request.getParameter("shopNO");
System.out.println("shopNO===="+StringUtil.isNotEmpty(shopNO));
TCustomer tCustomer = userService.getCustomer(custNO, shopNO);
return Rjx.jsonOk().setData(tCustomer).toJson();
}
@ApiOperation("修改密码")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "mobile", dataType = "String", required = true, value = "手机号码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "password", dataType = "String", required = true, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "smsCode", dataType = "String", required = true, value = "短信验证码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "smsTmpID", dataType = "String", required = true, value = "短信模板ID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
})
@RequestMapping(value = "/modifyPwd",method=RequestMethod.GET)
public String modifyPwd(HttpServletRequest request, HttpServletResponse response) {
String mobile = request.getParameter("mobile");
String password = request.getParameter("password")==null?"":request.getParameter("password");
String smsCode = request.getParameter("smsCode")==null?"":request.getParameter("smsCode");
String langID = request.getParameter("langID")==null?"936":request.getParameter("langID");
String smsTmpID = request.getParameter("smsTmpID")==null?"936":request.getParameter("smsTmpID");
Map<String,Object> params = new HashMap<String,Object>();
params.put("mobile", mobile);
params.put("password", password);
params.put("smsCode", smsCode);
params.put("langID", langID);
params.put("smsTmpID", smsTmpID);
return userService.modifyPwd(params);
}
@ApiOperation("发短信")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "mobile", dataType = "String", required = true, value = "手机号码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "smsTmpID", dataType = "String", required = true, value = "短信模板ID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "content", dataType = "String", required = true, value = "内容,按模板上的参数填值,以,分隔", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
})
@RequestMapping(value = "/sendSms",method=RequestMethod.GET)
public String sendSms(HttpServletRequest request, HttpServletResponse response) {
String mobile = request.getParameter("mobile");
String smsTmpID = request.getParameter("smsTmpID");
String content = request.getParameter("content");
String langID = request.getParameter("langID");
Map<String,Object> params = new HashMap<String,Object>();
params.put("mobile", mobile);
params.put("langID", langID);
params.put("smsTmpID", smsTmpID);
params.put("content",content);
return userService.sendSms(params);
}
}
package com.egolm.shop.encrypt;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
@Component("passwordEncoder")
public class EgoPasswordEncoder implements PasswordEncoder {
@Override
public String encode(CharSequence rawPassword) {
return EgoShopPasswordEncoder.encode(rawPassword.toString());
}
public String decode(CharSequence rawPassword) {
return EgoShopPasswordEncoder.decode(rawPassword.toString());
}
@Override
public boolean matches(CharSequence rawPassword, String encodedPassword) {
return encode(rawPassword.toString()).equals(encodedPassword);
}
public static void main(String[] args) {
EgoPasswordEncoder e = new EgoPasswordEncoder();
System.out.println(e.decode("zLnXcPGqQ/2iE2YwfoVkqXb1Ufb0bDYm"));
System.out.println(e.encode("13654804000123456"));
}
}
package com.egolm.shop.pojo;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Date;
import java.math.BigDecimal;
/**
* @author 曲欣亮
* @since 2018-10-09
* @version v-1.0
*/
@Entity(name="tCommon")
public class TCommon implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private Date dCreateDate;
private String sComDesc;
private Date dLastUpdateTime;
private String sMemo;
private Integer nTag;
@Id
private String sCommonNO;
private String sConfirmUser;
private BigDecimal nNum1;
private String sText1;
@Id
private String sComID;
private Date dConfirmDate;
private String sCreateUser;
/**
* 无参数构造方法
*/
public TCommon () {
super();
}
/**
* 全参数构造方法
* @param dCreateDate
* @param sComDesc
* @param dLastUpdateTime
* @param sMemo
* @param nTag
* @param sCommonNO
* @param sConfirmUser
* @param nNum1
* @param sText1
* @param sComID
* @param dConfirmDate
* @param sCreateUser
*/
public TCommon(Date dCreateDate, String sComDesc, Date dLastUpdateTime, String sMemo, Integer nTag, String sCommonNO, String sConfirmUser, BigDecimal nNum1, String sText1, String sComID, Date dConfirmDate, String sCreateUser) {
this.dCreateDate = dCreateDate;
this.sComDesc = sComDesc;
this.dLastUpdateTime = dLastUpdateTime;
this.sMemo = sMemo;
this.nTag = nTag;
this.sCommonNO = sCommonNO;
this.sConfirmUser = sConfirmUser;
this.nNum1 = nNum1;
this.sText1 = sText1;
this.sComID = sComID;
this.dConfirmDate = dConfirmDate;
this.sCreateUser = sCreateUser;
}
public void setdCreateDate(Date dCreateDate) {
this.dCreateDate = dCreateDate;
}
public Date getdCreateDate() {
return dCreateDate;
}
public void setsComDesc(String sComDesc) {
this.sComDesc = sComDesc;
}
public String getsComDesc() {
return sComDesc;
}
public void setdLastUpdateTime(Date dLastUpdateTime) {
this.dLastUpdateTime = dLastUpdateTime;
}
public Date getdLastUpdateTime() {
return dLastUpdateTime;
}
public void setsMemo(String sMemo) {
this.sMemo = sMemo;
}
public String getsMemo() {
return sMemo;
}
public void setnTag(Integer nTag) {
this.nTag = nTag;
}
public Integer getnTag() {
return nTag;
}
public void setsCommonNO(String sCommonNO) {
this.sCommonNO = sCommonNO;
}
public String getsCommonNO() {
return sCommonNO;
}
public void setsConfirmUser(String sConfirmUser) {
this.sConfirmUser = sConfirmUser;
}
public String getsConfirmUser() {
return sConfirmUser;
}
public void setnNum1(BigDecimal nNum1) {
this.nNum1 = nNum1;
}
public BigDecimal getnNum1() {
return nNum1;
}
public void setsText1(String sText1) {
this.sText1 = sText1;
}
public String getsText1() {
return sText1;
}
public void setsComID(String sComID) {
this.sComID = sComID;
}
public String getsComID() {
return sComID;
}
public void setdConfirmDate(Date dConfirmDate) {
this.dConfirmDate = dConfirmDate;
}
public Date getdConfirmDate() {
return dConfirmDate;
}
public void setsCreateUser(String sCreateUser) {
this.sCreateUser = sCreateUser;
}
public String getsCreateUser() {
return sCreateUser;
}
}
......@@ -67,7 +67,7 @@ public class TCustomer implements java.io.Serializable {
private String sFax;
private List<TShop> tshop ;
private List<TShop> tshops ;
/**
* 无参数构造方法
......@@ -132,12 +132,14 @@ public class TCustomer implements java.io.Serializable {
public List<TShop> getTshop() {
return tshop;
public List<TShop> getTshops() {
return tshops;
}
public void setTshop(List<TShop> tshop) {
this.tshop = tshop;
public void setTshops(List<TShop> tshops) {
this.tshops = tshops;
}
public void setToken(String token) {
......
package com.egolm.shop.service;
import java.util.List;
import com.egolm.shop.pojo.TCommon;
public interface CommonService {
/**
* 保存浏览记录
......@@ -10,4 +14,6 @@ public interface CommonService {
* @param values
*/
public void saveViewHistory(String zone,String terminalTypeID,String shopNO,String viewTypeID,String values);
public List<TCommon> getTCommon(String commonNO,String comID);
}
package com.egolm.shop.service;
import java.util.Map;
public interface SystemCtrlService {
public String queryTSystemCtrlByCode(String sCode,String langID);
public Map<String, Object> queryTSystemCtrlByCode(String sCode,String langID);
}
......@@ -8,7 +8,15 @@ import com.egolm.shop.pojo.TShop;
public interface UserService {
public TCustomer getCustomer(String custNO,String shopNO);
public TCustomer getCustomer(String mobile);
public TShop getShop(String shopNO);
public Map<String,Object> createGuest(Map<String,Object> params);
public String login(Map<String,Object> params) ;
public String modifyPwd(Map<String,Object> params);
public String sendSms(Map<String,Object> params);
}
......@@ -59,7 +59,7 @@ public class CategoryServiceImpl implements CategoryService {
}
return Rjx.jsonOk().setData(list1).toJson();
}catch(Exception e) {
return Rjx.jsonErr().setMessage("分类查询出错").toJson();
return Rjx.jsonErr().setCode(-1).setMessage("分类查询出错").toJson();
}
}
......
package com.egolm.shop.service.impl;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.shop.pojo.TCommon;
import com.egolm.shop.service.CommonService;
@Service
......@@ -25,6 +30,7 @@ public class CommonServiceImpl implements CommonService{
*/
public void saveViewHistory(String zone,String terminalTypeID,String shopNO,String viewTypeID,String values){
try{
jdbcTemplate.setDialect(new SqlServerDialect());
String checkSql="SELECT "
+ " COUNT(1) "
+ "FROM "
......@@ -57,4 +63,18 @@ public class CommonServiceImpl implements CommonService{
logger.error("浏览记录保存失败"+e);
}
}
public List<TCommon> getTCommon(String commonNO,String comID){
List<TCommon> commList = null;
jdbcTemplate.setDialect(new SqlServerDialect());
String sql = " SELECT * FROM tCommon WHERE nTag&1=0 AND sCommonNO = ? ";
if(StringUtil.isNotEmpty(comID)) {
sql += " and sComID = ? ";
commList = jdbcTemplate.queryForBeans(sql, TCommon.class, commonNO,comID);
}else {
commList = jdbcTemplate.queryForBeans(sql, TCommon.class, commonNO);
}
return commList;
}
}
......@@ -210,7 +210,7 @@ public class GoodsServiceImpl implements GoodsService {
//正式用户保存浏览记录
if(!customer.getsCustLeveTypeID().equals(ShopContstrant.GUEST_LEVEL_TYPE_ID)) {
commonService.saveViewHistory(customer.getTshop().get(0).getsOrgNO(), terminal, shopNO, "1", goodsID);
commonService.saveViewHistory(customer.getTshops().get(0).getsOrgNO(), terminal, shopNO, "1", goodsID);
}
Map<String,Object> goodsDetailMap = jdbcTemplate.queryForMap(goodsInfoSql);
......@@ -277,7 +277,7 @@ public class GoodsServiceImpl implements GoodsService {
if(customer == null) {
return Rjx.jsonErr().setMessage("用户不存在").toJson();
}
TShop shop = customer.getTshop().get(0);
TShop shop = customer.getTshops().get(0);
String districtID = shop.getsDistrictID();
......@@ -313,7 +313,7 @@ public class GoodsServiceImpl implements GoodsService {
return Rjx.jsonOk().setMessage("取消收藏成功").toJson();
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setMessage("取消收藏失败").toJson();
return Rjx.jsonErr().setCode(-1).setMessage("取消收藏失败").toJson();
}
}else if("1".equals(override)) {
try {
......@@ -321,9 +321,9 @@ public class GoodsServiceImpl implements GoodsService {
return Rjx.jsonOk().setMessage("收藏成功").toJson();
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setMessage("收藏失败").toJson();
return Rjx.jsonErr().setCode(-1).setMessage("收藏失败").toJson();
}
}
return Rjx.jsonErr().setMessage("操作失败").toJson();
return Rjx.jsonErr().setCode(-1).setMessage("操作失败").toJson();
}
}
......@@ -23,7 +23,7 @@ public class GoodsSql {
public static String goodsInfoSql(TCustomer customer,Map<String, Object> map) {
String goodsID=(String) map.get("goodsID");
String contractNO=(String) map.get("contractNO");
TShop tshop = customer.getTshop().get(0);
TShop tshop = customer.getTshops().get(0);
String goodInfoSql = "";
if(customer.getsCustLeveTypeID().equals(ShopContstrant.GUEST_LEVEL_TYPE_ID)) { //游客
goodInfoSql="SELECT TOP 1 "
......
......@@ -20,14 +20,14 @@ public class SystemCtrlServiceImpl implements SystemCtrlService {
private JdbcTemplate jdbcTemplate;
public String queryTSystemCtrlByCode(String sCode,String langID) {
public Map<String, Object> queryTSystemCtrlByCode(String sCode,String langID) {
try {
String sql = "select sDesc, sSysTypeID, sSysType, sValue1, sValue2, sValue3, sMemo from tSystemCtrl where sCode = ? and nTag&1 = 0";
Map<String, Object> mapRsult = jdbcTemplate.queryForMap(sql,sCode);
return Rjx.jsonOk().setData(mapRsult).toJson();
return mapRsult;
}catch (Exception e) {
logger.error("数据字典查询出错: "+e.getMessage());
return Rjx.jsonErr().setMessage("数据字典查询出错").toJson();
return null;
}
}
}
......@@ -5,4 +5,10 @@ public class ShopContstrant {
public static final String CUST_SIGN = "T_"; //游客账号标记
public static final String GUEST_LEVEL_TYPE_ID = "-1" ;// 游客 custLevelTypeID 状态
//短信
public static final String CHOICE_SMS_KEY= "ChoiceSmsKey"; // 短信选择器
public static final String SMS_TEMPLATE_CODE = "SmsTemplate"; //模板字典 code tcommon表
}
......@@ -32,4 +32,7 @@ spring.redis.pool.max-wait=2000
spring.redis.pool.max-idle=5
spring.redis.pool.min-idle=0
### 游客 用户生成用户的前缀
redis.guest.key=B2B_Guest
#### 用户验证码存储的前缀
redis.sms.code.key=B2B_Sms
\ No newline at end of file
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