NutzCN Logo
问答 一对一关系插入错误MySQLIntegrityConstraintViolationException:
发布于 2948天前 作者 Hamming 5723 次浏览 复制 上一个帖子 下一个帖子
标签:

错误日志

2016-10-27 16:46:44,272 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=uuid()
2016-10-27 16:46:44,274 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,275 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.uid()
2016-10-27 16:46:44,276 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,277 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.now()
2016-10-27 16:46:44,278 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,279 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.flag()
2016-10-27 16:46:44,281 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,290 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - INSERT INTO sys_user(id,loginname,password,salt,nickname,isOnline,disabled,email,loginAt,loginIp,loginCount,customMenu,loginTheme,opo_uid,loginSidebar,loginBoxed,loginScroll,loginPjax,unitid,opBy,opAt,delFlag) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) 
    |                                1 |         2 |                                            3 |                        4 |  5 |     6 |     7 |    8 | 9 |   10 | 11 |   12 |   13 |   14 |    15 |    16 |    17 |   18 |   19 |                               20 |         21 |    22 |
    |----------------------------------|-----------|----------------------------------------------|--------------------------|----|-------|-------|------|---|------|---|------|------|------|-------|-------|-------|------|------|----------------------------------|------------|-------|
    | 9b76a086ebac4d56a5a71884a2fd933c | yuhaiming | R0NBkwXNYQF7DfGXJL9lnvfH4IpGurAlQsF8oBaApIY= | c5oV/8mpNAVMDy9obDeaCg== | hh | false | false | NULL | 0 | NULL | 0 | NULL | NULL | NULL | false | false | false | true | NULL | 67ff178f6aa84f7186c4bd50190bf6b3 | 1477558004 | false |
  For example:> "INSERT INTO sys_user(id,loginname,password,salt,nickname,isOnline,disabled,email,loginAt,loginIp,loginCount,customMenu,loginTheme,opo_uid,loginSidebar,loginBoxed,loginScroll,loginPjax,unitid,opBy,opAt,delFlag) VALUES('9b76a086ebac4d56a5a71884a2fd933c','yuhaiming','R0NBkwXNYQF7DfGXJL9lnvfH4IpGurAlQsF8oBaApIY=','c5oV/8mpNAVMDy9obDeaCg==','hh',false,false,'NULL',0,'NULL',0,'NULL','NULL','NULL',false,false,false,true,'NULL','67ff178f6aa84f7186c4bd50190bf6b3',1477558004,false) "
2016-10-27 16:46:44,319 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - RUN 
2016-10-27 16:46:44,320 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,320 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.uid()
2016-10-27 16:46:44,321 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,322 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.now()
2016-10-27 16:46:44,322 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,323 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.flag()
2016-10-27 16:46:44,323 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,326 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - INSERT INTO opo_user(uuid,safe_password,real_name,Id_card,phone,safe_question,safe_solution,bank_account_name,bank,bank_branch,bank_account,alipay,we_chat,inviter,inviter_phone,opBy,opAt,delFlag) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) 
    |    1 |      2 |  3 |                  4 |           5 |   6 |  7 |   8 |    9 |     10 |                 11 | 12 |        13 |  14 |          15 |                               16 |         17 |    18 |
    |------|--------|----|--------------------|-------------|-----|----|-----|------|--------|--------------------|---|-----------|-----|-------------|----------------------------------|------------|-------|
    | NULL | 123456 | hh | 530112199209170015 | 18187119325 | 请选择 | 呵呵 | 余海明 | 中国银行 | 云南省昆明市 | 532546545321631353 | a | 294998512 | 余海明 | 18187119325 | 67ff178f6aa84f7186c4bd50190bf6b3 | 1477558004 | false |
  For example:> "INSERT INTO opo_user(uuid,safe_password,real_name,Id_card,phone,safe_question,safe_solution,bank_account_name,bank,bank_branch,bank_account,alipay,we_chat,inviter,inviter_phone,opBy,opAt,delFlag) VALUES('NULL','123456','hh','530112199209170015','18187119325','请选择','呵呵','余海明','中国银行','云南省昆明市','532546545321631353','a','294998512','余海明','18187119325','67ff178f6aa84f7186c4bd50190bf6b3',1477558004,false) "
2016-10-27 16:46:44,338 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - RUN 
2016-10-27 16:46:44,338 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,339 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=uuid()
2016-10-27 16:46:44,339 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,340 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.uid()
2016-10-27 16:46:44,340 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,341 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.now()
2016-10-27 16:46:44,342 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,342 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - // NOT SQL // ElFieldMacro=$me.flag()
2016-10-27 16:46:44,343 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) DEBUG - parser SQL sql, skip cache detect!! SQL=RUN 
2016-10-27 16:46:44,346 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - INSERT INTO sys_user(id,loginname,password,salt,nickname,isOnline,disabled,email,loginAt,loginIp,loginCount,customMenu,loginTheme,opo_uid,loginSidebar,loginBoxed,loginScroll,loginPjax,unitid,opBy,opAt,delFlag) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) 
    |                                1 |         2 |                                            3 |                        4 |  5 |     6 |     7 |    8 | 9 |   10 | 11 |   12 |   13 | 14 |    15 |    16 |    17 |   18 |   19 |                               20 |         21 |    22 |
    |----------------------------------|-----------|----------------------------------------------|--------------------------|----|-------|-------|------|---|------|---|------|------|---|-------|-------|-------|------|------|----------------------------------|------------|-------|
    | 93ae45c780e44c8d855228735a506e40 | yuhaiming | R0NBkwXNYQF7DfGXJL9lnvfH4IpGurAlQsF8oBaApIY= | c5oV/8mpNAVMDy9obDeaCg== | hh | false | false | NULL | 0 | NULL | 0 | NULL | NULL | 5 | false | false | false | true | NULL | 67ff178f6aa84f7186c4bd50190bf6b3 | 1477558004 | false |
  For example:> "INSERT INTO sys_user(id,loginname,password,salt,nickname,isOnline,disabled,email,loginAt,loginIp,loginCount,customMenu,loginTheme,opo_uid,loginSidebar,loginBoxed,loginScroll,loginPjax,unitid,opBy,opAt,delFlag) VALUES('93ae45c780e44c8d855228735a506e40','yuhaiming','R0NBkwXNYQF7DfGXJL9lnvfH4IpGurAlQsF8oBaApIY=','c5oV/8mpNAVMDy9obDeaCg==','hh',false,false,'NULL',0,'NULL',0,'NULL','NULL',5,false,false,false,true,'NULL','67ff178f6aa84f7186c4bd50190bf6b3',1477558004,false) "
2016-10-27 16:46:44,359 org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) DEBUG - SQLException
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'yuhaiming' for key 'INDEX_SYS_USER_LOGINNAMAE'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
	at com.mysql.jdbc.Util.getInstance(Util.java:387)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:934)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2526)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931)
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:308)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor._exec(CachedNutDaoExecutor.java:317)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:187)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:147)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:93)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:77)
	at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:63)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:61)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:266)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:274)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
	at org.nutz.dao.impl.NutDao.insertWith(NutDao.java:230)
	at org.nutz.service.EntityService._insertWith(EntityService.java:367)
	at cn.wizzer.modules.controllers.platform.opo.OpoUserController$1.run(OpoUserController.java:107)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.trans.Trans.exec(Trans.java:132)
	at cn.wizzer.modules.controllers.platform.opo.OpoUserController.addDo(OpoUserController.java:104)
	at cn.wizzer.modules.controllers.platform.opo.OpoUserController$$NUTZAOP._aop_invoke(OpoUserController.java:2)
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
	at cn.wizzer.common.services.log.SLogAopInterceptor.filter(SLogAopInterceptor.java:61)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at cn.wizzer.modules.controllers.platform.opo.OpoUserController$$NUTZAOP.addDo(OpoUserController.java:1)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.XssSqlFilterProcessor.process(XssSqlFilterProcessor.java:35)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.NutShiroProcessor.process(NutShiroProcessor.java:52)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:37)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at cn.wizzer.common.processor.LogTimeProcessor.process(LogTimeProcessor.java:21)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
	at cn.wizzer.common.filter.RouteFilter.doFilter(RouteFilter.java:33)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
	at org.eclipse.jetty.server.Server.handle(Server.java:499)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
	at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
	at java.lang.Thread.run(Thread.java:745)

实体类

package cn.wizzer.modules.models.sys;

import cn.wizzer.common.base.Model;
import cn.wizzer.modules.models.opo.opo_user;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by wizzer on 2016/6/21.
 */
@Table("sys_user")
@TableIndexes({@Index(name = "INDEX_SYS_USER_LOGINNAMAE", fields = {"loginname"}, unique = true)})
public class Sys_user extends Model implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @Prev(els = {@EL("uuid()")})
    private String id;

    @Column
    @Comment("用户名")
    @ColDefine(type = ColType.VARCHAR, width = 120)
    private String loginname;

    @Column
    @Comment("密码")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String password;// transient 修饰符可让此字段不在对象里显示

    @Column
    @Comment("密码盐")
    @ColDefine(type = ColType.VARCHAR, width = 50)
    private String salt;

    @Column
    @Comment("昵称")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String nickname;

    @Column
    @Comment("是否在线")
    @ColDefine(type = ColType.BOOLEAN)
    private boolean isOnline;

    @Column
    @Comment("是否禁用")
    @ColDefine(type = ColType.BOOLEAN)
    private boolean disabled;

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 255)
    private String email;

    @Column
    @Comment("登陆时间")
    @ColDefine(type = ColType.INT)
    private Integer loginAt;

    @Column
    @Comment("登陆IP")
    @ColDefine(type = ColType.VARCHAR, width = 255)
    private String loginIp;

    @Column
    @Comment("登陆次数")
    @ColDefine(type = ColType.INT)
    private Integer loginCount;

    @Column
    @Comment("常用菜单")
    @ColDefine(type = ColType.VARCHAR, width = 255)
    private String customMenu;

    @Column
    @Comment("皮肤样式")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String loginTheme;

    @Column
    @Comment("用户详情ID")
    private Long opo_uid;

    @Column
    private boolean loginSidebar;

    @Column
    private boolean loginBoxed;

    @Column
    private boolean loginScroll;

    @Column
    private boolean loginPjax;

    @Column
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String unitid;

    @One(target = Sys_unit.class, field = "unitid")
    private Sys_unit unit;

    @One(target = opo_user.class, field = "opo_uid")
    private opo_user opo_user;

    @ManyMany(from = "userId", relation = "sys_user_role", target = Sys_role.class, to = "roleId")
    private List<Sys_role> roles;

    @ManyMany(from = "userId", relation = "sys_user_unit", target = Sys_role.class, to = "unitId")
    protected List<Sys_unit> units;

    protected List<Sys_menu> menus;

    protected List<Sys_menu> firstMenus;

    protected Map<String, List<Sys_menu>> secondMenus;

    private List<Sys_menu> customMenus;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLoginname() {
        return loginname;
    }

    public void setLoginname(String loginname) {
        this.loginname = loginname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public boolean isOnline() {
        return isOnline;
    }

    public void setIsOnline(boolean isOnline) {
        this.isOnline = isOnline;
    }

    public boolean isDisabled() {
        return disabled;
    }

    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getLoginAt() {
        return loginAt;
    }

    public void setLoginAt(Integer loginAt) {
        this.loginAt = loginAt;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Integer getLoginCount() {
        return loginCount;
    }

    public void setLoginCount(Integer loginCount) {
        this.loginCount = loginCount;
    }

    public String getCustomMenu() {
        return customMenu;
    }

    public void setCustomMenu(String customMenu) {
        this.customMenu = customMenu;
    }

    public String getLoginTheme() {
        return loginTheme;
    }

    public void setLoginTheme(String loginTheme) {
        this.loginTheme = loginTheme;
    }

    public boolean isLoginSidebar() {
        return loginSidebar;
    }

    public void setLoginSidebar(boolean loginSidebar) {
        this.loginSidebar = loginSidebar;
    }

    public boolean isLoginBoxed() {
        return loginBoxed;
    }

    public void setLoginBoxed(boolean loginBoxed) {
        this.loginBoxed = loginBoxed;
    }

    public boolean isLoginScroll() {
        return loginScroll;
    }

    public void setLoginScroll(boolean loginScroll) {
        this.loginScroll = loginScroll;
    }

    public boolean isLoginPjax() {
        return loginPjax;
    }

    public void setLoginPjax(boolean loginPjax) {
        this.loginPjax = loginPjax;
    }

    public String getUnitid() {
        return unitid;
    }

    public void setUnitid(String unitid) {
        this.unitid = unitid;
    }

    public Sys_unit getUnit() {
        return unit;
    }

    public void setUnit(Sys_unit unit) {
        this.unit = unit;
    }

    public List<Sys_role> getRoles() {
        return roles;
    }

    public void setRoles(List<Sys_role> roles) {
        this.roles = roles;
    }

    public List<Sys_unit> getUnits() {
        return units;
    }

    public void setUnits(List<Sys_unit> units) {
        this.units = units;
    }

    public List<Sys_menu> getMenus() {
        return menus;
    }

    public void setMenus(List<Sys_menu> menus) {
        this.menus = menus;
    }

    public List<Sys_menu> getFirstMenus() {
        return firstMenus;
    }

    public void setFirstMenus(List<Sys_menu> firstMenus) {
        this.firstMenus = firstMenus;
    }

    public Map<String, List<Sys_menu>> getSecondMenus() {
        return secondMenus;
    }

    public void setSecondMenus(Map<String, List<Sys_menu>> secondMenus) {
        this.secondMenus = secondMenus;
    }

    public List<Sys_menu> getCustomMenus() {
        return customMenus;
    }

    public void setCustomMenus(List<Sys_menu> customMenus) {
        this.customMenus = customMenus;
    }

    public cn.wizzer.modules.models.opo.opo_user getOpo_user() {
        return opo_user;
    }

    public void setOpo_user(cn.wizzer.modules.models.opo.opo_user opo_user) {
        this.opo_user = opo_user;
    }

    public Long getOpo_uid() {
        return opo_uid;
    }

    public void setOpo_uid(Long opo_uid) {
        this.opo_uid = opo_uid;
    }
}

package cn.wizzer.modules.models.opo;

import cn.wizzer.common.base.Model;
import cn.wizzer.modules.models.sys.Sys_menu;
import cn.wizzer.modules.models.sys.Sys_role;
import cn.wizzer.modules.models.sys.Sys_unit;
import cn.wizzer.modules.models.sys.Sys_user;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by yuhaiming
 */

@Table("opo_user")
public class opo_user extends Model implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column
    @Comment("ID")
    private Long id;

    @Column
    @Comment("关联系统用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String uuid;

    @Column
    @Comment("二级密码")
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String safe_password;// transient 修饰符可让此字段不在对象里显示

    @Column
    @Comment("真实姓名")
    private String real_name;

    @Column
    @Comment("身份证")
    private String Id_card;

    @Column
    @Comment("手机号")
    private String phone;

    @Column
    @Comment("密保问题")
    private String safe_question;

    @Column
    @Comment("密保答案")
    private String safe_solution;

    @Column
    @Comment("银行账号姓名")
    private String bank_account_name;

    @Column
    @Comment("银行开户行")
    private String bank;

    @Column
    @Comment("开户行详细资料")
    private String bank_branch;

    @Column
    @Comment("银行账号")
    private String bank_account;

    @Column
    @Comment("支付宝账号")
    private String alipay;

    @Column
    @Comment("微信")
    private String we_chat;

    @Column
    @Comment("邀请人")
    private String inviter;

    @Column
    @Comment("领导人电话号码")
    private String inviter_phone;

/*    @One(target = Sys_user.class, field = "id",key ="id")
    public Sys_user user;*/

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getSafe_password() {
        return safe_password;
    }

    public void setSafe_password(String safe_password) {
        this.safe_password = safe_password;
    }

    public String getReal_name() {
        return real_name;
    }

    public void setReal_name(String real_name) {
        this.real_name = real_name;
    }

    public String getId_card() {
        return Id_card;
    }

    public void setId_card(String id_card) {
        Id_card = id_card;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getSafe_question() {
        return safe_question;
    }

    public void setSafe_question(String safe_question) {
        this.safe_question = safe_question;
    }

    public String getSafe_solution() {
        return safe_solution;
    }

    public void setSafe_solution(String safe_solution) {
        this.safe_solution = safe_solution;
    }

    public String getBank_account_name() {
        return bank_account_name;
    }

    public void setBank_account_name(String bank_account_name) {
        this.bank_account_name = bank_account_name;
    }

    public String getBank() {
        return bank;
    }

    public void setBank(String bank) {
        this.bank = bank;
    }

    public String getBank_branch() {
        return bank_branch;
    }

    public void setBank_branch(String bank_branch) {
        this.bank_branch = bank_branch;
    }

    public String getAlipay() {
        return alipay;
    }

    public void setAlipay(String alipay) {
        this.alipay = alipay;
    }

    public String getWe_chat() {
        return we_chat;
    }

    public void setWe_chat(String we_chat) {
        this.we_chat = we_chat;
    }

    public String getInviter() {
        return inviter;
    }

    public void setInviter(String inviter) {
        this.inviter = inviter;
    }

    public String getInviter_phone() {
        return inviter_phone;
    }

    public void setInviter_phone(String inviter_phone) {
        this.inviter_phone = inviter_phone;
    }

/*    public Sys_user getUser() {
        return user;
    }

    public void setUser(Sys_user user) {
        this.user = user;
    }*/

    public String getBank_account() {
        return bank_account;
    }

    public void setBank_account(String bank_account) {
        this.bank_account = bank_account;
    }
}

 @At
    @Ok("json")
    @SLog(tag = "新建opo_user", msg = "")
    public Object addDo(@Param("..") opo_user opoUser,
						@Param("loginname") String loginname,
						@Param("password") String password,
						HttpServletRequest req) {
		try {
			Sys_user user =new Sys_user();
			user.setLoginname(loginname);
			user.setPassword(password);
			String msg = userService.checkApp_user(user,true);
			if(msg!=null){
				return Result.error(msg);
			}
			if(opoUser!=null&&opoUser.getReal_name()!=null){
				user.setNickname(opoUser.getReal_name());
				RandomNumberGenerator rng = new SecureRandomNumberGenerator();
				String salt = rng.nextBytes().toBase64();
				String hashedPasswordBase64 = new Sha256Hash(user.getPassword(), salt, 1024).toBase64();
				user.setSalt(salt);
				user.setPassword(hashedPasswordBase64);
				user.setLoginPjax(true);
				user.setLoginCount(0);
				user.setLoginAt(0);
//				userService.insert(user);
			}
			Subject subject = SecurityUtils.getSubject();
			if (subject != null) {
				Sys_user LoginUser = (Sys_user) subject.getPrincipal();

				//设置邀请人
				opo_user ouTemp = opoUserService.fetch(Cnd.where("uuid","=",LoginUser.getId()));
				if(ouTemp!=null){
					opoUser.setInviter(ouTemp.getReal_name());
					opoUser.setInviter_phone(ouTemp.getPhone());
				}
			}
			user.setOpo_user(opoUser);
			// Begin transaction
			Trans.exec(new Atom(){
				public void run() {
					userService.insert(user);
					userService._insertWith(user,"opo_user");
				}
			});
			// End transaction

//			opoUserService.insert(opoUser);

			return Result.success("system.success");
		} catch (Exception e) {
			return Result.error("system.error");
		}
    }
2 回复
					userService.insert(user);
					userService._insertWith(user,"opo_user");

第一个insert是没用的...

添加回复
请先登陆
回到顶部