|
@@ -1,6 +1,8 @@
|
|
|
package com.dgtly.api.controller;
|
|
|
|
|
|
+import com.dgtly.apiframework.util.TokenUtil;
|
|
|
import com.dgtly.common.annotation.ApiPassToken;
|
|
|
+import com.dgtly.common.constant.UserConstants;
|
|
|
import com.dgtly.common.core.controller.ApiBaseController;
|
|
|
import com.dgtly.common.core.domain.AjaxResult;
|
|
|
import com.dgtly.common.core.domain.ParameterObject;
|
|
@@ -8,8 +10,12 @@ import com.dgtly.common.core.domain.ResultType;
|
|
|
import com.dgtly.companyext.domain.CompanyExtInfo;
|
|
|
import com.dgtly.companyext.service.ICompanyExtInfoService;
|
|
|
import com.dgtly.goods.domain.GoodsInfo;
|
|
|
+import com.dgtly.member.domain.MemberFollow;
|
|
|
+import com.dgtly.member.service.IMemberFollowService;
|
|
|
import com.dgtly.system.domain.SysCompany;
|
|
|
+import com.dgtly.system.domain.SysUser;
|
|
|
import com.dgtly.system.service.ISysCompanyService;
|
|
|
+import com.dgtly.system.service.ISysUserService;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -20,7 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
-@RequestMapping("/company/")
|
|
|
+@RequestMapping("/company")
|
|
|
@ApiPassToken/* 不用验证token 方法上可用*/
|
|
|
public class SysCompanyController extends ApiBaseController {
|
|
|
|
|
@@ -28,6 +34,12 @@ public class SysCompanyController extends ApiBaseController {
|
|
|
@Autowired
|
|
|
private ISysCompanyService companyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMemberFollowService memberFollowService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ICompanyExtInfoService companyExtInfoService;
|
|
|
|
|
@@ -39,8 +51,20 @@ public class SysCompanyController extends ApiBaseController {
|
|
|
obj.checkParameterNotNull("id");
|
|
|
Long companyId = obj.getLong(" id");
|
|
|
CompanyExtInfo companyExtInfo = companyExtInfoService.selectCompanyExtInfoByCompanyId(companyId);
|
|
|
+ int isFollow = 0;
|
|
|
+ /*判断用户是否关注商户*/
|
|
|
+ String memberId = TokenUtil.getTokenUserId();
|
|
|
+ if(memberId!=null){
|
|
|
+ MemberFollow mf= new MemberFollow();
|
|
|
+ mf.setCompanyId(companyId);
|
|
|
+ mf.setMemberId(Long.parseLong(memberId));
|
|
|
+ List<MemberFollow> mfList= memberFollowService.selectMemberFollowList(mf);
|
|
|
+ if(mfList.size()>0){
|
|
|
+ isFollow=1;
|
|
|
+ }
|
|
|
+ }
|
|
|
if(companyExtInfo!=null){
|
|
|
- return AjaxResult.success(companyExtInfo);
|
|
|
+ return AjaxResult.success(companyExtInfo).putKV("isFollow",isFollow);
|
|
|
}else{
|
|
|
return AjaxResult.error(ResultType.NUll);
|
|
|
}
|
|
@@ -55,4 +79,40 @@ public class SysCompanyController extends ApiBaseController {
|
|
|
return AjaxResult.success().putKV("list",goodsInfos);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @ApiOperation(value = "商家入驻")
|
|
|
+ @ApiImplicitParam(name = "params" , paramType = "body")
|
|
|
+ @PostMapping("/enter")
|
|
|
+ public Object enter(){
|
|
|
+ ParameterObject obj = getParameterObject();
|
|
|
+ obj.checkParameterNotNull("loginName,phonenumber,companyName");
|
|
|
+
|
|
|
+ SysUser sysUser = obj.parseBean(SysUser.class);
|
|
|
+
|
|
|
+ if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(sysUser.getLoginName())))
|
|
|
+ {
|
|
|
+ return AjaxResult.error(300,"新增用户'" + sysUser.getLoginName() + "'失败,登录账号已存在");
|
|
|
+ }
|
|
|
+ else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(sysUser)))
|
|
|
+ {
|
|
|
+ return AjaxResult.error(301,"新增用户'" + sysUser.getLoginName() + "'失败,手机号码已存在");
|
|
|
+ }
|
|
|
+ else if (sysUser.getPassword().length() < UserConstants.PASSWORD_MIN_LENGTH
|
|
|
+ || sysUser.getPassword().length() > UserConstants.PASSWORD_MAX_LENGTH)
|
|
|
+ {
|
|
|
+ return AjaxResult.error(302,"密码长度为6-19,请重新设置!!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ SysCompany sysCompany = obj.parseBean(SysCompany.class);
|
|
|
+ CompanyExtInfo cei = obj.parseBean(CompanyExtInfo.class);
|
|
|
+
|
|
|
+ companyService.apiAddCompany(sysUser,sysCompany,cei);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
}
|