43 changed files with 3453 additions and 5 deletions
@ -0,0 +1,219 @@ |
|||
package com.kelp.plat.controller; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.framework.base.controller.BaseController; |
|||
import com.kelp.framework.base.controller.ErrorMessage; |
|||
import com.kelp.plat.entity.E_Role; |
|||
import com.kelp.plat.entity.U_Role; |
|||
import com.kelp.plat.service.E_RFService; |
|||
import com.kelp.plat.service.E_RoleService; |
|||
import com.kelp.plat.service.U_RFService; |
|||
import com.kelp.plat.service.U_RoleService; |
|||
import com.opensymphony.oscache.util.StringUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.ModelMap; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.servlet.ModelAndView; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
@RequestMapping("/plat/urole") |
|||
@Controller |
|||
public class URoleController extends BaseController { |
|||
|
|||
@Autowired |
|||
private U_RoleService roleService; |
|||
|
|||
@Autowired |
|||
private U_RFService rfService; |
|||
|
|||
|
|||
@RequestMapping("/toPage") |
|||
public @ResponseBody ModelAndView toPage(HttpServletRequest request, HttpServletResponse response) { |
|||
ModelMap modelMap = new ModelMap(); |
|||
modelMap.put("mfs", rfService.getMFs()); |
|||
|
|||
return new ModelAndView("/plat/urole","modelMap", modelMap); |
|||
} |
|||
|
|||
@RequestMapping("/list") |
|||
public @ResponseBody Page<U_Role> list(HttpServletRequest request, Page<U_Role> page, String qname, String qtype, Integer qlevel) { |
|||
|
|||
if (page == null) { |
|||
page = new Page<U_Role>(); |
|||
} |
|||
|
|||
return roleService.getPage(page.getPageIndex(), page.getLimit(), qname, qlevel); |
|||
} |
|||
|
|||
@RequestMapping("/add") |
|||
public @ResponseBody ModelMap add(HttpServletRequest request,U_Role role) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
ErrorMessage message = invalid(role); |
|||
if (!message.getStatus()) { |
|||
modelMap.put(MESSAGE, message.getMessage()); |
|||
modelMap.put(RESULT, message.getStatus()); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (roleService.getByName(role.getName()) != null) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "角色名称已经存在!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
role.setId(null); |
|||
roleService.add(role); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "保存成功!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/update") |
|||
public @ResponseBody ModelMap update(HttpServletRequest request,U_Role role) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
ErrorMessage message = invalid(role); |
|||
if (!message.getStatus()) { |
|||
modelMap.put(MESSAGE, message.getMessage()); |
|||
modelMap.put(RESULT, message.getStatus()); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (role.getId() == null) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "数据有误!"); |
|||
modelMap.put("role", role); |
|||
return modelMap; |
|||
} |
|||
|
|||
U_Role roleP = roleService.getByName(role.getName()); |
|||
if (roleP != null && !role.getId().equals(roleP.getId())) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "角色名称已经存在!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
roleService.update(role); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "保存成功!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/toEdit") |
|||
public @ResponseBody ModelMap toEdit(HttpServletRequest request, String id) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "非法操作!"); |
|||
|
|||
if (id != null && id.length() > 0 && id.length() <= 32) { |
|||
U_Role role = roleService.getById(id); |
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "操作成功"); |
|||
modelMap.put("role", role); |
|||
} |
|||
|
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/delete") |
|||
public @ResponseBody ModelMap delete(HttpServletRequest request, String ids) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
if (ids == null || ids.length() == 0) { |
|||
ids = ""; |
|||
} |
|||
|
|||
String[] ids_ = ids.split(","); |
|||
|
|||
roleService.delete(ids_); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "删除成功!"); |
|||
|
|||
return modelMap; |
|||
} |
|||
|
|||
private ErrorMessage invalid(U_Role role) { |
|||
|
|||
if (role == null) { |
|||
return new ErrorMessage("数据有误!", false); |
|||
} |
|||
|
|||
if (StringUtil.isEmpty(role.getName()) |
|||
|| role.getName().length() > 20) { |
|||
return new ErrorMessage("角色名称不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (role.getLevel() == null) { |
|||
return new ErrorMessage("角色级别不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (!StringUtil.isEmpty(role.getDescription()) && role.getDescription().length() > 128) { |
|||
return new ErrorMessage("角色说明长度有误!", false); |
|||
} |
|||
|
|||
return new ErrorMessage("", true); |
|||
} |
|||
|
|||
@RequestMapping("/toGrant") |
|||
public @ResponseBody ModelMap toGrant(HttpServletRequest request, |
|||
String id) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
if (id == null || id.length() > 32) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "非法操作!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put("role", roleService.getById(id)); |
|||
modelMap.put("rfs", rfService.getRFs(id)); |
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/grant") |
|||
public @ResponseBody ModelMap grant(HttpServletRequest request, |
|||
String roleId, String functionIds) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
if (StringUtil.isEmpty(roleId) || roleId.length() > 32) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "非法数据!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (StringUtil.isEmpty(functionIds)) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "授权成功!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (functionIds.endsWith(",")) { |
|||
functionIds = functionIds.substring(0, functionIds.length() - 1); |
|||
} |
|||
|
|||
String[] functionIds_ = functionIds.split(","); |
|||
rfService.setRFs(roleId, functionIds_); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "授权成功!"); |
|||
|
|||
return modelMap; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,469 @@ |
|||
package com.kelp.website.controller; |
|||
|
|||
import com.google.code.kaptcha.Constants; |
|||
import com.kelp.base.Page; |
|||
import com.kelp.common.config.RedisBean; |
|||
import com.kelp.common.constant.KeyConstant; |
|||
import com.kelp.common.constant.RegexConstants; |
|||
import com.kelp.common.utils.CookieUtil; |
|||
import com.kelp.common.utils.jwt.JwtUtil; |
|||
import com.kelp.common.utils.security.Md5Utils; |
|||
import com.kelp.crm.entity.EAccount; |
|||
import com.kelp.plat.entity.Account; |
|||
import com.kelp.plat.service.E_RoleService; |
|||
import com.kelp.plat.service.RoleService; |
|||
import com.kelp.website.entity.UAccount; |
|||
import com.kelp.website.entity.UAccountVo; |
|||
import com.kelp.website.service.UAccountService; |
|||
import com.kelp.framework.base.controller.BaseController; |
|||
import com.kelp.framework.base.controller.ErrorMessage; |
|||
import com.opensymphony.oscache.util.StringUtil; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.ModelMap; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import org.springframework.web.servlet.ModelAndView; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/28 14:30 |
|||
*/ |
|||
@RequestMapping("/website") |
|||
@Controller |
|||
public class UAccountController extends BaseController { |
|||
|
|||
protected String RESULT = "result"; |
|||
protected String MESSAGE = "message"; |
|||
|
|||
@Autowired |
|||
protected RedisBean redisBean; |
|||
@Autowired |
|||
private E_RoleService roleService; |
|||
@Autowired |
|||
private UAccountService uAccountService; |
|||
|
|||
@RequestMapping("/login") |
|||
public @ResponseBody ModelMap login(HttpServletRequest request, HttpServletResponse response, String telephone, |
|||
String password, String timestamp, String captcha) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
if (StringUtil.isEmpty(telephone) || telephone.length() != 11) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "手机号格式有误!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (StringUtil.isEmpty(password) || password.length() > 50) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "密码不能为空或长度错误!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
// if (StringUtil.isEmpty(timestamp) || timestamp.length() > 128) {
|
|||
// modelMap.put(RESULT, false);
|
|||
// modelMap.put(MESSAGE, "非法请求!");
|
|||
// return modelMap;
|
|||
// }
|
|||
|
|||
// if (StringUtil.isEmpty(captcha) || captcha.length() > 4) {
|
|||
// modelMap.put(RESULT, false);
|
|||
// modelMap.put(MESSAGE, "非法请求!");
|
|||
// return modelMap;
|
|||
// }
|
|||
|
|||
// String captcha_ = redisBean.hget(Constants.KAPTCHA_SESSION_KEY, timestamp);
|
|||
// if(captcha_ == null || !captcha_.equals(captcha)) {
|
|||
// modelMap.put(RESULT, false);
|
|||
// modelMap.put(MESSAGE, "验证码不正确或已过期!");
|
|||
// return modelMap;
|
|||
// }
|
|||
|
|||
// 验证登录信息
|
|||
UAccount sysUser = uAccountService.getByTelephone(telephone); |
|||
if (sysUser == null) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "账号不存在!"); |
|||
return modelMap; |
|||
} |
|||
boolean a=!sysUser.getPassword().equals(password); |
|||
// if ((sysUser != null && !sysUser.getPassword().equals(password))) {
|
|||
// modelMap.put(RESULT, false);
|
|||
// modelMap.put(MESSAGE, "账号或密码错误!");
|
|||
// return modelMap;
|
|||
// }
|
|||
// if (sysUser.getState().equals("10")) {
|
|||
// modelMap.put(RESULT, false);
|
|||
// modelMap.put(MESSAGE, "账号已禁用!");
|
|||
// return modelMap;
|
|||
// }
|
|||
|
|||
// 删除redis中的验证码
|
|||
redisBean.hdel(Constants.KAPTCHA_SESSION_KEY, timestamp); |
|||
|
|||
String token = JwtUtil.sign(String.valueOf(sysUser.getId()), request.getSession().getId(), KeyConstant.JWTKEY); |
|||
// 设置token到cookie
|
|||
CookieUtil.addCookie(response, "token", token); |
|||
|
|||
// 向redis中写入
|
|||
redisBean.hset(String.valueOf(sysUser.getId()), "u_token", token); |
|||
redisBean.hset(String.valueOf(sysUser.getId()), "u_role",sysUser.getRoleId()); |
|||
modelMap.put("enterpriseName",sysUser.getEnterpriseName()); |
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "登录成功!"); |
|||
|
|||
return modelMap; |
|||
} |
|||
@RequestMapping("/register") |
|||
public @ResponseBody ModelMap register(HttpServletRequest request,HttpServletResponse response, UAccountVo sysUserVo ) { |
|||
ModelMap modelMap = new ModelMap(); |
|||
UAccount sysUser=new UAccount(); |
|||
BeanUtils.copyProperties(sysUserVo,sysUser); |
|||
ErrorMessage message = invalid(sysUser); |
|||
String timestamp=sysUserVo.getTimestamp(); |
|||
String captcha= sysUserVo.getCaptcha(); |
|||
if (StringUtil.isEmpty(timestamp) || timestamp.length() > 128) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "非法请求!"); |
|||
return modelMap; |
|||
} |
|||
String captcha_ = redisBean.hget(Constants.KAPTCHA_SESSION_KEY, timestamp); |
|||
if(captcha_ == null || !captcha_.equals(captcha)) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "验证码不正确或已过期!"); |
|||
return modelMap; |
|||
} |
|||
if (!message.getStatus()) { |
|||
modelMap.put(MESSAGE, message.getMessage()); |
|||
modelMap.put(RESULT, message.getStatus()); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (uAccountService.getByTelephone(sysUser.getTelephone()) != null) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "电话号码已经存在!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
sysUser.setId(null); |
|||
sysUser.setPassword(Md5Utils.hash(sysUser.getPassword())); |
|||
sysUser.setRoleId("1"); |
|||
uAccountService.add(sysUser); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "保存成功!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
|
|||
private ErrorMessage invalid(UAccount sysUser) { |
|||
|
|||
if (sysUser == null) { |
|||
return new ErrorMessage("数据有误!", false); |
|||
} |
|||
|
|||
if (StringUtils.isEmpty(sysUser.getName()) || sysUser.getName().length() > 128) { |
|||
return new ErrorMessage("昵称不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (StringUtils.isEmpty(sysUser.getTelephone()) || sysUser.getTelephone().length() > 128) { |
|||
return new ErrorMessage("手机号不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (!sysUser.getTelephone().matches(RegexConstants.MOBILE_PHONE_NUMBER_PATTERN)) { |
|||
return new ErrorMessage("手机号格式有误!", false); |
|||
} |
|||
|
|||
return new ErrorMessage("", true); |
|||
} |
|||
|
|||
@RequestMapping("/toPage") |
|||
public @ResponseBody ModelAndView toPage(HttpServletRequest request, HttpServletResponse response) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
modelMap.put("roles", roleService.getAll()); |
|||
|
|||
// 从redis中取当前登录人所属部门id
|
|||
modelMap.put("departmentId", getDepartmentId(request)); |
|||
|
|||
return new ModelAndView("/website/account", "modelMap", modelMap); |
|||
} |
|||
|
|||
@RequestMapping("/list") |
|||
public @ResponseBody Page<UAccount> list(HttpServletRequest request, Page<UAccount> page, String qdepartmentId, |
|||
String qname, String qtelephone, String qroleId, String qstate) { |
|||
|
|||
if (page == null) { |
|||
page = new Page<UAccount>(); |
|||
} |
|||
|
|||
if (StringUtil.isEmpty(qdepartmentId)) { |
|||
// 从redis中取当前登录人所属部门id
|
|||
qdepartmentId = getDepartmentId(request); |
|||
} |
|||
|
|||
return uAccountService.getPage(page.getPageIndex(), page.getLimit(), getEnterpriseId(request), qdepartmentId, |
|||
qname, qtelephone, qroleId, qstate); |
|||
} |
|||
|
|||
@RequestMapping("/toEdit") |
|||
public @ResponseBody ModelMap toEdit(HttpServletRequest request, String id) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "非法操作!"); |
|||
|
|||
if (id != null && id.length() > 0 && id.length() <= 32) { |
|||
UAccount account = uAccountService.getById(id); |
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, ""); |
|||
modelMap.put("account", account); |
|||
} |
|||
|
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/add") |
|||
public @ResponseBody ModelMap add(HttpServletRequest request, UAccount account) { |
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
ErrorMessage message = invalid(account); |
|||
if (!message.getStatus()) { |
|||
modelMap.put(MESSAGE, message.getMessage()); |
|||
modelMap.put(RESULT, message.getStatus()); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (uAccountService.getByTelephone(account.getTelephone()) != null) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "电话号码已经存在!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
account.setId(null); |
|||
|
|||
account.setPassword(Md5Utils.hash("d1234567")); |
|||
uAccountService.add(account); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "保存成功!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/update") |
|||
public @ResponseBody ModelMap update(HttpServletRequest request, UAccount account) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
ErrorMessage message = invalid(account); |
|||
if (!message.getStatus()) { |
|||
modelMap.put(MESSAGE, message.getMessage()); |
|||
modelMap.put(RESULT, message.getStatus()); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (account.getId() == null) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "数据有误!"); |
|||
modelMap.put("account", account); |
|||
return modelMap; |
|||
} |
|||
|
|||
UAccount accountP = uAccountService.getByTelephone(account.getTelephone()); |
|||
if (accountP != null && !account.getId().equals(accountP.getId())) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "电话号码已经存在!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
accountP = uAccountService.getById(String.valueOf(account.getId())); |
|||
if (accountP == null) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "非法请求!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
account.setCreateTime(accountP.getCreateTime()); |
|||
account.setUpdateTime(System.currentTimeMillis()); |
|||
account.setPassword(accountP.getPassword()); |
|||
|
|||
|
|||
uAccountService.update(account); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "保存成功!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/delete") |
|||
public @ResponseBody ModelMap delete(HttpServletRequest request, String ids) { |
|||
|
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
if (ids != null && ids.length() > 0) { |
|||
String[] ids_ = ids.split(","); |
|||
uAccountService.delete(ids_); |
|||
} |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "删除成功!"); |
|||
|
|||
return modelMap; |
|||
|
|||
} |
|||
|
|||
private ErrorMessage invalid(EAccount account) { |
|||
|
|||
if (account == null) { |
|||
return new ErrorMessage("数据有误!", false); |
|||
} |
|||
|
|||
if (account.getDepartmentId() == null) { |
|||
return new ErrorMessage("所属部门不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (StringUtils.isEmpty(account.getName()) || account.getName().length() > 128) { |
|||
return new ErrorMessage("昵称不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (account.getRealName() != null && account.getRealName().length() > 128) { |
|||
return new ErrorMessage("真实姓名长度有误!", false); |
|||
} |
|||
|
|||
if (StringUtils.isEmpty(account.getTelephone()) || account.getTelephone().length() > 128) { |
|||
return new ErrorMessage("手机号不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (!account.getTelephone().matches(RegexConstants.MOBILE_PHONE_NUMBER_PATTERN)) { |
|||
return new ErrorMessage("手机号格式有误!", false); |
|||
} |
|||
|
|||
if (account.getSex() == null || account.getSex().length() != 1) { |
|||
return new ErrorMessage("性别不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (account.getRoleId() == null) { |
|||
return new ErrorMessage("账号角色不能为空或长度有误!", false); |
|||
} |
|||
|
|||
if (account.getState() == null || account.getState().length() != 2) { |
|||
return new ErrorMessage("账号状态不能为空或长度有误!", false); |
|||
} |
|||
|
|||
return new ErrorMessage("", true); |
|||
} |
|||
|
|||
@RequestMapping("/toSelfInfo") |
|||
public @ResponseBody ModelAndView toSelfInfo(HttpServletRequest request, HttpServletResponse response) { |
|||
ModelMap modelMap = new ModelMap(); |
|||
modelMap.put("roleName", roleService.getById(redisBean.hget(getAccountId(request), "e_role")).getName()); |
|||
|
|||
UAccount account = uAccountService.getById(getAccountId(request)); |
|||
modelMap.put("account", account); |
|||
|
|||
return new ModelAndView("/website/self_info", "modelMap", modelMap); |
|||
} |
|||
|
|||
@RequestMapping("/selfInfo") |
|||
public @ResponseBody ModelMap selfInof(HttpServletRequest request, HttpServletResponse response, UAccount account, |
|||
MultipartFile avatarFile) { |
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
if (StringUtils.isEmpty(account.getName()) || account.getName().length() > 128) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "昵称不能为空或长度有误!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (account.getName() != null && account.getName().length() > 128) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "真实姓名长度有误!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
|
|||
|
|||
UAccount accountP = uAccountService.getById(getAccountId(request)); |
|||
accountP.setName(account.getName()); |
|||
|
|||
|
|||
// if (avatarFile != null && !avatarFile.isEmpty()) {
|
|||
// String avatarPath = fileUploadService.uploadImageFile(avatarFile);
|
|||
// if (avatarPath != null && avatarPath.equals("10")) {
|
|||
// modelMap.put(RESULT, false);
|
|||
// modelMap.put(MESSAGE, "文件格式不正确!");
|
|||
// return modelMap;
|
|||
// }
|
|||
//
|
|||
// accountP.setAvatar(avatarPath);
|
|||
// }
|
|||
|
|||
uAccountService.update(accountP); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "个人资料修改成功!"); |
|||
|
|||
return modelMap; |
|||
} |
|||
|
|||
@RequestMapping("/toPassword") |
|||
public @ResponseBody ModelAndView toPassword(HttpServletRequest request, HttpServletResponse response) { |
|||
return new ModelAndView("/crm/password"); |
|||
} |
|||
|
|||
@RequestMapping("/password") |
|||
public @ResponseBody ModelMap password(HttpServletRequest request, HttpServletResponse response, String opassword, |
|||
String npassword, String cpassword) { |
|||
ModelMap modelMap = new ModelMap(); |
|||
|
|||
if (StringUtils.isEmpty(opassword) || opassword.length() < 6) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "原始密码不能为空!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (StringUtils.isEmpty(npassword) || npassword.length() < 6) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "新密码不能为空且不能少于6位!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (!opassword.matches(RegexConstants.LETTER_DIGIT_PATTERN)) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "新密码必须包含数字和字母!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
if (StringUtils.isEmpty(cpassword) || !cpassword.equals(npassword)) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "新密码与确认密码不一致!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
String accountId = getAccountId(request); |
|||
UAccount account = uAccountService.getById(accountId); |
|||
if (!Md5Utils.hash(opassword).equals(account.getPassword())) { |
|||
modelMap.put(RESULT, false); |
|||
modelMap.put(MESSAGE, "旧密码输入不正确!"); |
|||
return modelMap; |
|||
} |
|||
|
|||
account.setPassword(Md5Utils.hash(npassword)); |
|||
uAccountService.update(account); |
|||
|
|||
modelMap.put(RESULT, true); |
|||
modelMap.put(MESSAGE, "密码修改成功,建议您重新登录!"); |
|||
|
|||
return modelMap; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,61 @@ |
|||
package com.kelp.website.controller; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.biz.entity.Dict; |
|||
import com.kelp.common.constant.KeyConstant; |
|||
import com.kelp.common.utils.AESUtil; |
|||
import com.kelp.common.utils.CookieUtil; |
|||
import com.kelp.common.utils.jwt.JwtUtil; |
|||
import com.kelp.crm.entity.ECustomer; |
|||
import com.kelp.crm.entity.Enterprise; |
|||
import com.kelp.crm.service.ECustomerService; |
|||
import com.kelp.crm.service.EnterpriseService; |
|||
import com.kelp.framework.base.controller.ErrorMessage; |
|||
import com.kelp.website.entity.UAccount; |
|||
import com.kelp.website.entity.UContract; |
|||
import com.kelp.website.service.UAccountService; |
|||
import com.kelp.website.service.UContractService; |
|||
import com.opensymphony.oscache.util.StringUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.ui.ModelMap; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/30 9:00 |
|||
*/ |
|||
@RequestMapping("/website/contract") |
|||
@Controller |
|||
public class UContractController { |
|||
protected String RESULT = "result"; |
|||
protected String MESSAGE = "message"; |
|||
@Autowired |
|||
UContractService uContractService; |
|||
@Autowired |
|||
UAccountService uAccountService; |
|||
@Autowired |
|||
ECustomerService eCustomerService; |
|||
@Autowired |
|||
EnterpriseService enterpriseService; |
|||
@RequestMapping("/list") |
|||
public @ResponseBody Page<UContract> list(HttpServletRequest request, Page<UContract> page, String qname, String qtype, String qstate) { |
|||
String token = CookieUtil.getCookie(request, "token"); |
|||
String accountId = JwtUtil.getId(token); |
|||
UAccount uAccount = uAccountService.getById(accountId); |
|||
String encrypt = AESUtil.encrypt(uAccount.getTelephone(), KeyConstant.TELEPHONE); |
|||
ECustomer byPhone = eCustomerService.getByPhone(encrypt); |
|||
if(byPhone ==null){ |
|||
page = new Page<UContract>(); |
|||
} |
|||
|
|||
if (page == null) { |
|||
page = new Page<UContract>(); |
|||
} |
|||
|
|||
return uContractService.getPage(page.getPageIndex(), page.getLimit(), byPhone.getId()); |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.kelp.website.controller; |
|||
|
|||
import com.kelp.framework.base.controller.BaseController; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
/** |
|||
* 后端访问地址 |
|||
*/ |
|||
@RequestMapping("/website") |
|||
@Controller |
|||
public class UIndexController extends BaseController { |
|||
|
|||
|
|||
/** |
|||
* springboot 启动访问的页面,如果不写默认访问index |
|||
* @param request |
|||
* @param response |
|||
* @return |
|||
*/ |
|||
@RequestMapping("/index") |
|||
public String index(HttpServletRequest request, HttpServletResponse response) { |
|||
return "/website/login"; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,413 @@ |
|||
layui.use([ 'form', 'table' ], function() { |
|||
var form = layui.form; |
|||
var table = layui.table; |
|||
|
|||
//table options
|
|||
options = { |
|||
elem : '#dataTable', |
|||
url : basePath + '/plat/urole/list', |
|||
method: 'post', |
|||
where:{ |
|||
qname:$("#qname").val(), |
|||
qlevel:$("#qlevel").val() |
|||
}, |
|||
//分页请求参数
|
|||
request:{ |
|||
pageName: 'pageIndex', //页码
|
|||
limitName: 'limit' //每页多少数据
|
|||
}, |
|||
//返回的数据格式
|
|||
response:{ |
|||
statusName: 'status', //数据状态的字段名称,默认:code
|
|||
statusCode: 200, //成功的状态码,默认:0
|
|||
msgName: 'message', //状态信息的字段名称,默认:msg
|
|||
countName: 'total', //数据总数的字段名称,默认:count
|
|||
dataName: 'data' //数据列表的字段名称,默认:data
|
|||
}, |
|||
//每页10条数据
|
|||
limit: 10, |
|||
//加载时出现加载条
|
|||
loading: true, |
|||
toolbar : '#toolbar' // 开启头部工具栏,并为其绑定左侧模板
|
|||
, |
|||
defaultToolbar : [ |
|||
{ // 自定义头部工具栏右侧图标
|
|||
title : '搜索', |
|||
layEvent : 'search_box_display', |
|||
icon : 'layui-icon-search' |
|||
} , |
|||
'filter', 'exports', 'print'], |
|||
title : '角色列表', |
|||
cellMinWidth: 120, |
|||
cols: [[ |
|||
{type:'numbers'}, |
|||
{type: 'checkbox'}, |
|||
{field:'id',title: 'id', hide:true}, |
|||
{field:'name', title: '名称',event:'edit',style:'cursor: pointer;'}, |
|||
{field:'level', title: '级别'}, |
|||
{field:'description', title: '说明'}, |
|||
{field: 'right',title:'操作', toolbar: '#rowbar'}, |
|||
]], |
|||
done:function (res) {//返回数据执行回调函数
|
|||
layer.close(layer.load(2)); //返回数据关闭loading
|
|||
}, |
|||
fixedHeader: true, |
|||
id: 'dataTable', |
|||
page : true |
|||
}; |
|||
|
|||
//加载数据
|
|||
table.render(options); |
|||
|
|||
//监听toolbar事件
|
|||
table.on('toolbar(tablefilter)', function(obj) { |
|||
var checkStatus = table.checkStatus(obj.config.id); |
|||
switch (obj.event) { |
|||
case 'add': |
|||
add(); |
|||
break; |
|||
case 'edit': |
|||
var data = checkStatus.data; |
|||
if(data.length == 0){ |
|||
layer.msg('请先选择要编辑的数据!',{icon:2,time:2000}); |
|||
return; |
|||
} |
|||
if(data.length > 1){ |
|||
layer.msg('只能选择一条要编辑的数据!',{icon:2,time:2000}); |
|||
return; |
|||
} |
|||
if(data.length == 1){ |
|||
edit(data[0].id); |
|||
} |
|||
break; |
|||
case 'delete': |
|||
var data = checkStatus.data; |
|||
if(data.length == 0){ |
|||
layer.msg('请先选择要删除的数据!',{icon:2,time:2000}); |
|||
return; |
|||
} |
|||
var ids_ = ""; |
|||
for(var i=0;i<data.length;i++){ |
|||
ids_ += data[i].id + ","; |
|||
} |
|||
layer.confirm('您真的要删除所选择数据吗?', function(index){ |
|||
delete_(ids_); |
|||
layer.close(index); |
|||
}); |
|||
break; |
|||
// 自定义头工具栏右侧图标 - 隐藏搜索栏
|
|||
case 'search_box_display': |
|||
searchboxToggle(); |
|||
break; |
|||
} |
|||
; |
|||
}); |
|||
|
|||
// 监听rowbar事件
|
|||
table.on('tool(tablefilter)', function(obj) { |
|||
var data = obj.data; |
|||
if (obj.event === 'del') { |
|||
layer.confirm('您真的要删除吗?', function(index) { |
|||
delete_(data.id); |
|||
layer.close(index); |
|||
}); |
|||
} else if (obj.event === 'edit') { |
|||
edit(data.id); |
|||
} else if(obj.event === 'grant'){ |
|||
grant(data.id); |
|||
} |
|||
}); |
|||
|
|||
//添加
|
|||
function add(){ |
|||
|
|||
//清理数据
|
|||
$("#edit_id_").val(""); |
|||
$("#name").val(""); |
|||
$("#level").val(""); |
|||
$("#description").val(""); |
|||
|
|||
//刷新页面
|
|||
form.render(); |
|||
|
|||
layer.open({ |
|||
title:"添加/编辑", |
|||
area: ['100%','100%'], |
|||
closeBtn:1, |
|||
type: 1, |
|||
scrollbar:false, |
|||
content:$("#form_edit"), |
|||
cancel: function(index, layero){ |
|||
layer.close(index); |
|||
return false; |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
//关闭添加/编辑页面
|
|||
form.on('submit(close_)', function (data){ |
|||
layer.close(layer.index); |
|||
}); |
|||
|
|||
//添加或编辑保存数据
|
|||
form.on('submit(edit_)', function (data){ |
|||
|
|||
var result = false; |
|||
|
|||
var name = data.field.name; |
|||
var level = data.field.level; |
|||
var description = data.field.description; |
|||
var id_ = data.field.edit_id_; |
|||
|
|||
var url = basePath + "/plat/urole/add"; |
|||
|
|||
if(id_.length > 0){ |
|||
url = basePath + "/plat/urole/update"; |
|||
} |
|||
|
|||
if(name.length == 0 || name.length > 20){ |
|||
layer.msg('名称不能为空且不能超过20个字符!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(level.length == 0 || level.length > 2){ |
|||
layer.msg('级别不能为空且不能超过20个字符!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(description.length == 0 || description.length > 20){ |
|||
layer.msg('说明不能超过20个字符!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
$.ajax({ |
|||
url: url, |
|||
data: { |
|||
"id":id_, |
|||
"name":name, |
|||
"level":level, |
|||
"description":description, |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
layer.msg(data.message,{icon:1,time:2000}); |
|||
layer.closeAll("page"); |
|||
reload(); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('保存失败,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
|
|||
return result; |
|||
|
|||
}); |
|||
|
|||
//编辑
|
|||
function edit(id){ |
|||
|
|||
$.ajax({ |
|||
url: basePath + "/plat/urole/toEdit", |
|||
data: { |
|||
"id":id |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
$("#edit_id_").val(data.role.id); |
|||
$("#name").val(data.role.name); |
|||
$("#level").val(data.role.level); |
|||
$("#description").val(data.role.description); |
|||
|
|||
//刷新页面
|
|||
form.render(); |
|||
|
|||
layer.open({ |
|||
title:"添加/编辑", |
|||
area: ['100%','100%'], |
|||
closeBtn:1, |
|||
type: 1, |
|||
scrollbar:false, |
|||
content:$("#form_edit"), |
|||
cancel: function(index, layero){ |
|||
layer.close(index); |
|||
return false; |
|||
} |
|||
}); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('服务器错误,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
//删除
|
|||
function delete_(ids){ |
|||
$.ajax({ |
|||
url: basePath + "/plat/urole/delete", |
|||
data: { |
|||
"ids":ids |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
reload(); |
|||
layer.msg('删除成功!',{icon:1,time:1000}); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('服务器错误,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
//监听全选事件
|
|||
form.on('checkbox(pgroup_)',function(data){ |
|||
if(data.elem.checked){ |
|||
$("input[name='" + data.elem.id +"']").each(function(){ |
|||
$(this).prop("checked",true); |
|||
}); |
|||
form.render(); |
|||
}else{ |
|||
$("input[name='" + data.elem.id +"']").each(function(){ |
|||
$(this).prop("checked",false); |
|||
}); |
|||
form.render(); |
|||
} |
|||
}); |
|||
|
|||
//打开授权页面
|
|||
function grant(id){ |
|||
|
|||
$.ajax({ |
|||
url: basePath + "/plat/urole/toGrant", |
|||
data: { |
|||
"id":id |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
|
|||
$("#grant_id_").val(data.role.id); |
|||
|
|||
$("input:checkbox").each(function(){ |
|||
$(this).prop("checked",false); |
|||
}); |
|||
|
|||
for(var i=0;i<data.rfs.length;i++){ |
|||
if($("input[fid='" + data.rfs[i].functionId + "']")[0] != null){ |
|||
var aa = $("input[fid='" + data.rfs[i].functionId + "']")[0].checked = true; |
|||
} |
|||
} |
|||
|
|||
//刷新页面
|
|||
form.render(); |
|||
|
|||
layer.open({ |
|||
title:"角色 " + data.role.name + " 权限", |
|||
area: ['100%','100%'], |
|||
closeBtn:1, |
|||
type: 1, |
|||
scrollbar:false, |
|||
content:$("#form_grant"), |
|||
cancel: function(index, layero){ |
|||
layer.close(index); |
|||
return false; |
|||
} |
|||
}); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('服务器错误,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
//授权
|
|||
form.on('submit(grant_)', function (data){ |
|||
|
|||
var result = false; |
|||
|
|||
var roleId = $("#grant_id_").val(); |
|||
|
|||
var functionIds = ""; |
|||
|
|||
$(".pfunction").each(function(){ |
|||
if($(this).prop("checked")){ |
|||
functionIds += $(this).val() + ","; |
|||
} |
|||
}); |
|||
|
|||
var url = basePath + "/plat/urole/grant"; |
|||
|
|||
if(roleId.length > 32){ |
|||
layer.msg('角色信息有误!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(functionIds.length == 0){ |
|||
layer.msg('请选择角色权限!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
$.ajax({ |
|||
url: url, |
|||
data: { |
|||
"roleId":roleId, |
|||
"functionIds":functionIds |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
result = true; |
|||
layer.msg(data.message,{icon:1,time:2000}); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('服务器错误,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
|
|||
return result; |
|||
|
|||
}); |
|||
|
|||
$('#reload').on('click', function(){ |
|||
reload(); |
|||
}); |
|||
|
|||
$("#resetq").on('click',function(){ |
|||
$("#qname").val(""); |
|||
$("#qlevel").val(""); |
|||
form.render(); |
|||
}); |
|||
|
|||
$("#resetf").on('click',function(){ |
|||
$("#form_edit")[0].reset(); |
|||
}); |
|||
|
|||
function reload(){ |
|||
layer.load(2); |
|||
options.where.qname = $("#qname").val(); |
|||
options.where.qlevel = $("#qlevel").val(); |
|||
table.reload("dataTable",options); |
|||
} |
|||
}); |
@ -0,0 +1,41 @@ |
|||
.layui-table-cell{ |
|||
height:auto!important; |
|||
white-space:normal; |
|||
} |
|||
|
|||
#avatarImg{ |
|||
width:200px; |
|||
height:200px; |
|||
margin-bottom:2px; |
|||
} |
|||
|
|||
.uploadButton { |
|||
width: 200px; |
|||
height: auto; |
|||
overflow: hidden; |
|||
|
|||
height: 40px; |
|||
line-height: 40px; |
|||
text-align: center; |
|||
background: #d8b49c; |
|||
display: block; |
|||
font-size: 16px; |
|||
border-radius: 2px; |
|||
|
|||
position: relative; |
|||
} |
|||
|
|||
.uploadFile { |
|||
display: block; |
|||
width: 100%; |
|||
height: 40px; |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
opacity: 0; |
|||
border-radius: 5px; |
|||
} |
|||
|
|||
.kelp-avatarPreview { |
|||
float:right; |
|||
} |
@ -0,0 +1,41 @@ |
|||
.layui-table-cell{ |
|||
height:auto!important; |
|||
white-space:normal; |
|||
} |
|||
|
|||
#avatarImg{ |
|||
width:200px; |
|||
height:200px; |
|||
margin-bottom:2px; |
|||
} |
|||
|
|||
.uploadButton { |
|||
width: 200px; |
|||
height: auto; |
|||
overflow: hidden; |
|||
|
|||
height: 40px; |
|||
line-height: 40px; |
|||
text-align: center; |
|||
background: #d8b49c; |
|||
display: block; |
|||
font-size: 16px; |
|||
border-radius: 2px; |
|||
|
|||
position: relative; |
|||
} |
|||
|
|||
.uploadFile { |
|||
display: block; |
|||
width: 100%; |
|||
height: 40px; |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
opacity: 0; |
|||
border-radius: 5px; |
|||
} |
|||
|
|||
.kelp-avatarPreview { |
|||
float:right; |
|||
} |
@ -0,0 +1,41 @@ |
|||
.layui-table-cell{ |
|||
height:auto!important; |
|||
white-space:normal; |
|||
} |
|||
|
|||
#avatarImg{ |
|||
width:200px; |
|||
height:200px; |
|||
margin-bottom:2px; |
|||
} |
|||
|
|||
.uploadButton { |
|||
width: 200px; |
|||
height: auto; |
|||
overflow: hidden; |
|||
|
|||
height: 40px; |
|||
line-height: 40px; |
|||
text-align: center; |
|||
background: #d8b49c; |
|||
display: block; |
|||
font-size: 16px; |
|||
border-radius: 2px; |
|||
|
|||
position: relative; |
|||
} |
|||
|
|||
.uploadFile { |
|||
display: block; |
|||
width: 100%; |
|||
height: 40px; |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
opacity: 0; |
|||
border-radius: 5px; |
|||
} |
|||
|
|||
.kelp-avatarPreview { |
|||
float:right; |
|||
} |
@ -0,0 +1,41 @@ |
|||
.layui-table-cell{ |
|||
height:auto!important; |
|||
white-space:normal; |
|||
} |
|||
|
|||
#avatarImg{ |
|||
width:200px; |
|||
height:200px; |
|||
margin-bottom:2px; |
|||
} |
|||
|
|||
.uploadButton { |
|||
width: 200px; |
|||
height: auto; |
|||
overflow: hidden; |
|||
|
|||
height: 40px; |
|||
line-height: 40px; |
|||
text-align: center; |
|||
background: #d8b49c; |
|||
display: block; |
|||
font-size: 16px; |
|||
border-radius: 2px; |
|||
|
|||
position: relative; |
|||
} |
|||
|
|||
.uploadFile { |
|||
display: block; |
|||
width: 100%; |
|||
height: 40px; |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
opacity: 0; |
|||
border-radius: 5px; |
|||
} |
|||
|
|||
.kelp-avatarPreview { |
|||
float:right; |
|||
} |
@ -0,0 +1,41 @@ |
|||
.layui-table-cell{ |
|||
height:auto!important; |
|||
white-space:normal; |
|||
} |
|||
|
|||
#avatarImg{ |
|||
width:200px; |
|||
height:200px; |
|||
margin-bottom:2px; |
|||
} |
|||
|
|||
.uploadButton { |
|||
width: 200px; |
|||
height: auto; |
|||
overflow: hidden; |
|||
|
|||
height: 40px; |
|||
line-height: 40px; |
|||
text-align: center; |
|||
background: #d8b49c; |
|||
display: block; |
|||
font-size: 16px; |
|||
border-radius: 2px; |
|||
|
|||
position: relative; |
|||
} |
|||
|
|||
.uploadFile { |
|||
display: block; |
|||
width: 100%; |
|||
height: 40px; |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
opacity: 0; |
|||
border-radius: 5px; |
|||
} |
|||
|
|||
.kelp-avatarPreview { |
|||
float:right; |
|||
} |
@ -0,0 +1,36 @@ |
|||
#avatarImg{ |
|||
width:200px; |
|||
height:200px; |
|||
margin-bottom:2px; |
|||
} |
|||
|
|||
.uploadButton { |
|||
width: 200px; |
|||
height: auto; |
|||
overflow: hidden; |
|||
|
|||
height: 40px; |
|||
line-height: 40px; |
|||
text-align: center; |
|||
background: #d8b49c; |
|||
display: block; |
|||
font-size: 16px; |
|||
border-radius: 2px; |
|||
|
|||
position: relative; |
|||
} |
|||
|
|||
.uploadFile { |
|||
display: block; |
|||
width: 100%; |
|||
height: 40px; |
|||
position: absolute; |
|||
left: 0; |
|||
top: 0; |
|||
opacity: 0; |
|||
border-radius: 5px; |
|||
} |
|||
|
|||
.kelp-avatarPreview { |
|||
float:right; |
|||
} |
@ -0,0 +1,328 @@ |
|||
layui.use([ 'form', 'table' ], function() { |
|||
var form = layui.form; |
|||
var table = layui.table; |
|||
|
|||
//table options
|
|||
options = { |
|||
elem : '#dataTable', |
|||
url : basePath + '/website/account/list', |
|||
method: 'post', |
|||
where:{ |
|||
qname:$("#qname").val(), |
|||
qtelephone:$("#qtelephone").val(), |
|||
qroleId:$("#qroleId").val(), |
|||
qstate:$("#qstate").val(), |
|||
}, |
|||
//分页请求参数
|
|||
request:{ |
|||
pageName: 'pageIndex', //页码
|
|||
limitName: 'limit' //每页多少数据
|
|||
}, |
|||
//返回的数据格式
|
|||
response:{ |
|||
statusName: 'status', //数据状态的字段名称,默认:code
|
|||
statusCode: 200, //成功的状态码,默认:0
|
|||
msgName: 'message', //状态信息的字段名称,默认:msg
|
|||
countName: 'total', //数据总数的字段名称,默认:count
|
|||
dataName: 'data' //数据列表的字段名称,默认:data
|
|||
}, |
|||
//每页10条数据
|
|||
limit: 10, |
|||
//加载时出现加载条
|
|||
loading: true, |
|||
toolbar : '#toolbar' // 开启头部工具栏,并为其绑定左侧模板
|
|||
, |
|||
defaultToolbar : [ |
|||
{ // 自定义头部工具栏右侧图标
|
|||
title : '搜索', |
|||
layEvent : 'search_box_display', |
|||
icon : 'layui-icon-search' |
|||
} , |
|||
'filter', 'exports', 'print'], |
|||
title : '账号列表', |
|||
cellMinWidth: 120, |
|||
cols: [[ |
|||
{type:'numbers'}, |
|||
{type: 'checkbox'}, |
|||
{field:'id', title: 'id',hide:true}, |
|||
{field:'name', title: '昵称',sort:true}, |
|||
{field:'telephone', title: '手机号',sort:true}, |
|||
{field:'roleId', title: '所属角色',sort:true,templet: '#roleTpl'}, |
|||
{field:'state', title: '状态',templet: '#stateTpl'}, |
|||
{field: 'right',title:'操作', toolbar: '#rowbar'}, |
|||
]], |
|||
done:function (res) {//返回数据执行回调函数
|
|||
layer.close(layer.load(2)); //返回数据关闭loading
|
|||
}, |
|||
fixedHeader: true, |
|||
id: 'dataTable', |
|||
page : true |
|||
}; |
|||
|
|||
//加载数据
|
|||
table.render(options); |
|||
|
|||
//监听toolbar事件
|
|||
table.on('toolbar(tablefilter)', function(obj) { |
|||
var checkStatus = table.checkStatus(obj.config.id); |
|||
switch (obj.event) { |
|||
case 'add': |
|||
add(); |
|||
break; |
|||
case 'edit': |
|||
var data = checkStatus.data; |
|||
if(data.length == 0){ |
|||
layer.msg('请先选择要编辑的数据!',{icon:2,time:2000}); |
|||
return; |
|||
} |
|||
if(data.length > 1){ |
|||
layer.msg('只能选择一条要编辑的数据!',{icon:2,time:2000}); |
|||
return; |
|||
} |
|||
if(data.length == 1){ |
|||
edit(data[0].id); |
|||
} |
|||
break; |
|||
case 'delete': |
|||
var data = checkStatus.data; |
|||
if(data.length == 0){ |
|||
layer.msg('请先选择要禁用的数据!',{icon:2,time:2000}); |
|||
return; |
|||
} |
|||
var ids_ = ""; |
|||
for(var i=0;i<data.length;i++){ |
|||
ids_ += data[i].id + ","; |
|||
} |
|||
layer.confirm('您真的要禁用所选择数据吗?', function(index){ |
|||
delete_(ids_); |
|||
layer.close(index); |
|||
}); |
|||
break; |
|||
// 自定义头工具栏右侧图标 - 隐藏搜索栏
|
|||
case 'search_box_display': |
|||
searchboxToggle(); |
|||
break; |
|||
} |
|||
; |
|||
}); |
|||
|
|||
// 监听rowbar事件
|
|||
table.on('tool(tablefilter)', function(obj) { |
|||
var data = obj.data; |
|||
if (obj.event === 'del') { |
|||
layer.confirm('您真的要禁用吗?', function(index) { |
|||
delete_(data.id); |
|||
layer.close(index); |
|||
}); |
|||
} else if (obj.event === 'edit') { |
|||
edit(data.id); |
|||
} |
|||
}); |
|||
|
|||
//添加
|
|||
function add(){ |
|||
|
|||
//清理数据
|
|||
$("#edit_id_").val(""); |
|||
$("#name").val(""); |
|||
$("#realName").val(""); |
|||
$("#telephone").val(""); |
|||
$("#sex").val("0"); |
|||
$("#roleId").val(""); |
|||
$("#state").val("00"); |
|||
|
|||
//刷新页面
|
|||
form.render(); |
|||
|
|||
layer.open({ |
|||
title:"添加/编辑", |
|||
area: ['100%','100%'], |
|||
closeBtn:1, |
|||
type: 1, |
|||
scrollbar:false, |
|||
content:$("#form_edit"), |
|||
cancel: function(index, layero){ |
|||
layer.close(index); |
|||
return false; |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
//关闭添加/编辑页面
|
|||
form.on('submit(close_)', function (data){ |
|||
layer.close(layer.index); |
|||
}); |
|||
|
|||
//添加或编辑保存数据
|
|||
form.on('submit(edit_)', function (data){ |
|||
|
|||
var result = false; |
|||
|
|||
var name = data.field.name; |
|||
var realName = data.field.realName; |
|||
var telephone = data.field.telephone; |
|||
var sex = data.field.sex; |
|||
var roleId = data.field.roleId; |
|||
var state = data.field.state; |
|||
var id_ = data.field.edit_id_; |
|||
|
|||
var url = basePath + "/website/account/add"; |
|||
|
|||
if(id_.length > 0){ |
|||
url = basePath + "/website/account/update"; |
|||
} |
|||
|
|||
if(name.length == 0 || name.length > 50){ |
|||
layer.msg('昵称不能为空且不能超过50个字符!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(realName != null && realName.length > 0 && realName.length > 50){ |
|||
layer.msg('真实姓名不能超过50个字符!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(telephone.length == 0 || telephone.length > 20){ |
|||
layer.msg('手机号不能为空且不能超过20个字符!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(sex.length == 0 || sex.length != 1){ |
|||
layer.msg('性别不能为空或数据非法!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(roleId.length == 0 || roleId.length > 32){ |
|||
layer.msg('所属角色不能为空或数据非法!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
if(state.length == 0 || state.length != 2){ |
|||
layer.msg('账号状态不能为空或数据非法!',{icon:2,time:2000}); |
|||
return result; |
|||
} |
|||
|
|||
$.ajax({ |
|||
url: url, |
|||
data: { |
|||
"id":id_, |
|||
"name":name, |
|||
"realName":realName, |
|||
"telephone":telephone, |
|||
"sex":sex, |
|||
"roleId":roleId, |
|||
"state":state, |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
layer.msg(data.message,{icon:1,time:2000}); |
|||
layer.closeAll("page"); |
|||
reload(); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('保存失败,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
|
|||
return result; |
|||
|
|||
}); |
|||
|
|||
//编辑
|
|||
function edit(id){ |
|||
|
|||
$.ajax({ |
|||
url: basePath + "/website/account/toEdit", |
|||
data: { |
|||
"id":id |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
$("#edit_id_").val(data.account.id); |
|||
$("#name").val(data.account.name); |
|||
$("#realName").val(data.account.realName); |
|||
$("#telephone").val(data.account.telephone); |
|||
$("#sex").val(data.account.sex); |
|||
$("#roleId").val(data.account.roleId); |
|||
$("#state").val(data.account.state); |
|||
|
|||
//刷新页面
|
|||
form.render(); |
|||
|
|||
layer.open({ |
|||
title:"添加/编辑", |
|||
area: ['100%','100%'], |
|||
closeBtn:1, |
|||
type: 1, |
|||
scrollbar:false, |
|||
content:$("#form_edit"), |
|||
cancel: function(index, layero){ |
|||
layer.close(index); |
|||
return false; |
|||
} |
|||
}); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('服务器错误,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
//删除
|
|||
function delete_(ids){ |
|||
$.ajax({ |
|||
url: basePath + "/website/account/delete", |
|||
data: { |
|||
"ids":ids |
|||
}, |
|||
type : 'post', |
|||
dataType : 'json', |
|||
success : function(data) { |
|||
if (data.result == true) { |
|||
reload(); |
|||
layer.msg('删除成功!',{icon:1,time:1000}); |
|||
} else { |
|||
layer.msg(data.message,{icon:2,time:2000}); |
|||
} |
|||
}, |
|||
error : function() { |
|||
layer.msg('服务器错误,请重试!',{icon:2,time:2000}); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
$('#reload').on('click', function(){ |
|||
reload(); |
|||
}); |
|||
|
|||
$("#resetq").on('click',function(){ |
|||
$("#qname").val(""); |
|||
$("#qtelephone").val(""); |
|||
$("#qroleId").val(""); |
|||
$("#qstate").val("00"); |
|||
form.render(); |
|||
}); |
|||
|
|||
$("#resetf").on('click',function(){ |
|||
$("#form_edit")[0].reset(); |
|||
}); |
|||
|
|||
function reload(){ |
|||
layer.load(2); |
|||
options.where.qname = $("#qname").val(); |
|||
options.where.qtelephone = $("#qtelephone").val(); |
|||
options.where.qroleId = $("#qroleId").val(); |
|||
options.where.qstate = $("#qstate").val(); |
|||
table.reload("dataTable",options); |
|||
} |
|||
}); |
@ -0,0 +1,149 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
|
|||
<meta charset="utf-8"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||
<meta name="keywords" content=""> |
|||
<meta name="description" content=""> |
|||
<title>客户角色管理</title> |
|||
<#include "/common/include.ftl"/> |
|||
<#include "/common/plugins.ftl"/> |
|||
<#include "/common/kelp.ftl"/> |
|||
<script type="text/javascript" src="${base}/static/plat/js/urole.js" ></script> |
|||
</head> |
|||
|
|||
<body > |
|||
<!-- search box start --> |
|||
<div class="kelp-search-collapse" id="kelp_searchbox"> |
|||
<div class="layui-form"> |
|||
|
|||
<div class="layui-form-item"> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">名称:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="qname" id="qname" class="layui-input"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">级别:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" name="qlevel" id="qlevel" class="layui-input"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline" style="margin-top:-7px;"> |
|||
<button class="layui-btn layui-btn-sm" id="reload">查询</button> |
|||
<button class="layui-btn layui-btn-sm" id="resetq">重置</button> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
<!-- search box end --> |
|||
|
|||
<!-- table start --> |
|||
<table class="layui-hide" id="dataTable" lay-filter="tablefilter"></table> |
|||
|
|||
<script type="text/html" id="toolbar"> |
|||
<div class="layui-btn-group"> |
|||
<button type="button" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"></i></button> |
|||
<button type="button" class="layui-btn layui-btn-sm" lay-event="edit"><i class="layui-icon"></i></button> |
|||
<button type="button" class="layui-btn layui-btn-sm" lay-event="delete"><i class="layui-icon"></i></button> |
|||
</div> |
|||
</script> |
|||
|
|||
<script type="text/html" id="rowbar"> |
|||
<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon"></i></a> |
|||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon"></i></a> |
|||
<a class="layui-btn layui-btn-xs" lay-event="grant"><i class="layui-icon"></i></a> |
|||
</script> |
|||
<!-- table end --> |
|||
|
|||
<!-- editor form start --> |
|||
<form class="layui-form" id="form_edit" hidden style="margin-top: 20px;"> |
|||
<input type="hidden" class="layui-input" placeholder="" id="edit_id_" name="edit_id_"> |
|||
|
|||
<div class="layui-form-item"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>名称:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="name" id="name" class="layui-input" lay-verify="required" maxlength="20"/> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>级别:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="number" name="level" id="level" class="layui-input" lay-verify="required" maxlength="20"/> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
<div class="layui-form-item"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>说明:</label> |
|||
<div class="layui-input-block"> |
|||
<textarea name="description" id="description" lay-verify="required" class="layui-textarea" style="width:97%;height:80%"></textarea> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-form-item layui-layout-admin"> |
|||
<div class="layui-input-block"> |
|||
<div class="layui-footer" style="left: 0;"> |
|||
<button lay-submit lay-filter="edit_" class="layui-btn layui-btn-sm" id="edit_save">保存</button> |
|||
<button lay-filter="close_" class="layui-btn layui-btn-sm" id="edit_close">关闭</button> |
|||
<button type="button" id="resetf" class="layui-btn layui-btn-primary layui-btn-sm">重置</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
<!-- editor form end --> |
|||
|
|||
<!-- grant form start --> |
|||
<form class="layui-form" id="form_grant" hidden style="margin-top: 20px;"> |
|||
<input type="hidden" class="layui-input" placeholder="" id="grant_id_" name="grant_id_"> |
|||
|
|||
<div style="width:96%;margin:0 auto;"> |
|||
<table class="layui-table" id="grant_table" lay-filter="grant_table"> |
|||
<colgroup> |
|||
<col width="200"> |
|||
<col> |
|||
</colgroup> |
|||
<thead> |
|||
<tr> |
|||
<th>模块名称</th> |
|||
<th>功能</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<#list modelMap.mfs as mfs> |
|||
<tr> |
|||
<td><input type="checkbox" lay-skin="primary" title="${mfs.module.name}" id="${mfs.module.id}" lay-filter="pgroup_" class="pgroup_"/></td> |
|||
<td> |
|||
<#list mfs.functions as function> |
|||
<div style="width:200px;float:left;margin-top:5px;"> |
|||
<input type="checkbox" lay-skin="primary" class="pfunction" fid="${function.id}" title="${function.name}" name="${function.moduleId}" value="${function.id}"/> |
|||
</div> |
|||
</#list> |
|||
</td> |
|||
</tr> |
|||
</#list> |
|||
</tbody> |
|||
</table> |
|||
<div class="layui-form-item layui-layout-admin"> |
|||
<div class="layui-input-block"> |
|||
<div class="layui-footer" style="left: 0;"> |
|||
<button lay-submit lay-filter="grant_" class="layui-btn layui-btn-sm" id="grant_save">授权</button> |
|||
<button lay-filter="close_" class="layui-btn layui-btn-sm" id="grant_close">关闭</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
<!-- grant form end --> |
|||
</body> |
|||
</html> |
@ -0,0 +1,193 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
|
|||
<meta charset="utf-8"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||
<meta name="keywords" content=""> |
|||
<meta name="description" content=""> |
|||
<title>账号管理</title> |
|||
<#include "/common/include.ftl"/> |
|||
<#include "/common/plugins.ftl"/> |
|||
<#include "/common/kelp.ftl"/> |
|||
<script type="text/javascript" src="${base}/static/website/js/account.js" ></script> |
|||
</head> |
|||
|
|||
<body > |
|||
<!-- search box start --> |
|||
<div class="kelp-search-collapse" id="kelp_searchbox"> |
|||
<div class="layui-form"> |
|||
|
|||
<div class="layui-form-item"> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">所属角色</label> |
|||
<div class="layui-input-block"> |
|||
<select name="qroleId" id="qroleId" lay-search=''> |
|||
<option value="" selected>全部</option> |
|||
<#list modelMap.roles as role> |
|||
<option value="${role.id}">${role.name}</option> |
|||
</#list> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">名称:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="qname" id="qname" class="layui-input"> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">电话:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="qtelephone" id="qtelephone" class="layui-input"> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
<div class="layui-form-item"> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">状态:</label> |
|||
<div class="layui-input-block"> |
|||
<select name="qstate" id="qstate"> |
|||
<option value="">全部</option> |
|||
<option value="00" selected>正常</option> |
|||
<option value="10">锁定</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline" style="margin-top:-7px;"> |
|||
<button class="layui-btn layui-btn-sm" id="reload">查询</button> |
|||
<button class="layui-btn layui-btn-sm" id="resetq">重置</button> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
<!-- search box end --> |
|||
|
|||
<!-- table start --> |
|||
<table class="layui-hide" id="dataTable" lay-filter="tablefilter"></table> |
|||
|
|||
<script type="text/html" id="stateTpl"> |
|||
{{#if(d.state == "00"){}} |
|||
正常 |
|||
{{#}}} |
|||
{{#if(d.state == "10"){}} |
|||
锁定 |
|||
{{#}}} |
|||
</script> |
|||
|
|||
<script type="text/html" id="roleTpl"> |
|||
<#list modelMap.roles as role> |
|||
{{#if(d.roleId == "${role.id}"){}} |
|||
${role.name} |
|||
{{#}}} |
|||
</#list> |
|||
</script> |
|||
|
|||
<script type="text/html" id="toolbar"> |
|||
<div class="layui-btn-group"> |
|||
<button type="button" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"></i></button> |
|||
<button type="button" class="layui-btn layui-btn-sm" lay-event="edit"><i class="layui-icon"></i></button> |
|||
<button type="button" class="layui-btn layui-btn-sm" lay-event="delete"><i class="layui-icon"></i></button> |
|||
</div> |
|||
</script> |
|||
|
|||
<script type="text/html" id="rowbar"> |
|||
<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon"></i></a> |
|||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon"></i></a> |
|||
</script> |
|||
<!-- table end --> |
|||
|
|||
<!-- editor form start --> |
|||
<form class="layui-form" id="form_edit" hidden style="margin-top: 20px;"> |
|||
<input type="hidden" class="layui-input" placeholder="" id="edit_id_" name="edit_id_"> |
|||
|
|||
<fieldset class="layui-elem-field layui-field-title"> |
|||
<legend>基本信息</legend> |
|||
</fieldset> |
|||
|
|||
<div class="layui-form-item"> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>所属角色:</label> |
|||
<div class="layui-input-block"> |
|||
<select name="roleId" id="roleId" lay-verify="required" lay-search=''> |
|||
<option value="">请选择</option> |
|||
<#list modelMap.roles as role> |
|||
<option value="${role.id}">${role.name}</option> |
|||
</#list> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>昵称:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="name" id="name" class="layui-input" lay-verify="required" maxlength="20"/> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>手机号:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="tel" name="telephone" id="telephone" class="layui-input" lay-verify="required|phone" maxlength="20"/> |
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
|
|||
<fieldset class="layui-elem-field layui-field-title"> |
|||
<legend>其他信息</legend> |
|||
</fieldset> |
|||
|
|||
<div class="layui-form-item"> |
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>真实姓名:</label> |
|||
<div class="layui-input-block"> |
|||
<input type="text" name="realName" id="realName" class="layui-input" lay-verify="required" maxlength="20"/> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label"><span style="color:red; margin-right: 5px">*</span>性别:</label> |
|||
<div class="layui-input-block"> |
|||
<select name="sex" id="sex" lay-verify="required" > |
|||
<option value="">请选择</option> |
|||
<option value="0">男</option> |
|||
<option value="1">女</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-inline"> |
|||
<label class="layui-form-label">状态:</label> |
|||
<div class="layui-input-block"> |
|||
<select name="state" id="state"> |
|||
<option value="00" selected>正常</option> |
|||
<option value="10">锁定</option> |
|||
</select> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="layui-form-item layui-layout-admin"> |
|||
<div class="layui-input-block"> |
|||
<div class="layui-footer" style="left: 0;"> |
|||
<button lay-submit lay-filter="edit_" class="layui-btn layui-btn-sm" id="edit_save">保存</button> |
|||
<button lay-filter="close_" class="layui-btn layui-btn-sm" id="edit_close">关闭</button> |
|||
<button type="button" id="resetf" class="layui-btn layui-btn-primary layui-btn-sm">重置</button> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
<!-- editor form end --> |
|||
|
|||
</body> |
|||
</html> |
@ -0,0 +1,141 @@ |
|||
/** |
|||
* 解决nginx负载均衡问题 |
|||
*/ |
|||
package com.kelp.framework.interceptor; |
|||
|
|||
import com.kelp.common.config.RedisBean; |
|||
import com.kelp.common.constant.KeyConstant; |
|||
import com.kelp.common.utils.AuthenticationBean; |
|||
import com.kelp.common.utils.CookieUtil; |
|||
import com.kelp.common.utils.jwt.JwtUtil; |
|||
import com.kelp.framework.exception.E_NOGrantException; |
|||
import com.kelp.framework.exception.E_NOLoginException; |
|||
import com.kelp.plat.service.U_RFService; |
|||
import com.opensymphony.oscache.util.StringUtil; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.web.servlet.ModelAndView; |
|||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
|||
|
|||
import javax.annotation.Resource; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
public class UInterceptor extends HandlerInterceptorAdapter{ |
|||
|
|||
private static Logger log = LoggerFactory.getLogger(UInterceptor.class); |
|||
|
|||
@Autowired |
|||
private RedisBean redisBean; |
|||
|
|||
@Resource |
|||
private U_RFService ufService; |
|||
|
|||
@Value("${token.alive.time}") |
|||
private int tokenLiveCount; |
|||
|
|||
@Override |
|||
public boolean preHandle(HttpServletRequest request, |
|||
HttpServletResponse response, Object handler) throws Exception { |
|||
|
|||
System.out.println("user interceptor ----- "); |
|||
|
|||
String url = request.getRequestURL().toString(); |
|||
if (url.lastIndexOf("website") > 0) { |
|||
url = url.substring(url.lastIndexOf("website") - 1); |
|||
} |
|||
|
|||
System.out.println("enterprise u r accessing : " + url); |
|||
|
|||
log.error("enterprise u r accessing : " + url); |
|||
|
|||
String token = CookieUtil.getCookie(request, "token"); |
|||
|
|||
//如果没有token则没有登录
|
|||
if(StringUtil.isEmpty(token)){ |
|||
log.error("accessed without token."); |
|||
throw new E_NOLoginException("EL-001","accessed without token."); |
|||
} |
|||
|
|||
//验证token是否合法,不合法则登录
|
|||
if(!JwtUtil.verify(token, KeyConstant.JWTKEY)){ |
|||
System.out.println("the token is : expired..."); |
|||
log.error("the token is : expired..."); |
|||
throw new E_NOLoginException("EL-002","the token has expired."); |
|||
} |
|||
|
|||
String accountId = JwtUtil.getId(token); |
|||
String host = JwtUtil.getHost(token); |
|||
|
|||
//判断是否在另外的设备上登录
|
|||
if(!request.getSession().getId().equals(host)){ |
|||
System.out.println("u were logined on anather device."); |
|||
log.error("u logined on anather device."); |
|||
throw new E_NOLoginException("EL-003","u logined on anather device."); |
|||
} |
|||
|
|||
//如果redis中没有本次访问的token或本次访问的token与redis中不同
|
|||
if(null == redisBean.hget(accountId, "u_token") || !redisBean.hget(accountId, "u_token").equals(token)){ |
|||
System.out.println("there is no token in redis."); |
|||
log.error("there is no token in redis."); |
|||
throw new E_NOLoginException("EL-004","the token don't match token in at."); |
|||
} |
|||
|
|||
//从redis中获取departmentId
|
|||
// String departmentId = redisBean.hget(accountId, "e_department");
|
|||
//如果没有找到,则视为没有登录
|
|||
// if(departmentId == null){
|
|||
// System.out.println("ur department is not valid.");
|
|||
// log.error("ur department is not valid.");
|
|||
// throw new E_NOLoginException("EL-005","the token of department has expired.");
|
|||
// }
|
|||
|
|||
//从redis中获取roleId
|
|||
String roleId = redisBean.hget(accountId, "u_role"); |
|||
//如果没有找到,则视为没有登录
|
|||
if(roleId == null){ |
|||
System.out.println("ur role is not valid."); |
|||
log.error("ur role is not valid."); |
|||
throw new E_NOLoginException("EL-006","the token of role has expired."); |
|||
} |
|||
|
|||
|
|||
//判断此account在本系统中的权限
|
|||
if(!AuthenticationBean.getERfMap().containsKey(roleId)){ |
|||
AuthenticationBean.getERfMap().put(roleId, ufService.getSRFs(roleId)); |
|||
} |
|||
|
|||
if(!AuthenticationBean.getERfMap().get(roleId).containsKey(url)){ |
|||
System.out.println(url +",u r not granted to access this url."); |
|||
log.error("u r not granted to access this url."); |
|||
throw new E_NOGrantException("EG-001","u r not granted to access this url."); |
|||
} |
|||
|
|||
//更新token
|
|||
token = JwtUtil.sign(accountId, request.getSession().getId(), KeyConstant.JWTKEY); |
|||
//更新redis
|
|||
redisBean.hset(accountId, "u_token",token); |
|||
redisBean.hset(accountId, "u_role",roleId); |
|||
// redisBean.hset(accountId, "u_department",departmentId);
|
|||
//更新cookie
|
|||
CookieUtil.editCookie(request, response, "token", token); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public void afterCompletion(HttpServletRequest request, |
|||
HttpServletResponse response, Object handler, Exception ex) |
|||
throws Exception { |
|||
super.afterCompletion(request, response, handler, ex); |
|||
} |
|||
|
|||
@Override |
|||
public void postHandle(HttpServletRequest request, |
|||
HttpServletResponse response, Object handler, |
|||
ModelAndView modelAndView) throws Exception { |
|||
super.postHandle(request, response, handler, modelAndView); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.kelp.plat.dao; |
|||
|
|||
import com.kelp.base.dao.BaseDao; |
|||
import com.kelp.plat.entity.Function; |
|||
import com.kelp.plat.entity.U_RF; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface U_RFDao extends BaseDao<U_RF, Long> { |
|||
|
|||
/** |
|||
* 取得这个Role可以访问的资源 |
|||
* @param roleId |
|||
* @return |
|||
*/ |
|||
public List<Function> getSRFByRoleId(Long roleId); |
|||
|
|||
/** |
|||
* 保存权限信息 |
|||
* @param roleId |
|||
* @param functionIds |
|||
*/ |
|||
public void setRFs(Long roleId,List<Long> functionIds); |
|||
|
|||
/** |
|||
* 取得这个Role的权限设置信息 |
|||
* @param roleId |
|||
* @return |
|||
*/ |
|||
public List<U_RF> getRFsByRoleId(Long roleId); |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.kelp.plat.dao; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.base.dao.BaseDao; |
|||
import com.kelp.plat.entity.U_Role; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface U_RoleDao extends BaseDao<U_Role, Long>{ |
|||
|
|||
public Page<U_Role> getPage(int pageNumber, int pageSize,String name,Integer level); |
|||
|
|||
public List<U_Role> getByLevel(Integer level); |
|||
|
|||
public List<U_Role> getAll(); |
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.kelp.plat.dao.impl; |
|||
|
|||
|
|||
import com.kelp.base.dao.impl.BaseDaoImpl; |
|||
import com.kelp.common.utils.IdWorker; |
|||
import com.kelp.plat.entity.E_RF; |
|||
import com.kelp.plat.entity.Function; |
|||
import com.kelp.plat.dao.U_RFDao; |
|||
import com.kelp.plat.entity.U_RF; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Repository; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Repository |
|||
@Transactional |
|||
public class U_RFDaoImpl extends BaseDaoImpl<U_RF, Long> implements U_RFDao { |
|||
|
|||
@Autowired |
|||
private IdWorker idWorker; |
|||
|
|||
@SuppressWarnings("unchecked") |
|||
@Override |
|||
public List<Function> getSRFByRoleId(Long roleId) { |
|||
String sql = "select o from Function o where o.id in (select functionId from U_RF where roleId = :roleId) order by moduleId"; |
|||
return em.createQuery(sql).setParameter("roleId", roleId).getResultList(); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public void setRFs(Long roleId, List<Long> functionIds) { |
|||
//先删除
|
|||
String sql = "delete U_RF where roleId = :roleId"; |
|||
em.createQuery(sql).setParameter("roleId", roleId).executeUpdate(); |
|||
|
|||
//再添加
|
|||
for(Long functionId : functionIds){ |
|||
E_RF rf = new E_RF(roleId,functionId); |
|||
rf.setId(idWorker.nextId()); |
|||
em.persist(rf); |
|||
} |
|||
} |
|||
|
|||
@SuppressWarnings("unchecked") |
|||
@Override |
|||
public List<U_RF> getRFsByRoleId(Long roleId) { |
|||
String sql = "select o from U_RF o where roleId = :roleId"; |
|||
return em.createQuery(sql).setParameter("roleId", roleId).getResultList(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,68 @@ |
|||
package com.kelp.plat.dao.impl; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.base.dao.impl.BaseDaoImpl; |
|||
import com.kelp.plat.dao.U_RoleDao; |
|||
import com.kelp.plat.entity.U_Role; |
|||
import org.springframework.stereotype.Repository; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Repository |
|||
@Transactional |
|||
public class U_RoleDaoImpl extends BaseDaoImpl<U_Role, Long> implements U_RoleDao { |
|||
|
|||
@Override |
|||
@Transactional |
|||
public boolean delete(List<Long> ids) { |
|||
|
|||
//处理RF
|
|||
String sql = "delete U_RF where roleId in(:roleIds)"; |
|||
em.createQuery(sql).setParameter("roleIds", ids).executeUpdate(); |
|||
|
|||
super.delete(ids); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public Page<U_Role> getPage(int pageNumber, int pageSize,String name,Integer level) { |
|||
|
|||
String sql = " from U_Role o where 1=1 "; |
|||
List<Object> params = new ArrayList<Object>(); |
|||
|
|||
int i = 1; |
|||
if(name == null || name.length() == 0){ |
|||
name = ""; |
|||
sql += " and name like ?" + i++; |
|||
params.add("%" + name + "%"); |
|||
} |
|||
|
|||
if(level != null) { |
|||
sql += "and level = ?" + i++; |
|||
params.add(level); |
|||
} |
|||
|
|||
sql += "order by level"; |
|||
|
|||
return getBeanPage(pageNumber, pageSize, sql, params); |
|||
} |
|||
|
|||
@SuppressWarnings("unchecked") |
|||
@Override |
|||
public List<U_Role> getAll() { |
|||
String sql = "select o from U_Role o order by level"; |
|||
return em.createQuery(sql).getResultList(); |
|||
} |
|||
|
|||
@SuppressWarnings("unchecked") |
|||
@Override |
|||
public List<U_Role> getByLevel(Integer level) { |
|||
String sql = "select o from U_Role o where level = :level "; |
|||
|
|||
return em.createQuery(sql).setParameter("level", level).getResultList(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,54 @@ |
|||
/** |
|||
* enterpirse rf |
|||
*/ |
|||
package com.kelp.plat.entity; |
|||
|
|||
import com.kelp.base.BaseEntity; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.Table; |
|||
|
|||
@Entity |
|||
@Table(name="dt_user_rf") |
|||
public class U_RF extends BaseEntity { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public U_RF() {} |
|||
|
|||
public U_RF(Long roleId, Long functionId) { |
|||
this.roleId = roleId; |
|||
this.functionId = functionId; |
|||
} |
|||
|
|||
/** |
|||
* 角色id |
|||
*/ |
|||
@Column(nullable = false) |
|||
private Long roleId; |
|||
|
|||
/** |
|||
* 资源id |
|||
*/ |
|||
@Column(nullable = false) |
|||
private Long functionId; |
|||
|
|||
|
|||
public Long getRoleId() { |
|||
return roleId; |
|||
} |
|||
public void setRoleId(Long roleId) { |
|||
this.roleId = roleId; |
|||
} |
|||
|
|||
public Long getFunctionId() { |
|||
return functionId; |
|||
} |
|||
public void setFunctionId(Long functionId) { |
|||
this.functionId = functionId; |
|||
} |
|||
} |
@ -0,0 +1,60 @@ |
|||
/** |
|||
* enterpirse role |
|||
*/ |
|||
package com.kelp.plat.entity; |
|||
|
|||
import com.kelp.base.BaseEntity; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.Table; |
|||
|
|||
@Entity |
|||
@Table(name="dt_user_role") |
|||
public class U_Role extends BaseEntity { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 角色名称 |
|||
*/ |
|||
@Column(length = 50, nullable = false) |
|||
private String name; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
@Column(nullable = false) |
|||
private Integer level = 0; |
|||
|
|||
/** |
|||
* 描述 |
|||
*/ |
|||
@Column(length=128) |
|||
private String description; |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public Integer getLevel() { |
|||
return level; |
|||
} |
|||
public void setLevel(Integer level) { |
|||
this.level = level; |
|||
} |
|||
|
|||
public String getDescription() { |
|||
return description; |
|||
} |
|||
public void setDescription(String description) { |
|||
this.description = description; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.kelp.plat.service; |
|||
|
|||
import com.kelp.plat.entity.MF; |
|||
import com.kelp.plat.entity.U_RF; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface U_RFService { |
|||
|
|||
/** |
|||
* 取得权限信息,key为url,value为roleId |
|||
* @param roleId |
|||
* @return |
|||
*/ |
|||
public Map<String, String> getSRFs(String roleId); |
|||
|
|||
/** |
|||
* 保存权限信息 |
|||
* @param roleId |
|||
* @param functionIds |
|||
*/ |
|||
public void setRFs(String roleId,String[] functionIds); |
|||
|
|||
public List<MF> getMFs(); |
|||
|
|||
/** |
|||
* 取得此角色所有的权限信息 |
|||
* @param roleId |
|||
* @return |
|||
*/ |
|||
public List<U_RF> getRFs(String roleId); |
|||
|
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.kelp.plat.service; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.plat.entity.U_Role; |
|||
|
|||
import java.util.List; |
|||
|
|||
|
|||
public interface U_RoleService { |
|||
|
|||
public void add(U_Role role); |
|||
|
|||
public void update(U_Role role); |
|||
|
|||
public void delete(String[] ids); |
|||
|
|||
public U_Role getById(String id); |
|||
|
|||
public U_Role getByName(String name); |
|||
|
|||
public Page<U_Role> getPage(int pageNumber, int pageSize,String name, Integer level); |
|||
|
|||
///////////////////////////////////////////
|
|||
|
|||
public List<U_Role> getByLevel(Integer level); |
|||
|
|||
public List<U_Role> getAll(); |
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.kelp.plat.service.impl; |
|||
|
|||
import com.kelp.plat.dao.FunctionDao; |
|||
import com.kelp.plat.dao.ModuleDao; |
|||
import com.kelp.plat.entity.Function; |
|||
import com.kelp.plat.entity.MF; |
|||
import com.kelp.plat.entity.Module; |
|||
import com.kelp.plat.dao.U_RFDao; |
|||
import com.kelp.plat.entity.U_RF; |
|||
import com.kelp.plat.service.U_RFService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class U_RFServiceImpl implements U_RFService { |
|||
|
|||
@Resource |
|||
private U_RFDao ufDao; |
|||
|
|||
@Resource |
|||
private FunctionDao functiondao; |
|||
|
|||
@Resource |
|||
private ModuleDao moduleDao; |
|||
|
|||
@Override |
|||
public Map<String, String> getSRFs(String roleId) { |
|||
|
|||
List<Function> functions = ufDao.getSRFByRoleId(Long.valueOf(roleId)); |
|||
Map<String, String> rfMap = new HashMap<String, String>(); |
|||
for(Function function : functions){ |
|||
rfMap.put(function.getUrl(), roleId); |
|||
} |
|||
|
|||
return rfMap; |
|||
} |
|||
|
|||
@Override |
|||
public void setRFs(String roleId, String[] functionIds) { |
|||
|
|||
List<Long> functionIds_ = new ArrayList<Long>(); |
|||
for(String functionId : functionIds){ |
|||
functionIds_.add(Long.valueOf(functionId)); |
|||
} |
|||
ufDao.setRFs(Long.valueOf(roleId), functionIds_); |
|||
} |
|||
|
|||
@Override |
|||
public List<MF> getMFs() { |
|||
|
|||
List<MF> mfs = new ArrayList<MF>(); |
|||
List<Module> modules = moduleDao.getAll("00"); |
|||
List<Function> allFunctions = functiondao.getAll("moduleId","asc"); |
|||
|
|||
for(Module module : modules){ |
|||
MF mf = new MF(); |
|||
mf.setModule(module); |
|||
List<Function> functions = new ArrayList<Function>(); |
|||
for(Function function : allFunctions){ |
|||
if(function.getModuleId().equals(module.getId())){ |
|||
functions.add(function); |
|||
} |
|||
} |
|||
mf.setFunctions(functions); |
|||
|
|||
mfs.add(mf); |
|||
} |
|||
|
|||
return mfs; |
|||
} |
|||
|
|||
@Override |
|||
public List<U_RF> getRFs(String roleId) { |
|||
return ufDao.getRFsByRoleId(Long.valueOf(roleId)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,76 @@ |
|||
package com.kelp.plat.service.impl; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.common.utils.IdWorker; |
|||
import com.kelp.plat.dao.U_RoleDao; |
|||
import com.kelp.plat.entity.U_Role; |
|||
import com.kelp.plat.service.U_RoleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class U_RoleServiceImpl implements U_RoleService { |
|||
|
|||
@Autowired |
|||
private IdWorker idWorker; |
|||
|
|||
@Resource |
|||
private U_RoleDao roleDao; |
|||
|
|||
@Override |
|||
public void add(U_Role role) { |
|||
role.setId(idWorker.nextId()); |
|||
roleDao.add(role); |
|||
} |
|||
|
|||
@Override |
|||
public void update(U_Role role) { |
|||
roleDao.update(role); |
|||
} |
|||
|
|||
@Override |
|||
public void delete(String[] ids) { |
|||
List<Long> ids_ = new ArrayList<Long>(); |
|||
for(String id : ids){ |
|||
ids_.add(Long.valueOf(id)); |
|||
} |
|||
roleDao.delete(ids_); |
|||
} |
|||
|
|||
@Override |
|||
public U_Role getById(String id) { |
|||
return roleDao.get(Long.valueOf(id)); |
|||
} |
|||
|
|||
@Override |
|||
public Page<U_Role> getPage(int pageNumber, int pageSize,String name, Integer level) { |
|||
|
|||
Page<U_Role> page = roleDao.getPage(pageNumber, pageSize,name,level); |
|||
|
|||
if(page == null){ |
|||
page = new Page<U_Role>(); |
|||
} |
|||
|
|||
return page; |
|||
} |
|||
|
|||
@Override |
|||
public U_Role getByName(String name) { |
|||
return roleDao.get("name", name); |
|||
} |
|||
|
|||
@Override |
|||
public List<U_Role> getAll() { |
|||
return roleDao.getAll(); |
|||
} |
|||
|
|||
@Override |
|||
public List<U_Role> getByLevel(Integer level) { |
|||
return roleDao.getByLevel(level); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.kelp.website.dao; |
|||
|
|||
import com.kelp.base.dao.BaseDao; |
|||
import com.kelp.website.entity.UAccount; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/28 14:24 |
|||
*/ |
|||
public interface UAccountDao extends BaseDao<UAccount, Long> { |
|||
public void setState(List<Long> ids, String state); |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.kelp.website.dao; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.base.dao.BaseDao; |
|||
import com.kelp.biz.entity.Dict; |
|||
import com.kelp.website.entity.UAccount; |
|||
import com.kelp.website.entity.UContract; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/30 8:45 |
|||
*/ |
|||
public interface UContractDao extends BaseDao<UContract, Long> { |
|||
public Page<UContract> getPage(int pageNumber, int pageSize, long id ); |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.kelp.website.dao.impl; |
|||
|
|||
import com.kelp.base.dao.impl.BaseDaoImpl; |
|||
import com.kelp.website.dao.UAccountDao; |
|||
import com.kelp.website.entity.UAccount; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import javax.transaction.Transactional; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/28 14:25 |
|||
*/ |
|||
@Repository |
|||
public class UAccountDaoImpl extends BaseDaoImpl<UAccount, Long> implements UAccountDao { |
|||
@Transactional |
|||
@Override |
|||
public void setState(List<Long> ids ,String state) { |
|||
String sql = "update EAccount set state = :state where id in (:ids)"; |
|||
em.createQuery(sql).setParameter("state", state).setParameter("ids", ids).executeUpdate(); |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.kelp.website.dao.impl; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.base.dao.impl.BaseDaoImpl; |
|||
import com.kelp.biz.entity.Dict; |
|||
import com.kelp.website.dao.UAccountDao; |
|||
import com.kelp.website.dao.UContractDao; |
|||
import com.kelp.website.entity.UAccount; |
|||
import com.kelp.website.entity.UContract; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/30 8:45 |
|||
*/ |
|||
@Repository |
|||
public class UContractDaoImpl extends BaseDaoImpl<UContract, Long> implements UContractDao { |
|||
@Override |
|||
public Page<UContract> getPage(int pageNumber, int pageSize, long id) { |
|||
String sql = " from UContract o where 1 = 1 "; |
|||
List<Object> params = new ArrayList<Object>(); |
|||
int index = 1; |
|||
|
|||
sql += " and customerId = ?" + index++; |
|||
params.add(id); |
|||
// sql += " order by type,code,name ";
|
|||
|
|||
return getBeanPage(pageNumber, pageSize, sql, params); |
|||
} |
|||
} |
@ -0,0 +1,85 @@ |
|||
package com.kelp.website.entity; |
|||
|
|||
import com.kelp.base.BaseEntity; |
|||
import com.kelp.common.constant.KeyConstant; |
|||
import com.kelp.common.utils.AESUtil; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.Table; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/28 14:16 |
|||
*/ |
|||
@Entity |
|||
@Table(name = "dt_user_account") |
|||
public class UAccount extends BaseEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
@Column(name="name",nullable = false) |
|||
private String name; |
|||
@Column(name="password",nullable = false) |
|||
private String password; |
|||
@Column(name="telephone",nullable = false) |
|||
private String telephone; |
|||
@Column(name="enterpriseName",nullable = false) |
|||
private String enterpriseName; |
|||
@Column(name="roleId",nullable = false) |
|||
private String roleId; |
|||
|
|||
|
|||
public UAccount(String name, String password, String telephone, String enterpriseName, String roleId) { |
|||
this.name = name; |
|||
this.password = password; |
|||
this.telephone = telephone; |
|||
this.enterpriseName = enterpriseName; |
|||
this.roleId = roleId; |
|||
} |
|||
|
|||
public UAccount() { |
|||
} |
|||
|
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getTelephone() { |
|||
return telephone != null ? AESUtil.decrypt(telephone, KeyConstant.TELEPHONE) : ""; |
|||
} |
|||
public void setTelephone(String telephone) { |
|||
if (!StringUtils.isEmpty(telephone)) { |
|||
this.telephone = AESUtil.encrypt(telephone, KeyConstant.TELEPHONE); |
|||
} |
|||
} |
|||
public String getPassword() { |
|||
return password; |
|||
} |
|||
|
|||
public void setPassword(String password) { |
|||
this.password = password; |
|||
} |
|||
|
|||
|
|||
public String getEnterpriseName() { |
|||
return enterpriseName; |
|||
} |
|||
|
|||
public void setEnterpriseName(String enterpriseName) { |
|||
this.enterpriseName = enterpriseName; |
|||
} |
|||
|
|||
public String getRoleId() { |
|||
return roleId; |
|||
} |
|||
|
|||
public void setRoleId(String roleId) { |
|||
this.roleId = roleId; |
|||
} |
|||
} |
@ -0,0 +1,104 @@ |
|||
package com.kelp.website.entity; |
|||
|
|||
import javax.persistence.Column; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/28 17:43 |
|||
*/ |
|||
|
|||
public class UAccountVo { |
|||
private String id; |
|||
@Column(name="name",nullable = false) |
|||
private String name; |
|||
@Column(name="password",nullable = false) |
|||
private String password; |
|||
@Column(name="realName",nullable = false) |
|||
private String realName; |
|||
@Column(name="telephone",nullable = false) |
|||
private String telephone; |
|||
@Column(name="enterpriseName",nullable = false) |
|||
private String enterpriseName; |
|||
@Column(name="enterpriseName",nullable = false) |
|||
private String captcha; |
|||
private String timestamp; |
|||
|
|||
public UAccountVo(String name, String password, String realName, String telephone, String enterpriseName, String captcha, String timestamp) { |
|||
|
|||
this.name = name; |
|||
this.password = password; |
|||
this.realName = realName; |
|||
this.telephone = telephone; |
|||
this.enterpriseName = enterpriseName; |
|||
this.captcha = captcha; |
|||
this.timestamp=timestamp; |
|||
} |
|||
|
|||
public UAccountVo() { |
|||
|
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public void setName(String name) { |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getPassword() { |
|||
return password; |
|||
} |
|||
|
|||
public void setPassword(String password) { |
|||
this.password = password; |
|||
} |
|||
|
|||
public String getRealName() { |
|||
return realName; |
|||
} |
|||
|
|||
public void setRealName(String realName) { |
|||
this.realName = realName; |
|||
} |
|||
|
|||
public String getTelephone() { |
|||
return telephone; |
|||
} |
|||
|
|||
public void setTelephone(String telephone) { |
|||
this.telephone = telephone; |
|||
} |
|||
|
|||
public String getEnterpriseName() { |
|||
return enterpriseName; |
|||
} |
|||
|
|||
public void setEnterpriseName(String enterpriseName) { |
|||
this.enterpriseName = enterpriseName; |
|||
} |
|||
|
|||
public String getCaptcha() { |
|||
return captcha; |
|||
} |
|||
|
|||
public void setCaptcha(String captcha) { |
|||
this.captcha = captcha; |
|||
} |
|||
|
|||
public String getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(String id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getTimestamp() { |
|||
return timestamp; |
|||
} |
|||
|
|||
public void setTimestamp(String timestamp) { |
|||
this.timestamp = timestamp; |
|||
} |
|||
} |
@ -0,0 +1,255 @@ |
|||
package com.kelp.website.entity; |
|||
|
|||
import com.kelp.base.BaseEntity; |
|||
import com.kelp.common.constant.KeyConstant; |
|||
import com.kelp.common.utils.AESUtil; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.Table; |
|||
import java.math.BigDecimal; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/30 8:47 |
|||
*/ |
|||
@Entity |
|||
@Table(name = "dt_enterprise_contract") |
|||
public class UContract extends BaseEntity { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 企业,目前不使用 |
|||
*/ |
|||
// @Column(nullable = false,name="enterpriseId")
|
|||
// private Long enterpriseId;
|
|||
|
|||
/** |
|||
* 企业id path,目前不使用 |
|||
*/ |
|||
// @Column(nullable = false,length = 512)
|
|||
// private String eidPath;
|
|||
|
|||
/** |
|||
* 部门,目前不使用 |
|||
*/ |
|||
// @Column(nullable = false,name="departmentId")
|
|||
// private Long departmentId;
|
|||
|
|||
/** |
|||
* 部门id path,目前不使用 |
|||
*/ |
|||
// @Column(nullable = false,length = 512)
|
|||
// private String didPath;
|
|||
|
|||
|
|||
/** |
|||
* 客户id,不可修改 |
|||
*/ |
|||
@Column(nullable = false) |
|||
private Long customerId; |
|||
|
|||
/** |
|||
* 客户名称,不可修改 |
|||
*/ |
|||
@Column(nullable = false,name="customerName",length = 128) |
|||
private String customerName_; |
|||
|
|||
/** |
|||
* 录入人,不可修改 |
|||
*/ |
|||
@Column(nullable = false) |
|||
private Long accountId; |
|||
|
|||
/** |
|||
* 录入人姓名,不可修改 |
|||
*/ |
|||
@Column(length = 128,nullable = false,name="accountName") |
|||
private String accountName_; |
|||
|
|||
/** |
|||
* 我方签订人 |
|||
*/ |
|||
@Column(length = 128,nullable = false,name="staffName") |
|||
private String staffName_; |
|||
|
|||
/** |
|||
* 甲方签订人 |
|||
*/ |
|||
@Column(length = 128,nullable = false,name="customerSignatory") |
|||
private String customerSignatory_; |
|||
|
|||
/** |
|||
* 签订时间 |
|||
*/ |
|||
@Column(nullable = false) |
|||
private Long signTime; |
|||
|
|||
/** |
|||
* 合同终止时间 |
|||
*/ |
|||
private Long endTime; |
|||
|
|||
/** |
|||
* 合同金额 |
|||
*/ |
|||
private BigDecimal amount; |
|||
|
|||
/** |
|||
* 发票情况 |
|||
*/ |
|||
@Column(length = 1024) |
|||
private String fapiao; |
|||
|
|||
/** |
|||
* 回款情况 |
|||
*/ |
|||
@Column(length = 1024) |
|||
private String dso; |
|||
|
|||
/** |
|||
* 备注或内容 |
|||
*/ |
|||
@Column(length = 1024) |
|||
private String content; |
|||
|
|||
|
|||
/** |
|||
* 状态:00-正常,10-删除 |
|||
*/ |
|||
@Column(nullable = false,length = 2) |
|||
private String state; |
|||
|
|||
// public Long getEnterpriseId() {
|
|||
// return enterpriseId;
|
|||
// }
|
|||
// public void setEnterpriseId(Long enterpriseId) {
|
|||
// this.enterpriseId = enterpriseId;
|
|||
// }
|
|||
|
|||
// public String getEidPath() {
|
|||
// return eidPath;
|
|||
// }
|
|||
// public void setEidPath(String eidPath) {
|
|||
// this.eidPath = eidPath;
|
|||
// }
|
|||
|
|||
// public Long getDepartmentId() {
|
|||
// return departmentId;
|
|||
// }
|
|||
// public void setDepartmentId(Long departmentId) {
|
|||
// this.departmentId = departmentId;
|
|||
// }
|
|||
|
|||
// public String getDidPath() {
|
|||
// return didPath;
|
|||
// }
|
|||
// public void setDidPath(String didPath) {
|
|||
// this.didPath = didPath;
|
|||
// }
|
|||
|
|||
public Long getAccountId() { |
|||
return accountId; |
|||
} |
|||
public void setAccountId(Long accountId) { |
|||
this.accountId = accountId; |
|||
} |
|||
|
|||
public String getAccountName() { |
|||
return accountName_ != null ? AESUtil.decrypt(accountName_, KeyConstant.REALNAME) : ""; |
|||
} |
|||
public void setAccountName(String accountName) { |
|||
if (!StringUtils.isEmpty(accountName)) { |
|||
this.accountName_ = AESUtil.encrypt(accountName, KeyConstant.REALNAME); |
|||
} |
|||
} |
|||
|
|||
public String getStaffName() { |
|||
return staffName_ != null ? AESUtil.decrypt(staffName_, KeyConstant.REALNAME) : ""; |
|||
} |
|||
public void setStaffName(String staffName) { |
|||
if (!StringUtils.isEmpty(staffName)) { |
|||
this.staffName_ = AESUtil.encrypt(staffName, KeyConstant.REALNAME); |
|||
} |
|||
} |
|||
|
|||
public Long getCustomerId() { |
|||
return customerId; |
|||
} |
|||
public void setCustomerId(Long customerId) { |
|||
this.customerId = customerId; |
|||
} |
|||
|
|||
public String getCustomerName() { |
|||
return customerName_ != null ? AESUtil.decrypt(customerName_, KeyConstant.REALNAME) : ""; |
|||
} |
|||
public void setCustomerName(String customerName) { |
|||
if (!StringUtils.isEmpty(customerName)) { |
|||
this.customerName_ = AESUtil.encrypt(customerName, KeyConstant.REALNAME); |
|||
} |
|||
} |
|||
|
|||
public String getCustomerSignatory() { |
|||
return customerSignatory_ != null ? AESUtil.decrypt(customerSignatory_, KeyConstant.REALNAME) : ""; |
|||
} |
|||
public void setCustomerSignatory(String customerSignatory) { |
|||
if (!StringUtils.isEmpty(customerSignatory)) { |
|||
this.customerSignatory_ = AESUtil.encrypt(customerSignatory, KeyConstant.REALNAME); |
|||
} |
|||
} |
|||
|
|||
public Long getSignTime() { |
|||
return signTime; |
|||
} |
|||
public void setSignTime(Long signTime) { |
|||
this.signTime = signTime; |
|||
} |
|||
|
|||
public Long getEndTime() { |
|||
return endTime; |
|||
} |
|||
public void setEndTime(Long endTime) { |
|||
this.endTime = endTime; |
|||
} |
|||
|
|||
public BigDecimal getAmount() { |
|||
return amount; |
|||
} |
|||
public void setAmount(BigDecimal amount) { |
|||
this.amount = amount; |
|||
} |
|||
|
|||
public String getFapiao() { |
|||
return fapiao; |
|||
} |
|||
public void setFapiao(String fapiao) { |
|||
this.fapiao = fapiao; |
|||
} |
|||
|
|||
public String getDso() { |
|||
return dso; |
|||
} |
|||
public void setDso(String dso) { |
|||
this.dso = dso; |
|||
} |
|||
|
|||
public String getContent() { |
|||
return content; |
|||
} |
|||
public void setContent(String content) { |
|||
this.content = content; |
|||
} |
|||
|
|||
public String getState() { |
|||
return state; |
|||
} |
|||
public void setState(String state) { |
|||
this.state = state; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.kelp.website.service; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.crm.entity.EAccount; |
|||
import com.kelp.website.entity.UAccount; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/28 14:26 |
|||
*/ |
|||
public interface UAccountService { |
|||
|
|||
public UAccount getByTelephone(String telephone); |
|||
public void add(UAccount uAccount); |
|||
public UAccount getById(String id); |
|||
public void update(UAccount uAccount); |
|||
public void delete(String[] ids); |
|||
/** |
|||
* |
|||
* @param pageNumber |
|||
* @param pageSize |
|||
* @param name - 昵称 |
|||
* @param telephone |
|||
* @param roleId |
|||
* @param state |
|||
* @return |
|||
*/ |
|||
public Page<UAccount> getPage(int pageNumber, int pageSize, String enterpriseId, String departmentId, String name, |
|||
String telephone, String roleId, String state); |
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.kelp.website.service; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.website.entity.UContract; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/30 8:47 |
|||
*/ |
|||
public interface UContractService { |
|||
|
|||
|
|||
public Page<UContract> getPage(int pageNumber, int pageSize,long id); |
|||
} |
@ -0,0 +1,68 @@ |
|||
package com.kelp.website.service.impl; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.common.constant.KeyConstant; |
|||
import com.kelp.common.utils.AESUtil; |
|||
import com.kelp.common.utils.IdWorker; |
|||
import com.kelp.crm.entity.EAccount; |
|||
import com.kelp.website.dao.UAccountDao; |
|||
import com.kelp.website.entity.UAccount; |
|||
import com.kelp.website.service.UAccountService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/28 14:26 |
|||
*/ |
|||
@Service |
|||
public class UAccountServiceImpl implements UAccountService { |
|||
@Autowired |
|||
private UAccountDao uAccountDao; |
|||
@Autowired |
|||
private IdWorker idWorker; |
|||
|
|||
@Override |
|||
public UAccount getByTelephone(String telephone) { |
|||
return uAccountDao.get("telephone", AESUtil.encrypt(telephone, KeyConstant.TELEPHONE)); |
|||
} |
|||
|
|||
@Override |
|||
public void add(UAccount uAccount) { |
|||
uAccount.setId(idWorker.nextId()); |
|||
uAccountDao.add(uAccount); |
|||
} |
|||
|
|||
@Override |
|||
public UAccount getById(String id) { |
|||
return uAccountDao.get(Long.valueOf(id)); |
|||
} |
|||
|
|||
@Override |
|||
public void update(UAccount uAccount) { |
|||
uAccountDao.update(uAccount); |
|||
} |
|||
|
|||
@Override |
|||
public void delete(String[] ids) { |
|||
List<Long> ids_ = new ArrayList<Long>(); |
|||
for(String id : ids){ |
|||
try { |
|||
ids_.add(Long.valueOf(id)); |
|||
} catch (Exception e) { |
|||
return; |
|||
} |
|||
} |
|||
uAccountDao.setState(ids_, "10"); |
|||
} |
|||
|
|||
@Override |
|||
public Page<UAccount> getPage(int pageNumber, int pageSize, String enterpriseId, String departmentId, String name, String telephone, String roleId, String state) { |
|||
return null; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,43 @@ |
|||
package com.kelp.website.service.impl; |
|||
|
|||
import com.kelp.base.Page; |
|||
import com.kelp.common.utils.IdWorker; |
|||
import com.kelp.common.utils.jwt.JwtUtil; |
|||
import com.kelp.crm.service.EnterpriseService; |
|||
import com.kelp.website.dao.UContractDao; |
|||
import com.kelp.website.entity.UContract; |
|||
import com.kelp.website.service.UContractService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2025/4/30 8:47 |
|||
*/ |
|||
@Service |
|||
public class UContractServiceImpl implements UContractService { |
|||
@Autowired |
|||
UContractDao uContractDao; |
|||
@Autowired |
|||
private IdWorker idWorker; |
|||
@Autowired |
|||
EnterpriseService enterpriseService; |
|||
|
|||
|
|||
|
|||
@Override |
|||
public Page<UContract> getPage(int pageNumber, int pageSize, long id ) { |
|||
|
|||
Page<UContract> page = uContractDao.getPage(pageNumber, pageSize,id); |
|||
|
|||
if(page == null){ |
|||
page = new Page<UContract>(); |
|||
} |
|||
|
|||
return page; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue