123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221 |
- package com.ccgj.platform.admin;
- import com.base.common.enums.Enums;
- import com.base.common.spring.TransactionManager;
- import com.ccgj.database.beans.LMB;
- import com.ccgj.database.beans.YHB;
- import com.ccgj.database.beans.ZQB;
- import com.ccgj.database.business.YHBService;
- import com.ccgj.database.business.ZQBService;
- import com.ccgj.database.factory.DatabaseFactory;
- import com.ccgj.database.interfaces.YHBIF;
- import com.ccgj.database.interfaces.ZQBIF;
- import com.ccgj.database.manager.LMBManager;
- import com.ccgj.database.manager.YHBManager;
- import com.ccgj.database.manager.ZQBManager;
- import com.ccgj.database.tool.MD5;
- import com.ccgj.database.tool.Website;
- import com.ccgj.database.tool.writeFile;
- import com.ccgj.platform.common.CommonAction;
- import com.ccgj.platform.util.*;
- import com.opensymphony.xwork2.ActionContext;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import java.util.StringTokenizer;
- import javax.servlet.http.HttpServletRequest;
- public class YHBAction
- extends CommonAction
- {
- private Long id;
- private String yhmc;
- private String yhzh;
- private String yhmm;
- private String passd;
- private int yhzt;
- private int yhsx;
- private String sjid;
- private String zdmc;
- private String zdbs;
- private int zdpx;
- private String zdmb;
- private String yhqx;
- private String yhsm;
- private String tjsj;
- private String tjyh;
- private String bgsj;
- private int dlcs;
- private String by1;
- private String by2;
- private String by3;
- private String oldPass;
- private String newPwd;
- private String newPwds;
- private Object[] datas;
- private String data;
- private String type;
- private YHB yhb;
- private List<LMB> lmbList;
- private String zqbId;
- private String searchZhmc;
- private List<ZQB> zqbList;
- public Long getId()
- {
- return this.id;
- }
- public void setId(Long id)
- {
- this.id = id;
- }
- public String getYhmc()
- {
- return this.yhmc;
- }
- public void setYhmc(String yhmc)
- {
- this.yhmc = yhmc;
- }
- public String getYhzh()
- {
- return this.yhzh;
- }
- public void setYhzh(String yhzh)
- {
- this.yhzh = yhzh;
- }
- public String getYhmm()
- {
- return this.yhmm;
- }
- public void setYhmm(String yhmm)
- {
- this.yhmm = yhmm;
- }
- public String getPassd()
- {
- return this.passd;
- }
- public void setPassd(String passd)
- {
- this.passd = passd;
- }
- public int getYhzt()
- {
- return this.yhzt;
- }
- public void setYhzt(int yhzt)
- {
- this.yhzt = yhzt;
- }
- public int getYhsx()
- {
- return this.yhsx;
- }
- public void setYhsx(int yhsx)
- {
- this.yhsx = yhsx;
- }
- public String getSjid()
- {
- return this.sjid;
- }
- public void setSjid(String sjid)
- {
- this.sjid = sjid;
- }
- public String getZdmc()
- {
- return this.zdmc;
- }
- public void setZdmc(String zdmc)
- {
- this.zdmc = zdmc;
- }
- public String getZdbs()
- {
- return this.zdbs;
- }
- public void setZdbs(String zdbs)
- {
- this.zdbs = zdbs;
- }
- public int getZdpx()
- {
- return this.zdpx;
- }
- public void setZdpx(int zdpx)
- {
- this.zdpx = zdpx;
- }
- public String getZdmb()
- {
- return this.zdmb;
- }
- public void setZdmb(String zdmb)
- {
- this.zdmb = zdmb;
- }
- public String getYhqx()
- {
- return this.yhqx;
- }
- public void setYhqx(String yhqx)
- {
- this.yhqx = yhqx;
- }
- public String getYhsm()
- {
- return this.yhsm;
- }
- public void setYhsm(String yhsm)
- {
- this.yhsm = yhsm;
- }
- public String getTjsj()
- {
- return this.tjsj;
- }
- public void setTjsj(String tjsj)
- {
- this.tjsj = tjsj;
- }
- public String getTjyh()
- {
- return this.tjyh;
- }
- public void setTjyh(String tjyh)
- {
- this.tjyh = tjyh;
- }
- public String getBgsj()
- {
- return this.bgsj;
- }
- public void setBgsj(String bgsj)
- {
- this.bgsj = bgsj;
- }
- public int getDlcs()
- {
- return this.dlcs;
- }
- public void setDlcs(int dlcs)
- {
- this.dlcs = dlcs;
- }
- public String getBy1()
- {
- return this.by1;
- }
- public void setBy1(String by1)
- {
- this.by1 = by1;
- }
- public String getBy2()
- {
- return this.by2;
- }
- public void setBy2(String by2)
- {
- this.by2 = by2;
- }
- public String getBy3()
- {
- return this.by3;
- }
- public void setBy3(String by3)
- {
- this.by3 = by3;
- }
- public YHB getYhb()
- {
- return this.yhb;
- }
- public void setYhb(YHB yhb)
- {
- this.yhb = yhb;
- }
- public String getOldPass()
- {
- return this.oldPass;
- }
- public void setOldPass(String oldPass)
- {
- this.oldPass = oldPass;
- }
- public String getNewPwd()
- {
- return this.newPwd;
- }
- public void setNewPwd(String newPwd)
- {
- this.newPwd = newPwd;
- }
- public String getNewPwds()
- {
- return this.newPwds;
- }
- public void setNewPwds(String newPwds)
- {
- this.newPwds = newPwds;
- }
- public Object[] getDatas()
- {
- return this.datas;
- }
- public void setDatas(Object[] datas)
- {
- this.datas = datas;
- }
- public String getData()
- {
- return this.data;
- }
- public void setData(String data)
- {
- this.data = data;
- }
- public String getSearchZhmc()
- {
- return this.searchZhmc;
- }
- public void setSearchZhmc(String searchZhmc)
- {
- this.searchZhmc = searchZhmc;
- }
- public String getType()
- {
- return this.type;
- }
- public void setType(String type)
- {
- this.type = type;
- }
- public List<LMB> getLmbList()
- {
- return this.lmbList;
- }
- public void setLmbList(List<LMB> lmbList)
- {
- this.lmbList = lmbList;
- }
- public List<ZQB> getZqbList()
- {
- return this.zqbList;
- }
- public void setZqbList(List<ZQB> zqbList)
- {
- this.zqbList = zqbList;
- }
- public String getZqbId()
- {
- return this.zqbId;
- }
- public void setZqbId(String zqbId)
- {
- this.zqbId = zqbId;
- }
- public String init()
- {
- try
- {
- if ((this.yhsx > 0) && (this.yhsx == 1)) {
- yhbById();
- } else if ((this.yhsx > 0) && (this.yhsx == 2)) {
- yhbById();
- } else if ((this.yhsx > 0) && (this.yhsx == 3)) {
- yhbById();
- }
- }
- catch (Exception e)
- {
- logger.debug(e);
- e.printStackTrace();
- }
- return "init";
- }
- public String yhbById()
- {
- try
- {
- if (this.id != null)
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- YHB yhb = yhbIF.getYHBService().searchYHBByID(this.id);
- setYhb(yhb);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return "data";
- }
- public String edit()
- {
- try
- {
- Date date = new Date();
- if (this.id != null)
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- YHB yhbBean = yhbIF.getYHBService().searchYHBByID(this.id);
- if (yhbBean != null) {
- if ((this.newPwd != null) && (this.newPwds != null) && (this.newPwd.equals(this.newPwds)))
- {
- if ((this.oldPass != null) && (this.oldPass.length() > 0)) {
- String decodePwd = StringCode.decrypt(yhbBean.getYhmm());
- if (decodePwd.equals(this.oldPass))
- {
- /**确认旧密码正确后,判断新密码强度**/
- if(CheckStrength.checkPasswordStrength(newPwd)< 6){
- setJsondata(JsonResult.ajax(Boolean.valueOf(true), "4"));
- return "data";
- }
- yhbBean.setYhmm(StringCode.encrypt(this.newPwd));
- yhbBean.setTjsj(DateFormat.shortDate(date));
- yhbIF.getYHBService().updateYHB(yhbBean);
- setJsondata(JsonResult.ajax(Boolean.valueOf(true), "3"));
- }
- else
- {
- setJsondata(JsonResult.ajax(Boolean.valueOf(true), "2"));
- return "data";
- }
- }
- }
- else
- {
- setJsondata(JsonResult.ajax(Boolean.valueOf(true), "1"));
- return "data";
- }
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return "data";
- }
- public String adminList()
- {
- try
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- YHB yhbBean = yhbIF.createYHB();
- yhbBean.setYhsx(2);
- yhbBean.setYhzt(4);
- if ((this.searchZhmc != null) && (this.searchZhmc.length() > 0)) {
- yhbBean.setYhzh(this.searchZhmc);
- }
- List lists = new ArrayList();
- List listCount = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean);
- List<YHB> listData = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean);
- for (int i = 0; i < listData.size(); i++)
- {
- YHB yhb = (YHB)listData.get(i);
- lists.add(yhb);
- }
- setJsondata(JsonResult.listByLigerUI(lists, Integer.valueOf(listCount.isEmpty() ? 0 : listCount.size())).toString());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR")));
- }
- return "list";
- }
- public String manageAdminList()
- {
- YHB yhbBeans = (YHB)ActionContext.getContext().getSession().get("zfmb_user");
- try
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- YHB yhbBean = yhbIF.createYHB();
- yhbBean.setYhsx(3);
- yhbBean.setYhzt(4);
- yhbBean.setZdbsid(yhbBeans.getZdbsid());
- if ((this.searchZhmc != null) && (this.searchZhmc.length() > 0)) {
- yhbBean.setYhzh(this.searchZhmc);
- }
- List lists = new ArrayList();
- List listCount = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean);
- List<YHB> listData = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean);
- for (int i = 0; i < listData.size(); i++)
- {
- YHB yhb = (YHB)listData.get(i);
- lists.add(yhb);
- }
- setJsondata(JsonResult.listByLigerUI(lists, Integer.valueOf(listCount.isEmpty() ? 0 : listCount.size())).toString());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR")));
- }
- return "list";
- }
- public String adminDel()
- {
- String returnType = null;
- try
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- if ((this.data != null) && (this.data.length() > 0))
- {
- YHB bean = yhbIF.searchYHBByID(Long.valueOf(Long.parseLong(this.data)));
- // 假删除改为真删除
- // bean.setYhzt(4);
- // yhbIF.getYHBService().updateYHB(bean);
- yhbIF.getYHBService().deleteYHB(bean);
- }
- else
- {
- StringTokenizer st = new StringTokenizer(SystemUtil.getStringByObject(this.datas), ",");
- while (st.hasMoreTokens())
- {
- yhbIF.getYHBService().getTransactionManager().begin();
- String id = st.nextToken();
- YHB bean = yhbIF.searchYHBByID(Long.valueOf(Long.parseLong(id)));
- // 假删除改为真删除
- // bean.setYhzt(4);
- // yhbIF.getYHBService().updateYHB(bean);
- yhbIF.getYHBService().deleteYHB(bean);
- yhbIF.getYHBService().getTransactionManager().commit();
- }
- }
- }
- catch (Exception e)
- {
- logger.debug(e);
- e.printStackTrace();
- setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR")));
- }
- if ((this.type != null) && (this.type.length() > 0))
- {
- if (this.type.equals("wzgl")) {
- returnType = manageAdminList();
- }
- }
- else {
- returnType = adminList();
- }
- return returnType;
- }
- public String saveXTGLY()
- {
- YHB yhbBeans = (YHB)ActionContext.getContext().getSession().get("zfmb_user");
- String returnType = null;
- try
- {
- Date data = new Date();
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- ZQBIF zqbIF = DatabaseFactory.getZQBIF();
- yhbIF.getYHBService().getTransactionManager().begin();
- YHB bean = yhbIF.createYHB();
- bean.setYhmc(this.yhmc);
- bean.setYhzh(this.yhzh);
- bean.setYhzt(this.yhzt);
- bean.setYhmm(StringCode.encrypt("123456"));
- if ((this.type != null) && (this.type.length() > 0))
- {
- if (this.type.equals("wzgl")) {
- bean.setYhsx(3);
- }
- bean.setZdbsid(yhbBeans.getZdbsid());
- bean.setZdbs(yhbBeans.getZdbs());
- }
- else
- {
- ZQB zqbBean = zqbIF.createZQB();
- zqbBean.setId(Long.valueOf(Long.parseLong(this.zqbId)));
- List<ZQB> zqbList = zqbIF.getZQBService().getZqbManager().searchListZqbByBean(zqbBean);
- bean.setYhsx(2);
- bean.setZdbsid(((ZQB)zqbList.get(0)).getId().toString());
- bean.setZdbs(((ZQB)zqbList.get(0)).getZqbs());
- }
- bean.setSjid("1");
- bean.setYhsm(this.yhsm);
- bean.setTjsj(DateFormat.shortDate(data));
- yhbIF.getYHBService().saveYHB(bean);
- yhbIF.getYHBService().getTransactionManager().commit();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- if ((this.type != null) && (this.type.length() > 0))
- {
- if (this.type.equals("wzgl")) {
- returnType = manageAdminList();
- }
- }
- else {
- returnType = adminList();
- }
- return returnType;
- }
- public String getXtglyById()
- {
- String returnType = null;
- try
- {
- if (this.id != null)
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- ZQBIF zqbIF = DatabaseFactory.getZQBIF();
- List<ZQB> listDatas = new ArrayList();
- YHB searchbean = yhbIF.getYHBService().searchYHBByID(this.id);
- if (searchbean != null)
- {
- String mm = searchbean.getYhmm();
- String pwd = StringCode.decrypt(mm);
- searchbean.setYhmm(pwd);
- setYhb(searchbean);
- getRequest().setAttribute("yhb", searchbean);
- ZQB zqbBean = zqbIF.createZQB();
- zqbBean.setFlag("1");
- List<ZQB> listData = zqbIF.getZQBService().getZqbManager().searchListZqbByBean(zqbBean);
- for (ZQB list : listData) {
- listDatas.add(list);
- }
- setZqbList(listData);
- getRequest().setAttribute("zdbsid", searchbean.getZdbsid());
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- if ((this.type != null) && (this.type.length() > 0))
- {
- if (this.type.equals("wzgl")) {
- returnType = "manageAdminEdit";
- } else {
- returnType = "yhbManageCompetenceEdit";
- }
- }
- else {
- returnType = "yhbManageEdit";
- }
- return returnType;
- }
- public String editXTGLY()
- {
- Date data = new Date();
- YHB yhbBeans = (YHB)ActionContext.getContext().getSession().get("zfmb_user");
- String returnType = null;
- try
- {
- if (this.id != null)
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- ZQBIF tZqbIF = DatabaseFactory.getZQBIF();
- YHB searchbean = yhbIF.getYHBService().searchYHBByID(this.id);
- if (searchbean != null)
- {
- searchbean.setYhmc(this.yhmc);
- searchbean.setYhzh(this.yhzh);
- searchbean.setYhmm(StringCode.encrypt(this.yhmm));
- searchbean.setYhzt(this.yhzt);
- searchbean.setYhsm(this.yhsm);
- searchbean.setTjsj(DateFormat.shortDate(data));
- if (this.zqbId != null)
- {
- ZQB bean = tZqbIF.createZQB();
- bean.setId(Long.valueOf(Long.parseLong(this.zqbId)));
- List<ZQB> zqbList = tZqbIF.getZQBService().getZqbManager().searchListZqbByBean(bean);
- searchbean.setZdbsid(((ZQB)zqbList.get(0)).getId().toString());
- searchbean.setZdbs(((ZQB)zqbList.get(0)).getZqbs());
- }
- else
- {
- searchbean.setZdbsid(yhbBeans.getZdbsid());
- searchbean.setZdbs(yhbBeans.getZdbs());
- }
- yhbIF.getYHBService().updateYHB(searchbean);
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- if ((this.type != null) && (this.type.length() > 0))
- {
- if (this.type.equals("wzgl")) {
- returnType = manageAdminList();
- }
- }
- else {
- returnType = adminList();
- }
- return returnType;
- }
- public String editYHBbyCompetence()
- {
- String returnType = null;
- try
- {
- YHBIF yhbIF = DatabaseFactory.getYHBIF();
- YHB searchbean = yhbIF.getYHBService().searchYHBByID(this.id);
- String[] right = getRequest().getParameterValues("right");
- String rights = ",";
- if (right != null) {
- for (int i = 0; i < right.length; i++) {
- rights = rights + right[i] + ",";
- }
- }
- if (searchbean != null)
- {
- searchbean.setYhzt(this.yhzt);
- searchbean.setYhqx(rights);
- yhbIF.getYHBService().updateYHB(searchbean);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- if ((this.type != null) && (this.type.length() > 0))
- {
- if (this.type.equals("wzgl")) {
- returnType = manageAdminList();
- }
- }
- else {
- returnType = adminList();
- }
- return returnType;
- }
- public String zqbList()
- {
- try
- {
- List<ZQB> listDatas = new ArrayList();
- ZQBIF tZqbIF = DatabaseFactory.getZQBIF();
- ZQB searchbean = tZqbIF.createZQB();
- searchbean.setFlag("1");
- List<ZQB> listData = tZqbIF.getZQBService().getZqbManager().searchListZqbByBean(searchbean);
- for (ZQB list : listData) {
- listDatas.add(list);
- }
- setZqbList(listDatas);
- }
- catch (Exception e)
- {
- logger.debug(e);
- e.printStackTrace();
- setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR")));
- }
- return "zqbList";
- }
- private YHBManager yhbdao = new YHBManager();
- private LMBManager lmdao = new LMBManager();
- private YHB dqyhb = null;
- private static writeFile log = new writeFile();
- public List getLmbOFyhQx(YHB yhb, String lmid)
- {
- if ((lmid == null) || ("".equals(lmid)) || ("0".equals(lmid))) {
- return null;
- }
- List<LMB> qxlist = null;
- List<LMB> slmblist = this.lmdao.getSecondLMB(yhb.getZdbs(), lmid);
- if (slmblist != null)
- {
- qxlist = new ArrayList();
- for (LMB slmb : slmblist) {
- if ("1".equals(slmb.getLmlx()))
- {
- List<LMB> sqxlist = getLmbOFyhQx(yhb, slmb.getId().toString());
- if ((sqxlist != null) || (sqxlist.size() > 0)) {
- for (LMB sslmb : sqxlist) {
- qxlist.add(sslmb);
- }
- }
- }
- else if (checkYhbOfyhqx(yhb, slmb.getId().toString()) > 0)
- {
- qxlist.add(slmb);
- }
- }
- }
- return qxlist;
- }
- public YHB getZdOfZdbs(String zdbs)
- {
- YHB yhb = getManagerByZdbs(zdbs);
- if (yhb != null)
- {
- yhb.setId(Long.valueOf(0L));
- yhb.setYhmc("");
- yhb.setYhmm("");
- yhb.setSjid("");
- yhb.setYhqx("");
- yhb.setYhsm("");
- yhb.setTjyh("");
- }
- else
- {
- yhb = new YHB();
- }
- return yhb;
- }
- public YHB getManagerByZdbs(String zdbs)
- {
- return this.yhbdao.getMangerByzdbs(zdbs);
- }
- public int setYhbOfYhzt(String yhid, int yhzt)
- {
- int recode = 1;
- try
- {
- recode = this.yhbdao.modifyYhbOfYhzt(yhid, yhzt);
- }
- catch (Exception e)
- {
- writeFile.println(3, e);
- recode = 0;
- }
- return recode;
- }
- public int setYhbOfYhqx(String yhid, String yhqx)
- {
- int recode = 1;
- try
- {
- recode = this.yhbdao.setYhbOfYhqx(yhid, yhqx);
- }
- catch (Exception e)
- {
- writeFile.println(3, e);
- recode = 0;
- }
- return recode;
- }
- public int checkYhbOfyhqx(YHB yhb, String lmid)
- {
- int recode = 1;
- try
- {
- if (yhb.getYhqx().indexOf("news" + lmid + "_") > 0) {
- return recode;
- }
- }
- catch (Exception e)
- {
- writeFile.println(3, e);
- recode = -1;
- }
- return 0;
- }
- public int checkYhbOfyhqx(YHB yhb, String lmid, int qxlx)
- {
- int recode = 1;
- try
- {
- switch (qxlx)
- {
- case 1:
- if (yhb.getYhqx().indexOf("news" + lmid + "_view,") > 0) {
- return 1;
- }
- case 2:
- if (yhb.getYhqx().indexOf("news" + lmid + "_check,") > 0) {
- return 2;
- }
- case 3:
- if (yhb.getYhqx().indexOf("news" + lmid + "_add,") > 0) {
- return 3;
- }
- case 4:
- if (yhb.getYhqx().indexOf("news" + lmid + "_edit,") > 0) {
- return 4;
- }
- case 5:
- if (yhb.getYhqx().indexOf("news" + lmid + "_del,") > 0) {
- return 5;
- }
- case 6:
- if (yhb.getYhqx().indexOf("news" + lmid + "_comm,") > 0) {
- return 6;
- }
- break;
- }
- return 0;
- }
- catch (Exception e)
- {
- writeFile.println(3, e);
- recode = 0;
- }
- return recode;
- }
- public int DropYhb(String yhid)
- {
- int recode = 1;
- YHB yhb = this.yhbdao.getYhbByYhid(yhid);
- if (yhb.getYhsx() == 3)
- {
- recode = this.yhbdao.removeyhb(yhid);
- if (recode < 0) {
- return -14;
- }
- }
- return recode;
- }
- public int ModifyYhbOfUser(String zdbs, YHB yhb)
- {
- try
- {
- int recode = 0;
- recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh());
- if (recode < 1) {
- return recode;
- }
- yhb.setZdbs(zdbs);
- yhb.setYhsx(3);
- recode = this.yhbdao.modifyYhbofManager(yhb);
- if (recode < 1) {
- return -13;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return 1;
- }
- public int ModifyYhbOfManager(YHB yhb)
- {
- int recode = 0;
- recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh());
- if (recode < 1) {
- return recode;
- }
- recode = checkZdbsUnique(yhb.getId().toString(), yhb.getZdbs());
- if (recode < 1) {
- return recode;
- }
- yhb.setYhsx(2);
- recode = this.yhbdao.modifyYhbofManager(yhb);
- if (recode < 1) {
- return -13;
- }
- return 1;
- }
- public int ModifyYhbOfYhmm(String yyhmm, String xyhmm, YHB yhb)
- {
- int recode = 0;
- MD5 md5 = new MD5();
- if (!yhb.getYhmm().equals(md5.getMD5ofStr(yyhmm))) {
- return -16;
- }
- yhb.setYhmm(md5.getMD5ofStr(xyhmm));
- recode = this.yhbdao.modifyYhbOfYhmm(yhb);
- if (recode < 1) {
- return -17;
- }
- return 1;
- }
- public int ResetYhbOfYhmm(String yhid)
- {
- try
- {
- int recode = 0;
- MD5 md5 = new MD5();
- YHB yhb = new YHB();
- yhb.setId(Long.valueOf(Long.parseLong(yhid)));
- yhb.setYhmm(md5.getMD5ofStr(Website.getDefault_passd()));
- recode = this.yhbdao.modifyYhbOfYhmm(yhb);
- if (recode < 1) {
- return -17;
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- return 1;
- }
- public int AddYhbOfUser(String zdbs, YHB yhb)
- {
- int recode = 0;
- recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh());
- if (recode < 1) {
- return recode;
- }
- yhb.setZdbs(zdbs);
- yhb.setYhsx(3);
- MD5 md5 = new MD5();
- yhb.setYhmm(md5.getMD5ofStr(yhb.getYhmm()));
- recode = this.yhbdao.addYhb(yhb);
- if (recode < 1) {
- return -13;
- }
- return 1;
- }
- public int AddYhbOfManager(YHB yhb)
- {
- int recode = 0;
- recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh());
- if (recode < 1) {
- return recode;
- }
- recode = checkZdbsUnique(yhb.getId().toString(), yhb.getZdbs());
- if (recode < 1) {
- return recode;
- }
- yhb.setYhsx(2);
- MD5 md5 = new MD5();
- yhb.setYhmm(md5.getMD5ofStr(yhb.getYhmm()));
- recode = this.yhbdao.addYhb(yhb);
- if (recode < 1) {
- return -13;
- }
- return 1;
- }
- public int checkYhzhUnique(String yhid, String yhzh)
- {
- YHB yhb = this.yhbdao.getYhbByYhzh(yhzh);
- if ((yhb != null) && (!yhb.getId().toString().equals(yhid))) {
- return -11;
- }
- return 1;
- }
- public int checkZdbsUnique(String yhid, String zdbs)
- {
- List<YHB> yhlist = this.yhbdao.getAllManager();
- for (YHB yhb : yhlist) {
- if ((yhb.getZdbs().equalsIgnoreCase(zdbs)) && (!yhb.getId().equals(yhid))) {
- return -12;
- }
- }
- return 1;
- }
- public YHB getWSYhbByYhid(String yhid)
- {
- YHB yhb = this.yhbdao.getYhbByYhid(yhid);
- if ((yhb != null) && (yhb.getYhsx() == 2)) {
- return yhb;
- }
- return null;
- }
- public YHB getYhbByYhid(String yhid)
- {
- YHB yhb = this.yhbdao.getYhbByYhid(yhid);
- if ((yhb != null) && (yhb.getYhsx() == 3)) {
- return yhb;
- }
- return null;
- }
- public List getAllManager()
- {
- return this.yhbdao.getAllManager();
- }
- public List getAllUserByzdbs(String zdbs)
- {
- return this.yhbdao.getAllUserByzdbs(zdbs);
- }
- public int getLoginYh(String username, String userpassword)
- {
- int recode = 1;
- if ((getString(username).length() == 0) || (getString(userpassword).length() == 0)) {
- return 0;
- }
- YHB dlyhb = new YHB();
- dlyhb = this.yhbdao.getYhbByYhzh(username);
- if ((dlyhb == null) || (dlyhb.getId().toString().length() == 0)) {
- return -1;
- }
- MD5 md5 = new MD5();
- if (!dlyhb.getYhmm().equals(md5.getMD5ofStr(userpassword))) {
- return -2;
- }
- if (dlyhb.getYhzt() > 2) {
- return -3;
- }
- this.dqyhb = dlyhb;
- return recode;
- }
- public YHB getCurrentYhb()
- {
- return this.dqyhb;
- }
- public String getMessage(int msgnum)
- {
- switch (msgnum)
- {
- case 0:
- return "输入信息错误,请重新输入!";
- case -1:
- return "此帐号不存在,请重新输入!";
- case -2:
- return "用户名或密码错误,请重新输入!";
- case -3:
- return "此帐号已经被锁定!";
- case -11:
- return "此帐号已经存在,请重新输入!";
- case -12:
- return "此站点标识已经存在,请重新输入!";
- case -13:
- return "添加站点管理员账号失败!";
- case -14:
- return "删除用户失败!";
- case -15:
- return "删除站点失败!";
- case -16:
- return "原密码错误!";
- case -17:
- return "修改用户密码失败!";
- }
- return "用户名或密码错误!";
- }
- private String getString(String str)
- {
- if ((str != null) && (str.length() > 0)) {
- return str.trim();
- }
- return "";
- }
- }
|