Bladeren bron

增加站点负责人后台相关接口

leon 5 jaren geleden
bovenliggende
commit
4528eb57c9

+ 2 - 0
src/main/java/com/mokamrp/privates/constant/HttpMsg.java

@@ -7,5 +7,7 @@ public class HttpMsg {
 
     public static final String error = "操作失败";
 
+    public static final String needLogin = "请先登录";
+
     public static final String importSuccess = "导入数据成功";
 }

+ 2 - 0
src/main/java/com/mokamrp/privates/constant/RedisKey.java

@@ -3,6 +3,8 @@ package com.mokamrp.privates.constant;
 public class RedisKey {
     //.企微小前台 登录token
     public static final String AuthToken = "mmc_auth_token:";
+    //.盘古微信养号站点后台登录token
+    public static final String PanStationToken = "pan_station_token:";
     //.验证码 redis key
     public static final String CAPTCHA_CODE_KEY = "mmc_captcha_codes:";
     //.防重提交 redis key

+ 92 - 3
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxMobileController.java

@@ -2,11 +2,16 @@ package com.mokamrp.privates.controller.pangu;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mokamrp.privates.constant.Constants;
+import com.mokamrp.privates.constant.HttpMsg;
 import com.mokamrp.privates.constant.HttpStatus;
+import com.mokamrp.privates.entity.DelHandle;
+import com.mokamrp.privates.entity.EditHandle;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.mokamrp.privates.service.pangu.FosterwxMobileWxfriendService;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
@@ -14,6 +19,7 @@ import com.mokamrp.privates.service.pangu.FosterwxMobileService;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
 import org.springframework.web.bind.annotation.RequestMapping;
 import com.mokamrp.privates.controller.BaseController;
+
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +38,9 @@ import java.util.Map;
 public class FosterwxMobileController extends BaseController<FosterwxMobile> {
 
     @Autowired
+    public FosterwxStationService fosterwxStationService;
+
+    @Autowired
     public FosterwxMobileService fosterwxMobileService;
 
     @Autowired
@@ -43,11 +52,11 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
      */
 
     @PostMapping("/list")
-    public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
+    public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        Map<String,Object> res = fosterwxMobileService.getList(postBasePageHandle);
+        Map<String, Object> res = fosterwxMobileService.getList(postBasePageHandle);
         return AjaxResult.success(res);
     }
 
@@ -57,7 +66,87 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
             return AjaxResult.error("ids null");
         }
         FosterwxMobile res = service.getOne(new QueryWrapper<FosterwxMobile>().eq("id", ids));
-        List<FosterwxMobileWxfriend> friendList = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id",res.getId()).orderByAsc("seq"));
+        List<FosterwxMobileWxfriend> friendList = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id", res.getId()).orderByAsc("seq"));
+        res.setFriend(friendList);
+        return AjaxResult.success(Constants.SUCCESS, res);
+    }
+
+    /*
+     *@Leon 以下接口为站点负责人后台页面接口,需要独立登陆才可访问
+     */
+
+    @PostMapping("/getMobileList")
+    public Object getMobileList(@RequestParam(name = "token") String token,
+                                @Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        //.登录验证
+        FosterwxStation fosterwxStation = fosterwxStationService.getAuthInfo(token);
+        if (fosterwxStation == null){
+            return AjaxResult.error(HttpStatus.LOGIN_ERROR, HttpMsg.needLogin);
+        }
+        Map<String, Object> res = fosterwxMobileService.getListByStationId(postBasePageHandle.getPage(),postBasePageHandle.getPagesize(),fosterwxStation.getId());
+        return AjaxResult.success(res);
+    }
+
+    @PostMapping("/delMobile")
+    public Object delMobile(@RequestParam(name = "token") String token,
+                            @Valid @RequestBody DelHandle<FosterwxMobile> delHandle, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        //.登录验证
+        FosterwxStation fosterwxStation = fosterwxStationService.getAuthInfo(token);
+        if (fosterwxStation == null){
+            return AjaxResult.error(HttpStatus.LOGIN_ERROR, HttpMsg.needLogin);
+        }
+        QueryWrapper<FosterwxMobile> QueryWrapper = new QueryWrapper<>();
+        String[] ids = delHandle.getIds().split(",");
+        QueryWrapper.in("id", ids).eq("station_id",fosterwxStation.getId());
+        boolean res = service.remove(QueryWrapper);
+        if (!res) {
+            return AjaxResult.error(HttpMsg.error);
+        }
+        return AjaxResult.success(Constants.SUCCESS, res);
+    }
+
+    @PostMapping("/editMobile")
+    public Object editMobile(@RequestParam(name = "token") String token,
+                             @Valid @RequestBody EditHandle<FosterwxMobile> editHandle, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
+        }
+        //.登录验证
+        FosterwxStation fosterwxStation = fosterwxStationService.getAuthInfo(token);
+        if (fosterwxStation == null){
+            return AjaxResult.error(HttpStatus.LOGIN_ERROR, HttpMsg.needLogin);
+        }
+        this.onUpdate(editHandle);
+        fosterwxMobileService.update(editHandle.getRaw(),
+                new QueryWrapper<FosterwxMobile>()
+                        .eq("station_id",fosterwxStation.getId())
+                        .in("id", editHandle.getIds()));
+        return AjaxResult.success(Constants.SUCCESS, true);
+    }
+
+    @GetMapping("/mobileInfo")
+    public Object mobileInfo(@RequestParam(name = "token") String token,
+                             @RequestParam(name = "ids") String ids) {
+        //.登录验证
+        FosterwxStation fosterwxStation = fosterwxStationService.getAuthInfo(token);
+        if (fosterwxStation == null){
+            return AjaxResult.error(HttpStatus.LOGIN_ERROR, HttpMsg.needLogin);
+        }
+        if (ids == null || ids.isEmpty()) {
+            return AjaxResult.error("ids null");
+        }
+        FosterwxMobile res = service.getOne(new QueryWrapper<FosterwxMobile>()
+                .eq("id", ids)
+                .eq("station_id",fosterwxStation.getId()));
+        List<FosterwxMobileWxfriend> friendList = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>()
+                .eq("mobile_id", res.getId())
+                .orderByAsc("seq"));
         res.setFriend(friendList);
         return AjaxResult.success(Constants.SUCCESS, res);
     }

+ 16 - 6
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxStationController.java

@@ -4,23 +4,20 @@ import com.mokamrp.privates.constant.Constants;
 import com.mokamrp.privates.constant.HttpStatus;
 import com.mokamrp.privates.entity.AddHandle;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.pangu.LoginStationHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.interceptor.AuthUser;
 import com.mokamrp.privates.mapper.pojo.User;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import com.mokamrp.privates.controller.BaseController;
 import javax.validation.Valid;
 import java.util.Map;
 
-import org.springframework.web.bind.annotation.RestController;
-
 
 /**
  * <p>
@@ -60,7 +57,7 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
         }
         addHandle.getRaw().setUploadUid(user.getId());
         this.onInsert(addHandle.getRaw());
-        Boolean res = service.save(addHandle.getRaw());
+        Boolean res = fosterwxStationService.save(addHandle.getRaw());
         if (res) {
             return AjaxResult.success(Constants.SUCCESS, res);
         } else {
@@ -68,6 +65,19 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
         }
     }
 
+    /**
+     * 站点负责人后台登录
+     * @param loginStationHandle
+     * @return
+     */
+    @PostMapping("/login")
+    public Object login(@Valid @RequestBody LoginStationHandle loginStationHandle){
+        Map<String,Object> res = fosterwxStationService.login(loginStationHandle);
+        if (res.get("token") == null || res.get("token").toString().isEmpty()){
+            return AjaxResult.error(res.get("msg").toString());
+        }
+        return AjaxResult.success(res.get("msg").toString(),res);
+    }
 
 }
 

+ 16 - 0
src/main/java/com/mokamrp/privates/entity/pangu/LoginStationHandle.java

@@ -0,0 +1,16 @@
+package com.mokamrp.privates.entity.pangu;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class LoginStationHandle {
+    @NotNull(message = "用户名不可为空")
+    private String username;
+    @NotNull(message = "密码不可为空")
+    private String password;
+//    @NotNull(message = "站点ID不可为空")
+//    private Integer stationId;
+
+}

+ 1 - 0
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileMapper.java

@@ -18,4 +18,5 @@ import java.util.List;
 @Component
 public interface FosterwxMobileMapper extends BaseMapper<FosterwxMobile> {
     public List<FosterwxMobile> getList(Page<FosterwxMobile> pageObj);
+    public List<FosterwxMobile> getListByStationId(Page<FosterwxMobile> pageObj,@Param("stationId") Integer stationId);
 }

+ 5 - 1
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileMapper.xml

@@ -36,6 +36,10 @@
         id, station_id, mobile_code, mobile_no, mobile_operator, mobile_create_at, mobile_advance_pay_amt, mobile_combo, mobile_combo_flow, mobile_real_name, mobile_identity_card_no, status, wx_status, wx_password, wx_real_name, wx_identity_card_no, wx_register_at, bank_card_no, bank_card_mobile_no, work_wx_corp, work_wx_register_at, work_wx_status, task_start_at, create_at, update_at
     </sql>
     <select id="getList" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile">
-        SELECT * FROM pan_fosterwx_mobile
+        SELECT * FROM pan_fosterwx_mobile order by id desc
+    </select>
+
+    <select id="getListByStationId" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile">
+        SELECT * FROM pan_fosterwx_mobile WHERE station_id = #{stationId} order by id desc
     </select>
 </mapper>

+ 2 - 0
src/main/java/com/mokamrp/privates/service/pangu/FosterwxMobileService.java

@@ -15,4 +15,6 @@ import java.util.Map;
 public interface FosterwxMobileService extends IService<FosterwxMobile> {
     //.@leon 获取数据列表
     public Map<String, Object> getList(PostBasePageHandle handle);
+    //.@leon 获取指定站点下账号列表
+    public Map<String, Object> getListByStationId(Integer page,Integer pagesize,Integer stationId);
 }

+ 7 - 0
src/main/java/com/mokamrp/privates/service/pangu/FosterwxStationService.java

@@ -1,9 +1,12 @@
 package com.mokamrp.privates.service.pangu;
 
+import com.mokamrp.privates.entity.pangu.LoginStationHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+
 import java.util.Map;
+
 /**
  * <p>
  * 盘古微信养号站点库 服务类
@@ -15,4 +18,8 @@ import java.util.Map;
 public interface FosterwxStationService extends IService<FosterwxStation> {
     //.@leon 获取数据列表
     public Map<String, Object> getList(PostBasePageHandle handle);
+    //.@leon 站点负责人后台登录
+    public Map<String, Object> login(LoginStationHandle loginStationHandle);
+    //.@Leon 通过站点ID和TOKEN获取用户登录信息
+    public FosterwxStation getAuthInfo(String token);
 }

+ 18 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxMobileServiceImpl.java

@@ -45,4 +45,22 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
         resMap.put("total", pageObj.getTotal());
         return resMap;
     }
+
+    /**
+     * 获取指定站点下账号列表
+     * @param page
+     * @param pagesize
+     * @param stationId
+     * @return
+     */
+    public Map<String, Object> getListByStationId(Integer page,Integer pagesize,Integer stationId) {
+        Page<FosterwxMobile> pageObj = new Page<FosterwxMobile>(page, pagesize);
+        List<FosterwxMobile> list = fosterwxMobileMapper.getListByStationId(pageObj,stationId);
+        Map<String, Object> resMap = new HashMap<String, Object>();
+        resMap.put("list", list);
+        resMap.put("total", pageObj.getTotal());
+        return resMap;
+    }
+
+
 }

+ 58 - 0
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxStationServiceImpl.java

@@ -1,9 +1,18 @@
 package com.mokamrp.privates.service.pangu.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.entity.pangu.LoginStationHandle;
 import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.mokamrp.privates.mapper.pangu.FosterwxStationMapper;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.mokamrp.privates.utils.StringUtils;
+import com.mokamrp.privates.utils.sign.Md5Utils;
+import io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueue;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -24,6 +33,9 @@ public class FosterwxStationServiceImpl extends ServiceImpl<FosterwxStationMappe
 
     @Autowired
     public FosterwxStationMapper fosterwxStationMapper;
+
+    @Autowired
+    public StringRedisTemplate stringRedisTemplate;
     /**
      * 获取数据列表 支持分页
      * @param handle
@@ -39,4 +51,50 @@ public class FosterwxStationServiceImpl extends ServiceImpl<FosterwxStationMappe
         resMap.put("total", pageObj.getTotal());
         return resMap;
     }
+
+    /**
+     * 站点负责人后台登录
+     * @param loginStationHandle
+     * @return
+     */
+    public Map<String,Object>login(LoginStationHandle loginStationHandle){
+        FosterwxStation fosterwxStation = this.getOne(new QueryWrapper<FosterwxStation>()
+//                .eq("id",loginStationHandle.getStationId())
+                .eq("login_username",loginStationHandle.getUsername())
+        );
+        Map<String,Object> res = new HashMap<>();
+        res.put("msg","");
+        res.put("data","");
+        res.put("token","");
+        if (fosterwxStation == null){
+            res.put("msg","账户不存在");
+            return res;
+        }
+        if (!loginStationHandle.getPassword().equals(fosterwxStation.getLoginPassword())){
+            res.put("msg","密码不正确");
+            return res;
+        }
+        String token = Md5Utils.hash(loginStationHandle.getUsername()) + StringUtils.getRandomString(6);
+        fosterwxStation.setLoginPassword("*********");
+        res.put("data",fosterwxStation);
+        res.put("msg","登录成功");
+        res.put("token",token);
+        String jsonStr = JSON.toJSONString(fosterwxStation);
+        stringRedisTemplate.opsForValue().set(RedisKey.PanStationToken+token,jsonStr);
+        return res;
+    }
+
+    /**
+     * 通过站点ID和TOKEN获取用户登录信息
+     * @param token
+     * @return
+     */
+    public FosterwxStation getAuthInfo(String token){
+        String jsonStr = stringRedisTemplate.opsForValue().get(RedisKey.PanStationToken+token);
+        if (jsonStr == null || jsonStr.isEmpty()){
+            return null;
+        }
+        FosterwxStation fosterwxStation = JSON.parseObject(jsonStr,FosterwxStation.class);
+        return fosterwxStation;
+    }
 }

+ 8 - 1
src/main/resources/application-local.properties

@@ -44,7 +44,14 @@ spring.servlet.multipart.max-request-size=10MB
 spring.servlet.multipart.max-file-size=10MB
 xxl.sso.server=https://sso.mokamrp.com/sso
 xxl.sso.logout.path=/logout
-xxl-sso.excluded.paths=/healthy,/pangu/custservice/getRandCustservice,/pangu/promoteCode/getRandPromoteCode,/mochat/weWork/callback
+xxl-sso.excluded.paths=/healthy,\
+  /pangu/custservice/getRandCustservice,\
+  /pangu/promoteCode/getRandPromoteCode,\
+  /mochat/weWork/callback,\
+  /pangu/fosterwxMobile/getMobileList,\
+  /pangu/fosterwxMobile/delMobile,\
+  /pangu/fosterwxMobile/editMobile,\
+  /pangu/fosterwxMobile/mobileInfo
 #xxl.sso.redis.address=redis://xxl-sso:Jch9shshl@r-uf633f3f27aa2174pd.redis.rds.aliyuncs.com:6379/0
 xxl.sso.redis.address=redis://xxl-sso:MokaSapce666$%25_RediS@r-uf6727zrr24ioihy72pd.redis.rds.aliyuncs.com:23563/0
 menu.host=http://space-server.mokamrp.com/space/menu/getMenuInterface?sysCode=1006&userId=

+ 8 - 1
src/main/resources/application-prod.properties

@@ -48,7 +48,14 @@ spring.servlet.multipart.max-file-size=10MB
 
 xxl.sso.server=https://sso.mokamrp.com/sso
 xxl.sso.logout.path=/logout
-xxl-sso.excluded.paths=/healthy,/pangu/custservice/getRandCustservice,/pangu/promoteCode/getRandPromoteCode,/mochat/weWork/callback
+xxl-sso.excluded.paths=/healthy,\
+  /pangu/custservice/getRandCustservice,\
+  /pangu/promoteCode/getRandPromoteCode,\
+  /mochat/weWork/callback,\
+  /pangu/fosterwxMobile/getMobileList,\
+  /pangu/fosterwxMobile/delMobile,\
+  /pangu/fosterwxMobile/editMobile,\
+  /pangu/fosterwxMobile/mobileInfo
 xxl.sso.redis.address=redis://xxl-sso:MokaSapce666$%25_RediS@r-uf6727zrr24ioihy72.redis.rds.aliyuncs.com:6379/0
 
 menu.host=http://space-server-in-svc/space/menu/getMenuInterface?sysCode=1006&userId=

+ 8 - 1
src/main/resources/application-test.properties

@@ -49,7 +49,14 @@ spring.servlet.multipart.max-file-size=10MB
 
 xxl.sso.server=https://sso.mokamrp.com/sso
 xxl.sso.logout.path=/logout
-xxl-sso.excluded.paths=/healthy,/pangu/custservice/getRandCustservice,/pangu/promoteCode/getRandPromoteCode,/mochat/weWork/callback
+xxl-sso.excluded.paths=/healthy,\
+  /pangu/custservice/getRandCustservice,\
+  /pangu/promoteCode/getRandPromoteCode,\
+  /mochat/weWork/callback,\
+  /pangu/fosterwxMobile/getMobileList,\
+  /pangu/fosterwxMobile/delMobile,\
+  /pangu/fosterwxMobile/editMobile,\
+  /pangu/fosterwxMobile/mobileInfo
 #xxl.sso.redis.address=redis://xxl-sso:Jch9shshl@r-uf633f3f27aa2174pd.redis.rds.aliyuncs.com:6379/0
 xxl.sso.redis.address=redis://xxl-sso:MokaSapce666$%25_RediS@r-uf6727zrr24ioihy72pd.redis.rds.aliyuncs.com:23563/0