UserDaoImpl.java
上传用户:quasar007
上传日期:2022-08-11
资源大小:4067k
文件大小:4k
- package com.dao;
- import com.domain.UserForm;
- import com.tool.JDBConnection;
- import com.tool.SQLCode;
- import java.sql.ResultSet;
- import java.sql.*;
- import java.util.List;
- import java.util.ArrayList;
- /**
- * <p>Title: </p>
- *
- * <p>Description: </p>
- *
- * <p>Copyright: Copyright (c) 2005</p>
- *
- * <p>Company: </p>
- *
- * @author not attributable
- * @version 1.0
- */
- //操作员
- public class UserDaoImpl
- implements UserDao {
- private JDBConnection connection = new JDBConnection();
- //登陆操作
- public UserForm checkUser(UserForm form) {
- UserForm user = null;
- String sql = SQLCode.getSQLCode("sql.user.check");
- sql = connection.editSqlCode(sql, form.getUser_name());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- user = new UserForm();
- user.setId(Integer.valueOf(rs.getString(1)));
- user.setUser_id(rs.getString(2));
- user.setUser_name(rs.getString(3));
- user.setUser_mm(rs.getString(4));
- user.setUser_bs(rs.getString(5));
- user.setMenu_jcxx(rs.getString(6));
- user.setMenu_khxx(rs.getString(7));
- user.setMenu_khfw(rs.getString(8));
- user.setMenu_xxcx(rs.getString(9));
- user.setMenu_fzgj(rs.getString(10));
- user.setMenu_xtgl(rs.getString(11));
- user.setMenu_sjgl(rs.getString(12));
- }
- }
- catch (SQLException ex) {
- }
- return user;
- }
- //修改操作员密码
- public void updateUserPassword(UserForm form) {
- String sql = SQLCode.getSQLCode("sql.user.updatePassword");
- sql = connection.editSqlCode(sql, form.getUser_mm());
- sql = connection.editSqlCode(sql, form.getUser_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- //查询授权的操作
- public List selectUserBs(UserForm form) {
- List list = new ArrayList();
- UserForm user = null;
- String sql = SQLCode.getSQLCode("sql.user.selectUser_bs");
- sql = connection.editSqlCode(sql, form.getUser_bs());
- try {
- ResultSet rs = connection.executeQuery(sql);
- while (rs.next()) {
- user = new UserForm();
- user.setId(Integer.valueOf(rs.getString(1)));
- user.setUser_id(rs.getString(2));
- user.setUser_name(rs.getString(3));
- user.setUser_mm(rs.getString(4));
- user.setUser_bs(rs.getString(5));
- user.setMenu_jcxx(rs.getString(6));
- user.setMenu_khxx(rs.getString(7));
- user.setMenu_khfw(rs.getString(8));
- user.setMenu_xxcx(rs.getString(9));
- user.setMenu_fzgj(rs.getString(10));
- user.setMenu_xtgl(rs.getString(11));
- user.setMenu_sjgl(rs.getString(12));
- list.add(user);
- }
- }
- catch (SQLException ex) {
- }
- return list;
- }
- //修改权利
- public void updateUserRight(UserForm form) {
- String sql = SQLCode.getSQLCode("sql.user.updateSelectRight");
- sql = connection.editSqlCode(sql, form.getMenu_jcxx());
- sql = connection.editSqlCode(sql, form.getMenu_khxx());
- sql = connection.editSqlCode(sql, form.getMenu_khfw());
- sql = connection.editSqlCode(sql, form.getMenu_xxcx());
- sql = connection.editSqlCode(sql, form.getMenu_fzgj());
- sql = connection.editSqlCode(sql, form.getMenu_sjgl());
- sql = connection.editSqlCode(sql, form.getUser_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- //帐号唯一性的操作
- public int countID() {
- int iCount = 0;
- String sql = SQLCode.getSQLCode("sql.user.countID");
- ResultSet rs = null;
- try {
- rs = connection.executeQuery(sql);
- while (rs.next()) {
- iCount = rs.getInt("t");
- }
- }
- catch (SQLException ex) {
- }
- connection.close();
- return iCount + 1;
- }
- public void insertUserRight(UserForm form) {
- String sql = SQLCode.getSQLCode("sql.user.insert");
- sql = connection.editSqlCode(sql, form.getUser_id());
- sql = connection.editSqlCode(sql, form.getUser_name());
- sql = connection.editSqlCode(sql, form.getUser_mm());
- connection.executeUpdate(sql);
- connection.close();
- }
- public void deleteUserRight(UserForm form) {
- String sql = SQLCode.getSQLCode("sql.user.delete");
- sql = connection.editSqlCode(sql, form.getUser_id());
- connection.executeUpdate(sql);
- connection.close();
- }
- }