|
|
@@ -1,213 +0,0 @@
|
|
|
-package com.mrxu.admin.controller.base;
|
|
|
-
|
|
|
-import com.mrxu.admin.controller.AdminBaseController;
|
|
|
-import com.mrxu.base.dto.PrivacySettingDto;
|
|
|
-import com.mrxu.base.dto.WxAuthDto;
|
|
|
-import com.mrxu.base.entity.WxAuth;
|
|
|
-import com.mrxu.base.enums.WxType;
|
|
|
-import com.mrxu.base.service.WxAuthService;
|
|
|
-import com.mrxu.base.service.WxComponentTemplateService;
|
|
|
-import com.mrxu.framework.boot.bean.LayuiPage;
|
|
|
-import com.mrxu.framework.boot.bean.PageResult;
|
|
|
-import com.mrxu.framework.boot.bean.ResponseObj;
|
|
|
-import com.mrxu.framework.common.util.MrxuAssert;
|
|
|
-import com.mrxu.framework.common.weixin.bean.Template;
|
|
|
-import com.mrxu.framework.common.xcx.bean.InterfaceList;
|
|
|
-import com.mrxu.framework.common.xcx.bean.OwnerSetting;
|
|
|
-import com.mrxu.framework.common.xcx.bean.PrivacySetting;
|
|
|
-import com.mrxu.framework.common.xcx.bean.Setting;
|
|
|
-import com.mrxu.framework.common.xcx.enums.PrivacyVersion;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
-import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.ui.Model;
|
|
|
-import org.springframework.validation.BindingResult;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
-
|
|
|
-import javax.validation.Valid;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Api(tags = "微信授权管理")
|
|
|
-@Controller
|
|
|
-@RequestMapping("/base/wxauth")
|
|
|
-@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
|
|
-public class WxAuthController extends AdminBaseController {
|
|
|
-
|
|
|
- private final WxAuthService wxauthApi;
|
|
|
-
|
|
|
- private final WxComponentTemplateService templateApi;
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:read")
|
|
|
- @RequestMapping("index.html")
|
|
|
- public String index(Model model) {
|
|
|
- List<Template> list = templateApi.getTemplateList().getTemplate_list();
|
|
|
- model.addAttribute("templateList",list);
|
|
|
- return "base/wxauth.html";
|
|
|
- }
|
|
|
-
|
|
|
- // 小程序隐私设置
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @RequestMapping("privacySetting.html")
|
|
|
- public String privacySetting(Model model,@RequestParam String groupId) {
|
|
|
- PrivacySetting devSetting = wxauthApi.getPrivacySetting(groupId, PrivacyVersion.dev);
|
|
|
- PrivacySetting prodSetting = wxauthApi.getPrivacySetting(groupId, PrivacyVersion.prod);
|
|
|
- model.addAttribute("devSetting",devSetting);
|
|
|
- model.addAttribute("devNeedPrivacyMap",getNeedPrivacyMap(devSetting));
|
|
|
- model.addAttribute("devSettingDesMap",getSettingDesMap(devSetting));
|
|
|
- model.addAttribute("prodSetting",prodSetting);
|
|
|
- model.addAttribute("prodNeedPrivacyMap",getNeedPrivacyMap(prodSetting));
|
|
|
- model.addAttribute("prodSettingDesMap",getSettingDesMap(prodSetting));
|
|
|
- model.addAttribute("groupId",groupId);
|
|
|
- return "base/privacySetting.html";
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/privacySettingSave.json")
|
|
|
- public ResponseObj<Boolean> privacySettingSave(@RequestParam String groupId,
|
|
|
- @RequestParam int version,
|
|
|
- @RequestParam String [] privacy_keys,
|
|
|
- @RequestParam String [] privacy_texts,
|
|
|
- OwnerSetting owner_setting) {
|
|
|
- List<Setting> setting_list = new ArrayList<>();
|
|
|
- for(int i=0;i<privacy_keys.length;i++) {
|
|
|
- Setting temp = new Setting();
|
|
|
- temp.setPrivacy_key(privacy_keys[i]);
|
|
|
- temp.setPrivacy_text(privacy_texts[i]);
|
|
|
- setting_list.add(temp);
|
|
|
- }
|
|
|
- PrivacyVersion privacy_ver = null;
|
|
|
- if(version == PrivacyVersion.prod.getVersion()) {
|
|
|
- privacy_ver = PrivacyVersion.prod;
|
|
|
- }
|
|
|
- else if(version == PrivacyVersion.dev.getVersion()) {
|
|
|
- privacy_ver = PrivacyVersion.dev;
|
|
|
- }
|
|
|
-
|
|
|
- PrivacySettingDto dto = new PrivacySettingDto();
|
|
|
- dto.setPrivacyVer(privacy_ver);
|
|
|
- dto.setOwnerSetting(owner_setting);
|
|
|
- dto.setSettingList(setting_list);
|
|
|
- wxauthApi.privacySettingSave(groupId, dto.getPrivacyVer(), dto.getOwnerSetting(), dto.getSettingList());
|
|
|
- return success(true);
|
|
|
- }
|
|
|
-
|
|
|
- private Map<String,Boolean> getNeedPrivacyMap(PrivacySetting setting) {
|
|
|
- HashMap<String,Boolean> map = new HashMap<String,Boolean>();
|
|
|
- for(String key:setting.getPrivacy_list()) {
|
|
|
- map.put(key,true);
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- private Map<String,String> getSettingDesMap(PrivacySetting setting) {
|
|
|
- HashMap<String,String> map = new HashMap<String,String>();
|
|
|
- for(Setting set:setting.getSetting_list()) {
|
|
|
- map.put(set.getPrivacy_key(),set.getPrivacy_text());
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:read")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/page.json")
|
|
|
- public LayuiPage<WxAuth> page(WxAuthDto queryDto) {
|
|
|
- queryDto.setType(WxType.xcx.getValue());
|
|
|
- PageResult<WxAuth> rs = wxauthApi.page(getTenantId(),queryDto);
|
|
|
- return renderLayuiPage(rs);
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:read")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/xcxInterface.json")
|
|
|
- public LayuiPage<InterfaceList.Interface> xcxInterface(@RequestParam String groupId) {
|
|
|
- InterfaceList list = wxauthApi.xcxInterface(groupId);
|
|
|
- LayuiPage<InterfaceList.Interface> rs = new LayuiPage<InterfaceList.Interface>();
|
|
|
- rs.setData(list.getInterface_list());
|
|
|
- return rs;
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/apply.json")
|
|
|
- public ResponseObj<Object> apply(String groupId,String api_name, String content) {
|
|
|
- wxauthApi.apply(groupId,api_name,content,null,null,null);
|
|
|
- return success();
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/release.json")
|
|
|
- public ResponseObj<Object> release(String groupId) {
|
|
|
- wxauthApi.release(groupId,getUsername());
|
|
|
- return success();
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/commit.json")
|
|
|
- public ResponseObj<Object> commit(String groupId,String templateId) {
|
|
|
- wxauthApi.commit(groupId,templateId,getUsername());
|
|
|
- return success();
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/submitAudit.json")
|
|
|
- public ResponseObj<Object> submitAudit(String groupId) {
|
|
|
- wxauthApi.submitAudit(groupId,getUsername());
|
|
|
- return success();
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:read")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/getById.json")
|
|
|
- public ResponseObj<WxAuth> getById(Integer id) {
|
|
|
- return success(wxauthApi.getById(getTenantId(),id));
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/save.json")
|
|
|
- public ResponseObj<Boolean> save(@Valid @RequestBody WxAuth bean,BindingResult bindingResult) {
|
|
|
- MrxuAssert.check(bindingResult);
|
|
|
- /*如果有状态请打开,没有请删除if(bean.getStatus() == null) {
|
|
|
- bean.setStatus(0);
|
|
|
- }*/
|
|
|
- return success(wxauthApi.saveOrUpdate(getTenantId(),bean,getUsername()));
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:update")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/updateStatus.json")
|
|
|
- public ResponseObj<Boolean> updateStatus(Integer id, Integer status) {
|
|
|
- WxAuth bean = new WxAuth();
|
|
|
- bean.setId(id);
|
|
|
- bean.setStatus(status);
|
|
|
- return success(wxauthApi.saveOrUpdate(getTenantId(),bean,getUsername()));
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:remove")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/remove.json")
|
|
|
- public ResponseObj<Boolean> remove(Integer id) {
|
|
|
- return success(wxauthApi.remove(getTenantId(),id));
|
|
|
- }
|
|
|
-
|
|
|
- @RequiresPermissions("base:wxauth:remove")
|
|
|
- @ResponseBody
|
|
|
- @RequestMapping("/removeBatch.json")
|
|
|
- public ResponseObj<Boolean> removeBatch(@RequestBody List<Integer> ids) {
|
|
|
- return success(wxauthApi.removeBatch(getTenantId(),ids));
|
|
|
- }
|
|
|
-
|
|
|
-}
|