Bladeren bron

添加 统计信息录入页面

lfj 3 jaren geleden
bovenliggende
commit
41e2f8b22c

+ 152 - 0
fjs-scenic-manager/src/main/java/com/fjs/scenic/controller/system/InputInfoController.java

@@ -0,0 +1,152 @@
+package com.fjs.scenic.controller.system;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fjs.scenic.controller.common.BaseController;
+import com.fjs.scenic.entity.system.Manage;
+import com.fjs.scenic.entity.system.TypeAuthority;
+import com.fjs.scenic.service.system.TypeAuthorityService;
+import com.fjs.scenic.service.system.impl.ManageServiceImpl;
+import com.fjs.scenic.utils.Cons;
+import com.fjs.scenic.utils.ReturnResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.security.Principal;
+import java.util.List;
+
+/**
+ * This class is used for ...
+ *
+ * @author lfj
+ * @version 1.0
+ * @CreateDate ${date} ${time}
+ */
+@RestController
+@RequestMapping("/inputInfo")
+public class InputInfoController extends BaseController<Manage> {
+
+    @Autowired
+    private ManageServiceImpl manageService;
+    @Autowired
+    private BCryptPasswordEncoder passwordEncoder;
+    @Autowired
+    private TypeAuthorityService typeAuthorityService;
+
+    @GetMapping("/index")
+    public ModelAndView sceniclist(HttpSession session) {
+        return new ModelAndView("system/inputInfo");
+    }
+
+    @PostMapping("/addManage")
+    public ReturnResult addManage(Manage record, HttpServletRequest request) {
+        /* WSessionInfo sessionInfo = (WSessionInfo) request.getSession().getAttribute(Cons.SESSION_INFO);*/
+
+        //检验用户名是否存在
+        Manage nameRepet = new Manage();
+        nameRepet.setName(record.getName());
+        List<Manage> selectName = manageService.selectRepet(nameRepet);
+        if (!selectName.isEmpty()) {
+            return ReturnResult.build(400, "该管理员已存在!");
+        }
+        //检验手机号 是否存在
+        Manage phoneRepet = new Manage();
+        phoneRepet.setPhone(record.getPhone());
+        List<Manage> selectPhone = manageService.selectRepet(phoneRepet);
+        if (!selectPhone.isEmpty()) {
+            return ReturnResult.build(400, "该手机号已存在!");
+        }
+        record.setStatus(Cons.MANAGE_STATUS.NORMAL);
+        record.setManageId(2);
+        record.setPassword(passwordEncoder.encode(record.getPassword()));
+        return manageService.save(record);
+    }
+
+    @PostMapping("/delManage")
+    @ResponseBody
+    public ReturnResult delManage(int id) {
+        return ReturnResult.ok(manageService.delManage(id));
+    }
+
+    @PostMapping("/saveRole")
+    @ResponseBody
+    public ReturnResult saveRole(String roles, Integer id) {
+        return manageService.saveManageRole(id, roles);
+    }
+
+    @PostMapping("/saveTypeAuthority")
+    @ResponseBody
+    public ReturnResult saveTypeAuthority(@RequestBody List<TypeAuthority> typeAuthoritys) {
+        typeAuthorityService.remove(new LambdaQueryWrapper<TypeAuthority>().eq(TypeAuthority::getManager, typeAuthoritys.get(0).getManager()));
+        return ReturnResult.ok(typeAuthorityService.saveBatch(typeAuthoritys));
+    }
+
+    @PostMapping("/getTypeAuthority/{id}")
+    @ResponseBody
+    public ReturnResult getTypeAuthority(@PathVariable("id") Integer id) {
+        return ReturnResult.ok(typeAuthorityService.listMaps(new LambdaQueryWrapper<TypeAuthority>()
+                .select(TypeAuthority::getCompany, TypeAuthority::getScenic, TypeAuthority::getAuthority)
+                .eq(TypeAuthority::getManager, id)
+        ));
+    }
+
+    @GetMapping("/get/{id}")
+    public ReturnResult get(@PathVariable("id") Integer id) {
+        return manageService.get(id);
+    }
+
+    @PostMapping("/page1")
+    public ReturnResult page1(Manage record, int currentPage, int pageSize) {
+        return manageService.selfPage(record,currentPage,pageSize);
+    }
+
+    /**
+     * 管理账户冻结 解冻
+     *
+     * @param id
+     * @param status
+     * @return
+     */
+    @PostMapping("/freezeUnfreeza")
+    public ReturnResult freezeUnfreeza(Integer id, String status) {
+        return manageService.freezeUnfreeza(id, status) == 0 ? ReturnResult.error("操作失败") : ReturnResult.ok("操作成功");
+    }
+
+
+    /**
+     * 修改密码
+     *
+     * @param principal
+     * @param oldPWD    原密码
+     * @param newPWD    新密码
+     * @return
+     */
+    @PostMapping("/updatePWD")
+    public ReturnResult updatePWD(Principal principal, String oldPWD, String newPWD) {
+        String account = principal.getName();
+        Manage manage = manageService.getMangerByAccount(account);
+        if (!passwordEncoder.matches(oldPWD, manage.getPassword())) {
+            return ReturnResult.error("原密码验证失败");
+        } else if (manageService.updatePWD(account, passwordEncoder.encode(newPWD))) {
+            return ReturnResult.ok("密码修改成功");
+        } else {
+            return ReturnResult.error("密码修改失败");
+        }
+    }
+
+    @PostMapping("/update")
+    public ReturnResult update(Manage record) {
+        String password = record.getPassword();
+        if (!StringUtils.isEmpty(password)) {
+            record.setPassword(passwordEncoder.encode(password));
+        } else {
+            record.setPassword(null);
+        }
+        return ReturnResult.ok(manageService.update(record));
+    }
+
+}

+ 1 - 0
fjs-scenic-manager/src/main/java/com/fjs/scenic/handler/MyUserDetailsService.java

@@ -48,6 +48,7 @@ public class MyUserDetailsService implements UserDetailsService {
 	private List<GrantedAuthority> getAuthorities(Manage manager) {
 		List<GrantedAuthority> authorities = new ArrayList();
 		authorities.add(new SimpleGrantedAuthority("/manage/index"));
+		authorities.add(new SimpleGrantedAuthority("/inputInfo/index"));
 		authorities.add(new SimpleGrantedAuthority("/leaderManage/index"));
 		authorities.add(new SimpleGrantedAuthority("/statisticalPermissions/index"));
 		authorities.add(new SimpleGrantedAuthority("/statisticalPermissions/page"));

+ 1 - 0
fjs-scenic-manager/src/main/resources/templates/incloud/left.ftl

@@ -38,6 +38,7 @@
                 <li><a href="/manage/index"><i class="fa fa-link"></i> <span>后台管理员维护</span></a></li>
                 <li><a href="/leaderManage/index"><i class="fa fa-link"></i> <span>领导账户维护</span></a></li>
                 <li><a href="/statisticalPermissions/index"><i class="fa fa-link"></i> <span>微信统计查看权限维护</span></a></li>
+                <li><a href="/inputInfo/index"><i class="fa fa-link"></i> <span>统计信息录入</span></a></li>
             </ul>
             <!--<ul class="sidebar-menu" data-widget="tree">
                 <li class="header">HEADER</li>